akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],min=INT_MAX,cnt=0;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]<min)
            min=a[i],cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

const ll INF = 1e18;
const int MAX = 111;

bool isprime(int x){
    if(x<2) return 0;
    for(int e=2;e*e<=x;e++){
        if(x%e==0) return 0;
    }
    return 1;
}

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll sum[100100];
    sum[0]=0;
    for(int i=1;i<100100;i++){
        if(isprime(i)&&isprime((i+1)/2)) sum[i]=sum[i-1]+1;
        else sum[i]=sum[i-1];
    }
    int q; cin >> q;
    rep(i,q){
        int l,r; cin >> l >> r;
        cout << sum[r]-sum[l-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 4452
#include <stdio.h>
#include <algorithm>
#include <math.h>
int main(void)
{
    int count=0,f=0,j=0;
    double n,n2,b,d=0.,sum = 0,k=1;
    scanf("%lf",&n);
    b = n;
    n2 = n;
    while(n){
    n = n /10;
    n = floor(n);
    count++;
    if(n ==0)break;
    b = n;
    }

    sum = 9;
    for(int i=0;i<count-1;i++){
        sum = sum * 10;
        k = k * 10;
        sum += 9;
    }

    for(int i=1 ; i<=9;i++){
        if(sum == n2){f = 1; j = 10 - i; break;}
        sum = sum - k;
    }

    if(f == 1){
        printf("%d\n",(count-1)*9+j);
    }else if(count==1){
        printf("%d\n",(int)n2);
    }else{
        printf("%d\n",(count-1)*9 + (int)b-1);
    }
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
unsigned long long power(unsigned long long a, long long b) {
    unsigned long long ret = 1;
    for ( ; b; b >>= 1, a = a * a) b & 1 ? ret = ret * a : 0;
    return ret;
}
int main() {
    unsigned long long n, k;
    cin >> n >> k;
    unsigned long long ans = k * power(k - 1, n - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[15][15][15]={{},{},{},
					{".aa",
					 "a..",
					 "a.."
					},
					{"aacd",
					 "bbcd",
					 "cdaa",
					 "cdbb"
					},
					{"aaeef",
					 "bbg.f",
					 "ccghh",
					 "..abc",
					 "..abc"
					},
					{"aa....",
					 "..a...",
					 "..a...",
					 "...aa.",
					 ".....a",
					 ".....a"
					},
					{"aacaa..",
					 "bbcbb..",
					 ".dd..ab",
					 "..e..ab",
					 "..effcc",
					 "g....ab",
					 "g....ab"
					},
					{"aacd....",
					 "bbcd....",
					 "cdaa....",
					 "cdbb....",
					 "....aacd",
					 "....bbcd",
					 "....cdaa",
					 "....cdbb"
					},};
char b[2][15][15]={
				   {".zz",
					"z..",
					"z.."
				   },
				   {"yyx",
					"x.x",
					"xyy"
				   }};
int n;
char tans[1005][1005];
int main()
{
	scanf("%d",&n);
	if(n<=2) printf("-1");
	else if(n<=8)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				printf("%c",a[n][i][j]);
			printf("\n");
		}
	}
	else
	{
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				tans[i][j]='.';
		if(n%3==0)
		{
			for(int i=0;i<n;i+=3)
				for(int j=0;j<3;j++)
					for(int k=0;k<3;k++)
						tans[i+j][i+k]=b[0][j][k];
		}
		else if(n%3==1)
		{
			for(int i=0;i<4;i++)
				for(int j=0;j<4;j++)
					tans[i][j]=a[4][i][j];
			for(int i=4;i<n;i+=3)
			{
				for(int j=0;j<3;j++)
					for(int k=0;k<3;k++)
						tans[i+j][i+k]=b[1][j][k];
				if(i+3<n)
				{
					for(int j=0;j<3;j++)
						for(int k=0;k<3;k++)
							tans[i+j+3][i+k]=b[0][j][k];
				}
			}
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					tans[4+j][n-3+k]=b[0][j][k];
		}
		else
		{
			for(int i=0;i<5;i++)
				for(int j=0;j<5;j++)
					tans[i][j]=a[5][i][j];
			for(int i=5;i<n;i+=3)
			{
				for(int j=0;j<3;j++)
					for(int k=0;k<3;k++)
						tans[i+j][i+k]=b[1][j][k];
				if(i+3<n)
				{
					for(int j=0;j<3;j++)
						for(int k=0;k<3;k++)
							tans[i+j+3][i+k]=b[0][j][k];
				}
			}
			for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
					tans[5+j][n-3+k]=b[0][j][k];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				printf("%c",tans[i][j]);
			printf("\n");
		}
	}
	return 0;
}

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

ll a[100005], dp[100005];

int main() {
    ll n, k; cin>>n>>k;
    for(ll i = 1; i <= n; ++i){
        cin>>a[i];
    }
    for(ll i = 2; i <= n; ++i){
        ll mn = 1e15;
        for(ll j = 1; j <= k; ++j){
            if(i - j > 0){mn = min(mn, dp[i-j] + abs(a[i]-a[i-j]));}
        }
        dp[i] = mn;
    }
    cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  auto A=make_v(n,(ll)0),B=A,C=A;
  rep(i,n) cin>>A[i]>>B[i]>>C[i];
  ll a,b,c; a=A[0],b=B[0],c=C[0];
  rep(i,1,n){
    ll newa=0,newb=0,newc=0;
    chmax(newa,max(b,c)+A[i]);
    chmax(newb,max(c,a)+B[i]);
    chmax(newc,max(a,b)+C[i]);
    a=newa,b=newb,c=newc;
  }
  cout<<max(max(a,b),c)<<"\n";
}

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

#define NM 100002

using namespace std;

struct seg1
{
    int l, r;
    bool operator< (const seg1 a) const
    {
        return (this->r < a.r || (this->r == a.r && this->l < a.l));
    }
};

struct seg2
{
    int l, r;
    bool operator< (const seg2 a) const
    {
        return (this->l > a.l || (this->l == a.l && this->r > a.r));
    }
};

multiset <seg1> s1;
multiset <seg2> s2;

int n, L[NM], R[NM];

long long f(bool r)
{
    long long k = 0;
    s1.clear();
    s2.clear();
    for(int i = 1; i <= n; i++)
    {
        s1.insert({L[i], R[i]});
        s2.insert({L[i], R[i]});
    }
    int pos = 0;
    for(int i = 1; i <= n; i++)
    {
        int l1, r1;
        if(i % 2 == r)
        {
            l1 = (*(s1.begin())).l;
            r1 = (*(s1.begin())).r;
            s1.erase(s1.begin());
            s2.erase(s2.find({l1, r1}));
        }
        else
        {
            l1 = (*(s2.begin())).l;
            r1 = (*(s2.begin())).r;
            s1.erase(s1.find({l1, r1}));
            s2.erase(s2.begin());
        }
        if(l1 <= pos && pos <= r1)
            continue;
        if(abs(l1 - pos) < abs(r1 - pos))
        {
            k += abs(l1 - pos);
            pos = l1;
        }
        else
        {
            k += abs(r1 - pos);
            pos = r1;
        }
    }
    k += abs(pos);
    return k;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> L[i] >> R[i];
    cout << max(f(0), f(1)) << "\n";
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int c[5];

signed main(){
  int k,a,b,p=0,ans=0;
  cin>>k>>a>>b;
  if(b-a>1){
    if(a>=k)cout<<k+1<<endl;
    else{
      p=k-a+1;
      if(p%2)p--,ans++;
      if(p>=2)ans+=a;
     // cout<<p<<endl;
      cout<<(b-a)*p/2+ans<<endl;
    }
  }
  else cout<<k+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll n,k;
	cin>>n>>k;
	cout<<min(n%k,k-n%k);
	re 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	m := map[rune]int{}
	for _, v := range s {
		m[v]+=1
	}
	for key := range m {
		if m[key] != 2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


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

int main() {


int a,b;
//int *num=new int[4];
//char *s=new char[3];
//string s;
cin >> a >> b;

if(a+b==15)
cout << "+" << endl;
else if(a*b==15)
cout << "*" << endl;
else
cout << "x" << endl;



}


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

int main(){
    int N; cin >> N;
    int q=N/8; int r=N%8;

    if(q==0&&r==3){
        cout << 2 << " " << 5 << " " << 63 << endl; return 0;
    }

    for(int i=0; i<q; i++){
        cout << 12*i+2 << " " << 12*i+3 << " " << 12*i+4 << " " << 12*i+6 << " ";
        cout << 12*i+8 << " " << 12*i+9 << " " << 12*i+10 << " " << 12*i+12 << " ";
    }

    if(r==0){
        cout << endl;
    }
    if(r==1){
        cout << 12*q+12 << endl;
    }
    if(r==2){
        cout << 12*q+6 << " " << 12*q+12 << endl;
    }
    if(r==3){
        cout << 12*q+4 << " " << 12*q+8 << " " << 12*q+12 << endl;
    }
    if(r==4){
        cout << 12*q+2 << " ";
        cout << 12*q+3 << " ";
        cout << 12*q+9 << " ";
        cout << 12*q+10 << endl;
    }
    if(r==5){
        cout << 12*q+2 << " ";
        cout << 12*q+3 << " ";
        cout << 12*q+6 << " ";
        cout << 12*q+9 << " ";
        cout << 12*q+10 << endl;
    }
    if(r==6){
        cout << 12*q+2 << " ";
        cout << 12*q+3 << " ";
        cout << 12*q+4 << " ";
        cout << 12*q+8 << " ";
        cout << 12*q+9 << " ";
        cout << 12*q+10 << endl;
    }
    if(r==7){
        cout << 12*q+2 << " ";
        cout << 12*q+3 << " ";
        cout << 12*q+4 << " ";
        cout << 12*q+6 << " ";
        cout << 12*q+8 << " ";
        cout << 12*q+9 << " ";
        cout << 12*q+10 << endl;
    }
}

Measured memory_bytes: 384
using System;
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            string[] xInputMax = Console.ReadLine().Split(' ');
            int xMaxX = int.Parse(xInputMax[0]);
            int xMaxY = int.Parse(xInputMax[1]);
            string[] xInputX = Console.ReadLine().Split(' ');
            long[] x = new long[xMaxX];
            for (int i = 0; i < xMaxX; ++i)
            {
                x[i] = long.Parse(xInputX[i]);
            }
            string[] xInputY = Console.ReadLine().Split(' ');
            long[] y = new long[xMaxY];
            for (int i = 0; i < xMaxY; ++i)
            {
                y[i] = long.Parse(xInputY[i]);
            }
            //計算
            long xDivisor = 1000000007;
            long xSumX = 0;
            for (int i = 0; i < xMaxX; ++i)
            {
                xSumX += x[i] * (2 * i - xMaxX + 1) ;
            }
            xSumX = xSumX % xDivisor;
            long xSumY = 0;
            for (int i = 0; i < xMaxY; ++i)
            {
                xSumY += y[i] * (2 * i - xMaxY + 1);
            }
            xSumY = xSumY % xDivisor;
            //出力
            Console.WriteLine((xSumX * xSumY) % xDivisor);
        }
    }


Measured memory_bytes: 37900
#include <iostream>

using namespace std;

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

    if(K > (N-1)*(N-2)/2){
        cout << -1;
        return 0;
    }

    int m = (N-1)*(N-2)/2;
    int cnt = 0;
    for(int i=1; i<N-1; i++){
        if(K == m - cnt) break;
        for(int j=i+1; j<N; j++){
            if(K == m - cnt) break;
            cnt++;
        }
    }

    cout << cnt + N - 1 << endl;
    for(int i=2; i<=N; i++){
        cout << 1 << " " << i << endl;
    }

    cnt = 0;
    for(int i=1; i<N-1; i++){
        if(K == m - cnt) break;
        for(int j=i+1; j<N; j++){
            if(K == m - cnt) break;
            cout << i+1 << " " << j+1 << endl;
            cnt++;
        }
    }

    return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
mod = int(1E9+7)

if abs(N-M) > 1:
    ans = 0
elif N == M:
    n = 1
    for i in range(1, N+1):
        n = n*i % mod
    ans = 2 * n * n % mod
else:
    n = 1
    for i in range(1, N+1):
        n = n*i % mod
    m = 1
    for i in range(1, M+1):
        m = m*i % mod
    ans = n * m % mod

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int main(){
  int i, l;
  char s[101];
  cin >> s;
  l=strlen(s);
  for(i=0; i<l; i++){
    if(i%2){
      if(s[i]=='R'){
        cout << "No" << endl;
        return 0;
      }}
    else
      if(s[i]=='L'){
        cout << "No" << endl;
        return 0;
      }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
num = 1
cnt = []
for x in a:
    c = 0
    for i in range(int(math.log(x,2))):
        if x>>c&1:
            break
        else:
            c+=1
    cnt.append(c)
if max(cnt) != min(cnt):
    print(0)
else:
    for x in a:
        num = num * (x//2) // fractions.gcd(num, x//2)
    print(m//num-(m//num)//2)

Measured memory_bytes: 16280
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
int n, m,a,b,ans=0;
vector<int> l,r;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a>>b;
l.push_back(a);
r.push_back(b);
}
sort(l.begin(),l.end());
sort(r.begin(),r.end());
ans=r.at(0)-l.at(n-1)+1;
  if(ans<0)cout<<"0"<<endl;
else cout<<ans<<endl;
return 0;
} 

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll A, B, C;

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

  cin >> A >> B >> C;

  int ans = 0;
  while (A%2 == 0 && B%2 == 0 && C%2 == 0) {
    ll i, j, k;
    i = (B+C)/2;
    j = (A+C)/2;
    k = (A+B)/2;
    A = i; B = j; C = k;
    ++ans;
    if ((A+B+C)%3 == 0 && A == (A+B+C)/3 && B == (A+B+C)/3 && C == (A+B+C)/3) {
      ans = -1;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int N;
vector<int> d(110);
set<int> result;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> d.at(i);
  }

  for (int i = 0; i < N; i++)
  {
    result.insert(d.at(i));
  }

  cout << result.size() << endl;
}


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

using namespace std;

const int nmax=50;
bool pass[nmax][nmax];
bool visited[nmax];
int n,m;

void dfs(int v){

  visited[v]=true;
  
  for(int w=0;w<n;w++){
   if(!pass[v][w]) continue;
   if(visited[w]) continue;
    dfs(w); 
  }
}

int main(){

  cin >> n >> m;
 
 pass[nmax][nmax]={false};
 vector<int> a(m),b(m);
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    pass[a[i]][b[i]]=pass[b[i]][a[i]]=true;
  }
  
  int res=0;
  for(int i=0;i<m;i++){
   pass[a[i]][b[i]]=pass[b[i]][a[i]]=false;
    
   for(int j=0;j<n;j++) visited[j]=false;
 
   dfs(0);
        
   bool bridge=false;
        
   for(int j=0;j<n;j++) {
     if(!visited[j]) bridge=true;
   }
   
  if(bridge) res++;
    
  pass[a[i]][b[i]]=pass[b[i]][a[i]]=true;
  } 
  cout << res << endl;
   
}


Measured memory_bytes: 256
s = input()

length = len(s)

res = -1
for i in range(length - 1):
    subs = s[i:i+2]
    if len(set(subs)) < 2:
        res = i
        break

if res == -1:
    for i in range(length - 2):
        subs = s[i:i+3]
        if len(set(subs)) < 3:
            res = i
            break
    if res == -1:
        print('-1 -1')
    else:
        print('%d %d' % (res + 1, res + 3))
else:
    print('%d %d' % (res + 1, res + 2))


Measured memory_bytes: 3188
yohou=input()
tenki=input()
yohou1=yohou[0]
yohou2=yohou[1]
yohou3=yohou[2]
tenki1=tenki[0]
tenki2=tenki[1]
tenki3=tenki[2]
kekka=[yohou1==tenki1, yohou2==tenki2, yohou3==tenki3]
a=kekka.count(True)
print(a)

Measured memory_bytes: 3060
Public Class Program
  Shared Sub Main()
    Dim n As Double = Double.Parse(Console.ReadLine())
    Dim xs(0 To n - 1) As Double
    Dim ys(0 To n - 1) As Double
    For i As Double = 0 To n - 1
      Dim xy As Double() = Array.ConvertAll(Of String, Double)(Console.ReadLine().Split(" "), AddressOf Double.Parse)
      xs(i) = xy(0)
      ys(i) = xy(1)
    Next
    Dim l As Double = 0 ' 町iと町jの間の距離の総和 '
    For i As Double = 0 To n - 2
      For j As Double = i + 1 To n - 1
        l += Math.Sqrt(((xs(i) - xs(j)) * (xs(i) - xs(j))) + ((ys(i) - ys(j)) * (ys(i) - ys(j))))
      Next
    Next
    ' N!通りの経路のうち、各町のペア間の移動が発生するような経路は 2(N-1)!通りある '
    ' よって、N!通りの経路の長さの平均値は l × 2(N-1)! ÷ N! = l × 2 ÷ N '
    Dim ans As Double = l * 2 / n
    Console.WriteLine(ans.ToString())
  End Sub
End Class


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7
#define LINF 1e18+10  
using ll = long long; 

using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
using Ps=pair<int,string>;

using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//const ll mod=998244353;
const ll mod=1e9+7;
const ll MAX=300000;

//////////////////////////////////////


int main(){
    int a;
    cin>>a;
    a-=400;
    int ans=8;
    while(a>=200){
        ans--;
        a-=200;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
import sys
from collections import deque

input = sys.stdin.readline
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
edge_colors = [0]*(N-1)
g = [[] for _ in range(N)]
for i, (a, b) in enumerate(ab):
    a -= 1
    b -= 1
    g[a].append((b, i))
    g[b].append((a, i))

q = deque([(0, 0)])
visited = [False] * N
visited[0] = True
while len(q) > 0:
    node, color = q.popleft()
    i = 1
    for v, edgeid in g[node]:
        if visited[v]:
            continue
        if i == color:
            i += 1
        visited[v] = True
        q.append((v, i))
        edge_colors[edgeid] = i
        i += 1


print(max(edge_colors))
for c in edge_colors:
    print(c)


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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long

int main(){
  string s;
  int n,m;
  
  cin >> s;
  n = s.size();
  m = (n%2 == 0)? (n-2)/2 : (n-1)/2;

  while(s.substr(0,m) != s.substr(m,m)){
    m-=1;
  }

  cout << 2*m << endl;

  return 0;
}



Measured memory_bytes: 256
/*//////////////////////////////////////*/
/*/  NULLCT$ (｀･ω･´) <<"Be accept!!"  /*/
/*//////////////////////////////////////*/
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <type_traits>
#include <cstdint>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  unsigned long long n,k;
  cin>>n>>k;
  n=n%k;
  if(k/2 < n){
    cout<<k-n<<endl;
  }else{
    cout<<n<<endl;
  }

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[107];
int main()
{
    long long int i,j,k,z,t,x,y,n;
    cin>>n;
    x=LLONG_MAX;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=-100;i<=100;i++)
    {
        y=0;
        for(j=1;j<=n;j++)
        {
            y+=(a[j]-i)*(a[j]-i);
        }
        x=min(x,y);
    }
    cout<<x<<endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  int k;string s;cin>>k>>s;
  if(s.size()<=k)cout<<s;
  else{
    cout<<s.substr(0,k)<<"...";
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,M;
ll a[105];
ll ans=0;
ll res;
int main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
		ans+=a[i]; 
	}
	if(ans==M)
	{
		cout<<N<<endl;
		return 0;
	}
	sort(a,a+N);
	if(ans>M)
	{
		//cout<<ans<<endl;
		for(int i=N-1;i>=0;i--)
		{
			//cout<<a[i]<<endl;
			ans-=a[i];
			res++;
			if(ans<=M)
			{
				//cout<<res<<endl;
				cout<<N-res<<endl;
				return 0;
			}
			else continue;
		}
	}
	else
	{
		cout<<N-1<<endl;
		return 0;
	}
	cout<<0<<endl;
	return 0;
}
/*
3 10
20 30 10
*/ 

Measured memory_bytes: 256
s = gets.chomp.split("")
t = gets.chomp.split("")

ans = t.length
for i in 0..(s.length-t.length)
  cnt = 0
  for j in 0..(t.length-1)
    cnt += 1 if s[i+j] != t[j]
  end
  ans = [ans,cnt].min
end
puts ans

Measured memory_bytes: 14340
N ,M ,Q = map(int,input().split())
l = [list(map(int,input().split())) for i in range(Q)]
ans=[]
score = 0
for i1 in range(1,M+1):
    for i2 in range(i1,M+1):
        for i3 in range(i2,M+1):
            for i4 in range(i3,M+1):
                for i5 in range(i4,M+1):
                    for i6 in range(i5,M+1):
                        for i7 in range(i6,M+1):
                            for i8 in range(i7,M+1):
                                for i9 in range(i8,M+1):
                                    for i10 in range(i9,M+1):
                                        A = [i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        for a, b, c, d in l:
                                            if A[b-1] - A[a-1] == c:
                                                score += d
                                            else:
                                                pass
                                        ans.append(score)
                                        score = 0
print(max(ans))

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

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

int main()
{
	int K, N, tmp, ans = 0, min = 0;
	vector<int> A;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> tmp;
		A.push_back(tmp);
		if (tmp == 1) min = i;
	}
	
/*
	ans += (N - min - 1) / (K-1) + ((N - min - 1) % (K-1) != 0);
	long long x = (K-1) - ((N - min - 1) % (K-1));
	ans += (min) / (K-1) + ((min) % (K-1) != 0);

	if (N == K) ans = 1;
	if (N % (K-1) == 1) {
		ans = N / (K-1);
	}

	*/

	ans = (N-1) /(K-1) + ((N - 1) % (K - 1) != 0);

	cout << ans << endl;

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL A,B;
int main(){
	int N; scanf("%d",&N);
	scanf("%lld%lld",&A,&B);
	LL p = 0;
	for (int i=3; i<=N; i++){
		LL x; scanf("%lld",&x);
		p = p^x;
	}
	LL s = A+B;
	if ((s-p)&1 || s-p<0) {
		puts("-1");
		return 0;
	}
	LL q = (s-p)/2, a = q;
	int flag = 1;
	for (int i=40; i>=0; i--){
		if ((q>>i)&1 && (p>>i)&1){
			flag = 0;
			break;
		}
		else if (!((q>>i)&1) && !((p>>i)&1)) continue;
		else if ((q>>i)&1 && !((p>>i)&1))continue;
		else {
			if ((a | (1LL<<i)) <= A) a |= (1LL<<i);
		}
	}
	if (a == 0 || a > A) flag = 0;
	if (flag) printf("%lld\n",A-a);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 3760
def main():

    s = str(input())
    n = len(s)

    cum = [[0]*(n+1) for _ in range(26)]

    for i in range(26):
        c = chr(i + ord('a'))
        for j in range(n):
            if s[j] == c:
                cum[i][j+1] = cum[i][j]+1
            else:
                cum[i][j+1] = cum[i][j]


    for i in range(26):
        for j in range(n+1):
            cum[i][j] = 2*cum[i][j] -j

    from collections import deque

    for i in range(26):
        min_ = 10**6
        min_id = -1
        q = deque()
        for j in range(n+1):
            if j == 0:
                q.append((cum[i][j], j))
            elif j == 1:
                q.append((cum[i][j], j))
            else:
                temp, temp_id = q.popleft()
                if temp <= min_:
                    min_ = temp
                    min_id = temp_id
                if cum[i][j] - min_ > 0:
                    print(min_id+1, j)
                    exit()
                q.append((cum[i][j], j))
    else:
        print(-1, -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 106468
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

const char *p;

int rec() {
  int res = 0;
  vector<int> v;

  ++p;
  if(*p == '[') {
    while(*p == '[') v.push_back(rec());
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size()/2+1; i++) res += v[i];
  } else {
    char *e;
    res = strtol(p, &e, 10) / 2 + 1;
    p = e;
  }

  ++p;
  return res;
}

int main() {
  int n;
  string str;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> str;
    p = str.c_str();
    cout << rec() << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i, n-1) cin >> b[i];

    vector<int> a(n);
    a[0] = b[0];
    a[n -1 ] = b[n-2];

    repi(i, n - 1) {
        a[i] = min(b[i], b[i-1]);
    }

    put(accumulate(all(a), 0));    

    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char** argv){
    int N;
    cin >> N;
    int H[N];
    for (int i=0; i<N; i++) cin >> H[i];
    if (N == 1) {
        cout << "0\n";
        return 0;
    }
    int ans = 0;
    int succ = 0;
    for (int i=N-2; i>=0; i--){
        if (H[i] >= H[i+1]) succ++;
        else {
            ans = max(ans, succ);
            succ = 0;
        }
    }
    ans = max(ans, succ);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())

typedef long long ll;

int main() {

	ll N,K; cin >> N >> K;
	vector < ll > A(N);
	REP(i,N) cin >> A[i];

	map <ll,ll> cnt;
	REP(i,N) cnt[A[i]]++;

	vector < pair <ll,ll> > t;
	for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
		t.push_back(make_pair(itr->second, itr->first));
	}

	ll ans = 0;
	sort(t.begin(),t.end());
	REP(i,max(0LL, (ll)t.size() - K)) {
		ans += t[i].first;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 18672
if __name__ == "__main__":
    n, m = map(int, input().split())
    part1 = 0
    if n >= 2:
        part1 = n * (n - 1) // 2
    part2 = 0
    if m >= 2:
        part2 = m * (m - 1) // 2
    print(part1 + part2)
 

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b < c+d)
    cout << "Right" << endl;
  if(a+b > c+d)
    cout << "Left" << endl;
  if(a+b == c+d)
    cout << "Balanced" << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string t = "yuiophjklnm";
  string s;
  while (cin >> s, s != "#") {
    int c = 0;
    loop(i, 1, s.size()) {
      c += (t.find(s[i - 1]) == string::npos) ^ (t.find(s[i]) == string::npos);
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		boolean chkStreak;
		long ans = 0;

		for (int i = 0; i < K; i++) {
			chkStreak = false;
			for (int j = i; j < N; j=j+K) {
				char hand = T.charAt(j);
				if (j > K - 1) {
					char pastHand = T.charAt(j - K);
					if (pastHand == hand) {
						chkStreak = !chkStreak;
					}else {
						chkStreak = false;
					}
				}

				if (chkStreak == false && hand == 'r') {
					ans += P;
				} else if (chkStreak == false && hand == 's') {
					ans += R;
				}else if (chkStreak == false && hand == 'p') {
					ans += S;
				}
			}
		}

		System.out.println(ans);

	}
}

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

#define rep(i,n) for(int i=0;i<(n); ++i)
#define INF 100000 // 2^31-1
#define MAX_V 100000


using namespace std;

using ll =long long;
using P = pair<int,int>;


 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}



int main() {

ios::sync_with_stdio(false);
cin.tie(0);
	int a,b;
cin>>a>>b;
	cout << a*b << endl;

}
//double res=10.11;
//printf("%.10f",ans);
//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;

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

int main() {
    int obs, roads;

    unordered_map<int, int> height;
    unordered_set<int> good;

    // read obs and roads
    cin >> obs >> roads;

    // load the height
    for (int i = 1; i <= obs; ++i) {
        int tmp;

        cin >> tmp;
        height[i] = tmp;
        good.insert(i); // initially, everything is good
    }

    // load the connections
    while (roads--) {
        int ob1, ob2;
        cin >> ob1 >> ob2;

        if (height[ob1] <= height[ob2])
            good.erase(ob1);
        if (height[ob2] <= height[ob1])
            good.erase(ob2);
    }

    cout << good.size() << endl;

    return 0;
}


Measured memory_bytes: 11388
/*
g++ -std=c++11 -o2 -Wall Yahoo2019C.cpp -o .\out\Yahoo2019C.out
.\out\Yahoo2019C.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  if (a+1 >= b) {
    cout << 1ll + k << "\n";
    return 0;
  }
  ll ans = 0ll;
  if (k == 1) {
    cout << "2\n";
    return 0;
  } else if (k <= a) {
    cout << 1ll + k << "\n";
    return 0;
  } else {
    ll r = k  - (a - 1);
    ans += a;
    ans += r - (r / 2) * 2;
    ans += 0ll + (b - a) * (r / 2);
    cout << ans << "\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	//
  int H, W;
  cin >> H >> W;
  for(int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  
  for(int i=0; i<H; i++){
    cout << '#';
    
    vector<char> pic(W);
     for(int i=0; i<W; i++){
      cin >> pic. at(i);
      cout << pic. at(i);
    }
    cout << '#' << endl;
  }
  
    for(int i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
 }

Measured memory_bytes: 3596
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string a, b, c;
    cin >> a >> b >> c;

    if(a.back() == b[0] && b.back() == c[0]){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    for (int i = 0, cur=0; i < n; ++i) {
        if(s[i] == 'R') {
            cur++;
            ans = max(ans, cur);
        } else {
            cur = 0;
        }
    }
    cout << ans << endl;
}


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

int main () {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += p.at(i);
  }
  ans -= p.at(N-1) / 2;
  cout << ans << endl;
}

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

using namespace std;

#define N 300000

int n,f[N],ans[N];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		int x; scanf("%d",&x); f[x]=i;
	}
	for (int i=1,j=1;i<=n*n;++i){
		if (f[i]){
			ans[i]=f[i];
			for (int k=1;k<f[i];++k){
				for (;ans[j];++j);
				ans[j]=f[i];
			}
			if (j>i){puts("No"); return 0;}
		}
	}
	for (int i=n*n,j=n*n;i;--i){
		if (f[i]){
			for (int k=f[i]+1;k<=n;++k){
				for (;ans[j];--j);
				ans[j]=f[i];
				if (j<i){puts("No"); return 0;}
			}
		}
	}
	puts("Yes");
	for (int i=1;i<=n*n;++i) printf(i==n*n?"%d\n":"%d ",ans[i]);
	
	return 0;
}
			

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std ;
int main () {
int A , B , K ; cin >> A >> B >> K ;
for ( int i = min (A , B ); i >= 1; --i ) {
if ( A % i == 0 && B % i == 0) {
--K ;
if ( K == 0) {
cout << i << endl ;
return 0;
}
}
}
assert ( false );
}


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

void fnInput(int& rnMaxNum, int& rnWinPnt)
{
  cin >> rnMaxNum >> rnWinPnt;
}

double fnWinRate(int nMaxNum, int nWinPnt)
{
  vector<int> vnBorder;

  int nBorder = nWinPnt;
  vnBorder.push_back( nBorder );

  while (nBorder > 1)
  {
    nBorder = (nBorder + 1) / 2;
    vnBorder.push_back( nBorder );
  }
  double nWinRate = 0.0;

  for (int nPower = vnBorder.size() - 1; nPower > 0; nPower--)
  {
    double nOneRate = 0.0;
    int nNum = vnBorder[nPower];

    while (nNum < min(vnBorder[nPower - 1], nMaxNum + 1))
    {
      nOneRate += 1.0 / nMaxNum;
      nNum++;
    }
    for (int n = 0; n < nPower; n++)
      nOneRate *= 1 / 2.0;

    nWinRate += nOneRate;
  }
  if (nMaxNum >= vnBorder[0])
  {
    int nDiff = nMaxNum - vnBorder[0] + 1;
    nWinRate += (double)nDiff / nMaxNum;
  }
  return nWinRate;
}
  
int main()
{
  int nMaxNum, nWinPnt;
  fnInput(nMaxNum, nWinPnt);
  cout << fixed << setprecision(10) << fnWinRate(nMaxNum, nWinPnt) << endl;

  return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <stdlib.h>
#include <string>
#define llint long long

using namespace std;

llint n, a, b, mod;
llint beki[35];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

llint calc2(llint n, llint x)
{
	if(n == 0) return 0;
	if(n % 2){
		return (calc2(n-1, x) + modpow(modpow(10, n-1), x) % mod) % mod;
	}
	else{
		llint res = calc2(n/2, x);
		llint ret = res * modpow(modpow(10, n/2), x) % mod + res; ret %= mod;
		return ret;
	}
}

llint calc(llint l, llint r, llint d)
{
	//cout << l << " " << r << " " << d << endl;
	if(l > r) return 0;
	if(l == r) return (a%mod+b%mod*l%mod) % mod;
	if((r-l+1)%2){
		return (calc(l+1, r, d) + modpow(modpow(10, r-l), d) % mod * ((a%mod+b%mod*l%mod)%mod) % mod) % mod;
	}
	else{
		llint m = (l+r)/2;
		llint res = calc(l, m, d);
		llint ret = res * modpow(modpow(10, r-m), d) % mod + res; ret %= mod;
		ret += b*(r-m)%mod * calc2(r-m, d) % mod, ret %= mod;
		return ret;
	}
}

int main(void)
{
	cin >> n >> a >> b >> mod;
	//mod = 1000000007;
	beki[0] = 1;
	for(int i = 1; i < 19; i++) beki[i] = beki[i-1] * 10;
	
	llint len = 1, ans = 0;
	for(int i = 18; i >= 1; i--){
		//cout << i << endl;
		llint l = (beki[i-1]-a+b-1)/b;
		llint r = (beki[i]-a+b-1)/b - 1;
		
		if((beki[i-1]-a+b-1) < 0) l = -1;
		if((beki[i]-a+b-1)/b < 0) r = -1;
		
		if(l >= n || r < 0) continue;
		r = min(r, n-1), l = max(l, 0LL);
		//cout << ans << endl;
		//cout << l << " " << r << " " << i << " " << len << endl;
		llint res = calc(l, r, i);
		ans += res * len % mod, ans %= mod;
		llint tmp = modpow(modpow(10, r-l+1), i);
		len *= tmp, len %= mod;
		//len += (r-l+1)%mod * i%mod, len %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
    int N=0;
    cin>>N;

    vector<int> pi(N);
    for(auto &x:pi){
        cin>>x;
    }


    sort(pi.begin(),pi.end());

    pi[N-1]/=2;

    cout<<accumulate(pi.begin(),pi.end(),0)<<endl;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {
	

	int n  ;
	cin >> n;

	if (n <= 9) {
		cout << "Yes";
	}
	else {
		for (int i = 2; i <= 9 ; i++) {
			if (n % i == 0 and n / i <= 9) {
				cout << "Yes";
				return 0 ;
			}
		}
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static vector<int32_t> x, y;

int main()
{
	int32_t N;
	scanf("%d", &N);

	vector<int32_t> x(N), y(N);
	for (int32_t i = 0; i < N; i++) {
		scanf("%d %d", &x[i], &y[i]);
	}

	vector<int32_t> v(N);
	for (int32_t i = 0; i < N; i++) {
		v[i] = i;
	}

	double res = 0.0;
	sort(v.begin(), v.end()); // need sort
	do {
		for (int32_t i = 0; i < N - 1; i++) {
			res += sqrt((x[v[i]] - x[v[i + 1]]) * (x[v[i]] - x[v[i + 1]]) + (y[v[i]] - y[v[i + 1]]) * (y[v[i]] - y[v[i + 1]]));
		}
	} while (std::next_permutation(v.begin(), v.end()));

	int32_t comb = 1;
	for (int32_t i = 2; i <= N; i++) {
		comb *= i;
	}
	res /= comb;

	printf("%.17f\n", res);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int isleap(int y)
{
	int leap=0;
	if(y%4==0)
	{
		leap=1;
		if(y%100==0)
		{
			leap=0;
			if(y%400==0)
			{
				leap=1;
			}
		}
	}
	return leap;
}

int main()
{
	int a,b,i,isNA,first=1;

	while(1)
	{
		scanf("%d %d",&a,&b);
		if(a==0&&b==0)
		{
			break;
		}
		isNA=1;
		if(first)
		{
			first=0;
		}
		else
		{
			putchar('\n');
		}

		for(i=a;i<=b;i++)
		{
			if(isleap(i))
			{
				isNA=0;
				printf("%d\n",i);
			}
		}
		if(isNA)
		{
			puts("NA");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll h,a;
  std::cin>>h>>a;

  rep(i,1,100000){
    h-=a;
    if(h<=0){
      std::cout<<i<<"\n";
      return 0;
    }
  }

  return 0;
}


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

int n,r;

int main()
{
  cin >> n >> r;
  if(n >= 10) cout << r << endl;
  else cout << r+100*(10-n) << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
    char c;
    int n[26]={0};
    int i;

    while(scanf("%c",&c)!=EOF){
        if(c>='a'&&c<='z'){
            c-='a'; 
            n[c]++;
        }else if (c>='A'&&c<='Z'){
            c-='A'; 
            n[c]++;
        }
    }
    
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i,n[i]);
    }

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  int ans = 0;

  for (int i = 0; i < n - 2; i++) {
    if (p[i + 1] < p[i] || p[i + 1] < p[i + 2]) {
      if (!(p[i + 1] < p[i] && p[i + 1] < p[i + 2])) {
        ans++;
      }
    }
  }

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

Measured memory_bytes: 256