akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

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

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

signed main(){
  int x;cin>>x;
  int a = x%100, b = x/100;
  if(a <= b*5){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}


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

int A[200005],B[200005];
map<pair<int,int>,pair<int,int> > f;

const int mod = 1e9+7;

int pw(int b, int e){
	if(e==0){
		return 1;
	}
	if(e&1){
		int k = pw(b,e/2);
		k*=k;
		k%=mod;
		k*=b;
		k%=mod;
		return k;
	}
	else {
		int k = pw(b,e/2);
		k*=k;
		k%=mod;
		return k;
	}
}

int32_t main(){
	int n;
	cin>>n;
	int ans = 1;
	int zeros = 0;
	int d = 0;
	for(int i=1;i<=n;i++){
		cin>>A[i]>>B[i];
		if(A[i]==0 && B[i]==0){
			zeros++;
		}
		else {
			if(make_pair(A[i],B[i])<make_pair(0LL,0LL)){
				A[i] = -A[i];
				B[i] = -B[i];
			}
			int g = __gcd(abs(A[i]),abs(B[i]));
			A[i] /= g;
			B[i] /= g;
			if(B[i]>0){
				f[{A[i],B[i]}].first++;
			}
			else {
				f[{-B[i],A[i]}].second++;
			}
		}
	}

	for(auto[a,b]:f){
		//cout<<a.first<<" "<<a.second<<" "<<b.first<<" "<<b.second<<"\n";
		ans = (ans*(pw(2,b.first)+pw(2,b.second)-1)) % mod;
	}
	cout<<(ans+zeros+mod-1)%mod;
}


Measured memory_bytes: 22272
#include <bits/stdc++.h>
#define int long long
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int32_t main(){
	cin.tie(0); ios::sync_with_stdio(0);
	
	int n, weight;
	cin >> n >> weight;
	int peso[n], val[n];
	for(int i = 0; i < n; i++){
		cin >> peso[i] >> val[i];
	}
	
	int dp[n+1][weight+1];
	memset(dp, 0, sizeof dp);
	for(int item = 0; item < n; item++){
		for(int w = 0; w <= weight; w++){
			dp[item+1][w] = dp[item][w];
			if(w >= peso[item]){
				dp[item+1][w] = max(dp[item+1][w], dp[item][w-peso[item]] + val[item]);
			}
		}
	}
	
	cout << dp[n][weight] << endl;
}


Measured memory_bytes: 79232
def main():

    A, B, C = map(int, input().split())
    K = int(input())
    for i in range(K+1):
        for j in range(K+1):
            for l in range(K+1):
                if i + j + l <= K:
                    x = A * pow(2, i)
                    y = B * pow(2, j)
                    z = C * pow(2, l)
                    if x < y and y < z:
                        return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())


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

using namespace std;

