akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
 
class Stack{
private:
  int sp;
  int S[100];
public:
  Stack(){
    sp=0;
  }
  bool isFull(){
    return (sp==100);
  }
  bool isEmpty(){
    return (sp==0);
  }
  void push(int d){
    if(isFull()){
      return;
    }
    S[sp++] = d;
  }
  void pop(){
    if(isEmpty()){
      return;
    }
    sp--;
  }
  int top(){
    if(isEmpty()){
      return -1;
    }
    return S[sp-1];
  }
};
 
int main(){
  Stack s;
  string expr;
  getline(cin, expr);
 
  istringstream is(expr);
 
  while(!is.eof()){
    string op;
    is >> op;
 
    int tmp1,tmp2;
 
    switch(op[0]){
      case'+':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2+tmp1);
        break;
      case'-':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2-tmp1);
        break;
      case'*':
        tmp1 = s.top();
        s.pop();
        tmp2 = s.top();
        s.pop();
        s.push(tmp2*tmp1);
        break;
      default:
        istringstream is2(op);
        is2 >> tmp1;
        s.push(tmp1);
        break;
    }
  }
  cout << s.top() << endl;
 
  return 0;
}


Measured memory_bytes: 3208
X = int(input())
def get_primes(n):
  numbers = [i for i in range(2, n+1)]
  primes = []
  while True:
    k = numbers[0]
    primes.append(k)
    numbers = [i for i in numbers if i % k != 0]
    if k**2 > n:
      return primes + numbers
l = get_primes(X)
if l[-1] == X:
  print(X)
else:
  x = X + 1
  while True:
    d = True
    for p in l:
      if x % p == 0:
        d = False
        break
    if d == False:
      x += 1
    else:
      break
  print(x)

