akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    int a,b,c,d,W,H;
    while(1){
        scanf("%d%d",&H,&W);
        if(W==0&&H==0)break;
        for(a=0;a<H;a++){
            for(b=0;b<W;b++){
                c=H-1;
                d=W-1;
                if(a==0||c==a){
                printf("#");
                }else if(b==0||b==d){
                printf("#");
                }else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int h;
    cin >> h;
    int k = floor(log2(h)) + 1;
    cout << (long long int)pow(2,k) - 1 << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if ((a*100+b*10+c)%4==0) cout << "YES" << endl;
 else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	double n,m;
	double x,y;
	int t=0;
	cin>>n>>m;
	cin>>x>>y;
	if(n/2.0==x && m/2.0==y)t=1;
	cout<<n*m/2.<<" "<<t<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100050;
int N, M;
long long A[MAX_N], C[MAX_N];
int B[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> M;

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

    for (int i = 1; i <= M; i++) {
        std::cin >> B[i] >> C[i];
    }

    std::vector<long long> vec;
    std::vector<int> op;

    for (int i = 1; i <= N; i++) {
        vec.push_back(A[i]);
    }

    std::sort(vec.begin(), vec.end());

    for (int i = 1; i <= M; i++) {
        op.push_back(i);
    }

    std::sort(op.begin(), op.end(),
        [](const int a, const int b) { return C[a] > C[b]; }
    );

    int cur = 0;
    for (int i = 0; i < op.size(); i++) {
        for (int j = 0; j < B[op[i]]; j++) {
            if (vec[cur] >= C[op[i]]) {
                break;
            }
            vec[cur] = C[op[i]];
            cur++;
            if (cur == N) {
                break;
            }
        }
        if (vec[cur] >= C[op[i]] || cur == N) {
            break;
        }
    }

    long long ret = 0;
    for (long long n : vec) {
        ret += n;
    }

    std::cout << ret << std::endl;



    return 0;
}


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

using namespace std;

int main(){
	/*/freopen("in.txt.txt","r",stdin);
	freopen("out.txt.txt","w",stdout);*/
	long long n;
	cin>>n;
	long long k=100,count=0;
	while(k<n){
		k+=k/100;
		count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3604
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static int mod = (int) (1e9+7),MAX=(int) (2e5+100);
    static List<Integer>[] edges;
    static long[][][][] dp;
    static int n,d;
    static char[] s;
    
	public static void main(String[] args) {
	
		s = sc.next().toCharArray();
		d = sc.nextInt();
		n = s.length;
		dp = new long[n+1][d][2][2];
		
		for(int i=0;i<dp.length;++i) {
			for(int j=0;j<dp[i].length;++j) {
				for(int k=0;k<dp[i][j].length;++k)
				Arrays.fill(dp[i][j][k], -1);
			}
		}
	    long ans = f(0,0,1,0);
	    out.print(ans);
		out.close();
   }

	private static long f(int i, int m, int tight,int st) {
		if(i == s.length) {
			if(m == 0 && st != 0) return 1;
			return 0;
		}
		if(dp[i][m][tight][st] != -1) return dp[i][m][tight][st];
		long o1 = 0;
		int end = (tight==1)?s[i]-'0':9;
		if(st == 0) {
		   o1 = (o1 + f(i+1,m,tight&(s[i]=='0'?1:0),st))%mod;	
		   for(int dig=1;dig<=end;++dig) {
				o1 = (o1 + f(i+1,(m+dig)%d,tight&((dig == end)?1:0),1))%mod;
			}
		}else {
		for(int dig=0;dig<=end;++dig) {
			o1 = (o1 + f(i+1,(m+dig)%d,tight&((dig == end)?1:0),1))%mod;
		}
		}
		return dp[i][m][tight][st] = o1;
	}
	


    }



Measured memory_bytes: 149736
s=input()
cand=["0"+str(i) for i in range(1,10)]+["10","11","12"]
if s[:2] in cand and s[2:] in cand:
    print("AMBIGUOUS")
elif s[:2] in cand:
    print("MMYY")
elif s[2:] in cand:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, f = 0, t = 0, o = 0;
	bool ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2)o++;
		else if (a % 4)t++;
		else f++;
	}
	if (n / 2 <= f)ans = 1;
	else if (o <= f)ans = 1;
	else if (!o)ans = 1;
	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string str;
	std::cin >> str;
	auto N = str.size() + 1;
	std::set<index_t> bottom;
	if (str.front() == '<')
	{
		bottom.emplace(0);
	}
	for (auto i : boost::irange<index_t>(1, N - 1))
	{
		if (str[i - 1] == '>' && str[i] == '<')
		{
			bottom.emplace(i);
		}
	}
	if (str.back() == '>')
	{
		bottom.emplace(str.size());
	}
	std::vector<std::int64_t> vec(N);
	for (auto b : bottom)
	{
		vec[b] = 0;
		for (auto i = b; 0 < i; --i)
		{
			if (str[i - 1] == '>')
			{
				vec[i - 1] = std::max(vec[i - 1], vec[i] + 1);
			}
			else
			{
				break;
			}
		}
		for (auto i = b; i < N - 1; ++i)
		{
			if (str[i] == '<')
			{
				vec[i + 1] = std::max(vec[i + 1], vec[i] + 1);
			}
			else
			{
				break;
			}
		}
	}
	std::cout << std::accumulate(vec.begin(), vec.end(), std::int64_t(0)) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 10524
import math as m
nums = [int(e) for e in input().split()]
count = 0
for i in range(nums[0]):
    list = [int(e) for e in input().split()]
    x = m.sqrt(list[0]*list[0]+list[1]*list[1])
    if x<=nums[1]:
        count = count+1

print(count)    


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

const int MAX_N = 2e3 + 5;

vector<int> adj [MAX_N];
int token [MAX_N];

int maxp [MAX_N];
int subc [MAX_N];
int minp [MAX_N];

int dfs (int u, int p) {
  subc[u] = token[u];
  maxp[u] = 0;
  minp[u] = 0;
  pair<int, int> bigch = {-1, -1};
  for (int nxt : adj[u]) {
    if (nxt != p) {
      dfs(nxt, u);
      subc[u] += subc[nxt];
      maxp[u] += maxp[nxt];
      bigch = max(bigch, make_pair(minp[nxt], nxt));
    }
  }

  if (bigch.first != -1) {
    for (int nxt : adj[u]) {
      if (nxt != p && nxt != bigch.second) {
        bigch.first -= maxp[nxt];
      }
    }

    if (bigch.first < 0) minp[u] = maxp[u] % 2;
    else minp[u] = bigch.first;
  } else {
    minp[u] = 0;
  }

  // assert(minp[u] % 2 == maxp[u] % 2);
  
  if (u == p) {
    //cerr << u << " " << minp[u] << " " << maxp[u] << endl;
    if (minp[u] == 0) return maxp[u] / 2;
    else return 1 << 30;
  } else {
    maxp[u] += subc[u];
    // if (subc[u] - token[u] != 0) minp[u]++;
    // if (token[u]) minp[u]++;
    minp[u] += subc[u];
    //cerr << " " << u << " " << minp[u] << " " << maxp[u] << endl;
    return 0;
  }
}

int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  string s;
  cin >> s;

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  for (int i = 1; i <= n; i++) {
    token[i] = s[i - 1] == '1';
  }

  int ans = 1 << 30;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, dfs(i, i));
  }

  if (ans == 1 << 30) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}


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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N+1);
    long long total = 0;
    for(int i=0; i<N+1; i++){
        std::cin >> A[i];
        total += A[i];
    }
    
    long long cnt_d = 1;
    long long cnt = 0;
    for(int i=0; i<N+1; i++){
        if(cnt_d < A[i]){
            std::cout << -1 << std::endl;
            return 0;
        }
        cnt += cnt_d;
        cnt_d = (cnt_d - (long long)A[i]) * 2;
        total -= A[i];
        if(cnt_d > total){
            cnt_d = total;
        }
    }
    
    std::cout << cnt << std::endl;
    
    return 0;
}



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