int A, B;
int main()
{
	cin >> A >> B;
	if(A >= 13)
		cout << B;
	if(A <= 12 && A >= 6)
		cout << B / 2;
	if(A < 6)
		cout << "0";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		List<Integer> list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			list.add(Integer.parseInt(tokens[i]));
		}
		Collections.sort(list);
		long count = 0L;
		for (int i = N - 1; i >= 0; --i) {
			int longEdge = list.get(i);
			for (int j = i - 1; j >= 0; --j) {
				int middleEdge = list.get(j);
				if (longEdge / 2 >= middleEdge) {
					break;
				}
				for (int k = j - 1; k >= 0; --k) {
					if(list.get(k) + middleEdge > longEdge) {
						++count;
					}else {
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}

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

int tree[1<<18], n, q;

void update(int x, int y, int v, int id=0, int l=0, int r=n)
{
    if (x>=r or y<=l) return;
    if (x<=l and r<=y) {
        tree[id]+=v;
        return;
    }
    int m=l+r>>1;
    int L=2*id+1, R=L+1;
    update(x, y, v, L, l, m);
    update(x, y, v, R, m, r);
    tree[id]=tree[L]+tree[R];
}

int sum(int x, int y, int id=0, int l=0, int r=n)
{
    if (x>=r or y<=l) return 0;
    if (x<=l and r<=y) return tree[id];
    int m=l+r>>1;
    int L=2*id+1, R=L+1;
    return sum(x, y, L, l, m)+sum(x, y, R, m, r);
}

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

    cin>>n>>q;
    while (q--) {
        int c, x, y; cin>>c>>x>>y;
        if (c==0)
            update(x-1, x, y);
        else
            cout<<sum(x-1, y)<<'\n';
    }
}

Measured memory_bytes: 4152
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}
fn main() {
    let n: usize = read();
    let list: Vec<usize> = read_vector(n - 1);
    let mut result = vec![0; n + 1];
    for n in list.into_iter() {
        result[n] += 1;
    }
    for index in 1..=n {
        println!("{}", result[index]);
    }
}


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

long long N, M;
vector<long long> A;
vector<pair<long long, long long> >BC;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	for(long long i = 0; i < M; i++){
		long long b, c;
		cin >> b >> c;
		BC.push_back(make_pair(c, b));
	}

	sort(A.begin(), A.end());
	sort(BC.begin(), BC.end(), greater<pair<long long, long long> >());

	long long aidx = 0;
	for(long long i = 0; i < BC.size(); i++){
		long long value = BC[i].first;
		long long num = BC[i].second;
		if(aidx == N){
			break;
		}
		for(long long j = 0; j < num; j++){
			if(A[aidx] < value){
				A[aidx] = value;
			}
			aidx++;
			if(aidx == N){
				break;
			}
		}
	}

	long long ans = 0;
	for(long long i = 0; i < N; i++){
		ans += A[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3188
import java.util.*;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int max = 0;
        char[] S = sc.next().toCharArray();
        int oneCount = 0;
        int zeroCount = 0;
        boolean zeroChainFlag = false;
        int totalChain = 0;
        int oneCountList[] = new int[N];
        int indexForMinus = 1;

        // 尺取り法で実装する
        // そもそも反転させるのは近い0同士が1の連結数が最大となると仮定
        for (int i = 0; i < S.length; i++) {
            // 1のとき
            if (S[i] == '1') {
                // 前までが0の場合、リストに0反転の1を含む、1連結数のリストに挿入
                // リストは、反転回数を超えた場合に、減算する用に使用する
                if (zeroChainFlag) {
                    oneCountList[zeroCount] = oneCount;
                    oneCount = 0;
                    zeroChainFlag = false;
                }
                oneCount++;
                totalChain++;
                // 0のとき
            } else {
                // 前までが0のとき、反転し続ける
                if (zeroChainFlag) {
                    oneCount++;
                    totalChain++;
                }
                // 前までが0ではないときの処理
                else {
                    zeroChainFlag = true;
                    zeroCount++;
                    // 指定回数K以下の場合
                    if (zeroCount <= K) {
                        oneCount++;
                        totalChain++;
                        // 指定回数Kを超えた場合
                        // ここがミソ。一番古い反転0を含む1の固まりを合計値から引き算する。
                    } else {
                        // 最大値更新
                        max = Math.max(max, totalChain);
                        // 一番古い反転0を含む1の固まりを合計値から引き算する。
                        totalChain = totalChain - oneCountList[indexForMinus];
                        indexForMinus++;
                        // 現在位置の0の反転分を足す
                        totalChain++;
                        oneCount++;
                    }
                }
            }
            // 最大値更新（上記処理に入らなかった場合の最大値更新）
            max = Math.max(max, totalChain);
        }
        System.out.println(max);
        sc.close();
    }
}

Measured memory_bytes: 40300
using System;

namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string Date = Console.ReadLine();
                string[] date = Date.Split(' ');
                int H = int.Parse(date[0]);
                int W = int.Parse(date[1]);

                if (H == 0 && W == 0)       //H,W??±???0????????????
                {
                    break;
                }
                for (int i = 1; i <= H; i++)        
                {
                    for (int j = 1; j <= W; ++j)
                    {
                        if (i == 1 || i == H)       //?§?????????¨?????????
                        {
                            if (j == W)             //????????????
                            {
                                Console.WriteLine("#");
                            }
                            else
                            {
                                Console.Write("#");
                            }
                        }
                        else
                        {
                            if (j == 1 || j == W)
                            {
                                if (j == 1)
                                {
                                    Console.Write("#");
                                }
                                else
                                {
                                    Console.WriteLine("#");
                                }
                            }
                            else
                            {
                                Console.Write(".");
                            }

                        }
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

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

int main() {

    int N, M;

    cin >> N >> M;

    tuple<int, int, int> data[M]; // (Y_i, P_i, i)の配列

    rep(i, M){
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    // tupleをソートするときは第一要素がkeyとなる
    // つまりY_iによって昇順にソートされる
    sort(data, data + M);

    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0); // 配列に全て同じ値を代入するfill
    // 各県に今属している市の数

    pair<int, int> id[M];
    // 各市の(属する県、県の中で誕生した順番)

    for (int i = 0; i < M; ++i) {
        int y, p, idx;
        tie(y, p, idx) = data[i]; // tieでtupleを分解
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i) {
        // setwで文字数、setfillで埋める文字を指定
        // iomanipをincludeする必要があるので注意
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int X,N,p; cin>>X>>N;
	set<int> st;
	for (int i=0; i<N; i++)
		cin>>p, st.insert(p);
	for (int i=0; i<=200; i++) {
		for (int sgn=-1; sgn<=1; sgn+=2) {
			int cur=X+i*sgn;
			if(!st.count(cur)) {
				cout<<cur<<"\n";
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N,P;
    cin >> N >> P;
    ll i,j;
    ll A;
    ll k=0;
    for(i=0;i<N;i++){
        cin >> A;
        if(A%2==1)k++;
    }
    if(k==0){if(P==1)cout<< 0;else cout<< setprecision(20)<< pow(2,N);}else cout << setprecision(20) << pow(2,N-1);
    return 0;
}


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

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

int dp[t];
dp[0]=0;
dp[1]=abs(cost[1]-cost[0]);

for(int i=2;i<t;i++)
{
int x=(abs(cost[i]-cost[i-1])+dp[i-1]);
for(int j=2;j<=k;j++)
{
if(i-j<0)
break;
x=min(x,(abs(cost[i]-cost[i-j])+dp[i-j]));
}
dp[i]=x;
}

int ans= dp[t-1];
cout<<ans;
return 0;
}

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

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

	int64_t sum = 0;

	for (int i = 1; i < N + 1; i++) {
		if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0);
		else sum += i;
	}
	cout << sum << endl;

	return 0;
}


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

#define LL long long
#define ULL unsigned long long

#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) (((l)+(r))>>1)

const int MOD = (int) 1e9 + 7;
const double eps = (double) 1e-8;
const int maxn = (int) 3e5 + 20;
const double pi = (double) acos(-1.0);

void work()
{
    int n, k;
    cin >>n >>k;
    double ans = 0;
    int pre = n;
    double tmp = 1.0;
    k--;
    while(1)
    {
        int cnt = max(0, pre - k);
        ans += cnt * tmp;
        pre -= cnt;
        tmp *= 0.5;
        if(k == 0) break;
        k >>= 1;
    }
    printf("%.12f\n", ans / n);
//    cout <<ans <<endl;
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r" ,stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416

    int tc = 1;
//    scanf("%d", &tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>

#define fs first
#define sc second
#define mp make_pair
#define pii pair<int,int> 

using namespace std;

int c, r, n, a, b, x, y, ctr;
vector <pii> v;
stack <pii> st;

bool cek(int a, int b) {
	if(a == 0 || b == 0 || a == r || b == c) {
		return true;
	}
	return false;
}

int nilai(int a, int b) {
	if(b == 0) {
		return a;
	} else if(a == r) {
		return r + b;
	} else if(b == c) {
		return r + c + r - a;
	} else if(a == 0) {
		return r + c + r + c - b;
	}
}

int main() {
	scanf("%d%d%d", &r, &c, &n);
	ctr = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d%d%d%d", &a, &b, &x, &y);
		if(cek(a, b) && cek(x, y)) {
			ctr++;
			v.push_back(mp(nilai(a, b), ctr));
			v.push_back(mp(nilai(x, y), ctr));
			// printf("%d %d --> %d\n", a, b, nilai(a, b));
			// printf("%d %d --> %d\n", x, y, nilai(x, y));
		}
	}
	sort(v.begin(), v.end());
	int vs = v.size();
	for(int i = 0; i < vs; i++) {
		if(st.size() && st.top().sc == v[i].sc) {
			st.pop();
		} else {
			st.push(v[i]);
		}
	}
	if(st.size()) {
		printf("NO\n");
	}  else {
		printf("YES\n");
	}
	return 0;
}

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

using namespace std;

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

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

  vector<long long> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

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

  if (n == 2) {
    cout << a[1] << endl;
    return 0;
  }

  if (n == 3) {
    int e, f, g;
    e = gcd(a[0], a[1]);
    f = gcd(a[0], a[2]);
    g = gcd(a[1], a[2]);
    cout << max(max(e, f), g) << endl;
    return 0;
  }

  long long max_koyaku = -1;
  for (long long i = 2; i < (n - 1); i += 1) {
    if (max_koyaku < 0) {
      max_koyaku = gcd(a[i], a[i+1]);
    } else {
      max_koyaku = gcd(max_koyaku, a[i+1]);
    }
  }

  long long max_first, max_second;
  max_first = gcd(a[0], max_koyaku);
  max_second = gcd(a[1], max_koyaku);

  long long first_gcd = gcd(a[0], a[1]);
  long long diff_count = 0;
  for (int i = 2; i < n; i++) {
    long long ans = gcd(first_gcd, a[i]);
    if (ans != first_gcd) {
      diff_count += 1;
    }
    if (diff_count > 1) {
      break;
    }
  }

  if (diff_count == 1) {
    if (first_gcd > max_first && first_gcd > max_second) {
      cout << first_gcd << endl;
    } else {
      if (max_first > max_second) {
        cout << max_first << endl;
      } else {
        cout << max_second << endl;
      }
    }
  } else if (max_first > max_second) {
    cout << max_first << endl;
  } else {
    cout << max_second << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    r, g, b, n = get_li()
    ans = 0
    for x in range(n // r + 1):
        for y in range(n // g + 1):
            z = n - r * x - g * y
            if z % b != 0 or z < 0:
                continue
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65772
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    double a = N - N/2;
    printf("%.10f",a/N);

    return 0;
}

Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int X,N;
int ans=0;
cin>>X>>N;

int p[N];

REP(i,N){cin>>p[i];}


sort(p,p+N);

if(!binary_search(p,p+N,X)){ans=X; cout<<ans<<endl; return 0;}
FOR(i,1,100){

	if(!binary_search(p,p+N,X-i)){ans=X-i;break;}
	if(!binary_search(p,p+N,X+i)){ans=X+i;break;}
}


cout<<ans<<endl;










return 0;

}

Measured memory_bytes: 3560
import java.util.Scanner;

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

		int A, B;
		A = scan.nextInt();
		B = scan.nextInt();
		scan.close();
		int a, b, c;
		a = A + B;
		b = A * B;
		c = A - B;
		if (a > b) {
			if (a > c) {
				System.out.println(a);
			}else{
				System.out.println(c);
			}
		}else{
			if(b>c) {
				System.out.println(b);
			}else {
				System.out.println(c);
			}
		}
	}
}


Measured memory_bytes: 21844
m,p,r,h,i,a,s;main(n){for(;scanf("%d%d",&n,&m)*n;i=h=!printf("%d\n",h?n:r))for(p=1e7;i++<n;s<=p?h=s==p,p=s,r=i:0)scanf("%d",&a),s=m/a*a*1000+a;}

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

int main(int argc, char const* argv[])
{
    int divisor = 100;
    int d, n;
    cin >> d >> n;
    int res = 1;
    for (int i = 0; i < d; i++) {
        res *= divisor;
    }
    if (n != 100) {
        res *= n;
    } else {
        res *= 101;
    }
    cout << res;
}


Measured memory_bytes: 256
//Binary Indexed Tree - RAQ and RSQ
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G
//https://algo-logic.info/binary-indexed-tree/#toc_id_3_1
#include<stdio.h>
#include<assert.h>

#define bsize 524288

long long sum_raw(long long i,long long bit[]){
  long long s=0;
  while(i>0){
    s+=bit[i];
    i-=i&(-i);
  }
  return s;
}
void add_raw(long long i,long long x,long long bit[]){
  while(i<=bsize){
    bit[i]+=x;
    i+=i&(-i);
  }
}

long long bitsg_raw[bsize+5]={0},bitd_raw[bsize+5]={0};

void raq_raw(long long st,long long fi,long long x){
  add_raw(st,-(x*(st-1)),bitsg_raw);
  add_raw(fi+1,(x*fi),bitsg_raw);
  add_raw(st,x,bitd_raw);
  add_raw(fi+1,-x,bitd_raw);
}

long long rsq_raw(long long st,long long fi){
  st--;
  long long stv,fiv;
  fiv=sum_raw(fi,bitsg_raw)+sum_raw(fi,bitd_raw)*fi;
  stv=sum_raw(st,bitsg_raw)+sum_raw(st,bitd_raw)*st;
  return fiv-stv;
}

#define mod 3
long long sum(long long i,long long bit[]){
  long long s=0;
  while(i>0){
    s+=bit[i];
    if(s>=mod){s-=mod;}
    i-=i&(-i);
  }
  return s;
}
void add(long long i,long long x,long long bit[]){
  while(i<=bsize){
    bit[i]+=x;
    if(bit[i]>=mod){bit[i]-=mod;}
    i+=i&(-i);
  }
}

long long bitsg[bsize+5]={0},bitd[bsize+5]={0};

long long mod_nomalize(long long x){
  if(x>=0){return x%mod;}
  x*=-1;x%=mod;x=mod-x;
  if(x==mod){x=0;}
  return x;
}

void raq(long long st,long long fi,long long x){
  long long mx=mod_nomalize(x);
  add(st,mod_nomalize((-mx*(st-1))),bitsg);
  add(fi+1,mod_nomalize(mx*fi),bitsg);

  add(st,mx,bitd);
  add(fi+1,mod_nomalize(mod-mx),bitd);
}

long long rsq(long long st,long long fi){
  st--;
  long long stv,fiv;
  fiv=(sum(fi,bitsg)+sum(fi,bitd)*fi)%mod;
  stv=(sum(st,bitsg)+sum(st,bitd)*st)%mod;
  return mod_nomalize(fiv-stv);
}

int main(){
  long long n,q,i;
  long long t,a,b,c;
  long long rl,ml;
  scanf("%lld%lld",&n,&q);
  for(i=0;i<q;i++){
    scanf("%lld",&t);
    //fprintf(stderr,"ok\n");
    if(t==0){
      scanf("%lld%lld%lld",&a,&b,&c);
      raq_raw(a,b,c);
      raq(a,b,c);
    }
    else{
      scanf("%lld%lld",&a,&b);
      rl=rsq_raw(a,b);
      ml=rsq(a,b);
      assert((rl)%mod==ml);
      printf("%lld\n",rl);
    }
  }
}


Measured memory_bytes: 4944
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>

using namespace std;
typedef long long int ll;


int main(int argc, char const *argv[])
{
	string s;
	ll a;
	cin >> a >> s;

	if (a >= 3200)
		cout << s << endl;
	else
	{
		cout << "red" << endl;
	}
}

Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 105;
const ll mm = 1e+18;
int f(int x){
    int res=0;
    while(x){
        res++;
        x/=10;
    }
    return res;
}
void solve()
{
    int n;
    cin>>n;
    int mi=mod;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            mi=min(mi,max(f(i),f(n/i)));
        }
    }
    pr(mi);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c;
 cin>>c>>a>>b;
 
 if(a-b>=0)
 	cout<<"delicious"<<endl;
 else if(a-b+c>=0)
  	cout<<"safe"<<endl;
 else
 	cout<<"dangerous"<<endl;
 
 
 return 0;
 }

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

struct Card{
    char mark;
    int num;
};

void bubbleSort(struct Card a[],int n){
    int flag=1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=n-1;j>i;j--){
            if(a[j-1].num>a[j].num){
                swap(a[j],a[j-1]);
                flag=1;
            }
        }
    }
}
void selectionSort(struct Card a[],int n){
    for(int i=0;i<n-1;i++){
        int min=i;
        for(int j=i+1;j<n;j++){
            if(a[min].num>a[j].num) min=j;
        }
        swap(a[i],a[min]);
    }
}

