akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define FASTBOI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pll pair<long long, long long>
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;
int arr[2000];

int main()
{
	FASTBOI;
	string s;
	cin>>s;
	int i=0;
	while(s[i]!='\0')
	{
		arr[s[i]-'0']++;
		i++;
	}
	int cnt=0;
	for(int y=0;y<2000;y++)
	{
		if(arr[y]==2)
			cnt++;
	}
	if(cnt==2)
		cout<<"Yes\n";
	else
		cout<<"No\n";
    return 0;
}


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

using namespace std;

int main()
{
	int N, t;
	cin >> N;

	vector<int> A(N + 1);

	for (int i = 1; i <= N; i++) {
		cin >> t;
		A[t] = i;
	}

	for (int i = 1; i <= N; i++) {
		cout << A[i] << endl;
	}

	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    ios::sync_with_stdio (false), cin.tie (0);
    int a , b;
    cin >> a >> b;
    auto Ok = [](int a){
        return 0 < a && a < 10;
    };
    if(Ok(a) && Ok(b) ){
        cout << a * b << '\n';
    }
    else{
        cout << "-1" << '\n';
    }


    return 0;
}













Measured memory_bytes: 256
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,ans=0;
    cin>>n;
    for(int i=1;i<=n-1;i++)
        ans+=n/i-(n%i==0);
    cout<<ans;
    return 0;
}



Measured memory_bytes: 3648
Imports System

Public Class Test
	Public Shared Sub Main()
		dim N as integer
		dim K as integer
		dim P as integer
		N=console.readline()
		K=console.readline()
		P=1
		for i as integer=1 to N
			if k>=p then
				p=2*p
			else
				p=p+k
			end if
		next i
		console.writeline(P)
	End Sub
End Class

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <queue>
#include <map>
#include <stack>
#include <set>
#define ll long long
using namespace std;

int main(){
//  cout<<123<<endl;
  int a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b) {
    cout<<"YES"<<endl;
  } else cout<<"NO"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int ans=0,i=0;
  char yohou[3],tenki[3];
  scanf("%s %s",yohou,tenki);
  for(i=0;i<3;i++){
    if(yohou[i]==tenki[i]){
      ans++;
    
    }
  
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
int main() {

    int s,w;
    std::cin >> s >> w;
    if(s <= w){
        std::cout << "unsafe" << std::endl;
    }
    else{std::cout << "safe" << std::endl;}

    return 0;
}

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

int main() {
  int r,c;
  cin >> r >> c;
  vector<vector<int>> table(r + 1, vector<int>(c + 1, 0));

  for (int y = 0; y < r; y++) {
    int sum = 0;
    for (int x = 0; x < c; x++) {
      cin >> table[y][x];
      sum += table[y][x];
      cout << table[y][x] << " ";
    }
    table[y][c] = sum;
    cout << sum << endl;
  }

  for (int x = 0; x < c + 1; x++) {
    int sum = 0;
    for (int y = 0; y < r; y ++) {
      sum += table[y][x];
    }
    table[r][x] = sum;
    if (x < c) {
      cout << sum << " ";
    } else {
      cout << sum << endl;
    }
  }
}



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

using namespace std;

double juedui(double a){
	if(a<0) return -a;
	return a;
}

int main(){
	int A,B,H,M;
	scanf("%d%d%d%d",&A,&B,&H,&M);
	double a1=(60.0*H+M*1.0)*0.5;
	int x=( (60*H+M)*6 )%360;
	double a2=double(x);
	double delt=juedui(a2-a1);
	double ans=A*A+B*B-2*A*B*cos((delt/180.0)*M_PI);
	printf("%.20f",sqrt(ans));
}


Measured memory_bytes: 4252
import collection.mutable.PriorityQueue

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val ar = Array.fill(n)(sc.nextLong)
    var q = new PriorityQueue[Long]()(Ordering.Long)
    ar.foreach{q+=_}
    for(i <- 1 to m) {
      val v = q.dequeue / 2
      q += v
    }
    var result = 0L
    q.foreach {
      result += _
    }
    println(result)
  }
}


Measured memory_bytes: 62008
import math
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

a,b,x=LI()

FUL=a*a*b

if x >= FUL*0.5:
    rest = FUL-x
    # rest = a*a*h*0.5
    h = rest / a / a * 2
    print((math.atan(h/a) / (2*math.pi))*360)
else:
    h = x / a / b * 2
    res = 90 - (math.atan(h / b) / (2*math.pi) * 360)
    print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector<int> a(3);
    for (int i = 0; i < 3; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;
    while (k && a[2] <= a[1] || a[1] <= a[0]) {
        if (a[1] <= a[0]) {
            a[1] *= 2;
        } else {
            a[2] *= 2;
        }
        k--;
    }
    if (a[2] > a[1] && a[1] > a[0]) {
        cout << "Yes" << endl;
    } else {
        cout << "No";
    }
}

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

