akhauriyash/Code-Regression huggingface dataset:
n,k=map(int,input().split())

b=1
S=0
a=0
m=0
for i in range(1,n+1):
    b=i
    for j in range(0,100000):
        if b>=k:
            m=j
            break
        else:
            b=b*2
            continue
    

    S=S+(1/(n*2**(m)))

print(S)

Measured memory_bytes: 40176
#include <iostream>

using namespace std;

long long int N, A, B;

int main(void) {

	cin >> N >> A >> B;

	if (A > B) { cout << 0 << endl; }
	else if (N == 1) {
		if (A == B) { cout << 1 << endl; }
		else { cout << 0 << endl; }
	}
	else {
		cout << ((N - 1)*B + A) - (B + (N - 1)*A) + 1 << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
M=(max(H)+B-1)//B
search=(1,2)
def check(H,k):
    cnt=0
    for i in range(N):
        x=H[i]-k*B
        if x>0:
            cnt+=(x+A-B-1)//(A-B)
    if cnt<=k:return True
    else:return False

mincan=M
maxcant=0
while True:
    k=M*search[0]//search[1]
    if check(H,k):
        if k==maxcant+1:
            ans=k
            break
        mincan=min(mincan,k)
        search=(search[0]*2-1,search[1]*2)
    else:
        if k==mincan-1:
            ans=k+1
            break
        maxcant=max(maxcant,k)
        search=(search[0]*2+1,search[1]*2)
print(ans)

Measured memory_bytes: 7088
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
dp = [[0]*W for _ in range(H)]

def cnt(i0, j0, i1, j1):
  if S[i0][j0] == "." and S[i1][j1] == "#":
    return 1
  else:
    return 0

for i in range(H):
  for j in range(W):
    if i == 0 and j == 0:
      dp[0][0] = 0 if S[0][0] == "." else 1
    elif i == 0:
      dp[i][j] = dp[i][j-1] + cnt(i, j-1, i, j)
    elif j == 0:
      dp[i][j] = dp[i-1][j] + cnt(i-1, j, i, j)
    else:
      dp[i][j] = min(dp[i][j-1] + cnt(i, j-1, i, j), dp[i-1][j] + cnt(i-1, j, i, j))

print(dp[H-1][W-1])

Measured memory_bytes: 3188
#include <stdio.h>

int main()
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2044
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        String b = scan.next();
        StringBuilder sb = new StringBuilder();
        char[] d = b.toCharArray();
        int len = b.length();
        for (int i = 0; i < len; i++) {
            if (d[i] == '.') {
                continue;
            }
            sb.append(d[i]);
        }
        long B = Long.valueOf(sb.toString());

        long ans = A * B / 100;
        System.out.println(ans);
    }
}


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