void print(struct Card a[],int n){
    string s="";
    for(int i=0;i<n;i++){
        cout<<s<<a[i].mark<<a[i].num;
        s=" ";
    }
    cout<<"\n";
}

bool isStable(struct Card C1[],struct Card C2[],int n){
    for(int i=0;i<n;i++){
        if(C1[i].mark!=C2[i].mark) return false;
    }
    return true;
}

int main(void){
    int n;
    cin>>n;
    Card C1[n],C2[n];
    for(int i=0;i<n;i++) cin>>C1[i].mark>>C1[i].num;
    for(int i=0;i<n;i++) C2[i]=C1[i];
    bubbleSort(C1,n);
    selectionSort(C2,n);
    print(C1,n);
    cout<<"Stable\n";
    print(C2,n);
    if(isStable(C1,C2,n)) cout<<"Stable\n";
    else cout<<"Not stable\n";
}


Measured memory_bytes: 3144
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make(map[int]int, n)

	ans := true
	for i := 0; i < n; i++ {
		tmp := nextInt()
		if _, already := a[tmp]; already {
			ans = false
		} else {
			a[tmp] = 1
		}
	}

	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 8960
N,M = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

def f(Z:list):
    res = 0
    for k, z in enumerate(Z, 1):
        res = (res + (k - 1) * z - (len(Z) - k) * z) % MOD
    return res