Measured memory_bytes: 7448
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n, m, x = map(int,input().strip().split())
    temp = list(map(int, input().strip().split()))
    a = ["none" for _ in range(n+1)]
    for i in temp:
        a[i] = "isCharge"

    ans1=0
    ans2=0
    for i in range(x, n+1):
        if a[i] == "isCharge":
            ans1+=1
    for i in range(0, x+1)[::-1]:
        if a[i] == "isCharge":
            ans2+=1
    print(min(ans1,ans2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61292
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#include <algorithm>
#define foror(i,a,b) for(i=a;i<b;i++)
#define foror2(i,a,b) for(i=a;i>b;i--)
#define EPS 1.0e-8
#define PI acos(-1.0)
#define INF 3000000000
#define MOD 1000000009
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
//using ll = long long;
//using ull= unsigned long long;
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
int main()
{
//freopen("in.txt", "r", stdin);
 //freopen("out.txt", "w", stdout);
 int n,p;
 cin >> n>>p;
 long long ans=1;
 int n1=0;
 int m=0;
   int x;
 for(int i=1;i<=n;i++)
 {
  cin >> x;
  if(x%2==1)
  n1++;
  else
  m++;
 }
  if(n==1)
 {
   int anser=0;
   if(x%2==p)
    anser++;
   if(p==0)
   anser++;
   cout <<anser;
   return 0;
 }
 if(n1==0&&p==1)
 {
        cout <<0;
        return 0;
 }
 int t=n;
 while(t>20)
 {
        ans*=1<<20;
        t-=20;
 }
        ans*=1<<t;
        if(p==0&&m==n)
        cout<<ans;
        else
        cout<<ans/2;
  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>12){
      cout << b << endl;
  }else if(a>5){
      cout << b/2 << endl;
  }else{
      cout << 0  << endl;
  }

}

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

#define INF (1e9)

using namespace std;

int main() {
    int N, K;
    int *h, *dp;

    scanf("%d %d", &N, &K);

    h = (int*)malloc(N * sizeof(*h));
    dp = (int*)malloc(N * sizeof(*dp));

    for (int i = 0; i < N; i++) {
        scanf("%d", h + i);
        dp[i] = 0;
    }

    for (int i = 1; i < N; i++) {
        int m = INF;
        for (int k = 1; k < K + 1; k++) {
            if(i - k < 0) continue;
            m = min(m, dp[i-k] + abs(h[i] - h[i-k]));
        }
        dp[i] = m;
    }

    printf("%d\n", dp[N-1]);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll unsigned long long int
#define pp long long int
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define ll unsigned long long int
#define test long int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
#define mm 1000000007

bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int binaryExponentiation(int x, int n) //function to calculate x raise to power n
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x;
		x = x * x;
		n = n / 2;
	}
	return result;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-______________________________________________________________________________
	int n;
	cin >> n;
	string s;
	cin >> s;
	pp r = 0;
	pp g = 0;
	pp b = 0;
	pp ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R')
		{
			r++;
		}
		else if (s[i] == 'G')
		{
			g++;
		}
		else
		{
			b++;
		}
	}
	ans = r * g * b;
	zip(i, 0, n)
	{
		zip(j, i + 1, n)
		{
			int k = 2 * j - i;
			if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k] && k < n && k != i && k != j)
			{
				ans--;
			}
		}
	}
	if (ans <= 0)
	{
		cout << 0 << en;
	}
	else
		cout << ans << en;

	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p,int r){
  int x,i,j,t;
  x=A[r];
  i=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

int main(){
  int i,q;

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

  q=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(s,e,st) for(int i=s;i<=e;i+=st)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
using namespace std;
int main()
{
    int n,even[100005],odd[100005],x;
    vector<pair<int,int>> ev,od;
    memset(odd,0,sizeof(odd));
    memset(even,0,sizeof(even));
    cin>>n;
   loop(0,n-1,1)
    {
        cin>>x;
        if(i%2==0)
        {
            even[x]++;
        }
        else
        {
            odd[x]++;
        }
    }
    loop(0,100004,1){
        ev.pb({even[i],i});
        od.pb({odd[i],i});
    }
    sort(ev.begin(),ev.end());
    sort(od.begin(),od.end());
    reverse(ev.begin(),ev.end());
    reverse(od.begin(),od.end());
    if(ev[0].S!=od[0].S){
        cout<<n-ev[0].F-od[0].F<<endl;
    }
    else{
        cout<<n-max(ev[0].F+od[1].F,ev[1].F+od[0].F)<<endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct UnionFind {
  vector<int> par, s;
  UnionFind(int n=2e5) { init(n); }
  void init(int n) { 
    s.assign(n, 1); par.resize(n); 
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};

ll n, d;
vector<ll> a, x, y, z;
void dfs(ll left, ll right) {
  if(right - left <= 1) return;
  ll mid = (left+right)/2;

  PII lmin(LLINF, -1);
  FOR(i, left, mid) if(lmin.first > a[i]-i*d) lmin = {a[i]-i*d, i}; 
  FOR(i, mid, right) {
    x.push_back(lmin.second);
    y.push_back(i);
    z.push_back(lmin.first + a[i] + i*d);
  }

  PII rmin(LLINF, -1);
  FOR(i, mid, right) if(rmin.first > a[i]+i*d) rmin = {a[i]+i*d, i};
  FOR(i, left, mid) {
    x.push_back(rmin.second);
    y.push_back(i);
    z.push_back(rmin.first + a[i] - i*d);
  }

  dfs(left, mid);
  dfs(mid, right);
}

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

  cin >> n >> d;
  a.resize(n);
  REP(i, n) cin >> a[i];

  dfs(0, n);

  vector<ll> idx(x.size());
  iota(ALL(idx), 0);
  sort(ALL(idx), [&](ll l, ll r){
    return z[l] < z[r];
  });
  ll ret = 0;
  UnionFind uf(n);
  REP(i, x.size()) {
    if(uf.same(x[idx[i]], y[idx[i]])) continue;
    uf.unite(x[idx[i]], y[idx[i]]);
    ret += z[idx[i]];
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 119716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll dp[200005],pd[200005];
void solve(){
	ll n,k,c;
	string s;
	cin>>n>>k>>c>>s;
	if(c==0){
		ll sum=0;
		for(ll i=0;i<n;i++)
		if(s[i]=='o')
		sum++;
		if(sum<=k){
			for(ll i=0;i<n;i++)
			if(s[i]=='o')
			cout<<i+1<<endl;
		}
		exit(0);
	}
	for(ll i=0;i<n;i++)
	if(s[i]=='x')
	dp[i+1]=dp[i];
	else
	dp[i+1]=max(dp[i],dp[max(ll(0),i-c)]+1);
	for(ll i=n-1;i>=0;i--)
	if(s[i]=='x')
	pd[i+1]=pd[i+2];
	else
	pd[i+1]=max(pd[i+2],pd[min(n+1,i+2+c)]+1);
	if(dp[n]<k){
		for(ll i=0;i<n;i++)
		if(s[i]=='o')
		cout<<i+1<<endl;
		exit(0);
	}
	else if(dp[n]>k)
	exit(0);
	vector<ll> res;
	for(ll i=1;i<=n;i++)
	if(dp[i]+pd[i+c+1]==k)
	res.push_back(i);
	for(ll i=1;i<=n;i++)
	if(s[i-1]=='o'&&dp[max(ll(0),i-c-1)]+pd[min(n+1,i+c+1)]==k-1&&pd[i+1]<k&&dp[i-1]<k){
		auto it=lower_bound(res.begin(),res.end(),i-c);
		if(it==res.end()||(*it)>=i)
		cout<<i<<endl;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 4752
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Integer, Integer> freqMap = new HashMap<>();
      for(int i = 0; i < n; i++) {
        int num = sc.nextInt();
        freqMap.put(num, freqMap.getOrDefault(num, 0) + 1);
      }
      int sum = 0;
      for(int freq : freqMap.values()) {
        sum += freq - 1;
      }
      if(sum % 2 == 0)
        System.out.println(freqMap.size());
      else
        System.out.println(freqMap.size() - 1);
  }
}

Measured memory_bytes: 59244
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		BigInteger bi = BigInteger.ONE;
		for(int i=2;i<=n+1;i++) bi = bi.multiply(BigInteger.valueOf(i));
		System.out.println(bi.add(BigInteger.valueOf(2)));
		for(int i=2;i<=n+1;i++) System.out.println(i);
	}
}

Measured memory_bytes: 28496
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i;
    cin>>n;
    ll dp[n+1];
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[i]=mod;
    }
    dp[1]=0;
    for(i=1;i<n;i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
        if((i+2)<=n)
        {
            dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
        }
    }
    cout<<dp[n];

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> d;
	for(int i=0; i<n; i++){
		int x;
		cin >> x;
		d.push_back(x);
	}
	sort(d.begin(), d.end());
	cout << d[n/2]-d[(n-1)/2] << endl;
	return 0;
}


Measured memory_bytes: 3884
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
			}
			int cnt = 0;
			for (int i = 1; i < n - 1; i++) {
				if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
					cnt++;
				}
				else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int n; cin >> n;
  vector<int> x(n); rep(i,n) cin >> x[i];
  vector<int> v = x;
  sort(all(v));
  int med1 = v[n/2-1], med2 = v[n/2];
  rep(i,n){
    if(x[i]<=med1) cout << med2 << endl;
    else cout << med1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
  double w,h,b;
  int n;
  
  while((scanf("%d,%lf,%lf",&n,&w,&h))!=EOF){
    b = w/(h*h);
    if(b>=25)
      printf("%d\n",n);
  }
  
  return 0;

}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define INF 1100000000
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
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() {
  ll N; cin >> N;
  vector<ll> A(N),B(N),C(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end());
  rep(i,N) cin >> B[i];
  rep(i,N) cin >> C[i];
  sort(C.begin(), C.end());

  ll ans = 0;
  rep(i, N) {
    ll a = distance(A.begin(), lower_bound(A.begin(), A.end(), B[i]));
    ll b = distance(upper_bound(C.begin(), C.end(), B[i]), C.end());
    ans += a*b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
x,y = map(int, input().split())
A = []
if 0<=x<=y: A.append(y-x)
if 0<=y<=x: A.append(x-y+2)
if y<=0<=x: A.append(abs(x+y)+1)
if x<=0<=y: A.append(abs(x+y)+1)
if x<=y<=0: A.append(y-x)
if y<=x<=0: A.append(x-y+2)
print(min(A))

Measured memory_bytes: 61736
//https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_c
//C - 3 Steps
//2部グラフ判定
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
    int col=-1;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
bool dfs(WeightedGraph<T>& g, int idx, int par, int col) {
    bool ret=true;
    if(g[idx].col == -1) {
        g[idx].col = col;
        for(auto& e:g[idx].edges){
            if(e.to == par) continue;
            ret &= dfs(g, e.to, idx, (col+1)&1);
        }
    }
    if(g[idx].col != col) return false;
    return ret;
}

int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M; cin>>N>>M;
    WeightedGraph<ll> graph(N+1);
    REP(i,M){
        ll A,B; cin>>A>>B;
        graph.at(A).edges.emplace_back(A,B,1);
        graph.at(B).edges.emplace_back(B,A,1);
    }

    ll ans=0;
    bool nibu=dfs(graph, 1, -1, 0);
    if(nibu){
        ll n[2]={};
        FOR(i,1,N+1){
            auto c = graph.at(i).col;
            assert(c!=-1);
            n[c]++;
        }
        ans = n[0]*n[1] - M;
    } else {
        ans = N * (N-1) / 2 - M;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
	int N;
	int A[3][3];
	bool b_A[3][3];
	int b[10];

	for(int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
			b_A[i][j] = false;
		}
	}
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> b[i];
	}

	for(int z = 0; z < N; z++) {
		int _tmp = b[z];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				if(_tmp == A[i][j]) {
					b_A[i][j] = true;
				}
			}
		}
	}

	string res = "No";
	for(int i = 0; i < 3; i++) {
		if(b_A[i][0] && b_A[i][1] && b_A[i][2]) {
			res = "Yes";
		}
	}
	for(int i = 0; i < 3; i++) {
		if(b_A[0][i] && b_A[1][i] && b_A[2][i]) {
			res = "Yes";
		}
	}
	if(b_A[0][0] && b_A[1][1] && b_A[2][2]) {
		res = "Yes";
	}
	if(b_A[0][2] && b_A[1][1] && b_A[0][2]) {
		res = "Yes";
	}

	cout << res << endl;
}