using namespace std;

#define primes    first
#define multiples second

class segmented_sieve_t: public std::vector< int64_t >
{
    /// Set your CPU's L1 data cache size (in bytes) here

    static constexpr int64_t L1D_CACHE_SIZE = 32768;

public:

    segmented_sieve_t( const int64_t limit )
    {
        int64_t Sqrt = std::sqrt( limit ), Segment_Size = std::max( Sqrt, L1D_CACHE_SIZE );

        std::vector< char > sieve( Segment_Size ), is_prime( Sqrt + 1, true );

        std::vector< std::pair< int64_t, int64_t > > prime; size_t q = 0;

        push_back( 2 );

        // we sieve primes >= 3
        for ( int64_t low = 0, i = 3, i2 = 9, n = 3, s = 3, s2 = 9; low <= limit; low += Segment_Size )
        {
            std::fill( sieve.begin(), sieve.end(), true );

            // current segment = [low, high]
            int64_t high = std::min( low + Segment_Size - 1, limit );

            // generate sieving primes using simple sieve of Eratosthenes
            for ( int64_t t = i2; t <= high; i2 = ( t += ++i << 2 ), i++ )
                if ( is_prime[ i ] )
                    for ( int64_t j = t; j <= Sqrt; j += i )
                        is_prime[ j ] = false;

            // initialize sieving primes for segmented sieve
            for ( int64_t t = s2; t <= high; s2 = ( t += ++s << 2 ), s++ )
                if ( is_prime[ s ] )
                    prime.emplace_back( s, t - low ), q++;

            // sieve the current segment
            for ( size_t l = 0; l < q; l++ )
            {
                int64_t j = prime[ l ].multiples;

                for ( int64_t k = prime[ l ].primes << 1; j < Segment_Size; j += k )
                    sieve[ j ] = false;

                prime[ l ].multiples = j - Segment_Size;
            }

            int64_t k = n - low;

            for( int64_t p = high - low; k <= p; k += 2 )
                if ( sieve[ k ] ) // n =  low + k is a prime
                    push_back( low + k );

            n = low + k;
        }
    }

    bool exists( int x ) const { return std::binary_search( cbegin(), cend(), x ); }

    const_iterator lower_bound( int x ) const { return std::lower_bound( cbegin(), cend(), x ); }

    const_iterator upper_bound( int x ) const { return std::upper_bound( cbegin(), cend(), x ); }

};

const size_t N = 55, P = 55555; size_t a[ N ]; segmented_sieve_t prime( P );

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

    size_t n, count = 0; cin >> n;

    for( size_t p = 7; p < P and count < n; p += 10 )
        if( prime.exists( p ) )
            a[ count++ ] = p;

    for( size_t i = 0; i < n; i++ )
        cout << a[ i ] << ' ';
}

Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

ll a, b, c, d;

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

ll calc_divided(ll l, ll r, ll divisor) {
    if (divisor > r || (divisor < l && 2 * divisor > r)) {
        return 0;
    }

    ll x = (l + divisor - 1) / divisor;
    ll y = r / divisor;

    return y - x + 1;
}

int main() {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    printf("%lld\n", (b - a + 1) - (calc_divided(a, b, c) + calc_divided(a, b, d) - calc_divided(a, b, (c * d) / gcd(c, d))));

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
 
      if(M==N){
    System.out.println("Yes");
      }else{
	System.out.println("No");
      }
      }
}


Measured memory_bytes: 22740
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 200005
#define M 200005
#define K 17
#define seed 23333
#define Mo 998244353