print(f(X) * f(Y) % MOD)

Measured memory_bytes: 83044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class DEqueue {
public:
        int N,K;

void solve(std::istream& cin, std::ostream& cout) {
    ll A[55],S[55];
    memset(S,0,sizeof(S));
    cin >> N >> K;
    _for(i,N)cin >> A[i];
    _for(i,N)S[i+1] = S[i]+A[i];
    ll mx = -1;
    rep(i,0,N)rep(j,N+1,i){
            int k = K-(N-(j-i));
        if(k<0)continue;
        ll sum = S[N] - (S[j] - S[i]);
        vector<int > v;
        _for(ii,i)v.emplace_back(A[ii]);
        rep(jj,j,N)v.emplace_back(A[jj]);
        sort(all(v));
        int ind = 0;
        if(!v.empty()){
            while(v[ind] < 0 && ind < v.size() && k > 0)sum -= v[ind],ind++,k--;
        }
        mx = max(sum ,mx);
    }

    cout << mx << endl;
}
};


#undef int
int main() {
	DEqueue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string N;
    ll i,s=0;
    cin>>N;
    for(i=0;i<N.size();i++){
        s+=(N[i]-48);
    }
    if(s%9==0){
        cout<<"Yes";
    }
    else cout<<"No";
}


Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	if (X > Y) {
		cout << "War" << endl;
		PAU;
		return 0;
	}
	vi VX(N);
	vi VY(M);
	REP(i, N) cin >> VX[i];
	REP(i, M)cin >> VY[i];
	so(VX); so(VY);
	if (VX[N - 1] >= VY[0]) {
		cout << "War" << endl;
		PAU;
		return 0;
	}
	if (VX[N - 1] >= Y) {
		cout << "War" << endl;
		PAU;
		return 0;
	}
	if (VY[0] <= X) {

		cout << "War" << endl;
		PAU;
		return 0;
	}
	cout << "No War" << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,n,x,y;
	char s[101];
	x=0;
	y=0;
	cin>>n>>s;
	for(i=0;i<n;i++){
		if(s[i]=='I'){
			x=x+1;
			//cout<<'+'<<endl;
		}
		if(s[i]=='D'){
			x=x-1;
			//cout<<'-'<<endl;
		}
		if(x>y){
			y=x;
		}
	}
	cout<<y<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