namespace Contest.cs
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = ReadStr()[0];
			int ans = 0;
			for(int i = 0; i < 4; i++)
			{
				if(s[i] == '+')
				{
					ans++;
				}
				else
				{
					ans--;
				}
			}
			Console.WriteLine(ans);
		}

		static string[] ReadStr()
		{
			return Console.ReadLine().Split(' ').ToArray();

		}

		static int[] ReadIntList()
		{
			return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 19 03:01:30 2018

@author: ashida
"""

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

flag = -1

for n_10k in range(N+1):
    for n_5k in range(N+1-n_10k):
        n_1k = N-n_10k-n_5k
        if 10000*n_10k + 5000*n_5k + 1000*n_1k == Y:
            flag = 1
            ans = [n_10k, n_5k, n_1k]
                
if flag == -1:
    ans = [-1, -1, -1]

print(" ".join(map(str, ans)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n = in();
  ll k = in();
  int q = in();
  //vi a(q); cin >> a;
  vi b(n);
  int x;
  rep(i, q) {
    cin >> x;
    b[x - 1]++;
  }
  if (k > q) {
    rep(i, n) cout << "Yes" << endl;
    return 0;
  } else {
    rep(i, n) {
      if (q - k < b[i]) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1152
/*スタックの実装*/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];/*S[1000]がスタック*/

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}


int main(){
    int a,b;
    int to_push;
    top=0;
    char s[100];/*入力文字列の処理用。スタックではない*/
    while(scanf("%s",s)!=EOF){
        if (s[0]=='+'){
            b=pop();
            a=pop();
            to_push=a+b;
        }else if(s[0]=='-'){
            b=pop();
            a=pop();
            to_push=a-b;
        }else if(s[0]=='*'){
            b=pop();
            a=pop();
            to_push=a*b;
        }else{
            to_push=atoi(s);/*数字の場合はsが２以上の長さになる可能性もあるのでそれを考慮*/
        }
        push(to_push);
    }
    printf("%d\n",pop());
    
    return 0;
}



Measured memory_bytes: 2108
n, k = map(int, input().split())
x = list(map(int, input().split()))

neg_to_pos = n
for i in range(n):
    if x[i] > 0:
        neg_to_pos = i
        break

res = 10 ** 14
for i in range(n - k + 1):
    l = min(x[i], 0)
    r = max(0, x[i + k - 1])
    if i <= neg_to_pos and neg_to_pos - 1 <= i + k - 1:
        tmp = min(-2 * l + r, -l + 2 * r)
        res = min(res, tmp) 
print(res)

Measured memory_bytes: 20028
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll dp[100009][5];

void add(ll &a, ll b){
    a += b;
    if(a>=MOD) a -= MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;
    cin>>S;
    
    mem(dp,0);
    dp[0][0]=1;
    rep(i,S.size()){
        rep(j,5){
            if(S[i]!='?') add(dp[i+1][j], dp[i][j]);
            else add(dp[i+1][j], dp[i][j]*3%MOD);
        }
        if(S[i]=='A' || S[i]=='?') add(dp[i+1][1], dp[i][0]);
        if(S[i]=='B' || S[i]=='?') add(dp[i+1][2], dp[i][1]);
        if(S[i]=='C' || S[i]=='?') add(dp[i+1][3], dp[i][2]);
    }
    
    cout1(dp[S.size()][3]);
}

Measured memory_bytes: 4432
import Prelude             hiding (length)
import Control.Applicative ((<$>))
import Control.Monad       (replicateM)
import Data.List           (sort)
import Data.Vector.Unboxed (Vector(..), (!), fromList, length) 

main :: IO ()
main = do
  n <- readLn
  as <- replicateM n readLn
  print $ solve as

solve :: [Int] -> Int
solve = head . drop 2 . sort . comb . fromList . take 4 . sort

comb :: Vector Int -> [Int]
comb xs = [ (xs ! i) <++> (xs ! j) | i <- is, j <- is, i /= j ]
  where
    x <++> y = read (show x ++ show y)
    is = [0 .. (length xs - 1)]


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

int main(){
  string S;
  int w;
  cin >> S >> w;
  for(int i=0;i<S.size();i++){
    if(i%w==0){
      cout << S.at(i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bits/stdc++.h>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define INF 1LL << 40;
#define MOD 1000000007;
#define ll long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
template <class T> inline void chmax(T &a, T b) { a < b ? a = b : a; };
template <class T> inline void chmin(T &a, T b) { a > b ? a = b : a; };
struct edge {
    int to, cost;
};

int dp[101][1001000];

int main() {
    int n, weight;
    cin >> n >> weight;
    vector<int> w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    rep(i, n + 1) {
        rep(j, 100100) { dp[i][j] = 1000010000; }
    }
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 100010) {
            chmin(dp[i + 1][j], dp[i][j]);
            if(j + v[i] < 100100) {
                chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
            }
        }
    }
    int ans = 0;
    rep(i, n + 1) {
        rep(j, 100010) {
            if(dp[i][j] <= weight) {
                chmax(ans, j);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 244352
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define MAX_N 105
int vx [4]= {1,0,-1,0};
int vy [4]= {0,1,0,-1};
long long  dp[MAX_N][21]={};//dp[i???????????§???][???]????????°
int V[MAX_N],W[MAX_N];
int data[MAX_N],B[MAX_N];
int K ,N,a[MAX_N];
using namespace std;
void init(){

  /*cin >> N;
  cin >> a[1];
    dp[1][a[1]]=1;
  for(int l= 2;l<=N-1;l++){
    cin >> a[l];
    for(int i= 0;i<=20;i++){
      if(i-a[l]>=0&&i-a[l]<=20) dp[l][i] += dp[l-1][i-a[l]];
      if(i+a[l]>=0&&i+a[l]<=20) dp[l][i] += dp[l-1][i+a[l]];
    }
      //REP(i,21)cout<<l<<':'<< i<<' '<<dp[l-1][i]<<endl;
  }
  //REP(i,21)cout<< i<<' '<<dp[N-1][i]<<endl;
  cin >> a[N];
  cout << dp[N-1][a[N]]<<endl;
  */
}
void solve(){
  init();

}
int main(){
  REP(i,9)REP(j,9)cout << i+1<<'x'<<j+1<<'='<<(i+1)*(j+1)<<endl;
    solve();
}

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

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i] && b[i] == c[i])
      continue;
    if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i])
      cnt += 2;
    else
      cnt += 1;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()



int main(){

    map<ll,ll> q1;
    map<ll,ll> q2;

    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        ll val;
        cin >> val;
        q1[val] ++;
    }

    int M;
    cin >> M;
    for(int i = 0; i < M; i++){
        ll val;
        cin >> val;
        q2[val] ++;
    }


    for( auto i = q2.begin(); i != q2.end() ; ++i ) {
        if( q1[i->first] < i->second ){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

}


Measured memory_bytes: 25216
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int nums[26];
int imos[100000+1][26];

int main() {
	string s;
	cin >> s;
	int len = s.size();
	if (len >= 3) {	
		REP(i,0,len-2) {
			if (s[i] == s[i+1] || s[i] == s[i+2]) {
				cout << i+1 << " " << i+3 << endl;
				return 0;
			}
		}
		
		for (int i = len - 1; i >= 2; --i) {
			if (s[i] == s[i-1] || s[i] == s[i-2]) {
				cout << i-1 << " " << i+1 << endl;
				return 0;
			}			
		}
		
	} else if (len == 2) {
		if (s[0] == s[1]) {
			cout << "1 2" << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;

	return 0;
}

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

int selectionSort(int A[], int N)
{
  int sw = 0;
  for (int i = 0; i < N; i++)
  {
    int minj = i;
    for (int j = i; j < N; j++)
    {
      if (A[j] < A[minj])
      {
        minj = j;
      }
    }
    if (minj != i)
    {
      swap(A[i], A[minj]);
      // int v = A[i];
      // A[i] = A[minj];
      // A[minj] = v;
      sw++;
    }
  }
  return sw;
}

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

  int a[n];
  rep(i, n) cin >> a[i];

  int cnt = selectionSort(a, n);
  rep(i, n) {
    cout << a[i];
    if (i != n - 1)
    {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  cout << cnt << endl;

  return 0;
}



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

int main(){
    int N,Y; cin >> N >> Y;
    Y /= 1000;
    for (int i=0;i<=Y/10;i++){
        for (int j=0;j<=Y/5;j++){
            int k=Y-10*i-5*j;
            if (i+j+k==N&&k>=0) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 384
#include <stdio.h>          // printf(), scanf()
#include <ctype.h>          // isdigit()
#include <stdbool.h>

#define L 112
#define L1 (L / 16)
static const long D = 10000000000000000L;
static const int NUL = '\0';

bool
is_zero(long a[])
{
	int i;
	for (i = 0; i < L1; ++i)
	{
		if (a[i] != 0)
			return false;
	}

	return true;
}

void
set_zero(long a[])
{
	int i;
	for (i = 0; i < L1; ++i)
		a[i] = 0;
}

void
ladd(long a[], long b[], long c[])
{
	int i;

	int cy = 0;
	for (i = L1 - 1; i >= 0; --i)
	{
		c[i] = a[i] + b[i] + cy;
		if (c[i] < D)
			cy = 0;
		else
		{
			c[i] -= D;
			cy = 1;
		}
	}
}

void
lmul(long a[], long b, long c[])
{
	long t;
	int i;

	int cy = 0;
	for (i = L1 - 1; i >= 0; --i)
	{
		t = a[i] * b + cy;
		c[i] = t % D;
		cy = t / D;
	}
}

void
ldiv(long a[], long b, long c[])
{
	long t;
	int i;

	long rem = 0;
	for (i = 0; i < L1; ++i)
	{
		t = a[i] + rem;
		c[i] = t / b;
		rem = (t % b) * D;
	}
}

void
calc()
{
	long A[L1];
	long B[L1];
	long C[L1];
	long T[L1];
	char str[L + 1];
	bool overflow;
	int ix;
	int i;
	char c;

	set_zero(A);
	set_zero(B);
	set_zero(C);
	set_zero(T);
	overflow = false;
	for (i = 1; i <= 100; ++i)
	{
		scanf("%c", &c);
		if (!isdigit(c))
			break;

		if (i > 80)
			overflow = true;

		T[L1 - 1] = c - '0';
		lmul(A, 10, A);
		ladd(A, T, A);
	}

	for (i = 1; i <= 100; ++i)
	{
		scanf("%c", &c);
		if (!isdigit(c))
			break;

		if (i > 80)
			overflow = true;

		T[L1 - 1] = c - '0';
		lmul(B, 10, B);
		ladd(B, T, B);
	}

	ladd(A, B, C);
	ix = L;
	str[ix] = NUL;
	for (i = 1; i <= 100; ++i)
	{
		if (i > 80)
		{
			overflow = true;
			break;
		}

		str[--ix] = (C[L1 - 1] % 10) + '0';
		ldiv(C, 10, C);
		if (is_zero(C))
			break;
	}

	if (overflow)
	{
		printf("overflow\n");
		return;
	}

	printf("%s\n", &str[ix]);
}

int
main(int argc, char** argv)
{
	int n, i;

	scanf("%d\n", &n);
	for (i = 0; i < n; ++i)
		calc();

	return 0;
}

Measured memory_bytes: 584
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if ((c>=a)&&(c<=b)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll X[202020],Y[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	ll maP=-1LL<<60,miP=1LL<<60;
	ll maN=-1LL<<60,miN=1LL<<60;
	
	
	FOR(i,N) {
		cin>>X[i]>>Y[i];
		maP=max(maP,X[i]+Y[i]);
		miP=min(miP,X[i]+Y[i]);
		maN=max(maN,X[i]-Y[i]);
		miN=min(miN,X[i]-Y[i]);
	}
	
	cout<<max(maP-miP,maN-miN)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()
#define allpt_r(v) (v).rbegin(), (v).rend()



const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(vector<T> v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;
    return;
}

template <typename T>
void show2dvec(vector<vector<T>> v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

bool in_field(int h, int w, int y, int x)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll h, w, black, white;
    cin >> h >> w;
    string field[h];
    vector<vector<bool>> check(h, vector<bool>(w, false));
    vector<PLL> ans;
    ll answer = 0;
    rep(i, h) cin >> field[i];

    vector<PLL> search, new_search, adjust = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

    rep(i, h) rep(j, w)
    {
        if (!check[i][j])
        {
            black = white = 0;
            search.push_back(make_pair(i, j));
            if (field[i][j] == '.')
                white++;
            if (field[i][j] == '#')
                black++;
            check[i][j] = true;
            while (!search.empty())
            {
                for (auto z : search)
                {
                    for (auto dz : adjust)
                    {
                        if (in_field(h, w, z.first + dz.first, z.second + dz.second) && !check[z.first + dz.first][z.second + dz.second] && field[z.first + dz.first][z.second + dz.second] != field[z.first][z.second])
                        {
                            new_search.push_back(make_pair(z.first + dz.first, z.second + dz.second));
                            if (field[z.first + dz.first][z.second + dz.second] == '.')
                                white++;
                            if (field[z.first + dz.first][z.second + dz.second] == '#')
                                black++;
                            check[z.first + dz.first][z.second + dz.second] = true;
                        }
                    }
                }

                search.clear();
                search = new_search;
                new_search.clear();
            }
            ans.push_back(make_pair(black, white));
        }
    }

    for (auto z : ans)
        answer += z.first * z.second;
    cout << answer << rt;


    return 0;
}


Measured memory_bytes: 6512
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from bisect import bisect_left, bisect_right
n = int(input())
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
    
a.sort()
b.sort()
thre = n//2 if n%2 else n//2-1
def sub(x):
    # xが含まれうるか
    small = bisect_right(a, x) - 1
    large = n - bisect_left(b, x) - 1
    if small>=thre and large>=thre:
        return True
    else:
        return False
    
l = 0
r = 10**9+1

def mid(l):
    if n%2:
        return l[n//2]
    else:
        return (l[n//2-1]+l[n//2])/2
    
ml = mid(a)
mr = mid(b)

if n%2:
    print(mr - ml + 1)
else:
    print(int(2*mr - 2*ml + 1))

Measured memory_bytes: 85060
import math
a, b, c = map(int, raw_input().split())
radius = c / 180.0 * math.pi
h = b * math.sin(radius)
print (a * h) / 2.0
print a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(radius))
print h

Measured memory_bytes: 6744
/**
 *    author:  nasimnoob
**/

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

typedef long long                       ll;
typedef unsigned long long              ull;
typedef long double                     ld;


#define      PI                         3.141592654


int main()
{
    //string ;
    int  a,b,c;
    cin>>a;
    if(a%2==0)
        cout<<a/2<<endl;
    else
        cout<<(a/2)+1<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
//#define INF 0x8f8f8f8f

using namespace std;

char mapp[1005][1005];
int dir[4][2]={0,1,0,-1,1,0,-1,0};
struct poin
{
    int a,b;
};
int ans=0,num=0,n,m;
queue<poin>q1;
queue<poin>q2;

bool check(poin la)
{
    if(mapp[la.a][la.b]=='.'&&la.a<n&&la.a>=0&&la.b<m&&la.b>=0) return true;
    return false;
}

void bfs1()
{
    void bfs2();
    poin now,next;
    while(!q1.empty())
    {
        now=q1.front();
        q1.pop();
        for(int i=0;i<4;i++)
        {
            next.a=now.a+dir[i][0];
            next.b=now.b+dir[i][1];
            if(check(next))
            {
                mapp[next.a][next.b]='#';
                q2.push(next);
                num++;
            }
        }
    }
    ans++;
    if(num<n*m) bfs2();
    else cout<<ans<<endl;
}

void bfs2()
{
    poin now,next;
    while(!q2.empty())
    {
        now=q2.front();
        q2.pop();
        for(int i=0;i<4;i++)
        {
            next.a=now.a+dir[i][0];
            next.b=now.b+dir[i][1];
            if(check(next))
            {
                mapp[next.a][next.b]='#';
                q1.push(next);
                num++;
            }
        }
    }
    ans++;
    if(num<n*m) bfs1();
    else cout<<ans<<endl;
}


int main()
{
    cin>>n>>m;
    getchar();
    for(int i=0;i<n;i++)
    {
        gets(mapp[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(mapp[i][j]=='#')
            {
                poin ss;
                ss.a=i;
                ss.b=j;
                q1.push(ss);
                num++;
            }
        }
    }
    if(num<n*m) bfs1();
    else cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

    if(n%2==0)
    {
        int k=n/2;
        char a[200];
        char b[200];

        for(int i=0,j=k;i<k,j<n;i++,j++)
        {
            a[i]=s[i];
            b[i]=s[j];
        }

        int c=0;

        for(int i=0;i<k;i++)
        {
            if(a[i]==b[i])
            {
                c++;
            }
        }
        if(c==k)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int INF = 1e9 + 7;

class edge{
  public:
    int f, t, c;
    edge(){};
    edge(int ff, int tt, int cc) { f = ff; t = tt; c = cc; }
    bool operator < (const edge &e) const { return c < e.c; }
};

int find(int a, vector<int> &parent){
  if(parent[a] == a) return a;
  else return parent[a] = find(parent[a], parent);
}

void merge(int a, int b, vector<int> &parent, vector<int> &depth){
  int pa = find(a, parent), pb = find(b, parent);
  if(pa == pb) return ;
  if(depth[pa] > depth[pb]) swap(pa, pb);
  if(depth[pa] == depth[pb]) ++depth[pa];
  parent[pb] = pa;
}

bool same(int a, int b, vector<int> &parent){
  return find(a, parent) == find(b, parent);
}

int main(){
  int N, M;
  while(cin >>N >>M && N){
    vector<P> H(N);
    vector<edge> es(M);
    REP(i, N) { cin >>H[i].first; H[i].second = i; }
    REP(i, M) {
      cin >>es[i].f >>es[i].t >>es[i].c;
      --es[i].f; --es[i].t;
    }
    SORT(H); REVERSE(H);
    SORT(es);
    vector<bool> v(N, false);
    vector<int> parent(N), depth(N, 1);
    REP(i, N) parent[i] = i;
    int  ans = 0, cnt = 0;
    REP(i, N){
      P n = H[i];
      v[n.second] = true;
      if(i != N - 1 && H[i].first == H[i + 1].first) continue;
      REP(j, M){
        edge e = es[j];
        if(v[e.f] && v[e.t] && !same(e.f, e.t, parent)){
          merge(e.f, e.t, parent, depth);
          ans += e.c;
          ++cnt;
        }
      }
      if(cnt != i){
        REP(j, N) parent[j] = j;
        cnt = 0;
        ans = 0;
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1436
#include<iostream>
#define M 10000000007
using namespace std;
int main()
{
	int n,h,w;
	cin >> n>>h>>w;
	int f=0,a,b;
	for(int i=0;i<n;i++){
		cin >> a >> b;
		if(a>=h&&b>=w) f++;
	}
	cout << f;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int D = sc.nextInt();
        int G = sc.nextInt();
        int[] p = new int[D];
        int[] c = new int[D];

        for (int i = 0; i<D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int ans = Integer.MAX_VALUE;

        for (int mask=0; mask<(1<<D); mask++) {
            int score = 0, num = 0, rest_max = -1;

            for (int i=0; i<D; i++) {
                if ((mask>>i & 1) == 1) {
                    score += 100 * (i+1) * p[i] + c[i];
                    num += p[i];
                } else {
                    rest_max = i;
                }
            }

            if (score < G) {
                int s1 = 100 * (rest_max + 1);
                int need = (G - score + s1 - 1) / s1;
                if (need >= p[rest_max]) {
                    continue;
                }

                num += need;
            }
            ans = Math.min(ans, num);
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, k;
	int a[55], i;
	while (cin >> n >> k)
	{
		for (i = 1; i <= n; i++)
			cin >> a[i];
		sort(a, a + n + 1);
		int sum = 0;
		for (i = n - k + 1; i <= n; i++)
			sum += a[i];
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  for (int i = 0; i < s.size(); ++i)
  {
    //基数番目
    if(i%2==0){
      if(s[i]=='L') {
        cout<<"No";
        return 0;
      }
    }

    //偶数番目
    else{
      if(s[i]=='R'){
        cout<<"No";
        return 0;
      }
    }
  }
  cout<<"Yes";

}

Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << 0;
        return 0;
    } 
    int a[N];
    forn(i, N) {
        cin >> a[i];
    }

    int b[N];
    b[N-1] = 0;
    int mx = -300;
 
   for (int i = N -2 ; i >= 0; --i) {
        if(a[i] >= a[i+1]) {
            b[i] = b[i+1] + 1;
        } else {
            b[i] = 0;
        }
      mx = max(mx, b[i]);
   }

cout << mx;
return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string a, b;

    cin >> a >> b;

    string s = a + b;
    int n = stoi(s);

    bool ok = false;
    for (int i = 0; i < 400; i++) {
        if (i * i == n) {
            ok = true;
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int N;
	while (cin >> N && N != 0)
	{
		int t[20][20];
		for (int i = 0; i < N; i++)
		{
			for (int j = 0; j <= N; j++)
			{
				cin >> t[i][j];
			}
		}
		vector<int> bitDp(1 << N,1e9);
		bitDp[0] = 0;
		for (int i = 0; i < (1 << N); i++)
		{
			for (int j = 0; j < N; j++)
			{
				if (i & (1 << j))continue;
				int minTime = t[j][0];
				for (int k = 0; k < N; k++)
				{
					if (i & (1 << k))minTime = min(minTime,t[j][k + 1]);
				}
				bitDp[(i | (1 << j))] = min(bitDp[i | (1 << j)],bitDp[i] + minTime);
			}
		}

		cout << bitDp[(1 << N) - 1] << endl;

	}
	return 0;
}

Measured memory_bytes: 1452
#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
bool prime[10000000];

int main(){
	long long n,ans;
	rep(i,10000001)prime[i]=true;
	prime[0]=prime[1]=false;
	rep(i,10000){
		if(!prime[i])continue;
		for(int j=i*2;j<10000001;j+=i){
			prime[j]=false;
		}
	}
	while(cin>>n,n){
		for(int i=n;i>=8;i--){
			if(prime[i-8] && prime[i-6] && prime[i-2] && prime[i]){ans=i;break;}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

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

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

    double ans = v[0];
    for (int i = 1; i < n; i++) {
        ans = (ans + v[i]) / 2.0;
    }

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    abc127d()
}

fun abc127d() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val heap = PriorityQueue<Long>()
    var total = 0L
    readLine()!!.split(" ").map { it.toLong() }.forEach {
        heap.add(it)
        total += it
    }
    val operation = mutableListOf<Pair<Int, Long>>()
    repeat(m) {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        operation.add(b.toInt() to c)
    }
    operation.sortByDescending { it.second }
    for ((i, v) in operation) {
        if (heap.isEmpty()) break
        if (heap.peek() > v) break
        repeat(i) {
            if (heap.isNotEmpty() && heap.peek() < v) {
                val origin = heap.poll()
                total += v - origin
            } else {
                return@repeat
            }
        }
    }
    println(total)
}


Measured memory_bytes: 106312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int A, B;
int main() {
  cin >> A >> B;
  set<int> s = {1, 2, 3};
  s.erase(A);
  s.erase(B);
  cout << *s.begin() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int m,n1,n2;
  cin >> m >> n1 >> n2;
  while(m||n1||n2){
    int g=n1-1;
    int i,j,k;
    int d[300]={};
    for(i=0;i<m;i++) cin >> d[i];
    for(i=n1-1;i<n2;i++) {
      if(d[i]-d[i+1]>=d[g]-d[g+1]) g=i;
      //cout << g+1 << endl;
    }
    cout << g+1 << endl;
    //cout << endl;
    cin >> m >> n1 >> n2;
  }
  return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;
    
    if((a*b)%2)cout<<"Odd";
    else cout<<"Even";
    
    return 0;
    }
    

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val n = readInteger()
    if (n % 2 == 1) {
        println("No")
        return
    }

    val s = readLine()!!
    val pre= s.substring(0, s.length / 2 );
    val suf = s.substring(s.length / 2)
    val ans = if (pre == suf) "Yes" else "No"
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)


Measured memory_bytes: 31756
#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 pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
ll const mod=998244353;
//ll const mod=1e9+7;
const ll MAX=300000;
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 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;}


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


int main(){
    int n,k;
    cin>>n>>k;
    int r,c,p;
    cin>>r>>c>>p;
    map<int,int>mp;
    mp['r'-'a']=p;
    mp['s'-'a']=r;
    mp['p'-'a']=c;
    string s;
    cin>>s;
    ll ans=0;
    rep(i,k){
      vi dp(2),tmp(2),p;
      for(int j=i;j<n;j+=k){
        p.push_back(s[j]-'a');
      }
      int n=p.size();
      
      rep(j,n){
        swap(dp,tmp);
        if(j==0){
          dp[1]=mp[p[j]];
          continue;
        }
        if(p[j]==p[j-1]){
          dp[1]=tmp[0]+mp[p[j]];
        }
        else{
          dp[1]=max(tmp[0],tmp[1])+mp[p[j]];
        }
        dp[0]=max(tmp[0],tmp[1]);
        
      }
      ans+=max(dp[0],dp[1]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
#include<algorithm>
using namespace std;
int x[131072],y[131072];
struct node{
	int l;
	int r;
	int wz;
	bool operator<(node b) const
	{
		if(l==b.l)
		{
			return r<b.r;
		}
		return l<b.l;
	}
};
node nn[131072];
int num=0;
int c[131072];
void inc(int x,int val)
{
	for(int i=x;i<=num;i+=(i&(-i)))
	{
		c[i]+=val;
		if(c[i]>=1000000007)
		{
			c[i]-=1000000007;
		}
	}
}
int query(int x)
{
	int ans=0;
	for(int i=x;i>0;i-=(i&(-i)))
	{
		ans+=c[i];
		if(ans>=1000000007)
		{
			ans-=1000000007;
		}
	}
	return ans;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d",&y[i]);
	}
	int now=0;
	for(int i=0;i<n;i++)
	{
		if(x[i]>y[m-1])
		{
			break;
		}
		while(x[i]>y[now])
		{
			now++;
		}
		if(now==0)
		{
			continue;
		}
		nn[num].l=y[now-1]-x[i];
		nn[num].r=y[now]-x[i];
		num++;
	}
	if(num==0)
	{
		printf("1\n");
		return 0;
	}
	sort(nn,nn+num);
	int num2=0;
	for(int i=1;i<num;i++)
	{
		if(nn[num2]<nn[i])
		{
			num2++;
			nn[num2]=nn[i];
		}
	}
	num2++;
	num=num2;
	for(int i=0;i<num;i++)
	{
		nn[i].wz=i;
		int t=nn[i].l;
		nn[i].l=nn[i].r;
		nn[i].r=t;
	}
	sort(nn,nn+num);
	inc(1,1);
	for(int i=0;i<num;i++)
	{
		int val=query(num-nn[i].wz);
		inc(num-nn[i].wz,val);
	}
	printf("%d\n",query(num));
	return 0;
}

Measured memory_bytes: 2560
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

N = int(input())
# S = input()
# N, M = map(int, input().split())
# 横
V = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

V.sort()
ans = V[0]

for i, v in enumerate(V) :
    if i == 0 :
        continue
    
    ans = (ans + v) / 2

print(ans)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define p 1000000007
char c[100010];int a[100010];
int f[100010],la[3];
int main(){
	scanf("%s",c+1);
	int n=strlen(c+1);bool fla=0;
	for(int i=1;i<=n;i++){
		a[i]=(a[i-1]+(c[i]=='b')+1)%3;
		if(c[i]==c[i-1])fla=1;
	}
	if(!fla)return putchar('1'),0;
	for(int i=1;i<=n;i++)(f[i]+=((long long)f[la[0]]+f[la[1]]+f[la[2]]+(a[i]>=1)-f[la[a[i]]])%p)%=p,la[a[i]]=i;
	printf("%d",f[n]);
	return 0;
}


Measured memory_bytes: 1152
N = int(input())
H = list(map(int, input().split()))
ans = 0
cnt = 0

pre = H[0]
for h in H[1:]:
    if h <= pre:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
    pre = h
if cnt != 1:
    ans = max(ans, cnt)

print(ans)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, x; cin >> n >> x;
  x--;
  n = 2*n - 1;
  int mid = n/2;
  if(n == 3 && x == 1) {
    cout << "Yes" << endl;
    cout << 1 << endl;
    cout << 2 << endl;
    cout << 3 << endl;
  } else if(n == 3 || x == 0 || x == n-1) {
    cout << "No" << endl;
  } else if(x == 1) {
    cout << "Yes" << endl;
    int now = 0;
    REP(i, n) {
      if(mid-1 <= i && i <= mid+1) {
        cout << x - (i - mid) + 1 << endl;
      } else if(i == mid+2) {
        cout << x+2 + 1 << endl;
      } else {
        if(now == x-1) now += 4;
        cout << now + 1 << endl;
        now++;
      }
    }
  } else {
    cout << "Yes" << endl;
    int now = 0;
    REP(i, n) {
      if(mid-1 <= i && i <= mid+1) {
        cout << x + i - mid + 1 << endl;
      } else if(i == mid+2) {
        cout << x-2 + 1 << endl;
      } else {
        if(now == x-2) now += 4;
        cout << now + 1 << endl;
        now++;
      }
    }
  }

  
}


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

#define ll long long
#define pb push_back
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* 
* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
*/

int main(){
    fcin;
	int n;
	cin >> n;
	vector<double> a(n);
	for(auto& x : a) cin >> x;
	double ans = 0.0;
	sort(a.rbegin(), a.rend());
	while(a.size() >= 2){
		ans = a.back() + a[a.size() - 2];
		ans /= 2.0;

		a.pop_back();
		a.pop_back();
		a.push_back(ans);
	}
			
	cout << fixed << setprecision(10) <<  ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++)
            P[i] = sc.nextInt();

        int min = P[0];
        int cnt = 0;

        for (int i = 0; i < N; i++) {
            if (min >= P[i]) {
                cnt++;
                min = P[i];
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 65304
#include<bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define loop(i,a,b) for(ll i=a;i<b;++i)
#define loope(i,a,b) for(ll i=a;i<=b;++i)
#define loopr(i,a,b) for(ll i=a;i>=b;--i)
#define loops(i,a,b,step) for(ll i=a;i<b;i+=step)
#define all(a) a.begin(),a.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define V vector
using namespace std;
typedef string str;
ll vis[55][55]={0};
ll inp[55][55];
set<pair<ll,ll>> points,point;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
void dfs(ll x,ll y,ll k,ll n)
{
    if (x<0 || y<0 || x>n-1 || y>n-1 || inp[x][y]==1 || vis[x][y]==k)
    {
        return ;
    }
    else
    {
        vis[x][y]=k;
        if (k==1)
        {
            points.insert(make_pair(x,y));
        }
        else
        {
            point.insert(make_pair(x,y));            
        }
        dfs(x-1,y,k,n);
        dfs(x,y-1,k,n);
        dfs(x+1,y,k,n);
        dfs(x,y+1,k,n);
    }
    
}
int main ()
{
	FAST;
	//test cases
	ll t;
    cin>>t;
    V<ll>v(t);
    ll ans=0;
    ll num=1000000007;
    loop(i,0,t)
    {
        cin>>v[i];
        ans+=v[i];
    }
    ans%=num;
    ans=ans*ans;
    ans%=num;
    loop(i,0,t)
    {
        ans%=num;
        ll tem=((v[i]*v[i])%num);
        ans-=tem;
        if (ans<0)
        {
            ans+=num;
        }
    }
    ll num2=1000000008/2;
    ans=(ans*num2)%num;
    cout<<ans<<endl;
}   

Measured memory_bytes: 4816