using namespace std;
int i,j,m,n,p,k,big[N],T[N],lim[N],X,Y,ans=1,Q[N];
struct Tre{
		vector<int>v[N];
		int fa[N][K+1],deep[N];
		void dfs(int x)
		{
				int i;
				for (i=1;i<=K;++i) fa[x][i]=fa[fa[x][i-1]][i-1];
				for (i=0;i<(int)v[x].size();++i)
				{
							int p=v[x][i];
							if (fa[x][0]==p) continue;
							fa[p][0]=x;
							deep[p]=deep[x]+1;
							dfs(p);
				}
		}
		void read()
		{
				for (i=1;i<n;++i)
				{
						int x,y;
						scanf("%d%d",&x,&y);
						v[x].pb(y); v[y].pb(x);
				}
				dfs(1);
		} 
		int getfa(int x,int y)
		{
			  int i,k;
			  if (deep[x]<deep[y]) swap(x,y);
			  for (i=K,k=deep[x]-deep[y];i>=0;--i)
			  	if (k&(1<<i)) x=fa[x][i];
			  if (x==y) return x;
			  for (i=K;i>=0;--i)
			  	if (fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
			  return fa[x][0];
		}
		void bfs_first()
		{
				memset(lim,-1,sizeof(lim));
				lim[Y]=0;
				Q[Q[0]=1]=Y;
				int l,i;
				for (l=1;l<=Q[0];++l)
				{
						int p=Q[l];
						for (i=0;i<(int)v[p].size();++i)
						{
								int k=v[p][i];
								if (lim[k]!=-1) continue;
								lim[k]=lim[p]+1;
								Q[++Q[0]]=k;
						}
				}
		}
		void bfs_second()
		{
				memset(T,60,sizeof(T));
				T[X]=0;
				Q[Q[0]=1]=X;
				int l,i;
				for (l=1;l<=Q[0];++l)
				{
						int p=Q[l];
						if (T[p]<=lim[p]) ans=max(ans,lim[p]);
						if (T[p]>=lim[p]) continue; 
						for (i=0;i<(int)v[p].size();++i)
						{
								int k=v[p][i];
								if (T[k]<(int)1e9)
								{
									if (lim[k]<=T[p]+1) ans=max(ans,T[p]+1);
								}
								else 
								{
									T[k]=min(T[k],T[p]+1);
									Q[++Q[0]]=k;
								}
						}
				}
		}
}r,b;
int main()
{
		scanf("%d%d%d",&n,&X,&Y);
		r.read(); b.read(); 
		for (i=1;i<n;++i)
			for (j=0;j<(int)r.v[i].size();++j)
			{
					int x=r.v[i][j];
					int lca=b.getfa(i,x);
					if (b.deep[i]+b.deep[x]-2*b.deep[lca]>=3) big[i]=big[x]=1;
			}
		b.bfs_first();
		r.bfs_second();
		for (i=1;i<=n;++i) 
		if (big[i]&&T[i]<lim[i]) 
		{
				puts("-1");
				return 0; 
		}
		printf("%d\n",ans*2);
}


Measured memory_bytes: 63744
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

struct Combination {
	vector<int64_t> _fact, _rfact, _inv;
	int64_t MOD;

	Combination(size_t sz, int64_t mod) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1), MOD(mod) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; ++i) {
			_fact[i] = _fact[i - 1] * i % MOD;
		}
		_rfact[sz] = inverse(_fact[sz]);
		for (int i = sz - 1; i >= 0; --i) {
			_rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
		}
		for (int i = 1; i <= sz; ++i) {
			_inv[i] = _rfact[i] * _fact[i - 1] % MOD;
		}
	}

	inline int64_t fact(int k) const { return _fact[k]; }
	inline int64_t rfact(int k) const { return _rfact[k]; }
	inline int64_t inv(int k) const { return _inv[k]; }

	int64_t inverse(int64_t x) const { return pow(x, MOD - 2); }
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}

	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(n - r) % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
	}
};

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

const Int MOD = 1e9 + 7;
Int func(Int a, Int b) {
	Int x = 1, y = 1;
	b = min(b, a - b);
	for (Int i = 0; i < b; ++i) {
		(x *= (a - i)) %= MOD;
	}
	for (Int i = 1; i <= b; ++i) {
		(y *= i) %= MOD;
	}
	Int ret = (x * modpow(y, MOD - 2, MOD)) % MOD;
	return ret;
}