void solve(){
  	 int n;
  	 cin >> n;
  	 vector<int> v;
  	 vector<int> prev, next;
  	 for(int i = 0; i < n; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);	 
	}
	prev = v, next = v;
	if(prev_permutation(all(prev))) print_vector(prev);
	print_vector(v);
	if (next_permutation(all(next))) print_vector(next);
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3212
s = input()[::-1]

cnts = [0] * 2019
cnts[0] = 1

n, d = 0, 1

for char in s:
    n = (n + int(char) * d) % 2019
    d = d * 10 % 2019
    cnts[n] += 1

ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)


Measured memory_bytes: 9388
#!/usr/bin/env python3
n, Q = map(int, input().split())
s = input()
q = [[*map(int, input().split())] for _ in range(Q)]
R = [0]
for i in range(n - 1):
    R.append(R[-1] + (s[i:i + 2] == "AC"))
for l, r in q:
    print(R[r-1]-R[l-1])


Measured memory_bytes: 31372
n = int(input())
g = [[0,0] for _ in range(n)]
for i in range(n):
  a = int(input())
  for _ in range(a):
    x,y = map(int,input().split())
    g[i][y] |= 1 << (x-1)
ans = 0
for num in range(1<<n):
  p = [g[j] for j in range(n) if num&(1<<j)]
  fl = 0
  if all(num & y == y and not num & x for x,y in p):
    if ans < len(p): ans = len(p)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
     