Measured memory_bytes: 256
S = input()
T = input()

dict_S = {}
dict_T = {}

for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Measured memory_bytes: 3632
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N, W;
  
  vector<int> w, v;
  
  REP(i, N) {
    int wt, vt;
    
    cin >> wt >> vt;
    w.push_back(wt);
    v.push_back(vt);
  }
  
  int dp[1000001];
  
  for (auto&& i : dp) i = 999999999;
  dp[0] = 0;
  int r = 0;
  
  REP(i, N)
    for(int j = 1000000 - v[i]; j >= 0; j--) {
    if (dp[j] + w[i] <= W) {
      dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
      r = max(r, j + v[i]);
    }
  }


  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}





Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m; cin >> n >> m;
    string s,t; cin >> s >> t;
    int a = lcm(n,m);
    
    n = a / n;
    m = a / m;
    int a2 = lcm(n,m);
    for(int i = 0; i < a; i += a2){
        if(s[i/n] != t[i/m]){
            cout << -1 << endl;
            return 0;
        }
    }
    OUT(a);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll s; cin >> s;
    vector<bool> a(1000000,false);
    a[s] = true;
    ll count = 1;

    while(1){
        if(s%2 == 0) s = s/2;
        else s = 3*s + 1;
        count++;
        if(a[s] == true) break;
        a[s] = true;
    }

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, k, sum = 0;
	cin >> a >> b >> c >> k;
    if(k <= a){
        sum = k;
    }else if(k <= a+b){
        sum = a;
    }else{
        sum = a;
        k -= a + b;
        sum -= k;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
long long n,a[234567]; 
map<long long,long long>mp;
long long fix(long long x){
	return x*(x-1)/2;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	for(int i=0;i<n;i++)mp[a[i]]++;
	long long ans=0;
	for(auto it=mp.begin();it!=mp.end();it++){
		ans+=fix(it->second);
	}
	cout<<ans+mp[0]<<endl;
	return 0;
}

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

int main() {
  ll n, x, m;
  cin >> n >> x >> m;
  vector<int> id(m,-1);
  vector<int> a;
  int len = 0;
  ll tot = 0;
  while (id[x] == -1) {
    a.push_back(x);
    id[x] = len;
    len++;
    tot += x;
    x = (x*x)%m;
  }

  int c = len-id[x];
  ll s = 0;
  for (int i = id[x]; i < len; ++i) s += a[i];

  ll ans = 0;
  if (n <= len) {
    rep(i,n) ans += a[i];
  } else {
    ans += tot;
    n -= len;
    ans += s*(n/c);
    n %= c;
    rep(i,n) ans += a[id[x]+i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long a = scanner.nextInt();
        final long v = scanner.nextInt();
        final long b = scanner.nextInt();
        final long w = scanner.nextInt();
        final long t = scanner.nextInt();

        if (a < b) {
            if (a + v * t >= b + w * t) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        } else {
            if (a - v * t <= b - w * t) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 32816
from scipy.sparse.csgraph import floyd_warshall
from numpy import where
n,m,l=map(int,input().split())
abc=[list(map(int,input().split()))for i in range(m)]
q=int(input())
st=[list(map(int, input().split()))for i in range(q)]
t=[[float("inf")]*n for _ in range(n)]
for a,b,c in abc:
 if c<=l:t[a-1][b-1]=c
f=floyd_warshall(t,0)
l=floyd_warshall(where(f<=l,1,f),0)
for s, t in st:print(-1if l[s-1,t-1]==float("inf")else int(l[s-1,t-1])-1)

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

int main()
{   ll n,k;
    scanf("%lld%lld",&n,&k);
    ll z[n],x[n];
    for(ll i=0;i<n;i++)
    {   scanf("%lld",&z[i]);
        x[i]=0;
    }
    x[0]=0;
    x[1]=abs(z[0]-z[1]);
    for(ll i=2;i<n;i++)
    {   ll temp = INT_MAX;
        for(ll j=1;j<=k;j++)
        {   if(j<=i)
                temp=min(x[i-j]+abs(z[i]-z[i-j]),temp);
        }
        x[i]=temp;
    }
    printf("%lld",x[n-1]);
    return 0;
}


Measured memory_bytes: 1792
// AOJ 2151: Brave Princess Revisited
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

typedef struct { int t, n, m; } QUE;
QUE que[20001]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].n, *m = que[0].m;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int t, int n, int m)
{
	int i, min;

	i = qsize++;
	que[i].t = t, que[i].n = n, que[i].m = m;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

typedef struct { int to[101], d[101], e[101]; } TBL;
TBL tbl[101];
int len[101];
int node[101][101]; int size;

int search(int start, int goal, int l)
{
	int s, m, i, k, e, p, ans;
	TBL *tp;

	qsize = 0;
	memset(node, 0x33, sizeof(node));
	node[start][l] = 0; enq(0, start, l);
	ans = 0x7fffff;
	while (qsize) {
		s = que[0].n, m = que[0].m, deq();
		p = node[s][m];
		if (s == goal) {
			if (p < ans) ans = p;
			if (ans == 0) break;
			continue;
		}

		for (tp = tbl + s, i = 0; i < len[s]; i++) {
			e = tp->to[i];

			k = p + tp->e[i];
			if (k < node[e][m]) node[e][m] = k, enq(node[e][m], e, m);

			k = m - tp->d[i];
			if (tp->d[i] <= m && p < node[e][k]) node[e][k] = p, enq(node[e][k], e, k);
		}
	}
	return ans;
}

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, l, a, b, d, e, i;
	TBL *tp;
#if TM
	clock_t start, end;
	start = clock();
#endif

	while (fgets(p=buf, 30, stdin) && *p != '0') {
		n = getint(), p++, m = getint(), p++, l = getint();
		memset(len, 0, sizeof(len));
		while (m--) {
			fgets(p=buf, 30, stdin);
			a = getint()-1, p++, b = getint()-1, p++, d = getint(), p++, e = getint();
			i = len[a], tp = tbl+a;
			tp->to[i] = b, tp->d[i] = d, tp->e[i] = e, len[a]++;
			i = len[b], tp = tbl+b;
			tp->to[i] = a, tp->d[i] = d, tp->e[i] = e, len[b]++;
		}
		size = n;
		printf("%d\n", search(0, n-1, l));
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;
    cin>>N;
    bool used[100000];
    fill_n(used,100000,false);
    int cnt=0;
    REP(i,N){
        int tmp;
        cin>>tmp;
        if(used[--tmp]){
            cnt++;
        }else{
            used[tmp]=true;
        }
    }

    cout<<N-(cnt+(cnt%2))<<endl;
    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	string s; cin >> s;

	map <char, int> m;

	for(char c : s){
		m[c]++;
	}

	if(m.size() == 2){
		cout << (m.begin()->second == 2 and next(m.begin())->second == 2 ? "Yes" : "No") << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n,m,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

la = [0] + list(accumulate(a))
lb = [0] + list(accumulate(b))

ans = 0
i = n
for j in range(m+1):
    while la[i]+lb[j] > k and i>0:
        i -= 1
    if i==0 and lb[j] > k:
        break
    ans = max(ans, i+j)

print(ans)


Measured memory_bytes: 49252
#include <iostream>
using namespace std;
int n, a[1007], dp[1007][8]; char c;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> c;
		a[i] = c == 'J' ? 0 : (c == 'O' ? 1 : 2);
	}
	for(int i = 1; i < 8; i += 2) {
		if(i & (1 << a[0])) dp[0][i] = 1;
	}
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < 8; j++) {
			if((j & (1 << a[i])) == 0) continue;
			for(int k = 0; k < 8; k++) {
				if(j & k) dp[i][j] += dp[i - 1][k];
			}
			dp[i][j] %= 10007;
		}
	}
	int ret = 0;
	for(int i = 1; i < 8; i++) ret += dp[n - 1][i];
	cout << ret % 10007 << endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll a[100001] = {};
ll s[100001] = {};
map<ll, ll> mp;
int main() {
	ll n, m; cin >> n >> m;
	repe(i, 1, n)cin >> a[i];
	repe(i, 1, n)s[i] += s[i - 1] + a[i];
	repe(i, 1, n) {
		s[i] %= m;
		mp[s[i]]++;
	}

	ll ans = 0;
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (!it->first) {
			ans += it->second;
		}

		ans += it->second * (it->second - 1) / 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
import java.util.*;
import java.lang.*;

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 max = 0;
        int min = 2147483647;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < N; j++){
            max = Math.max(max, a[j]);
        }
        for(int k = 0; k < N; k++){
            min = Math.min(min, a[k]);
        }
        System.out.println(max-min);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){

    int D;
    
    scanf("%d",&D);
    
    if(D==25){
         printf("Christmas");
    }else if(D==24){
        printf("Christmas Eve");
    }else if(D==23){
        printf("Christmas Eve Eve");
    }else if(D==22){
        printf("Christmas Eve Eve Eve");
    }
    
    
    return 0;
}


Measured memory_bytes: 128
import sys
input=sys.stdin.readline
s=input().rstrip()
n=len(s)
check=True
for i in range(n-1//2):
    if s[i]==s[n-1-i]:
        pass
    else:
        check=False
for i in range(((n-1)//2)//2):
    if s[i]==s[(n-1)//2-1-i]:
        pass
    else:
        check=False
for i in range(((n-1)//2)//2):
    if s[(n+1)//2+i]==s[(n+1)//2+(n-1)//2-1-i]:
        pass
    else:
        check=False
if check:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#input
A, B = map(int,input().split())
#消費税0.08 0.1
import math

ans = -1

for n in range(1001):##最大値を間違えていた
        if math.floor(n*0.08) == A and math.floor(n*0.1) == B:
            ans = int(n)
            break

print(ans)

Measured memory_bytes: 3060
h,w  = [int(j) for j in input().split()]
l = []
for i in range(h):
    l.append(input())
dp = dict()
dp[h-1,w-1]=1

for i in range(h)[::-1]:
    for j in range(w)[::-1]:
        if i==h-1 and j==w-1:
            continue
        if l[i][j] == "#":
            dp[i,j]=0
        else:
            flag =True
            if i+1<h and l[i+1][j]!="#":
                dp[i,j] = dp[i+1,j]
                flag = False
            if j+1<w and l[i][j+1]!="#":
                try:
                    dp[i,j]=dp[i,j+1]+dp[i,j]
                except:
                    dp[i,j]=dp[i,j+1]
                flag = False
            if flag:
                # print(i,j)
                dp[i,j]=0
# print(dp)
mod = 10**9+7
print(dp[0,0]%mod)


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

int a[200005];
int b[200005];
int c[200005];
int d[200005];

int N;

bool boleh(int k){
    for(int i = 0; i < 2*N-1; i ++){
        b[i] = (a[i] < k);
    }

    queue<int> q;
    c[0] = b[0];
    c[2*N-2] = b[2*N-2];

    q.push(0);
    q.push(2*N-2);
    for(int i = 1; i < 2*N-2; i ++){
        if(b[i+1] == b[i-1] && b[i] != b[i+1]){
            c[i] = 3;
        }else{
            c[i] = b[i];
            q.push(i);
        }
    }

    while(!q.empty()){
        int u = q.front(); q.pop();
        //printf("visited %d c[%d]=%d\n", u, u, c[u]);

        if(u < 2*N-1 && c[u+1] == 3){
            c[u+1] = c[u];
            q.push(u+1);
        }

        if(u > 0 && c[u-1] == 3){
            c[u-1] = c[u];
            q.push(u-1);
        }
    }

    return c[N-1];
}

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

    for(int i = 0; i < 2*N-1; i ++){
        scanf("%d", &a[i]);
        b[i] = a[i];
    }

    int lo = 1;
    int hi = 2*N;
    while(lo < hi){
        int mid = (lo+hi+1)>>1;
        if(boleh(mid)){
            hi = mid-1;
        }else{
            lo = mid;
        }
    }

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

    for(int i = 1; i <= 2*N-1; i ++){
        printf("boleh(%d)=%d\n", i, boleh(i));
    }

    for(int i = 0; i < 2*N-1; i ++){
        b[i] = a[i];
    }

    for(int i = 0; i < N-1; i ++){
        for(int j = 0; j < 2*N-3-2*i; j ++){
            if(b[j] >= b[j+1] && b[j] <= b[j+2]){
                c[j] = b[j];
            }else if(b[j] <= b[j+1] && b[j] >= b[j+2]){
                c[j] = b[j];
            }else if(b[j+1] >= b[j] && b[j+1] <= b[j+2]){
                c[j] = b[j+1];
            }else if(b[j+1] <= b[j] && b[j+1] >= b[j+2]){
                c[j] = b[j+1];
            }else if(b[j+2] >= b[j] && b[j+2] <= b[j+1]){
                c[j] = b[j+2];
            }else if(b[j+2] <= b[j] && b[j+2] >= b[j+1]){
                c[j] = b[j+2];
            }
        }

        for(int j = 0; j <= i; j ++){
            printf("  ");
        }

        for(int j = 0; j < 2*N-3-2*i; j ++){
            b[j] = c[j];
            printf("%d ", b[j]);
        }
        printf("\n");
    }

    printf("%d", b[0]);
    return 0;
}


Measured memory_bytes: 3472
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  double l;
  cin >> l;
  double a;
  a = l/3;
  double ans;
  ans = a*a*a;
  printf("%lf\n",ans );
  return 0;
}


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

int n,v;
struct node
{
	int x,c;
}a[100010],b[100010];
int maxn=-1;

inline int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0' || c>'9') {if (c=='-') f=0;c=getchar();}
	while (c>='0' && c<='9') x=x*10+(c^48),c=getchar();
	return f?x:-x;
}

bool cmp(node x,node y) {return x.c>y.c;}

int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		v=read();maxn=max(maxn,v);
		if (i%2) a[v].c++,a[v].x=v;
		else b[v].c++,b[v].x=v;
	}
	sort(a+1,a+maxn+1,cmp);
	sort(b+1,b+maxn+1,cmp);
	if (a[1].x!=b[1].x) printf("%d\n",n-a[1].c-b[1].c);
	else
	{
		if (a[2].c>b[2].c) printf("%d\n",n-a[2].c-b[1].c);
		else printf("%d\n",n-a[1].c-b[2].c);
	}
}

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

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n - 1) cin >> b[i];
    a[n - 1] = b[n - 2];
    for (int i = n - 2; i > 0; i--) {
        a[i] = min(b[i], b[i - 1]);
    }
    a[0] = b[0];

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include<omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int cnt = 0;
	for (int i = 1000; i >= 1; --i) {
		if (a % i == 0 && b % i == 0) {
			cnt++;
			if (cnt == k) {
				cout << i << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

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

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

using bit = std::bitset<50>;

int main()
{
    using namespace std;

    vec<bool> v(3);
    string s;
    cin >> s;

    for (auto c : s)
    {
        v[c - 'a'] = true;
    }

    if (all_of(v.cbegin(), v.cend(), [](bool b) { return b; }))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S.length() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < S.length(); i += 2) {
        if (S[i] != 'h' || S[i + 1] != 'i') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
typedef unsigned long long int uli;
using namespace std;
int main() {
	uli w, h;
	cin >> w >> h;
	if(w == 1 || h == 1) {
		cout << 1 << endl;
		return 0;
	}
	cout << (w  *h + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int X,Y;
    cin >> X >> Y;
    int A,B,C;
    cin >> A >> B >> C;
    vector<ll> a(A), b(B), c(C);
    REP(i, A) cin >> a[i];
    REP(i, B) cin >> b[i];
    REP(i, C) cin >> c[i];
    sort(ALL(a));reverse(ALL(a));
    sort(ALL(b));reverse(ALL(b));
    RSORT(c);
    a.erase(a.begin() + X, a.end());
    b.erase(b.begin() + Y, b.end());
    a.insert(a.end(), b.begin(), b.end());
    SORT(a);
    int n = a.size();
    REP(i, min(n, C)){
        if(a[i] < c[i]){
            a[i] = c[i];
        }else{
            break;
        }
    }
    ll ans = 0;
    REP(i, n){
        ans += a[i];
    }
    pr(ans);
}

Measured memory_bytes: 3968