int main() {
	Int N, K;
	cin >> N >> K;

	if (K >= N - 1) {
		Int ans = func(N + N - 1, N) % MOD;
		cout << ans << endl;
		return 0;
	} 
	Combination cb(200010, MOD);
	Int ans = 0;
	for (int i = K; i >= 0; i -= 1) {
		(ans += cb.C(N - 1, i) * cb.C(N, i) % MOD) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int fib(int);

int main(){
  int n,i;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n){
  int i,F[44];
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
    F[i]=F[i-2]+F[i-1];
  }
  return F[n];
}



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

int main(){
    
    int n,k;
    cin>>n>>k;
    
    int a[n+1]={0};
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    
    double max = a[k]-a[0];
    for(int i=k+1;i<=n;i++){
        if(a[i]-a[i-k]>max)
            max = a[i]-a[i-k];
    }
    
    max /= 2.0;
    max += k/2.0;
    
    printf("%.7lf",max);
    
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> X, std::vector<long long> L){
    vector<pll> rec(N);
    REP(i, N){
        rec[i].first = X[i]+L[i];
        rec[i].second = X[i]-L[i];
    }
    sort(ALL(rec));
    ll cnt = 0;
    ll T = -INF;
    REP(i, N){
        if(rec[i].second >= T){
            T = rec[i].first;
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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


Measured memory_bytes: 3328
s=""
l=[]
string = input()
key=[]
for j in string:
    key.append(j)

for i in key:
    if i=='0':
        l.append(i)
    elif i=='1':
        l.append(i)
    elif i=='B':
        if len(l)==0:
            pass
        else:
            l.pop()

for i in l:
    s=s+i
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll a[maxn];
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i = 0; i < n; ++i)cin>>a[i];
        sort(a,a+n);
        ll ans = 0;
        int x = 0,y = n - 1;
        ll xx = a[x],yy = a[y];
        ans += abs(xx - yy);
        x++;y--;
        int now = 1;
        int cnt = 0;
        while(y >= x)
        {
            cnt++;
            //cout<<ans<<endl;
            if(x == y)
            {
                ans += max(abs(a[x] - xx),abs(a[x] - yy));
                break;
            }

            if(cnt <= 2)
            {
                if(now&1)
            {
                ans += abs(a[y] - xx);
                xx = a[y];
                y--;
            }
            else
            {
                ans += abs(a[x] - yy);
                yy = a[x];
                x++;
            }

            }
            else
            {
                if(now&1)
            {
                ans += abs(a[y] - yy);
                yy = a[y];
                y--;
            }
            else
            {
                ans += abs(a[x] - xx);
                xx = a[x];
                x++;
            }

            }

            if(cnt == 4)
            cnt = 0;

            //cout<<ans<<"  "<<xx<<"  "<<yy<<endl;
            now ^= 1;
        }
        printf("%lld\n",ans);
    }
}













Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
long tousa(long a,long b){
  return b*(b+1)/2-a*(a-1)/2;
}

int main() {
  long N,K;cin>>N>>K;
  long wa=0;
  long mod=1000000007;
  for(long i=K;i<=N+1;i++){
    long x=tousa(N-i+1,N);
    long y=(i*(i-1)/2);
    //cout<<x<<" "<<y<<endl;
    wa+=(x-y+1)%mod;
    wa%=mod;
  }
  cout<<wa<<endl;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))