#define LL long long
#define RG register
     
using namespace std;
template<class T> T gi() {
	T x = 0; bool f = 0; char c = getchar();
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	if (c == '-') f = 1, c = getchar();
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f ? -x : x;
}
const int N = 1e5 + 10;
int a[N], n;
struct node {
	int to, nxt;
} g[N << 1];
int lst[N], gl, d[N];
void add(int x, int y) {
	g[++gl] = (node) {y, lst[x]}; lst[x] = gl;
	g[++gl] = (node) {x, lst[y]}; lst[y] = gl;
	d[x]++; d[y]++;
}
LL dfs(int u, int ff) {
	if (d[u] == 1) return a[u];
	LL sum = 2ll * a[u];
	for (int i = lst[u]; i; i = g[i].nxt) {
		int v = g[i].to; if (v == ff) continue;
		LL k = dfs(v, u);
		if (k > a[u]) { puts("NO"); exit(0); }
		sum -= k;
	}
	if (sum < 0 || sum > a[u]) { puts("NO"); exit(0); }
	return sum;
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi<int>();
	for (int i = 1; i <= n; i++) a[i] = gi<int>();
	if (n == 2) {
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for (int i = 1; i < n; i++)
		add(gi<int>(), gi<int>());
	for (int i = 1; i <= n; i++)
		if (d[i] > 1) {
			puts(dfs(i, 0) ? "NO" : "YES");
			return 0;
		}
	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[200008], b[200008];

bool f(ll x, ll y){
	ll cnt = 0;
	zep(i, 0, n){
		if(b[i] >= x)cnt++;
	}
	return cnt >= y;
}

bool g(ll x, ll y){
	ll cnt = 0;
	zep(i, 0, n){
		if(a[i] <= x)cnt++;
	}
	return cnt >= y;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	zep(i, 0, n)cin >> a[i] >> b[i];
	
	if(n%2 == 1){
		ll hok = 0;
		ll hng = 1e9+1;
		
		while(hng-hok > 1){
			ll mid = (hok+hng)/2;
			
			if(f(mid, n/2+1)){
				hok = mid;
			}else{
				hng = mid;
			}
		}
		
		ll lok = 1e9+1;
		ll lng = -1;
		
		while(lok-lng > 1){
			ll mid = (lok+lng)/2;
			
			if(g(mid, n/2+1)){
				lok = mid;
			}else{
				lng = mid;
			}
		}
		print(hok-lok+1)
	}else{
		ll hok = 0;
		ll hng = 1e9+1;
		
		while(hng-hok > 1){
			ll mid = (hok+hng)/2;
			
			if(f(mid, n/2)){
				hok = mid;
			}else{
				hng = mid;
			}
		}
		ll hrok = hok;
		
		hok = 0;
		hng = 1e9+1;
		
		while(hng-hok > 1){
			ll mid = (hok+hng)/2;
			
			if(f(mid, n/2+1)){
				hok = mid;
			}else{
				hng = mid;
			}
		}
		ll hlok = hok;
		
		ll lok = 1e9+1;
		ll lng = -1;
		
		while(lok-lng > 1){
			ll mid = (lok+lng)/2;
			
			if(g(mid, n/2+1)){
				lok = mid;
			}else{
				lng = mid;
			}
		}
		ll lrok = lok; 
		
		lok = 1e9+1;
		lng = -1;
		
		while(lok-lng > 1){
			ll mid = (lok+lng)/2;
			
			if(g(mid, n/2)){
				lok = mid;
			}else{
				lng = mid;
			}
		}
		ll llok = lok;
		
		print(hrok+hlok-(lrok+llok)+1)
	}
	
	return 0;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a<b){
		if(b<c){
	                        cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3052
#include<iostream>
using namespace std;
int main(){

	int H,W,j,i;
	for(;;){
		int x=0;
		cin>>H>>W;
		if(H==0 && W==0){
			break;
		}
		for(j=1;j<=H;j++){
			for(i=1;i<=W;i++){
				if(j==1 || i==1 || j==H || i==W){
					cout<<"#";
				}else{
					cout<<".";
				}if(j==H && i==W){
					cout<<endl;
				}
			}
			cout<<endl;
		}
	}
	return 0;

}

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var X = input[0];
            var Y = input[1];
            var ans = 0;
            if (X == 1 && Y == 1)
            {
                ans = 1000000;
            }
            else
            {
                ans += X == 3 ? 100000 : X == 2 ? 200000 : X == 1 ? 300000 : 0;
                ans += Y == 3 ? 100000 : Y == 2 ? 200000 : Y == 1 ? 300000 : 0;
            }

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

int S[1000000];
int T[1000000];
int Scount;
int Tcount;
int count;
int i,j;

int binarySearch(int);
int main(){


  scanf("%d",&Scount);

  for(count = 0;count < Scount;count++){
    scanf("%d",&S[count]);
  }

  scanf("%d",&Tcount);

  for(count = 0;count < Tcount;count++){
    scanf("%d",&T[count]);
  }
  count = 0;

  for(i = 0;i < Tcount;i++){
  if(binarySearch(T[i])==1)count++;
  }

  printf("%d\n",count);
  return 0;
}

int binarySearch(int key){
  int left;
  int right;
  int mid;

  left = 0;
  right = Scount;
  while(left < right){
    mid = (left+right)/2;
    if(S[mid]==key)return 1;
    else if(key < S[mid])right = mid;
    else left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 4896
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Integer[] a = new Integer[N];
		for(int i=0;i<N;i++) {
			a[i]=in.nextInt();
		}
		Arrays.sort(a);
		;
		System.out.println(Arrays.stream(a).distinct().toArray().length);
	}
}


Measured memory_bytes: 27348
N, M, *A = map(int, open(0).read().split())

C = [0, 1, 4, 4, 3, 4, 5, 2, 6, 5]

dp = [0] * N + [-1] * 9
for i in range(N):
    dp[i + 1] = max(a + 10 * dp[i - C[a]] for a in A)

print(dp[N])


Measured memory_bytes: 14388
N = int(input())
h = list(map(int, input().split()))
ans = 0
s = [h[N-1]]
for i in range(1, N):
    s.append(s[-1] + h[-i-1])
for i in range(N-1):
    ans += h[i] * s[-i-2]
ans = ans % (10 ** 9 + 7)
print(int(ans))

Measured memory_bytes: 31304
import java.util.HashSet;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

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

        String s = sc.next();
        int x = sc.nextInt();
        int y = sc.nextInt();

        System.out.println(solve(s, x, y) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(String s, int x, int y) {
        Set<State> xStates = new HashSet<>();
        xStates.add(new State(0, 1));

        Set<State> yStates = new HashSet<>();
        yStates.add(new State(0, 1));

        boolean xOrY = true;
        for (char command : s.toCharArray()) {
            if (command == 'F') {
                if (xOrY) {
                    xStates = xStates.stream().map(xState -> new State(xState.value + xState.offset, xState.offset))
                            .collect(Collectors.toSet());
                } else {
                    yStates = yStates.stream().map(yState -> new State(yState.value + yState.offset, yState.offset))
                            .collect(Collectors.toSet());
                }
            } else {
                xOrY = !xOrY;

                if (xOrY) {
                    xStates.addAll(xStates.stream().map(xState -> new State(xState.value, -xState.offset))
                            .collect(Collectors.toList()));
                } else {
                    yStates.addAll(yStates.stream().map(yState -> new State(yState.value, -yState.offset))
                            .collect(Collectors.toList()));
                }
            }
        }

        return xStates.stream().anyMatch(xState -> xState.value == x)
                && yStates.stream().anyMatch(yState -> yState.value == y);
    }
}

class State {
    int value;
    int offset;

    State(int value, int offset) {
        this.value = value;
        this.offset = offset;
    }

    @Override
    public int hashCode() {
        return Objects.hash(value, offset);
    }

    @Override
    public boolean equals(Object obj) {
        State other = (State) obj;

        return value == other.value && offset == other.offset;
    }
}

Measured memory_bytes: 349364
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n;cin >> n;
  vector<int> A(n);
  loop(i,0,n) cin >> A[i];
  loop(i,1,n) {
    if (A[i-1]>A[i]) {
      cout << "No" << endl; // 高くすることは出来ない.
      return;
    }
    
    if (A[i-1]==A[i]) continue; // これ以上低く出来ない.
    A[i]--; // 低いほうが得.
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
using namespace std;
typedef long long ll;
const int maxN = 110;
const int maxP = 2;
vector<int> v[maxN]; 
int a[maxN];
int b[maxN];
ll c[maxN][maxN];
void combine(int n,int m)
{
	for(int i=0;i<=n;i++)
		c[i][0] = 1;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++)
		{
			if(i==0 && j==0)
				continue;
			c[i][j] = c[i-1][j-1] + c[i-1][j];
		}
}
int main()
{
	int N,P;
	scanf("%d%d",&N,&P);
	combine(N,N);
	int z=0,t=0;
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i]%2;
		if(b[i])
			t++;
		else 
			z++;	
	}
	ll c_0 = 1LL<<z;
	int s = 0;
	if(P == 0)
	{
		if(t%2 != 0)
			s = t-1;
		else
			s = t;
		ll ans = 0;
		for(int i=0;i<=s;i+=2) 
			ans += (ll)c[t][i];
		ans *= c_0;
		printf("%lld\n",ans);
		return 0;
	}
	else
	{
		if(t%2 == 0)
			s = t-1;
		else 
			s = t;
		ll ans = 0;
		for(int i=1;i<=s;i+=2) 
			ans += (ll)c[t][i];
		ans *= c_0;
		printf("%lld\n",ans);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
H = [int(i) for i in input().split()]

result = 'Yes'
for i in range(N-2, -1, -1):
    if H[i] - H[i+1] >= 2:
        result = 'No'
        break
    elif H[i] - H[i+1] == 1:
        H[i] -= 1
    else:
        continue
print(result)

Measured memory_bytes: 23084