akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;

int main()
{
	// 入力
	ll N, M;
	cin >> N >> M;
	vec L(M,-1),R(M,-1);

	ll maxL=0;
	ll minR=N-1;

	REP(i,M){
		cin>>L[i]>>R[i];
		L[i]--;
		R[i]--;
		maxL=max(maxL,L[i]);
		minR=min(minR,R[i]);
		if(maxL>minR){
			cout<<0<<endl;
			return 0;
		}
	}

	cout<<minR-maxL+1<<endl;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0;
  while(true){
    for(int i = 0; i < n; i++){
      if(a[i] % 2 != 0){
        cout << ans << endl;
        return 0;
      }
    }
    for(int i = 0; i < n; i++){
      a[i] /= 2;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * Author : anaksoleh
 * 7 september 2019
 */

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

typedef long long ll;
int N;

int idx[25];
int B[25];
int C[25];

int main()
{
	cin >> N;

	for(int i = 1 ; i <= N ; i++){
		cin >> idx[i];
	}
	for(int i = 1 ; i <= N ; i++){
		cin >> B[i];
	}
	for(int i = 1 ; i <= (N-1) ; i++){
		cin >> C[i];
	}

	ll sum = 0;
	for(int i = 1; i <= N ; i++){
		int pos = idx[i];
		sum += B[pos];
		if(i != N){
			if(idx[i+1] == (idx[i] + 1)){
				sum += C[pos];
			}	
		}
	}

	cout << sum << '\n';
	
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

int MOD = 1e9+7;

//ll po(ll b, ll p){ return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;}
// ll pomd(ll a, ll k, ll md) { ll p; if (k == 0){ return 1; } p = pomd(a, k / 2, md); p = p * p % md; if (k % 2){ p = p * a % md; } return p; }
// counting divsrs: vi arr(N); for(int i{1}; i<N; ++i) for(int j=i; j<N; j+=i) d[j]++;

#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}	

ll calc(ll h){
	if(h==1) return 1;
	return 2*calc(abs(h/2))+1;
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
	ll h; cin >> h;
	cout << calc(h) << "\n";
	
}





Measured memory_bytes: 3636
#include <bits/stdc++.h>
const int N=200050;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
struct date{
  int s,id;
  bool operator < (const date &c) const {
    return s<c.s;
  }
}d[N];
int tot,R,C,st[N],top;
int num(int x,int y){
  if (y==0) return x;
  if (x==R) return R+y;
  if (y==C) return R+C+R-x;
  return 2*R+2*C-y;
}
int main(){
  R=gi(),C=gi(); int n=gi(),a,b,c,f;
  for (int i=1; i<=n; ++i){
    a=gi(),b=gi(),c=gi(),f=gi();
    if ((a==0||b==0||a==R||b==C)&&(c==0||f==0||c==R||f==C)){
      d[++tot]=(date){num(a,b),i};
      d[++tot]=(date){num(c,f),i};
    }
  }
  sort(d+1,d+tot+1);
  for (int i=1; i<=tot; ++i){
    if (st[top]==d[i].id) --top;
    else st[++top]=d[i].id;
  }
  puts(top?"NO":"YES");
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;

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

    vector<long long> div;
    for (long long i = 1; i * i <= n; i++) {
        if (n%i == 0) {
            div.push_back(i);
            div.push_back(n/i);
        }
    }
    sort(div.begin(), div.end());
    int p1;
    p1 = div.size()/2;

    //for (auto x : div) cout << x << "\n";

    cout << div[p1] + div[p1 - 1] - 2 << "\n";
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] num = s.split("");
		int[] num3 = new int[s.length()-2];
		for(int i = 0;i < s.length() - 2;i ++) {
			num3[i] = Integer.parseInt(num[i]+num[i+1]+num[i+2]);
		}
		Arrays.sort(num3);
		int dmin = 0;
		String S = "";
		int sum = 0,d = 0;
		for(int i = s.length() - 3;i >= 0;i --) {
			d = Math.abs(num3[i] - 753);
			if(i == s.length() - 3) dmin = d;
			else {
				if(num3[i] < 753 && dmin < d) break;
				if(dmin > d) dmin = d;
			}
		}
		System.out.println(dmin);
	}
}

Measured memory_bytes: 22736
N=int(input())
graph=[[] for i in range(N)]
for _ in range(N-1):
    a,b=list(map(int,input().strip().split(' ')))
    graph[a-1]+=[b-1]
    graph[b-1]+=[a-1]
from collections import deque
def bfs(graph):
    q=deque([0])
    N=len(graph)
    visit=[]
    parent=[-1]*N
    while(q):
        v=q.popleft()
        visit+=[v]
        for adj in  graph[v]:
            if adj!=parent[v]:
                parent[adj]=v
                q+=[adj]
    return visit,parent
visit,parent=bfs(graph)
path=[]
v=N-1
path+=[v]
while(parent[v]!=-1):
    v=parent[v]
    path+=[v]
subtree=[0 for i in range(N)]
for i in range(1,len(visit)+1):
    v=visit[-i]
    if graph[v]==[parent[v]]:
        subtree[v]=1
    else:
        temp=0
        for adj in graph[v]:
            if adj!=parent[v]:
                temp+=subtree[adj]
        subtree[v]=temp+1
ca1=0
ca2=0
if len(path)%2==0:
    stop=(len(path))//2-1
    stop=path[stop]
    ca2=subtree[stop]
    ca1=N-ca2

    if ca1>=ca2+1:
        print('Fennec')
    else:
        print('Snuke')
else:
    stop=(len(path))//2-1
    stop=path[stop]
    
    ca2=subtree[stop]
    ca1=N-ca2
    
    if ca1>=ca2+1:
        print('Fennec')
    else:
        print('Snuke')    
    
    

Measured memory_bytes: 67488
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int a;
  cin>>a;
  if(a<1200)
  cout<<"ABC"<<endl;
  else if(a<2800)
    cout<<"ARC"<<endl;
  else 
    cout<<"AGC"<<endl;
  
  
  
  return(0);
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
int main() {
	int m, n;
	cin >> m >> n;
	vector<string> map(m);
	for (auto &a : map)cin >> a;
	bool f = 1;
	int score = 0;
	while (f) {
		f = 0;
		rep(i, m)rep(j, n) {
			if (map[i][j] != '.')continue;
			vector<pair<char,string::iterator>> buf;
			rep(k, 4) {
				int x = j, y = i;
				while (x >= 0 && x < n&&y>=0 && y < m&&map[y][x] == '.')x += dx[k], y += dy[k];
				if (x >= 0 && x < n&&y>=0 && y < m)buf.push_back(make_pair(map[y][x],map[y].begin()+x));
			}
			sort(ALL(buf), [](pair<char, string::iterator> a, pair<char, string::iterator> b) {return a.first < b.first; });
			if (buf.size() < 2)continue;
			rep1(i, buf.size()-1) {
				if (buf[i].first == buf[i - 1].first) {
					*(buf[i].second) = *(buf[i - 1].second) = '.';
					score += 2;
					f = 1;
				}
			}
		}
	}
	cout << score << endl;
}

Measured memory_bytes: 3328
def calc(S: str, cur: int, e: str):
    if S == "":
        if cur == 7:
            print(e+"=7")
            quit()
        else:
            return

    calc(S[1:], cur + int(S[0]), e + "+" + S[0])
    calc(S[1:], cur - int(S[0]), e + "-" + S[0])


S = input().strip()
ans = calc(S[1:], int(S[0]), S[0])


Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

vector<long long> P(55),ALL(55);

long long calc(long long N,long long X) {
  if(N == 0) return 1;
  else if(X == 0) return 0;
  else if(1 < X && X < ALL.at(N-1)+2) return calc(N-1,X-1);
  else if(X == ALL.at(N-1)+2) return P.at(N-1)+1;
  else if(ALL.at(N-1)+2 < X && X < 2*ALL.at(N-1)+3) return P.at(N-1)+1+calc(N-1,X-2-ALL.at(N-1));
  else if(X == 2*ALL.at(N-1)+3) return 2*P.at(N-1)+1;
}

int main() {

  long long N,X;
  cin >> N >> X;

  
  P.at(0) = 1; ALL.at(0) = 1;
  for(int i = 1;i <= N;i++) {
    P.at(i) = 2*P.at(i-1) + 1;
    ALL.at(i) = 2*ALL.at(i-1) + 3;
  }

  long long ans = calc(N,X);
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  
  vector<ll> H(N);
  for (auto i = 0; i < N; ++i) {
    READ(H[i]);
  }

  vector<size_t> A(M), B(M);
  for (auto i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
  }
  

  // main procedure
  unordered_set<size_t> remained_viewpoint;
  for (auto i = 0; i < N; ++i) {
    remained_viewpoint.insert(i);
  }

  for (auto i = 0; i < M; ++i) {
    if (H[A[i] - 1] > H[B[i] - 1]) {
      remained_viewpoint.erase(B[i] - 1);
    } else if (H[A[i] - 1] < H[B[i] - 1]) {
      remained_viewpoint.erase(A[i] - 1);
    } else {
      remained_viewpoint.erase(A[i] - 1);
      remained_viewpoint.erase(B[i] - 1);
    }
  }

  // output
  WRITE_N(remained_viewpoint.size());

  return 0;
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define pb push_back
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

int main()
{
	fio;
	int R, G, B, N, ans = 0;
	cin >> R >> G >> B >> N;
	for(int i=0; i*R<=N; i++)
		for(int j=0; i*R + j*G <= N; j++)
			if((N - i*R - j*G) % B == 0)
				ans++;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	n%=1000;
	if(n==0)cout << 0;
	else cout << 1000-n;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 3652
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    S = input()
    ans = 0
    for i in range(N):
        a = set(S[:i])
        b = set(S[i:])
        ans = max(ans, len(set(a & b)))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
n = int(input())
l = [int(x) for x in input().split()]


def count(ls, front):
    # replace ls[0] by front
    res = abs(front - ls[0])
    sm = front
    for i in range(1, n):
        temp = ls[i]
        if sm > 0 and ls[i] > -sm-1:
            res += abs(-sm-1 - ls[i])
            temp = -sm-1
        elif sm < 0 and ls[i] < -sm+1:
            res += abs(-sm+1 - ls[i])
            temp = -sm+1
        sm += temp
    return res


ans = 0
if l[0] == 0:
    ans = min(count(l, 1), count(l, -1))
else:
    ans = min(count(l, l[0]), count(l, -l[0] // abs(l[0])))
print(ans)

Measured memory_bytes: 19948
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        int digitSum = 0;
        for (int i = 0; i < n; i++)
            digitSum += (str.charAt(i) - '0');
        if(digitSum % 9 == 0) {
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 40156
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

vector<ll> Eratosthenes(const ll N) {
  bool is_prime[1000000 + 1];
  vector<ll> P;
  for (ll i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  for (ll i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (ll j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

int main() {
  int k, x;
  cin >> k >> x;
  cout << (500 * k >= x ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
def Water( list1, n):
    sp = -1
    for i in range( n ):
        if list1[ i ] > 0:
            sp = i
            break
    for i in range(sp,n):
        if list1[ i ] > 0 :
            list1[ i ] -= 1
        else:
            break
    return list1

N = int(input())
Hlist = list(map(int,input().split()))
mizu = 0

while max(Hlist) > 0:
    mizu += 1
    Water( Hlist, N )

print( mizu )


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 305;
const int INF = 1e9+5;
int e[MAX_N][MAX_N];
int d[MAX_N][MAX_N];

void init()
{
	rep(i,MAX_N)
	{
		rep(j,MAX_N)
		{
			if (i == j)
			{
				 d[i][j] = 0;
				 e[i][j] = 0;
			}
			else 
			{
				d[i][j] = INF;
				e[i][j] = INF;
			}
		}
	}
}


int main()
{
	init();
	int N,M,L;
	cin >> N >> M >> L;
	for (int i = 0; i < M; ++i)
	{
		int a,b,c;
		cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}

	rep(k,N)
	{
		rep(i,N)
		{
			rep(j,N)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	rep(i,N)
	{
		rep(j,N)
		{
			if (i != j && d[i][j] <= L) e[i][j] = 1;
		}
	}

	rep(k,N)
	{
		rep(i,N)
		{
			rep(j,N)
			{
				e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
			}
		}
	}

	int Q;
	cin >> Q;
	rep(i,Q)
	{
		int s,t;
		cin >> s >> t;
		if (e[s-1][t-1] == INF) cout << "-1" << endl;
		else cout << e[s-1][t-1] - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000000
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}


int main(){
    ll n; cin>>n;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    ll mn = arr[0],ans = 1;
    rep(i,1,n)
    {
        if(arr[i]<=mn)
        {
            ans++;
        }
        mn = min(mn,arr[i]);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define forn(i,n) for(int i=0;i<int(n);i++)
#define forsn(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define dforsn(i,s,n) for(int i=(int)(n-1);i>=int(s);i--)
#define si(a) int((a).size())
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#ifdef LOCAL
    #define DBG(a) //cerr << #a << "=" << a << endl
#else
    #define DBG(a)
    #define endl '\n'
#endif
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int tint;

set<pii> reds;

vector<pii>pred,pblue;

int main() {
	fastio;

    int n;
    cin >> n;
    pred = vector<pii>(n);
    pblue = vector<pii>(n);
    forn(i,n){
        cin >> pred[i].first >> pred[i].second;
    }
    forn(i,n){
        cin >> pblue[i].first >> pblue[i].second;
    }
    sort(all(pred));
    sort(all(pblue));

    int indr=0,indb=0;
    int res=0;
    while(indr<n&&indb<n){
        pii r = pred[indr],b=pblue[indb];
        if(r.first<b.first){
            reds.insert(mp(r.second,r.first));
            indr++;
        }
        else{
            auto pos = reds.lower_bound(mp(b.second,b.first));
            if(pos!=reds.begin()){
                pos--;
                res++;
                //cerr << b.first << " " << b.second<<endl;
                //cerr << pos->second << " " << pos->first << endl;
                reds.erase(pos);
            }
            indb++;
        }
    }
    while(indb<n){
        pii b=pblue[indb];
        auto pos = reds.lower_bound(mp(b.second,b.first));
        if(pos!=reds.begin()){
            pos--;
            res++;
            //cerr << b.first << " " << b.second<<endl;
            //cerr << pos->second << " " << pos->first << endl;
            reds.erase(pos);
        }
        indb++;
    }
    cout << res << endl;

	return 0;
}


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

using lli = long long int;

using namespace std;

//10^5 = 100000

vector<lli> L(100000);
vector<lli> R(100000);

int main() {

    int N, M;
    cin >> N >> M;

    for (lli i = 0; i < M; ++i) {
        cin >> L[i] >> R[i];
    }

    //境界は可
    auto limit = make_pair(L[0], R[0]);
    for (lli i = 1; i < M; i++) {
        if (limit.first < L[i]) { limit.first = L[i]; }
        if (limit.second > R[i]) { limit.second = R[i]; }
        if (limit.first > limit.second) { break; }
    }
    
    if (limit.first > limit.second) {
        printf("%d", 0);
    } else {
        printf("%lld", limit.second - limit.first + 1);
    }

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n, k; cin >> n >> k;
   vector<ll> A(n);
   rep(i,n)cin>>A[i];
   ll l = 1, r = 0;
   rep(i,n)r=max(r,A[i]);
   while (l<r){
      ll med = (l+r)/2;
      ll sum = 0;
      rep(i,n)sum += ((A[i]-1)/med);
      if (k < sum){
         l = med+1;
      }
      else{
         r = med;
      }
   }
   cout << r << endl;
}

Measured memory_bytes: 4744
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int H,W;
  cin>>H>>W;
  vector<vector<char> >map(H,vector<char>(W,'#'));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>map[i][j];
    }
  }
  vector<vector<int> >cost(H,vector<int>(W,-1));
  queue<int> x,y;
  x.push(0);y.push(0);cost[0][0]=0;
  bool check=false;
  while(x.size()){
    int now_x=x.front(),now_y=y.front();
    int ncost=cost[now_y][now_x];
    x.pop();y.pop();
    if(now_x>0){
      if(map[now_y][now_x-1]=='.'&&cost[now_y][now_x-1]<0){
        x.push(now_x-1);y.push(now_y);cost[now_y][now_x-1]=ncost+1;
      }
    }
    if(now_x<(W-1)){
      if(map[now_y][now_x+1]=='.'&&cost[now_y][now_x+1]<0){
        x.push(now_x+1);y.push(now_y);cost[now_y][now_x+1]=ncost+1;
      }
    }
    if(now_y>0){
      if(map[now_y-1][now_x]=='.'&&cost[now_y-1][now_x]<0){
        x.push(now_x);y.push(now_y-1);cost[now_y-1][now_x]=ncost+1;
      }
    }
    if(now_y<(H-1)){
      if(map[now_y+1][now_x]=='.'&&cost[now_y+1][now_x]<0){
        x.push(now_x);y.push(now_y+1);cost[now_y+1][now_x]=ncost+1;
      }
    }
  }
  if(cost[H-1][W-1]>0) check=true;
  vector<int> ax,ay;
  ax.push_back(W-1);ay.push_back(H-1);
  int ans=-1;
  if(check){
    ans=0;
    int nx=W-1,ny=H-1;
    while((nx!=0)||(ny!=0)){
      int ncost=cost[ny][nx];
      if(nx>0){
        if(map[ny][nx-1]=='.'&&cost[ny][nx-1]==(ncost-1)){
          ny=ny;nx=nx-1;ax.push_back(nx);ay.push_back(ny);continue;
        }
      }
      if(nx<(W-1)){
        if(map[ny][nx+1]=='.'&&cost[ny][nx+1]==(ncost-1)){
          ny=ny;nx=nx+1;ax.push_back(nx);ay.push_back(ny);continue;
        }
      }
      if(ny>0){
        if(map[ny-1][nx]=='.'&&cost[ny-1][nx]==(ncost-1)){
          ny=ny-1;nx=nx;ax.push_back(nx);ay.push_back(ny);continue;
        }
      }
      if(ny<(H-1)){
        if(map[ny+1][nx]=='.'&&cost[ny+1][nx]==(ncost-1)){
          ny++;nx=nx;ax.push_back(nx);ay.push_back(ny);continue;
        }
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(map[i][j]=='.'){
          bool acheck=true;
          for(int k=0;k<ax.size();k++){
            if(i==ay[k]&&j==ax[k])acheck=false;
          }
          if(acheck){ans++;}
        }
      }
    }
  }
  
  cout<<ans<<endl;

  return 0;
}







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

typedef long long ll;



int main() {
  int K, X; cin >> K >> X;
  if(500 * K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
      int N;
      string S;
      cin >> N;
      cin >> S;

      vector<int> E(N+1);
      vector<int> W(N+1);

      E[0] = 0;
      W[0] = 0;
      for (int i=0; i<N; i++){
            E[i+1] = E[i];
            W[i+1] = W[i];
            if (S[i] == 'E')
                  E[i+1] += 1;
            else
                  W[i+1] += 1;
      }

      int min = N;
      for (int i=0; i<N; i++){
            if (min > W[i] + E[N] - E[i+1])
                  min = W[i] + E[N] - E[i+1];
      }
      
      cout << min << endl;
      return 0;
}

      


Measured memory_bytes: 3076
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(b<10) a=a*10+b;
	else if(b<100) a=a*100+b;
	else a=a*1000+b;
	if(int(sqrt(a))*int(sqrt(a))==a){
		printf("Yes\n");
	}else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
const LL MOD = 1e9 + 7;
LL mPow2[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    map<P, LL> m;
    LL a, b, g, ga, gb;
    int z = 0;
    rep(i, N){
        scanf("%lld %lld", &a, &b);
        
        // 両方ゼロの場合を保存.
        if(a == 0 && b == 0){
            z++;
            continue;
        }
        
        // 片方ゼロの場合を保存.
        if(a == 0 && b != 0){
            m[{0, 1}]++;
            continue;
        }
        
        // 片方ゼロの場合を保存.
        if(a != 0 && b == 0){
            m[{1, 0}]++;
            continue;
        }
        
        // 最大公約数.
        ga = abs(a);
        gb = abs(b);
        g = __gcd(ga, gb);
        a /= g;
        b /= g;
        
        // 符号調整.
        if(a < 0 && b < 0) a = -a, b = -b;
        if(a > 0 && b < 0) a = -a, b = -b;
        
        // 保存.
        m[{a, b}]++;
    }
    
    // 2. 2 の べき乗 を 保存.
    mPow2[0] = 1;
    rep(i, 202019) mPow2[i + 1] = (mPow2[i] << 1), mPow2[i + 1] %= MOD;
    
    // 3. 仲が悪い組み合わせを調査.
    set<P> used;          // すでに確認したペアであるか判定.
    vector<P> bad;        // 仲の悪い組み合わせの個数のペアを保存.
    LL res = (LL)(N - z); // 残数.
    for(auto &p : m){
        LL sd = p.a.a, sf = p.a.b, sc = p.b;
        LL od = sf, of = sd;
        if(of < 0) of = -of;
        else       od = -od;
        P op = {od, of};
        if(used.count(p.a) == 0){
            used.insert(p.a);
            if(m.count(op) > 0){
                used.insert(op);
                bad.pb({sc, m[op]});
                // 残数更新.
                res -= sc;
                res -= m[op];
            }
        }
    }
    
    // 4. イワシの選び方は？
    LL ans = 1;
    rep(i, (int)res) ans <<= 1, ans %= MOD;
    for(auto &p : bad){
        int pa = (int)p.a, pb = (int)p.b;
        LL t = ((mPow2[pa] + mPow2[pb]) % MOD + MOD - 1) % MOD;
        ans *= t;
        ans %= MOD;
    }
    
    // 5. ゼロの場合を考慮.
    ans += (LL)z;
    ans %= MOD;
    
    // 6. 全く選択しないパターンを考慮.
    ans += (MOD - 1);
    ans %= MOD;
    
    // 7. 出力.
    printf("%lld\n", ans);
    return 0;
    
}


Measured memory_bytes: 30336
#include<bits/stdc++.h>
using namespace std;
#define h first
#define w second
vector<pair<bool,pair<int,int> > >v;
int n,m,p,q,r,i;
void Vp(bool a,int b,int c){v.push_back(make_pair(a,make_pair(b,c)));}
int main(){
	while(cin>>n&&n){
	cin>>m>>p>>q>>r;v.clear();
	Vp(1,1,r);Vp(0,r+1,n);
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		for(i=0;i<v.size();i++){
			int a=v[i].w.h,b=v[i].w.w;bool c=v[i].h;
			if(a<=x&&x<b){Vp(c,x+1,b);b=x;}
			if(a<=y&&y<b){Vp(c,y+1,b);b=y;}
			if(0<a&&b<=x)a+=n-x,b+=n-x;
			else if(x<a&&b<=y)a+=n-x-y,b+=n-x-y;
			else if(y<a&&b<=n)a-=y,b-=y;
			v[i].w.h=a,v[i].w.w=b;
		}
	}n=0;
	for(i=0;i<v.size();i++)if(v[i].h)n+=max(0,1+min(v[i].w.w,q)-max(v[i].w.h,p));
	cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 3288
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	H, W, M := ReadInt(), ReadInt(), ReadInt()
	grid := make(map[int]bool)
	toID := func(x, y int) int {
		return y*W + x
	}

	cx := make([]int, W)
	cy := make([]int, H)
	for i := 0; i < M; i++ {
		y, x := ReadInt()-1, ReadInt()-1
		cx[x]++
		cy[y]++
		grid[toID(x, y)] = true
	}

	xidx := make([]int, W)
	for i := 0; i < W; i++ {
		xidx[i] = i
	}
	yidx := make([]int, H)
	for i := 0; i < H; i++ {
		yidx[i] = i
	}

	sort.Slice(xidx, func(i, j int) bool {
		return cx[xidx[i]] > cx[xidx[j]]
	})
	sort.Slice(yidx, func(i, j int) bool {
		return cy[yidx[i]] > cy[yidx[j]]
	})

	maxCx := cx[xidx[0]]
	maxCy := cy[yidx[0]]
	maxSum := maxCx + maxCy - 1
	for xi := 0; xi < W; xi++ {
		x := xidx[xi]
		if cx[x] != maxCx {
			break
		}
		for yi := 0; yi < H; yi++ {
			y := yidx[yi]
			if cy[y] != maxCy {
				break
			}
			if !grid[toID(x, y)] {
				fmt.Println(cx[x] + cy[y])
				return
			}
		}
	}
	fmt.Println(maxSum)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 26764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  vi p(n);
  rep(i,n) cin >> p[i];
  int cnt =0;
  rep(i,n-2) {
    if((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1]&& p[i+1]>p[i+2])){
      cnt++;
      //cout << i << endl;
      //if(i==2) cout <<p[i] << endl;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int a[100005];

signed main()
{
	IO_OP;

	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	int ans = 0, l = 0;
	for(int i=0;i<n;i++) {
		if(a[i] == 0) {
			l = 0;
			continue;
		}
		ans += (a[i] + l) / 2;
		l = (a[i] + l) % 2;
	}
	cout << ans << endl;
}





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

int solve(int A,int B,int C){
	if(A&1 || B&1 || C&1)return 0;
	if(A==B && B==C)return -1;
	return 1+solve((B+C)/2,(A+C)/2,(A+B)/2);
}

int main(void){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<solve(A,B,C)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> L(N, 0), D(N + 1, 0);
    int ans = 0;
    rep(i, 0, N)
    {
        cin >> L.at(i);
        D.at(i + 1) = D.at(i) + L.at(i);
    }
    rep(i, 0, N + 1)
    {
        if (D.at(i) <= X)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
    string s;cin>>s;
    int n = s.size();

    vec ans(n,0);

    int even_num,cnt=0;
    for(int i=0; i<n; i++){
        if(s.at(i)=='R'){
            cnt++;
            continue;
            }else{
            if(cnt%2==0)
            {
                even_num = (cnt)/2;
                }else{
                    even_num = (cnt-1)/2;
                    }
            int odd_num = cnt - even_num;
            ans[i] += even_num;
            ans[i-1] += odd_num;
            cnt = 0;
             }
    }

    
    for(int i=n-1; i>-1; i--){
        if (s[i] == 'L'){
            cnt ++;
            continue;
        }else{
            if(cnt%2==0){
                even_num = (cnt)/2;
                }else{
                    even_num = (cnt-1)/2;
                    }
            int odd_num = cnt - even_num;
            ans[i] += even_num;
            ans[i+1] += odd_num;
            cnt = 0;
        }
    }

    rep(i,n) cout<<ans[i]<<" ";

}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N =nextInt();
		int K =nextInt();
		int[] p = nextInts();
		String T =nextString();

		long ans =0;
		for(int i=0;i<K;i++){
			ans+=p[asWin(T.charAt(i))];
			boolean flg=false;
			for(int k=i+K;k<N;k+=K){
				if(T.charAt(k-K)==T.charAt(k)){
					if(flg){
						ans+=p[asWin(T.charAt(k))];
						flg=false;
					}else{
						flg=true;
					}
				}else{
					ans+=p[asWin(T.charAt(k))];
					flg=false;
				}
			}
		}

		System.out.println(ans);
	}

	public static int asWin(char s){
		if('r'==s){
//			System.out.println("パー");
			return 2;
		}else if('s'==s){
//			System.out.println("グー");
			return 0;
		}else{
//			System.out.println("チョキ");
			return 1;
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

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

using namespace std;
using ll = long long;

int main() {
    ll sum = 0, left_sum = 0, right_sum = 0;
    priority_queue<ll> left;
    priority_queue<ll, vector<ll>, greater<ll>> right;
    int Q;
    cin >> Q;
    while(Q--) {
        int query;
        cin >> query;
        if(query == 1) {
            ll a, b;
            cin >> a >> b;
            sum += b;
            if((int)left.size() == 0) {
                left.push(a);
                left_sum += a;
            }else if((int)left.size()<=(int)right.size()){
                if(left.top()>=a){
                    left.push(a);
                    left_sum += a;
                }else{
                    right.push(a);
                    right_sum -= right.top();
                    right_sum += a;
                    left.push(right.top());
                    left_sum += right.top();
                    right.pop();
                }
            }else {
                if(left.top()>=a){
                    left.push(a);
                    left_sum += a;
                    left_sum -= left.top();
                    right_sum += left.top();
                    right.push(left.top());
                    left.pop();
                }else{
                    right.push(a);
                    right_sum += a;
                }
            }
        }else {
            cout << left.top() << " " << -left_sum + left.top() * (ll)left.size() + right_sum - left.top() * (ll)right.size() + sum << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> ii;

int N;
vll A;

int b_search(int i, ll a){
  int lb=-1, ub=i;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(A[mid]<=a) lb=mid;else{ub=mid;}
  }
  return lb;
}


int main(){
  cin>>N;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }

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

  int used[N];
  memset(used, 0, sizeof(used));

  int cnt=0;
  for (int i=N-1;i>=1;--i){
    if(used[i]==1) continue;
    for (int t=1;t<40;++t){
      int j=b_search(i, (ll)pow(2, t)-A[i]);
      while(used[j]==1){j--;}
      if(A[j]+A[i]==(ll)pow(2, t)){
        cnt++;
        used[j]=1;
        break;
      }
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 2672
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
double a[200005],b[200005]; 
int main()
{ 
  int n, m;
  cin >> n >> m;
  a[0]=0;b[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]=(a[i]+1)/2;
		b[i]=b[i-1]+a[i];
	}
	double maxn=0;
	for(int i=m;i<=n;i++)
	{
		maxn=max(maxn,b[i]-b[i-m]);
	}
	cout<<fixed<<setprecision(12)<<maxn;
	
}



	
	


Measured memory_bytes: 3328
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))



Measured memory_bytes: 6396
import java.util.Scanner;

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

		String s = sc.next();

		int l = s.length();



		int[] a = new int[l-2];

		String[] figure = new String[l-2];

		for(int i=0; i<=l-3; i++) {
			figure[i] = s.substring(i,i+3);
			a[i] = Integer.parseInt(figure[i]);  // Integer.parseInt(String s) stringをintで返す
			//substring(int a, int b)  !!aからb-1番目!!までの文字列を返す　0始まり
		}
		int min = 999;
		for(int i=0; i<=l-3; i++) {
			min =Math.min(min, Math.abs(753-a[i]));
		}

		System.out.println(min);

	}

}


Measured memory_bytes: 21972
n = int(input())
a=list(map(int, input().split()))
b = True
for i in a:
    if i % 2 == 0:
        if i % 3 != 0 and i % 5 != 0:
            b = False
            print("DENIED")
            break
if b == True:
    print("APPROVED")


Measured memory_bytes: 2940
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	cin >> n;
	vector<ll> d(n);
	rep(i, n) {
		cin >> d[i];
	}
	if (d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	map<ll, ll> mp;
	rep(i, n) {
		mp[d[i]]++;
	}
	if (mp[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	ll res = 1;
	for (ll i = 1; i < n; i++) {
		ll tmp = 1;
		rep(j, mp[i]) {
			tmp*=mp[i-1];
			tmp %= 998244353;
		}
		res *= tmp;
		res %= 998244353;
	}
	cout << res << endl;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(){
	int x,y,i;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)break;
		if(x>y){
			i=x;
			x=y;
			y=i;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}



Measured memory_bytes: 2108
(A, B, M) = (int(x) for x in input().split(' '))

#print(A, B, M)
ai = [int(x) for x in input().split(' ')]
bj = [int(x) for x in input().split(' ')]
ck = []
for k in range(int(M)):
  ck.append([int(x) for x in input().split(' ')])

amin = min(ai)
bmin = min(bj)
abmin = amin + bmin
#print(abmin)

for cupon in ck:
  ac = ai[cupon[0]-1]
  bc = bj[cupon[1]-1]
  cost = ac + bc - cupon[2]
#  print(cost)
  if cost < abmin:
    abmin = cost

print(abmin)


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

int main(void)
{
    int N;
    cin >> N;
    
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    
    cout << "No" << endl;
}


Measured memory_bytes: 3620
/* #include <bits/stdc++.h> */
#include <iostream>
#include <vector>
using namespace std;
#define _GLIBCXX_DEBUG

vector<pair<int, int>> rW; // <base, relative weight>
int n;

void init() {
  for (int i = 1; i <= n; i++)
    rW[i] = make_pair(i, 0);
}
pair<int, int> get_weight(int x) {
  if (rW[x].first == x) {
    return {x, 0};
  } else {
    pair<int, int> res = get_weight(rW[x].first);
    res.second += rW[x].second;
    return (rW[x] = res);
  }
}
bool is_same_set(int a, int b) {
  return get_weight(a).first == get_weight(b).first;
}
void punite(int parent, int child, int w) {
  pair<int, int> b = get_weight(parent);
  b.second += w - get_weight(child).second;
  rW[get_weight(child).first] = b;
}

int main() {
  int m;
  while (cin >> n >> m) {
    if (!n && !m) {
      break;
    }
    rW = vector<pair<int, int>>(n + 1);
    vector<bool> checked(n + 1, false);
    init();
    for (int i = 0; i < m; i++) {
      char ope;
      cin >> ope;
      if (ope == '!') {
        int a, b, w;
        cin >> a >> b >> w;
        punite(a, b, w);
        checked[a] = true;
        checked[b] = true;
      } else {
        int a, b;
        cin >> a >> b;
        if (!checked[a] || !checked[b] || !is_same_set(a, b)) {
          cout << "UNKNOWN" << endl;
        } else {
          cout << get_weight(b).second - get_weight(a).second << endl;
        }
      }
    }
  }
}



Measured memory_bytes: 5320
from collections import deque
n = int(input())

tree = [[] for _ in range(n+1)]
color1 = [-1] * (n+1)
color1[1] = 0
color2 = [-1] * (n+1)
color2[1] = 1
for _ in range(n-1):
    u, v, w = map(int, input().split())
    tree[u].append((v, w))
    tree[v].append((u, w))

q = deque([1])
visited = {1}
while len(q) > 0:
    now = q.popleft()
    visited.add(now)
    for v, w in tree[now]:
        if v in visited:
            pass
        else:
            q.append(v)
            if w % 2 == 0:
                color1[v] = color1[now]
                color2[v] = color2[now]
            else:
                color1[v] = int(not color1[now])
                color2[v] = int(not color2[now])

print("\n".join(tuple(map(str, color1[1:]))))







Measured memory_bytes: 50852
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int ans;
    double ave = 0;
    double diff;
   	double stack;
    
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
      ave += a[i];
    }
    
    ave /= n;
    diff = Math.abs(a[n-1] - ave);
    ans = n-1;
    
    for(int i = n-2;i > -1;i--){
      stack = Math.abs(a[i] - ave);
      if(stack <= diff){
        diff = stack;
        ans = i;
      }
    }
    
    System.out.println(ans);
    
  
  }
}


Measured memory_bytes: 35960