int main() {
	long int N, p = 9, q = 1;
	int sum = 0, i;

	scanf("%lu", &N);

	for (i = 0; i <= 16; i++){
		if (N > p){
			sum += 9;
		}
		else{
			sum += ((N -p+9*q)/q);
			break;
		}
		p += (9 * q*10);
		q = q * 10;
	}
		printf("%d", sum);
	


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for ( int i = 0; i < (n); ++i )
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long int;
const long long int INF = 1001001001001001LL;
const int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;


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

    int N, M;
    cin >> N >> M;   
    if( N == M ) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int A[7] = { 1,3,5,7,8,10,12 };
	int B[4] = { 4,6,9,11 };
	int X, Y;
	cin >> X >> Y;

	int ok = 0;
	int hantei = 0;

	rep(i, 7) {
		if (A[i] == X) hantei++;
		if (A[i] == Y) hantei++;
	}
	if (hantei == 2) ok = 1;
	hantei = 0;

	rep(i, 4) {
		if (B[i] == X) hantei++;
		if (B[i] == Y) hantei++;
	}
	if (hantei == 2) ok = 1;

	if (ok) co("Yes");
	else co("No");

	Would you please return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{
	int n,a[10000],min,max,i;
	double sum;
	scanf("%d", &n);
	if(n!=0){
		for(i=0;i<n;i++){
			scanf("%d", &a[i]);
		}
		min=a[0];max=a[0];sum=a[0];
		for(i=1;i<n;i++){
			if(min > a[i]){min = a[i];}
			if(max < a[i]){max = a[i];}
			sum += a[i];
		}
		printf("%d %d %.0lf\n", min, max, sum);
	}
	else {printf("     \n");}
	return 0;
}

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

vector<int> adjlist[100005];
int mem[100005];

int dp(int i){
	if(mem[i]!=-1)
	return mem[i];
	if(adjlist[i].size()==0)
	return 0;
	int x =0;
	for(int j=0;j<adjlist[i].size();j++){
		x = max(x,dp(adjlist[i][j])+1);
	}
	mem[i]=x;
	return x;
}

int main()
{
	int n,m;
	memset(mem,-1,sizeof(mem));
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		adjlist[x].push_back(y);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dp(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11288
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

constexpr double eps = 1e-10;

int main() {
    int N, M, L;
    cin >> N >> M >> L;
    vector<vector<vector<double>>> cmb(N, vector<vector<double>>(M+1, vector<double>(M+1)));
    for(int i=0; i<N; ++i) {
        cmb[i][0][0] = 1;
    }
    vector<double> P(N), T(N), V(N);
    for(int i=0; i<N; ++i) {
        cin >> P[i] >> T[i] >> V[i];
        P[i] /= 100;
    }
    for(int i=0; i<N; ++i) {
        for(int j=1; j<=M; ++j) {
            for(int k=0; k<=j; ++k) {
                cmb[i][j][k] = cmb[i][j-1][k] * (1 - P[i]) + (k-1 >= 0 ? cmb[i][j-1][k-1] * P[i] : 0);
            }
        }
    }
    for(int i=0; i<N; ++i) {
        if(V[i] == 0) {
            cout << 0 << endl;
            continue;
        }
        double res = 0;
        for(int j=0; j<=M; ++j) {
            double t = L / V[i] + T[i] * j;
            double p = cmb[i][M][j];
            for(int k=0; k<N; ++k) {
                if(i == k || V[k] == 0) {
                    continue;
                }
                double tt = L / V[k];
                if(T[k] == 0 && tt - t <= 0) {
                    p = 0;
                    break;
                }
                int cnt = (T[k] == 0 ? 0 : ceil(max(0.0, t - tt) / T[k]));
                if(tt + T[k] * cnt - t < eps) {
                    cnt += 1;
                } 
                double pp = 0;
                for(int l=cnt; l<=M; ++l) {
                    pp += cmb[k][M][l];
                }
                p *= pp;
            }
            res += p;
        }
        cout << fixed << setprecision(10) << res << endl;
    }
}


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

public static class Program
{
    public static void Main(params string[] args)
    {
        var l = Console.ReadLine()
           .Select(x => int.Parse(x.ToString()))
           .ToArray();
        var op = new[] { true, false };
        foreach (var p1 in op)
        {
            foreach (var p2 in op)
            {
                foreach (var p3 in op)
                {
                    if (l[0] + (p1 ? 1 : -1) * l[1] + (p2 ? 1 : -1) * l[2] + (p3 ? 1 : -1) * l[3] == 7)
                    {
                        Console.Write(l[0]);
                        Console.Write(p1 ? "+" : "-");
                        Console.Write(l[1]);
                        Console.Write(p2 ? "+" : "-");
                        Console.Write(l[2]);
                        Console.Write(p3 ? "+" : "-");
                        Console.Write(l[3]);
                        Console.WriteLine("=7");
                        return;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int a = 0;
        int b = 0;
        for (int i = 0 ; i < S.length(); i++){
            if (S.charAt(i) == 'A')
                a ++;
            else
                b ++;
        }
        System.out.println(a > 0 && b > 0 ? "Yes" : "No");
        sc.close();
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
//issame:同じか判定
//unite:併合
//findroot:根の検索
//treesize:その木の要素数
struct UnionFind{
    vector<long long> size, par;
    UnionFind(long long n) {
        size.resize(n, 0);
        par.resize(n, 0);
        for (long long i = 0; i < n;i++){
            maketree(i);
        }
    }
    void maketree(long long x){
        par[x] = x;
        size[x] = 1;
    }
    long long findroot(long long x){
        if (x != par[x]) par[x] = findroot(par[x]);
        return par[x];
    }
    bool issame(long long x,long long y){
        return findroot(x) == findroot(y);
    }
    bool unite(long long x,long long y){
        x = findroot(x);
        y = findroot(y);
        if (x == y) return false;  //already united
        if(size[x]>size[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    long long treesize(long long x){
        return size[findroot(x)];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    vector<ll> ans(m, 0);
    UnionFind uf(n);
    ans[m - 1] = n * (n - 1) / 2;
    for (ll i = m - 2; i >= 0; i--) {
        if (uf.issame(a[i+1],b[i+1]))
            ans[i] = ans[i + 1];
        else {
            ans[i] = ans[i + 1] - uf.treesize(a[i+1]) * uf.treesize(b[i+1]);
        }
		uf.unite(a[i+1], b[i+1]);
    }
    for (ll i = 0; i < m;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 7168
main(i,n){
	double a[101];double m;
	for(;;){
		for(i=0;i<101;a[i++]=0);
		scanf("%d",&n);if(!n)break;
		for(i=1;i<=n;scanf("%lf",&a[i]),a[0]+=a[i++]);
		m=a[0]/n;a[0]=0;
		for(i=1;i<=n;a[0]+=pow(a[i++]-m,2));
		printf("%lf\n",sqrt(a[0]/n));
	}
	exit(0);
}

Measured memory_bytes: 660
from collections import deque


n, m = map(int, input().split())
s = input()
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
for i in range(m):
    a, b = info[i]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

v_num = [0] * n 
for i in range(n):
    if s[i] == "B":
        v_num[i] = 1

q = deque([])
used = [False] * n
v_cnt = [[0, 0] for i in range(n)]
for i in range(n):
    for j in graph[i]:
        v_cnt[j][v_num[i]] += 1
for i in range(n):
    if v_cnt[i][0] * v_cnt[i][1] == 0:
        q.append(i)
        used[i] = True

while q:
    pos = q.pop()
    for next_pos in graph[pos]:
        if used[next_pos]:
            continue
        v_cnt[next_pos][v_num[pos]] -= 1
        if v_cnt[next_pos][v_num[pos]] == 0:
            q.append(next_pos)
            used[next_pos] = True

for i in range(n):
    if not used[i]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 124092
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  ll m=0;
  for(int i=0; i<N; i++) {
    if(i%2==0) {
      m+=A[i];
    } else {
      m-=A[i];
    }
  }
  for(int i=0; i<N; i++) {
    if(i+1<N)
      std::cout << m << " ";
    else
      std::cout << m << std::endl;
    m = 2*A[i]-m;
  }
}

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



Measured memory_bytes: 2048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	puts((nextInt() + 1) / 2)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
S=input()
ans=0
tmp=0
for i in range(len(S)):
	if S[i]!='A' and S[i]!='T' and S[i]!='G' and S[i]!='C':
		tmp=0
	else:
		tmp+=1
		if ans<tmp:
			ans=tmp
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);

    if(A == B && B != C)
{
    printf("Yes\n");

    }
    else if(B == C && B != A)
{
    printf("Yes\n");

    }
    else if(A == C && C != B)
{
    printf("Yes\n");

    }

    else
    {
        printf("No\n");

    }

return 0;
}



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

int main(){
    long long x, curr, pred, t;
    cin>>x;
    pred = 100;
    curr = 100;
    t = 0;
    while(curr< x){
        curr+=curr/100;
       // cout<<curr<<'\n';
        t++;
    }

    cout<<t;

    return 0;
}


Measured memory_bytes: 3192
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
immutable string YES = "Yes";
immutable string NO = "No";
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long K;
    K = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, K, A);
}

void solve(long N, long K, long[] A)
{
    foreach (i; K .. N)
    {
        writeln(A[i - K] < A[i] ? YES : NO);
    }
}


Measured memory_bytes: 18604
N,X=map(int,input().split())
L=list(map(int,input().split()))

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(1)] for i in range(N)]
for i in range(N):
    S[i][0]=L[i]
for i in range(X):
    A,B=map(int,input().split())
    A-=1
    B-=1
    S[A].append(L[B])
    S[B].append(L[A])

count=0

for i in range(N):
    nagasa=len(S[i])
    max_H=0
    if nagasa==1:
        count+=1
    else:
        for j in range(nagasa):
            if j!=0:
                if max_H<S[i][j]:
                    max_H=S[i][j]
        if S[i][0]>max_H:
            count+=1
    
print(count)

Measured memory_bytes: 24228
#include <iostream>
#include <sstream>

int main(){
    std::string str;
    std::cin >> str;

    for(int i = 0; i < 3; ++i){
        if('1' == str.at(i)){
            str.at(i) = '9';
        }else{
            str.at(i) = '1';
        }
    }

    std::stringstream ss;
    ss << str;

    int ans;
    ss >> ans;

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
S = int(input())

a = int(S/100 - (S%100)/100)
b = int(S%100)

if( 0<a<13 and 0<b<13 ):
  print("AMBIGUOUS")
if( (0<a<13 and 12<b<100) or (0<a<13 and b==0) ):
  print("MMYY")
if( (12<a<100 and 0<b<13) or (a==0 and 0<b<13) ):
  print("YYMM")
if( 12<a<100 and 12<b<100 ):
  print("NA")
if( a==0 and 12<b<100 ):
  print("NA")
if( 12<a<100 and b==0 ):
  print("NA")
if( a==0 and b==0 ):
  print("NA")



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

using ll = long long;

int const M = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int k;
    cin >> n >> k;
    vector<int> a(n), temp(n);
	int f[2001]{};
	ll r = 0;
	for (int i = 0; i < n; i++) {
        cin >> a[i];
		f[a[i]]++;
		for (int j = 0; j < i; j++) {
			if (a[i] < a[j]) {
				r += k;
			}
		}
    }
	int c = n * (n - 1) / 2;
	for (int i = 1; i <= 2000; i++) {
		c -= f[i] * (f[i] - 1) / 2;
	}
	cout << (r + (ll)k * (k - 1) / 2 % M * c) % M << '\n';
    return 0;
}


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

int a[500][500];

int main(){
  int n;

  cin >> n;

  int tmp = 0;
  int cnt = 0;
  for(int i = 1;tmp < n;i++){
    tmp += i;
    cnt++;
  }

  if(tmp > n){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  cout << cnt + 1 << endl;


  tmp = 1;
  for(int i = 0;i < cnt;i++){
    for(int j = 0;j < cnt;j++){
      if(i <= j){
        a[i][j] = tmp;
        a[j+1][i] = tmp;
        tmp++;
      }
    }
  }

  for(int i = 0;i <= cnt;i++){
    cout << cnt << " ";

    for(int j = 0;j < cnt;j++){
      cout << a[i][j];
      if(j < cnt-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 2304
N = int(input())
S = input()
W = []
E = []
w = 0
e = 0
for i in range(N):
    W.append(w)
    if S[i] == 'W':
        w += 1
for j in range(N - 1, -1, -1):
    E.append(e)
    if S[j] == 'E':
        e += 1
R = W[0] + E[N - 1]
for i in range(N):
    R = min(R, W[i] + E[N - 1 - i])
print(R)

Measured memory_bytes: 17840
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題160

            float l = float.Parse(Console.ReadLine());

            Console.WriteLine(l * l * l / 27.0f);
        }

    }





    
}


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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 1e16;
const int inf = 1e9;

int main () {
	boost;
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0, h = 0;
	ans = min (a, c);
	c -= ans;
	h = min (b, c);
	ans += 2 * h;
	c -= h;
	b -= h;
	ans += min (1, c);
	cout << ans + b;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  int c=0;
  int j=1;
  for (int i=0; i<n; i++) {
    if (vec.at(i)==j) {
      c++;
      j++;
    }
  }
  
  if (j==1) cout << -1 << endl;
  else cout << n-c << endl;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Text;

namespace atcoder
{
    class ac
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int ans = 180 * (n-2);
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
 int r, tmp;
 if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main(){
	int n,A;
	cin >> n >> A;
	vector<int> x(n);
	for(int i =0; i< n;i++) {
		cin >> x[i];
		x[i]-=A;
		x[i] = abs(x[i]);
	}
	int tmp=x[0];
	for(int i = 1; i< n;i++)
	{
		tmp  = gcd(tmp, x[i]);
	}
	cout << tmp << endl;
}

Measured memory_bytes: 640
N=int(input())
A=list(map(float,input().split()))
a,b,c=0,0,0
for i in range(N):
  if A[i]==1:
    a+=1
  elif A[i]==2:
    b+=1
c=N-a-b
i=1
dp=[[[0]*(N+2) for i in range(N+2)] for j in range(N+2)]
for k in range(c+1):
  for j in range(N-k-a+1):
    for i in range(N-k-j+1):
      if i==0 and j==0 and k==0:
        continue
      dp[k][j][i]=(dp[k][j][i-1]*i+dp[k][j-1][i+1]*j+dp[k-1][j+1][i]*k+N)/(i+j+k)
print(dp[c][b][a])

Measured memory_bytes: 513032
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] x = new long[N];
		long[] y = new long[N];
		for(int i=0; i<N; i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
		}
		long ans = Long.MAX_VALUE;
		for(int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++) {
				for(int k=0; k<N; k++) {
					for(int l=k+1; l<N; l++) {
						long p1 = Math.min(x[i], x[j]);
						long p2 = Math.max(x[i], x[j]);
						long p3 = Math.min(y[k], y[l]);
						long p4 = Math.max(y[k], y[l]);
						int count = 0;
						for(int h=0; h<N; h++) {
							if(p1<=x[h] && x[h]<=p2 && p3<=y[h] && y[h] <= p4) count++;
						}
						if(count>=K) {
							ans = Math.min(ans, (p2-p1)*(p4-p3));
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 24404
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using ll = long long;

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

int op(int a, int b){
  return max(a,b);
}
int e(){
  return -1;
}

int main(){
  int n,q; cin >> n >> q;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  segtree<int,op,e> seg(a);
  rep(i,q){
    int t; cin >> t;
    if(t == 1){
      int x,v; cin >> x >> v;
      seg.set(x-1,v);
    }else if(t == 2){
      int l,r; cin >> l >> r;
      cout << seg.prod(l-1,r) << endl;
    }else if(t == 3){
      int x,v; cin >> x >> v;
      cout << 1 + seg.max_right(x - 1, [&](int y){ return (v > y);}) << endl;
    }
  }
  
}


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

#define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
#define DREP(i,a,b) for(int i=a,i##_end_=b;i>=i##_end_;--i)
#define pb push_back
typedef long long ll;

using namespace std;

void File(){
	freopen("duliu.in","r",stdin);
	freopen("duliu.out","w",stdout);
}

template<typename T>void read(T &_){
	T __=0,mul=1; char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')mul=-1;
		ch=getchar();
	}
	while(isdigit(ch))__=(__<<1)+(__<<3)+(ch^'0'),ch=getchar();
	_=__*mul;
}

const int maxn=2e5+10;
int n,sa,sb,a[maxn],b[maxn],fa[maxn],c[maxn],tot,ans=-1;

int find(int x){return fa[x]==x ? x : fa[x]=find(fa[x]);}

int main(){
	//File();
	read(n);
	REP(i,1,n)read(a[i]),sa^=a[i],c[++tot]=a[i];
	REP(i,1,n)read(b[i]),sb^=b[i],c[++tot]=b[i];
	c[++tot]=sa;
	++n; a[n]=sa; b[n]=sb;
	int ta[maxn],tb[maxn];
	REP(i,1,n)ta[i]=a[i],tb[i]=b[i];
	sort(ta+1,ta+n+1); sort(tb+1,tb+n+1);
	REP(i,1,n)if(ta[i]!=tb[i]){puts("-1");return 0;}
	sort(c+1,c+tot+1);
	tot=unique(c+1,c+tot+1)-c-1;
	REP(i,1,n){
		a[i]=lower_bound(c+1,c+tot+1,a[i])-c;
		b[i]=lower_bound(c+1,c+tot+1,b[i])-c;
	}
	fa[a[n]]=a[n];
	REP(i,1,n-1)if(a[i]!=b[i]){
		if(!fa[a[i]])fa[a[i]]=a[i];
		if(!fa[b[i]])fa[b[i]]=b[i];
		fa[find(a[i])]=find(b[i]);
		++ans;
	}
	REP(i,1,tot)if(fa[i]==i)++ans;
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    long long N, M;
    std::cin >> N >> M;
    std::vector< long long > A(N);
    long long total = 0;
    for(int i=0; i<N; i++){
        std::cin >> A[i];
        total += A[i];
    }
    long long cnt = 0;
    for(int i=0; i<N; i++){
        if(A[i] * 4 * M >= total){
            cnt++;
        }
    }
    if(cnt >= M){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
    
}



Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const int INF = 1<<29;

int main()
{
	int n;
	scanf("%d", &n);
	
	vector<pii> cards(n);
	rep(i, n){
		scanf("%d%d", &cards[i].first, &cards[i].second);
	}
	
	vvi dp(n+1, vi(n));
	rep(j, n)
		dp[1][j] = 0;
	
	reep(i, 2, n+1){
		rep(j, n-i+1){
			dp[i][j] = INF;
			reep(k, 1, i){
				int cost = cards[j].first * cards[j+k-1].second * cards[j+k].first * cards[j+i-1].second;
				dp[i][j] = min(dp[i][j], dp[k][j] + dp[i-k][j+k] + cost);
			}
		}
	}
	
	printf("%d\n", dp[n][0]);
	
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> b(n - 1);
  int64_t ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    cin >> b[i];
    if (i == 0) {
      ans += b[i];
    } else {
      ans += min(b[i], b[i - 1]);
    }
  }
  ans += b[n - 2];

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3644
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scan(&n)
  hs := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&hs[i])
  }
  result := 0
  num := 0
  for i := 0; i < n-1; i++ {
    if hs[i] < hs[i+1] {
      if result < num {
        result = num
      }
      num = 0
    } else {
      num++
    }
  }
  if result < num {
    result = num
  }
  fmt.Println(result)

}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amin(T& a,T b){ a=min(a,b);}
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m, ans=0;

	cin >>n >>m;
	
	map<int, int>mp;
	
	rep(i,n){
		int k, w; cin >>k;
		rep(j, k){
			cin >>w;
			mp[w]++;
		} 
	}
	
	for(auto x: mp){
		if(x.second==n) ans++;
	}
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

bool comp(const pair<int, int> x, const pair<int, int> y) {
    return x.second > y.second;
}

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

    // (number, count)
    // number: 1 to n
    // count: count the number appears in A_i
    map<int, int> as;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        auto it = as.find(x);
        if (it == as.end()) {
            as[x] = 1;
        } else {
            as[x] = as.at(x) + 1;
        }
    }

    // sort as
    vector<pair<int, int>> bs;
    for (auto p : as) {
        bs.push_back(p);
    }

    sort(bs.begin(), bs.end(), comp);

    // ds[0] means the size of numbers which appears once in A_i.
    // ds[1] means ...                               twice in A_i.
    // ...
    vector<int> ds(n, 0);
    for (auto p : as) {
        ds[p.second-1]++;
    }

    // cout << "[ds]" << endl;
    // for (size_t i = 0; i < ds.size(); i++) {
    //     cout << i+1 << ":" << ds[i] << endl;
    // }
    // cout << endl;

    // calculate f(x) (see answer pdf)
    vector<int> fs(n);
    int m = bs.size(); // how many distinct numbers are in A_i
    int g = m;
    fs[0] = g / 1; // f(1)
    int acc = ds[0];
    for (int i = 1; i < n; i++) {
        g += (m - acc);
        fs[i] = g / (i+1);
        acc += ds[i];
    }

    // cout << "[fs]" << endl;
    // for (size_t i = 0; i < fs.size(); i++) {
    //     cout << i+1 << ":" << fs[i] << endl;
    // }
    // cout << endl;

    for (int k = 1; k <= n; k++) {
        int left = -1, right = n, mid;
        while (right - left > 1) {
            mid = left + (right - left) / 2;
            if (fs[mid] < k) right = mid;
            else left = mid;
        }

        if (left >= 0) cout << left+1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 19180