#define MOD 10000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    int l;
    cin >> l;
    cout << l*l << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[15];
int main(){
	int a,b;
	cin>>a>>b;
	getchar();
	for(int i=0;i<a+b+1;i++){
		s[i]=getchar();	
		if(i!=a){
			
			if(s[i]<'0' || s[i]>'9'){
				cout<<"No";
				return 0;
			}
			
		}
		else{
			if(s[i]!='-'){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
		
	
	
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

int main(){
    int N;
    string name;
    cin >> N >> name;
    int ans=0;
    REP(m,N){
        string sb;
        cin >> sb;
        if(name.length()>sb.length())continue;
        string::size_type idx;
        int flag=0;
        while((idx = sb.find(name[0])) != string::npos){
            sb = sb.substr(idx);
            //            cout << sb << endl;
            //            cout << idx << endl;
            FOR(i,1,100){
                REP(j,sb.length()){
                    if(j*i>=sb.length()){
                        break;
                    }
                    if(sb[j*i]!=name[j]){
                        break;
                    }
                    if(j==name.length()-1){
                        flag=1;
                        goto end;
                    }
                }
            }
            if(1==sb.length())break;
            sb = sb.substr(1);
        }
end:;
    if(flag)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main()
{
	int N;
	cin >> N;
	double ans = (double)(N/2 + N%2) / (double)N;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    string S,T;  cin >> S >> T;
    string ans = "";
    rep(i,2*N){
        if(i % 2 == 0){
            ans +=S[i/2];
        }
        else ans += T[i/2];
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
kouho = []
for i in range(f // (100 * a) + 1):
    for j in range(f // (100 * b) + 1):
        water = 100 * (a * i + b * j)
        if water > f:
            break
        if water == 0:
            continue
        sugar_max = (a * i + b * j) * e
        for k in range(sugar_max // c + 1):
            for l in range(sugar_max // d + 1):
                sugar = c * k + d * l
                if water + sugar > f:
                    break
                if sugar > sugar_max:
                    break
                density = (sugar / (water + sugar), water + sugar, sugar)
                kouho.append(density)
kouho.sort(reverse=True)
print(kouho[0][1], kouho[0][2])


Measured memory_bytes: 109548
def resolve():
    D = int(input())
    C = [int(x) for x in input().split()]
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))
    last_d = []
    score = 0

    for d in range(D):
        contest = 0
        for i in range(len(C)):
            contest = max(contest, S[d][i])
        score += contest
        last_d.append(S[d].index(contest))
        for i in range(len(C)):
            if i in last_d:
                score -= C[i] * last_d[::-1].index(i)
            else:
                score -= C[i] * (d + 1)
        print(S[d].index(contest) + 1)

    
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9212
#include<stdio.h>
 
int main()
{
  int n,m,l,i,j,k;
  double sum;
  scanf("%d %d %d",&n,&m,&l);
  int a[n][m],b[m][l];
  double out[n][l];
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
  for(i=0;i<m;i++)
    for(j=0;j<l;j++)
      scanf("%d",&b[i][j]);
 
  sum=0;
 
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
        for(k=0;k<m;k++)  sum+=(double)a[i][k]*b[k][j];
 
        out[i][j]=sum;
        sum=0;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++) {
      printf("%.0lf",out[i][j]);
      if(j<l-1) printf(" ");
    }
    printf("\n");
  }
 
  return 0;
 
}

Measured memory_bytes: 792
import numpy as np

N,K=map(int,input().split())
H=list(map(int,input().split()))
sortedH=np.hstack((np.zeros(1,dtype=np.int64), np.sort(H)))

dic={}
for i,h in enumerate(sortedH):
    dic[h]=i

inf=10**15
dp=np.full((302,len(sortedH)+1),inf,dtype=np.int64)
dp[0,0]=0

for i,h in enumerate(H):
    for k in range(i+1,-1,-1):
        dp[k+1]=np.minimum(dp[k+1],dp[k])
        idx=dic[h]
        ma=np.min(dp[k][:idx]+h-sortedH[:idx])
        mb=np.min(dp[k][idx:])
        dp[k]=np.full(len(sortedH)+1,inf,dtype=np.int64)
        dp[k][idx]=min(ma,mb)
print(np.min(dp[:K+1]))

Measured memory_bytes: 15172
#include <bits/stdc++.h>
using namespace std;
#define l1 long long
int main(){
	int n,p,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
        cin>>p;
        if(i%2!=0 && p%2!=0)c++;
	}cout<<c;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;



int main()
{
  fastio();

ll int T=1;
//cin>>T;
while(T--)
{
  ll int n,m,k,ans,cnt;
  ans=1;cnt=0;
  cin>>n;

  ll int a[n];
  for(ll int i=0;i<n;i++)
  {  
         cin>>a[i];
         if( a[i]%2==0 )
         {
              if( a[i]%3!=0 && a[i]%5!=0 )
                 ans=0;
         }
  }

  
  if(ans)
   cout<<"APPROVED"<<endl;
  else
   cout<<"DENIED"<<endl;
}}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	b+=c;
	if(b>a)
	c=b-a;
	else
	c=0;
	printf("%d\n", c);
	
	return 0;
}

Measured memory_bytes: 128
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, ll X, std::vector<ll> m) {
  ll r = X;

  sort(all(m));
  rep(i, N) { r -= m.at(i); }
  cout << N + r / m.at(0) << endl;
}

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


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

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




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

{

cout<<"1.0000000000"<<endl;
return 0;
}
kk=n/2;
if(n%2==0)
   {
       cout<<setprecision(6)<<fixed<<(kk)/n<<endl;
   }
   else{cout<<setprecision(6)<<fixed<<(kk+1)/n<<endl;}




}


Measured memory_bytes: 3844
#include <iostream>

using namespace std;

int main(){
  int N, a[10010];

  cin >> N;
  for(int i = 1; i <= N; i++) cin >> a[i];

  int cnt=0;
  for(int i = 1; i <= N; i++){
   while(a[i]%2 == 0){
    a[i] /= 2;
     cnt++;
   }
  }
  
  cout << cnt << endl;

  return 0;
}


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

int n, sol;
string s;

int main()
{
    cin >> n;
    cin >> s;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            sol++;
        }
    }
    int nr = sol;
    for(int i = 0; i < nr; i++) {
        if(s[i] == 'R') {
            sol--;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 3756
def read():
    N, K = list(map(int, input().strip().split()))
    return N, K

def solve(N, K):
    count = 0
    while N > 0:
        N //= K
        count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	map<int, int> x;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		x[a]++;
	}

	if (k >= x.size())
	{
		println(0);
	}
	else
	{
		int j = 0;
		vector<int> p(x.size());
		for (auto i : x)
		{
			if (i.second > 0)
			{
				p.at(j++) = i.second;
			}
		}

		sort(all(p));

		int res = 0;
		int l = x.size() - k;
		for (int i = 0; i < l; i++)
		{
				res += p.at(i);
		}

		println(res);
	}
}

Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	vector<string> s(n);

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

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

	for (int i = 0; i < n; i++) {
		cout << s[i];
	}



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;i++)
#define rep1(i,n)  for(int i=1;i<=n;i++)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
typedef long long ll;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(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 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
int main() {
	char a, b;
	cin >> a >> b;
	string Ans;
	if (ctoi(a) == ctoi(b)) {
		for (i = 0; i < ctoi(a); i++) {
			Ans += a;
		}
	}
	else if (ctoi(a) > ctoi(b)) {
		for (i = 0; i < ctoi(a); i++) {
			Ans += b;
		}
	}
	else {
		for (i = 0; i < ctoi(b); i++) {
			Ans += a;
		}
	}
	cout << Ans;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll h1,w1,h2,w2,f;
    cin>>h1>>w1>>h2>>w2>>f;
    ll k=(h2-h1)*60+(w2-w1);
   cout<<k-f<<endl;
}


Measured memory_bytes: 3608
/*
        ALLAH HOAKBAR

        Showkat Reza
        Dept of ICT
        Comilla University

        reminder=20000/30;
        reminder= 666;
*/
#include <bits/stdc++.h>
using namespace std;
#define     LL      long long int
#define     yes     cout<<"YES"<<endl
#define     no     cout<<"NO"<<endl


vector<LL> v,v2,v3;


void read()
{
    LL a,b,c,d;
    cin>>a>>b>>c>>d;
    LL x=a*c;
    LL y=b*d;
    LL z=a*d;
    LL t=b*c;
    cout<<max(max(x,y),max(z,t))<<endl;


}


int main()
{
    read();
    //solve();
    return 0;

}


Measured memory_bytes: 3620
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
fn main() {
    input!(A: i64, B: i64, C: i64);
    input!(K: i64);
    let mut ans = false;
    for i in 0..=K {
        for j in 0..=K {
            for k in 0..=K {
                if i + j + k <= K {
                    ans = ans
                        || check(
                            A * 2i64.pow(i as u32),
                            B * 2i64.pow(j as u32),
                            C * 2i64.pow(k as u32),
                        );
                }
            }
        }
    }

    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn check(r: i64, g: i64, b: i64) -> bool {
    r < g && g < b
}


Measured memory_bytes: 2120
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map_as(H, W, replace={'#': 1, '.': 0}):
    '''
    文字列のmapを置換して読み込み。デフォでは#→1,.→0
    '''
    ret = []
    ret.append([1] * (W + 2))
    for _ in range(H):
        ret.append([1] + [replace[s] for s in read()[:-1]] + [1])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    ret.append([1] * (W + 2))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc129/tasks/abc129_d
# すべてのマスにおいてみてって感じかな
# 2000*2000だとマスにおいたときにO(1)で何マス照らせるか取得したい
# 前処理で横/縦に何マス伸びてるか記録しておけばいいのでは？

H, W = read_ints()
S = read_map_as(H, W)

yoko = [[-1] * (W + 2) for _ in ra(H + 2)]
tate = [[-1] * (W + 2) for _ in ra(H + 2)]

# 横の前処理
for i in ra(H + 2):
    fillranges = []
    pre_0 = 0
    for j in ra(1, W + 2):
        if S[i][j] == 1:
            fillranges.append((pre_0, j))
            pre_0 = j
    for l, r in fillranges:
        for j in range(l, r):
            yoko[i][j] = r - l - 1

# 縦の前処理
for j in ra(W + 2):
    fillranges = []
    pre_0 = 0
    for i in ra(1, H + 2):
        if S[i][j] == 1:
            fillranges.append((pre_0, i))
            pre_0 = i
    for l, r in fillranges:
        for i in range(l, r):
            tate[i][j] = r - l - 1

# from pprint import pprint
# pprint(tate)
# pprint(yoko)
ans = 0
for i, j in product(range(1, H + 1), range(1, W + 1)):
    ans = max(yoko[i][j] + tate[i][j] - 1, ans)
print(ans)


Measured memory_bytes: 136968
var input = function()
{

  return require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
};

var out = function(x)
{
  console.log(x);
  return x;
}

var drawRect = function(H,W)
{
  var rect = "";
  for (var i = 0; i < H; i++)
  {
    if (i%2 == 0)
    {
      rect = rect+drawLine1(W);
    }
    else
    {
      rect = rect+drawLine2(W);
    }

  }
  out(rect);
  return rect;
}

var drawLine1 = function(W)
{
  var line = "";
  for(i=0;i<W;i++)
  {
    if(i%2 == 0)
    {
      line = line+'#';
    }
    else
    {
      line = line+'.';
    }
  }
  line = line+'\n';
  return line;
}

var drawLine2 = function(W)
{
  var line = "";
  for(i=0;i<W;i++)
  {
    if(i%2 != 0)
    {
      line = line+'#';
    }
    else
    {
      line = line+'.';
    }
  }
  line = line+'\n';
  return line;
}

var calc = function(x)
{
for (var i = 0; i < x.length; i++) {
  var HW = x[i].split(' ').map(Number);
  if(HW[0]==0 && HW[1] ==0)return;
  drawRect(HW[0],HW[1]);
}
return x;
};

calc(input());

Measured memory_bytes: 10680
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]).sort();
    auto b = readln.split.to!(int[]).sort();
    auto c = readln.split.to!(int[]).sort();

    long ans;

    foreach (bi ; b) {
        auto lw = a.lowerBound(bi).length.to!long;
        auto up = c.upperBound(bi).length.to!long;
        ans += lw * up;
    }

    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 12360
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 200005
using namespace std;
int n,v,len,tt,a[MN],l[25][MN],r[25][MN],f[1<<18],g[1<<18];
int main(){
	scanf("%d%d",&n,&v);
	while(v>>len)len++;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=0;i<=len;i++){
		l[i][1]=1;r[i][n]=n;
		for(int j=2;j<=n;j++)if(a[j]-a[j-1]<=(v>>i))l[i][j]=l[i][j-1];else l[i][j]=j;
		for(int j=n-1;j>=1;j--)if(a[j+1]-a[j]<=(v>>i))r[i][j]=r[i][j+1];else r[i][j]=j;
	}g[0]=n+1;
	for(int i=0;i<(1<<len);i++){
		g[i]=n+1;
		for(int j=0;j<len;j++)if(i&(1<<j)){
			f[i]=max(f[i],r[len-j][min(f[i-(1<<j)]+1,n)]);
			g[i]=min(g[i],l[len-j][max(g[i-(1<<j)]-1,1)]);
		}
	}bool pd=false;
	for(int i=1;i<=n;i++)if(l[0][i]!=l[0][i-1])tt++;
	if(tt>20){for(int i=1;i<=n;i++)puts("Impossible");return 0;}
	for(int i=1,j;i<=n;i++){
		if(l[0][i]!=l[0][i-1]){
			for(j=0;j<(1<<len);j++)if(f[j]>=l[0][i]-1&&g[(1<<len)-j-1]<=r[0][i]+1){pd=true;break;}
			if(j==(1<<len))pd=false;
		}printf("%s\n",pd?"Possible":"Impossible");
	}
}

Measured memory_bytes: 37888
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int H,W,ans=0,cnt=0;
  cin>>H>>W;
  vector<string> A(H+2);
  for(int i=0; i<W+2; i++){A[0].push_back('@');A[H+1].push_back('@');}
  for(int i=1; i<=H; i++){
    string a;
    cin>>a;
    A[i].push_back('@');
    A[i]+=a;
    A[i].push_back('@');
  }
  vector<vector<int>> memo(H+1,vector<int>(W+1,0));
  queue<pair<int,int>> que;
  int y,x;
  vector<int> dy={1,-1,0,0},dx={0,0,1,-1};
  /*for(int i=1; i<=H; i++){
      for(int j=1; j<=W; j++){
        if(A[i][j]=='#') {
          que.push(make_pair(i,j));
          memo[i][j]=1;
          y=i; x=j;
        }
      }
  }*/
  while(cnt<H*W){
    for(int i=1; i<=H; i++){
      for(int j=1; j<=W; j++){
        if(A[i][j]=='#') {
          que.push(make_pair(i,j));
          cnt++;
          memo[i][j]=0;
        }
      }
    }
    
    while(que.size()){
    y=que.front().first; x=que.front().second;
    que.pop();
    for(int i=0; i<4; i++){
    if(A[y+dy[i]][x+dx[i]]=='.'){
      A[y+dy[i]][x+dx[i]]='#';
      cnt++;
      memo[y+dy[i]][x+dx[i]]=memo[y][x]+1;
      ans=max(ans,memo[y+dy[i]][x+dx[i]]);
      if(cnt==H*W)break;
      que.push(make_pair(y+dy[i],x+dx[i]));
        }
      }
    }
    
        /*for(int i=1; i<=H; i++)cout<<A[i]<<endl;
    cout<<endl;cout<<cnt<<endl;*/
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 14352
N = int(input())
s = input()

def countSameChar(x,y):
  cnt = 0
  for char in [chr(ord("a")+i) for i in range(26)]:
    if char in x and char in y:
      cnt += 1
  return cnt

def solve(n,s):
  ans = 0
  for i in range(n-2):
    x = s[:i+1]
    y = s[i+1:]
    ans = max(ans,countSameChar(x,y))
  return ans

print(solve(N,s))

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1);
    rep2(i,1,N+1) cin >> a[i];
    vector<int> a_put(N+1);
    for(int i=N;i>0;i--){
        int num=0;
        rep2(j,1,(int)(N/i)){
            num+=a_put[i+i*j];
        }
        if(num%2!=a[i]){
            a_put[i]=1;
        }
    }

    int cnt=0;
    vector<int> ans;
    rep2(i,1,N+1){
        if(a_put[i]==1){
            cnt++;
            ans.push_back(i);
        }
    }

    cout << cnt << endl;
    rep(i,ans.size()) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3064
n,k,q=map(int,input().split())
a=[int(input()) for x in range(q)]
point=[k-q for x in range(n)]
for i in range(q):
    point[a[i]-1]+=1

for i in range(n):
    if(point[i] > 0):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11796
package main

import (
	"fmt"
	"sort"
)

type rest struct {
	Number int
	City   string
	Point  int
}

func main() {
	var N int
	fmt.Scan(&N)
	rs := make([]rest, N)
	mc := make(map[string]int, 0)
	for i := range rs {
		var s string
		var p int
		fmt.Scan(&s, &p)
		rs[i].Number = i + 1
		rs[i].City = s
		rs[i].Point = p
		mc[s]++
	}
	ss := make([]string, 0)
	for k := range mc {
		ss = append(ss, k)
	}
	sort.Strings(ss)
	for i := 0; i < len(ss); i++ {
		// 名前はすでにソート済み
		m := make(map[int]int, 0) // ポイント -> 番号
		for j := 0; j < N; j++ {
			if ss[i] == rs[j].City {
				m[rs[j].Point] = rs[j].Number
			}
		}
		ks := make([]int, 0)
		for k := range m {
			ks = append(ks, k)
		}
		sort.Sort(sort.Reverse(sort.IntSlice(ks)))
		for j := 0; j < len(ks); j++ {
			fmt.Println(m[ks[j]])
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n, k;
int a[510], c[510], s = 0, ans = 0;
int cal(int k) {
    for(int i = 0; i < n; i++) c[i] = a[i] % k;
    sort(c, c + n);
    int l = 0, r = n-1, ret = 0;
    while(l < r) {
        if(c[l] < k-c[r]) {
            c[r] += c[l];
            ret += c[l];
            l++;
        }
        else {
            c[l] -= k-c[r];
            ret += k-c[r];
            r--;
        }
    }
    return ret;
}
int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        scanf("%d", a + i);
        s += a[i];
    }
    for(int i = 1; i*i <= s; i++) {
        if(s % i == 0) {
            if(cal(i) <= k) ans = max(ans, i);
            if(cal(s/i) <= k) ans = max(ans, s/i);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

int p[1001];
int h[1000*1000+1001];

int main(){
	int n,m,ans;
	while(cin>>n>>m){
		if(n==0&&m==0) break;
		p[0]=0;
		ans=0;
		for(int i=1; i<=n; ++i){
			cin >> p[i];
		}
		for(int i=0; i<=n; ++i){	
			for(int j=0; j<=n; ++j){
				h[i*n+j]=p[i]+p[j];
			}
		}
		sort(h,h+n*n+1);
		/*
		for(int i=0; i<=n*n; ++i){
			cout << h[i] << "\n";
		}
		*/
		for(int i=0; i<=n; ++i){	
			for(int j=0; j<=n; ++j){	
				int tmp=p[i]+p[j];
				int l=0,r=n*n;
				int cnt=0;
				while(1){
					int mid=(r+l)/2;
					if(cnt>=30){
						if(h[mid]+tmp<=m) ans=max(ans,h[mid]+tmp);
						break;
					}
					if(h[mid]+tmp>m){
						r=mid;
					} else if(h[mid]+tmp<m){
						l=mid;
					} else if(h[mid]+tmp==m){
						ans=m;
						break;
					}
					++cnt;
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 5092
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long



int main(){
    long long int K,A,B;//10^9
    scanf("%lld %lld %lld",&K,&A,&B);
    long long int ans=0;
    if(B>A+1){
        ans=A+((K-A+1)/2)*(B-A)+((K-A+1)%2);
    }else{
        ans=K+1;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int i, j, h[n];
    for(i=0; i<n; i++) {
        cin >> h[i];
    }
    int cost[n];
    cost[0] = 0;

    int temp, min;
    for(i=1; i<n; i++) {
        for(j=i-1, min = 1000000000; j>=(i-k) && j>=0; j--) {
            temp = abs(h[i] - h[j]) + cost[j];
            if(temp < min) min=temp;
        }
        cost[i] = min;
    }

    cout << cost[n-1] << endl;
}



Measured memory_bytes: 1024
#include<stdio.h>
#define N 5
int main()
{
	int s[5],k=0,t=9,l,f=0,i;

	for(i=0;i<N;i++)
		scanf("%d",&s[i]);

	l=s[0];
	for(i=0;i<N;i++)
		if((t>s[i]%10)&&(s[i]%10>0)){
			l=s[i];
			t=s[i]%10;
		}
	for(i=0;i<N;i++){
		if(s[i]%10!=0){
			s[i]=s[i]+(10-s[i]%10);
			f=1;
		}
		k+=s[i];
	}
	if(f==1)
		k=k-(l+10-l%10)+l;
	printf("%d",k);
	return 0;
}

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

#define ll long long

using namespace std;

int n,q,l,r;
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>q>>s;
    vector <int> frec(s.size());
    for (int i=0; i<s.size()-1; i++){
        if (s[i]=='A' && s[i+1]=='C') frec[i+1]=1;
    }
    for (int i=1; i<frec.size(); i++){
        frec[i] = frec[i]+frec[i-1];
    }
    while(q--){
        cin>>l>>r;
        cout<<frec[r-1]-frec[l-1]<<"\n";
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1488
#include<iostream>
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
 {
	
	
	    int n,k;
	    cin>>n>>k;
	    int arr[n];
	    for(int i=0; i<n; i++){
	        cin>>arr[i];
	    }
	    
	    
	    if(n<2){
	    	cout<<"0"<<endl;
		}
	    else{
			long long int dp[n]={0};
		    
		    dp[0]=0;
		    dp[1]=abs(arr[1]-arr[0]);
		    
		    for(int i=2; i<n; i++){
		    	dp[i] = INT_MAX;
		    	for(int j=i-1; j>=i-k && j>=0; j--){
		    		dp[i] = min(dp[i],dp[j]+abs(arr[i]-arr[j]));
				}
			}
			
			cout<<dp[n-1]<<endl;
		}
	
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(int argc, const char * argv[])
{

    double n, sum;
    double s[10];
    int i;
    
    while (scanf("%lf", &n) != EOF) {
        s[0] = n;
        sum = n;
        for (i = 1; i < 10; i++) {
            if (i % 2 != 0) {
                s[i] = s[i - 1] * 2;
            } else {
                s[i] = s[i - 1] / 3;
            }
            sum += s[i];
        }
        printf("%.8lf\n", sum);
    }
    
    return 0;
}

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

using Field = vector<vector<char>>;

int main() {
  int H, W; cin >> H >> W;
  Field field(H, vector<char>(W));
  int count_black = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> field[i][j];
      if (field[i][j] == '#') count_black++;
    }
  }
  
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int>> que;
  dist[0][0] = 1;
  que.push(make_pair(0, 0));
  
  vector<int> dx = {0, 1, 0, -1};
  vector<int> dy = {1, 0, -1, 0};
  
  while(!que.empty()) {
    int x = que.front().second;
    int y = que.front().first;
    for (int k = 0; k < 4; k++) {
      int nx = x + dx[k];
      int ny = y + dy[k];
      if (nx < 0 || ny < 0 || H <= ny || W <= nx) continue;
      if (field[ny][nx] == '#') continue;
      if (dist[ny][nx] != -1) continue;
      
      dist[ny][nx] = dist[y][x] + 1;
      que.push(make_pair(ny, nx));
    }
    que.pop();
  }
  
  int min_dist = dist[H-1][W-1];
  int ans;
  if (min_dist == -1) ans = -1;
  else ans = H*W - min_dist - count_black;
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e18 + 7;
const int N = 21;
std::vector <set <string> > v(N);

int32_t main(){
 L_T_S_K;
 int n;
 cin >> n;
 int x[n] , y[n];
 for(int i = 0 ; i < n ;i++){
  cin >> x[i] >> y[i];
 }
 double ans = 0;
 std::vector<int> v(n , 0);
 iota(v.begin() , v.end() , 0);
 do{
    for(int i = 0 ; i < n - 1  ;i++){
      ans+=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(next_permutation(v.begin() , v.end()) );
 int fact = 1;
 for(int i = 1 ; i <= n ;i++) fact*=i;
 cout << fixed << setprecision(10) << ans/fact << "\n";
  return 0;
}

Measured memory_bytes: 256
import numpy as np

# s = input()
# n = int(input())

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def __call__(self, a, b=None): # calc [a, b) summation by O(1)
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[min(self.n-1, a-1)]
        return res


N, K  = map(int, input().split())

s = input()
ar = np.array(list(map(int, s)))

idx = -1
b = []

for i in np.where(ar[:-1] - ar[1:] != 0)[0]:
    b.append(i-idx)
    idx = i

b.append(N-1-idx)

b_int = Interval(b)

if s[0] == '1':
    print(max(
        b_int(i, i+2*K+1) for i in range(0, b_int.n) if i%2 == 0
    ))    
else:
    res = b_int(0, 2*K)
    if b_int.n > 1:
        res = max(res,max(
            b_int(i, i+2*K+1) for i in range(1, b_int.n) if i%2 == 1
        ))
    print(res)
    


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

using namespace std;

int n, m, q;
vector<int> a, b, c, d, A;
int ans;

void solve() {
	if (A.size() == n) {
		int tmp = 0;
		for (int i = 0; i < q; ++i) tmp += (A[b[i]] - A[a[i]] == c[i] ? d[i] : 0);
		ans = max(ans, tmp);
		return;
	}
	for (int i = (A.size() ? A.back() : 1); i <= m; ++i) {
		A.push_back(i);
		solve();
		A.pop_back();
	}
}

int main() {
	cin >> n >> m >> q;
	a.resize(q); b.resize(q); c.resize(q); d.resize(q);
	for (int i = 0; i < q; ++i) cin >> a[i] >> b[i] >> c[i] >> d[i], --a[i], --b[i];
	solve();
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3644
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))

def fact(n):
    x = 1
    for i in range(1,n+1):
        x *= i
    return x

a = [1,2,3,4,5,6,7,8]
pj = 0
for i in range(0,n-1):
    pj += fact(n-i-1)*a[p[i]-1]
    for j in range(p[i]-1,8):
        a[j] -= 1

a = [1,2,3,4,5,6,7,8]
qj = 0
for i in range(0,n-1):
    qj += fact(n-i-1)*a[q[i]-1]
    for j in range(q[i]-1,8):
        a[j] -= 1


print(abs(pj - qj))


Measured memory_bytes: 3064