akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

ll f(ll b,ll k){
  return pow(b+k,5)-pow(b,5);
}

int main(){
  ll X; cin>>X;
  if(X==1){
    cout<<0<<" "<<-1<<endl;
    return 0;
  }
  for(ll i = sqrt(X); i >= 1; i--){
    if(X%i==0){
      //iは約数候補
      for(ll j = 0; j < 100000; j++){
        if(X==f(j,i)){
          cout<<j+i<<" "<<j<<endl;
          return 0;
        }
        if(X==f(-j,i)){
          cout<<-j+i<<" "<<-j<<endl;
          return 0;
        }
      }
    }
  }
}


Measured memory_bytes: 4156
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, X;

int dpa[3030][6060]; // len, sum
i64 dpb[3030][3030]; // two lines; allowed max 2s, sum of # of 0 and 2
int comb[3030][3030]; // C(i,j)
int combacc[3030][3030];
int combacc2[3030][3030];

i64 cumu[3030];

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

	comb[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		comb[i][0] = 1;
		for (int j = 1; j <= N; ++j) comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
	}
	for (int i = 0; i <= N; ++i) {
		combacc[i][0] = comb[i][0];
		for (int j = 1; j <= N; ++j) {
			combacc[i][j] = (combacc[i][j - 1] + comb[i][j]) % MOD;
		}
	}
	for (int j = 0; j <= N; ++j) combacc2[0][j] = combacc[0][j];
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			combacc2[i][j] = (combacc2[i - 1][j] + combacc[i][j]) % MOD;
		}
	}
	/*
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			ADD(combacc[i][j], combacc[i - 1][j]);
		}
	}
	*/

	dpa[0][0] = 1;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= 2 * i; ++j) {
			for (int k = 0; k <= 2; ++k) ADD(dpa[i + 1][j + k], dpa[i][j]);
		}
	}

	for (int i = 0; i <= N; ++i) {
		dpb[0][i] = i + 1;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) cumu[j] = dpb[i - 1][j];
		for (int j = 1; j <= N; ++j) ADD(cumu[j], cumu[j - 1]);
		for (int j = 1; j <= N; ++j) ADD(cumu[j], cumu[j - 1]);

		for (int j = 0; j <= N; ++j) {
			// both contains 2
			if (j >= 2) ADD(dpb[i][j], cumu[j - 2]);

			// only one contains 2
			ADD(dpb[i][j], combacc2[j][i] * 2);

			// correction (no 2)
			ADD(dpb[i][j], MOD - (j + 1));
		}
		//for (int j = 0; j <= N; ++j) printf("%d %d: %lld\n", i, j, dpb[i][j]);
	}

	i64 ret = 0;
	for (int s = 0; s <= 2 * N; ++s) {
		// ... 1 s 1 ...
		for (int l = 2; l <= N; ++l) {
			if (s % 2 == X % 2) {
				int maxp = (X - s - 2) / 2 - 1;
				if (maxp >= 0) ADD(ret, (i64)dpa[l - 2][s] * combacc[N - l][maxp] % MOD * (N - l + 1));
				//printf("%d %d: %d %lld\n", s, l, maxp, (i64)dpa[l - 2][s] * combacc[N - l][maxp] % MOD * (N - l + 1));
			} else {
				int maxp = (X - s - 3) / 2;
				if (maxp >= 0) ADD(ret, (i64)dpa[l - 2][s] * dpb[maxp][N - l]);
				//printf("%d %d: %lld\n", s, l, (i64)dpa[l - 2][s] * dpb[maxp][N - l]);
			}
			//printf("%d %d %lld\n", s, l, ret);
		}
	}
	//printf("%lld\n", ret);

	// ... 1 ...
	if (X % 2 == 1) {
		int maxp = (X - 1) / 2 - 1;
		for (int i = 0; i <= maxp; ++i) ADD(ret, (i64)comb[N - 1][i] * N);
		//if (maxp >= 0) ADD(ret, (i64)combacc[N - 1][maxp] * N);
	} else {
		int maxp = (X - 2) / 2;
		if (maxp >= 0) ADD(ret, (i64)dpb[maxp][N - 1]);
	}
	//printf("%lld\n", ret);

	// ...
	int yt;
	if (X % 2 == 1) yt = N;
	else yt = X / 2 - 1;

	for (int i = 0; i <= yt; ++i) ADD(ret, comb[N][i]);

	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 250624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<HashMap<Integer, Boolean>> graph = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            graph.add(new HashMap<>());
        }
        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            boolean c = (sc.nextInt() % 2 == 1);
            graph.get(a).put(b, c);
            graph.get(b).put(a, c);
        }
        boolean[] ans = new boolean[n];
        setAns(0, 0, false, graph, ans);
        StringBuilder sb = new StringBuilder();
        for (boolean b : ans) {
            if (b) {
                sb.append(1);
            } else {
                sb.append(0);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    
    static void setAns(int idx, int parent, boolean value, ArrayList<HashMap<Integer, Boolean>> graph, boolean[] ans) {
        ans[idx] = value;
        for (Map.Entry<Integer, Boolean> entry : graph.get(idx).entrySet()) {
            if (entry.getKey() == parent) {
                continue;
            }
            boolean next = value;
            if (entry.getValue()) {
                next ^= true;
            }
            setAns(entry.getKey(), idx, next, graph, ans);
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
int main(){
	ll N,A,B; cin>>N>>A>>B;
	//A=2 B=3 {5,6}{3,4}{1,2} N=6
	//A=2 B=3 {5}{3}{1,2} N=A+B-1(限界)
	//A=3 B=4 {10,11,12}{7,8,9}{4,5,6}{1,2,3}
	//A=3 B=4 {10,*,*}{7,*,*}{4,5,*}{1,2,3}->7,6,4,5,1,2,3

	if(N<A+B-1 || A*B<N) cout<<-1;
	else{//A+B-1<=N<=A*B　OK
		ll W=A*B-N;//消す数
		//{A*B-(A-1) ... A*B}...{A*1-(A-1) ... A*1}
		ll X=(A!=1ll?W/(A-1):0ll);//まとまり
		ll Y=(A!=1ll?W%(A-1):0ll);//あまり
		for(int i=1;i<=B;i++){
			if(i<=X){
				cout<<A*(B+1-i)-(A-1)-(W-i*(A-1))<<" ";
			}
			else if(i==X+1 && Y>0){
				rep(j,A-Y){
					cout<<A*(B+1-i)-(A-1)+j<<" ";
				}
			}
			else{
				rep(j,A){
					cout<<A*(B+1-i)-(A-1)+j<<" ";
				}
			}
		}
	}
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>

using namespace std;
using ll = long long;

void solve(int n, int w, int d){
  vector<pair<int, int>> cake;
  cake.push_back({w, d});
  for(int i = 0; i < n; i++){
    int p, s; cin >> p >> s;
    p--;
    int cnt = 0;
    pair<int, int> selected;
    for(pair<int, int> &i:cake){
      if(i.first == -1) continue;
      if(cnt == p){
        selected = i;
        i = {-1, -1};
      }
      cnt++;
    }
    s %= 2*(selected.first+selected.second);
    if(s < selected.first){
      cake.push_back({min(s, selected.first - s) , selected.second});
      cake.push_back({max(s, selected.first - s) , selected.second});
    }
    else if(s < selected.first+selected.second){
      s -= selected.first;
      cake.push_back({selected.first , min(s, selected.second - s)});
      cake.push_back({selected.first , max(s, selected.second - s)});
    }
    else if(s < selected.first * 2 + selected.second){
      s -= selected.first + selected.second;
      cake.push_back({min(s, selected.first - s) , selected.second});
      cake.push_back({max(s, selected.first - s) , selected.second});
    }
    else{
      s -= selected.first * 2 + selected.second;
      cake.push_back({selected.first , min(s, selected.second - s)});
      cake.push_back({selected.first , max(s, selected.second - s)});
    }
  }
  vector<int> area;
  for(auto i : cake){
    if(i.first == -1) continue;
    area.push_back(i.first * i.second);
  }
  sort(area.begin(), area.end());
  for(int i = 0; i < area.size(); i++){
    cout << area[i];
    if(i < area.size()-1) cout << ' ';
  }
  cout << endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, w, d;
  while(cin >> n >> w >> d && w){
    solve(n, w, d);
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] team = new int[n];
		for(int i=0; i<n; ++i) team[i]=0;
		int[] t = new int[4];
		for(int i=0; i<n*(n-1)/2; ++i){
			for(int j=0; j<4; ++j) t[j] = sc.nextInt();
			if(t[2]>t[3]) team[ t[0]-1 ] +=3;
			else if(t[2]<t[3]) team[ t[1]-1 ] +=3;
			else{
				team[ t[0]-1 ] +=1;
				team[ t[1]-1 ] +=1;
			}
		}
		for(int i=0; i<n; ++i){
			int cnt=0;
			for(int j=0; j<n; ++j){
				if(team[i]<team[j]) ++cnt;
			}
			System.out.println(cnt+1);
		}	
	}
}

Measured memory_bytes: 43868
import numpy as np
from scipy import optimize
a,b,x = (int(x) for x in input().split())
v = a**2*b
def f(s):
    return v - (a**3*np.tan(s)/2) - x
def g(s):
    return (a*(b**2)*np.tan(s)/2) - x
if 2*x >= v:
    c = optimize.fsolve(f,0)
    print(np.rad2deg(c)[0])
else:
    c = optimize.fsolve(g,0)
    print(90-np.rad2deg(c)[0])

Measured memory_bytes: 25500
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int p = 0;
    StringBuilder sb1 = new StringBuilder();
    StringBuilder sb2 = new StringBuilder();    
    int q = sc.nextInt();
    for(int i = 0; i < q; i++) {
      int f = sc.nextInt();
      if(f == 1) {
        p = 1 - p;
      } else {
        int t = sc.nextInt();
        String c = sc.next();
        if(p == 0) {
          if(t == 1) {
            sb1.append(c);
          } else {
            sb2.append(c);
          }
        } else {
          if(t == 1) {
            sb2.append(c);
          } else {
            sb1.append(c);
          }          
        }
      }
    }
    String s1 = new String(sb1);
    String s2 = new String(sb2);
    StringBuffer ss = new StringBuffer(s1);
    String ans = ss.reverse().toString() + s + s2;
    if(p == 1) {
      StringBuffer str = new StringBuffer(ans);
      ans = str.reverse().toString();
    }
    System.out.println(ans);
  }
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String line;
        char[][] mineMap = new char[H+2][W+2];
        for(int h=1;h<=H;h++){
        	line = sc.next();
        	for(int w=1;w<=W;w++){
        		mineMap[h][w]=line.charAt(w-1);
        	}
        }
        for(int h=1;h<=H;h++)for(int w=1;w<=W;w++){
        	int bombCount=0;
        	if(mineMap[h-1][w-1]=='#') bombCount++;
        	if(mineMap[h-1][w]=='#') bombCount++;
        	if(mineMap[h-1][w+1]=='#') bombCount++;
        	if(mineMap[h][w-1]=='#') bombCount++;
        	if(mineMap[h][w+1]=='#') bombCount++;
        	if(mineMap[h+1][w-1]=='#') bombCount++;
        	if(mineMap[h+1][w]=='#') bombCount++;
        	if(mineMap[h+1][w+1]=='#') bombCount++;
        	
        	if(mineMap[h][w]!='#') mineMap[h][w]=(char)('0'+bombCount);
        }
        
        for(int h=1;h<=H;h++){
        	for(int w=1;w<=W;w++){
        		System.out.print(mineMap[h][w]);
        	}
        	System.out.println();
        }
    }
}

Measured memory_bytes: 23764
function equal(a, b) {
    var aP = Object.getOwnPropertyNames(a);
    var bP = Object.getOwnPropertyNames(b);
    if (aP.length != bP.length)
        return false;
    for (var i = 0; i < aP.length; i++)
        if (a[aP[i]] !== b[aP[i]])
            return false;
    return true;
}
function pi(text) {
    return parseInt(text, 10);
}
var six = [6, 5, 4, 3, 2, 1].map(_ => Math.pow(6, _));
var nine = [5, 4, 3, 2, 1].map(_ => Math.pow(9, _));
function count(i) {
    if (i < 6)
        return i;
    if (i < 9)
        return 1 + (i - 6);
    return Math.min(count(i - six.find(_ => _ <= i)) + 1, count(i - nine.find(_ => _ <= i)) + 1);
}
function main(input) {
    var i = pi(input);
    console.log(count(i));
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10300
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    SORT(a);
    REV(a);
    priority_queue<P> q;
    ll ans = 0;
    q.push(make_pair(a[0],a[0]));
    drep(i, 1, n-1){
        P top = q.top();
        q.pop();
        ans += top.first;
        // cout << top.first << " " << top.second << endl;
        q.push(make_pair(min(top.first, a[i]),max(top.first,a[i])));
        q.push(make_pair(min(top.second, a[i]),max(top.second,a[i])));

    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 6144
import sys

n = int(sys.stdin.readline())+1

m = [[0] * n for _ in range(n)]
discover_time = [-1] * n
finish_time = [0] * n
clock = -1

def walk(p):
    global clock
    clock += 1

    for i in range(n):
        if m[p][i]==0: continue
        if discover_time[i]<0:
            discover_time[i] = clock
            clock = walk(i)
            finish_time[i] = clock
            clock +=1

    return clock

m[0] = [1] * n
for i in range(1,n):
    cols = list(map(int, sys.stdin.readline().split()))
    for j in cols[2:]:
        m[i][j]=1

walk(0)

for i in range(1,n):
    print(i,discover_time[i],finish_time[i])


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

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int h, w, k;
	cin >> h >> w >> k;

	vector<string> bd(h);
	rep(i, h) cin >> bd[i];

	int ans = 0;
	for(int a = 0; a < (1 << h); a++){
		for(int b = 0; b < (1 << w); b++){
			int t = 0;
			rep(i, h){
				rep(j, w){
					if(((a >> i) & 1) && ((b >> j) & 1) && bd[i][j] == '#') t++;
				}
			}

			if(t == k) ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,V[30],C[30],X[30],max=0;
    cin>>N;
    for(int i=0;i<N;++i)cin>>V[i];
    for(int i=0;i<N;++i){
        cin>>C[i];
        X[i]=V[i]-C[i];
        if(X[i]>0)max+=X[i];
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SZ = 40;
int cok[SZ];
int main(void){
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		int x; scanf("%d",&x);
		for(int j=0;j<x;j++){
			int y; scanf("%d",&y);
			cok[y]++;
		}
	}
	int ans = 0;
	for(int i=1;i<=m;i++){
		if(cok[i]==n) ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, g, b, n;
  scanf("%d%d%d%d", &r, &g, &b, &n);
  int cnt = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      int k = n - i - j;
      if (k < 0) break;
      if (i % r == 0 and j % g == 0 and k % b == 0) cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}

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


#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define MOD 1000000007

inline void normal(long long &a) { a %= MOD; (a < 0) && (a += MOD); }
inline long long modMul(long long a, long long b) { normal(a), normal(b); return (a*b)%MOD; }
inline long long modAdd(long long a, long long b) { normal(a), normal(b); return (a+b)%MOD; }
inline long long modSub(long long a, long long b) { normal(a), normal(b); a -= b; normal(a); return a; }
inline long long modPow(long long b, long long p) { long long r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline long long modInverse(long long a) { return modPow(a, MOD-2); }
inline long long modDiv(long long a, long long b) { return modMul(a, modInverse(b)); }


int main()
{
    O_O;
#ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
#endif
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        int n;
        cin >> n;
        int arr[n+5];
        int c1=0,c0=0;
        for(int i=0;i<n;i++)
        {
        	cin >> arr[i];
        	if(arr[i]%2==0)	c0++;
        	else 			c1++;	
        }
        if(c1%2==0)	
        {
        	cout << "YES\n";
        }
        else 
        {
        	if(n==1)	cout << "YES\n";
        	else 		cout << "NO\n";
        }

    }
    return 0;
}




Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b)     for(int i=a;i>=b;--i)
#define init(a, x) memset(a,x,sizeof(a))
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
	cin>>n;
      cout<<1-n<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <limits.h>
#include <math.h>

int main(){
  long n;
  long i;
  long temp;
  long distance=1000000000000;
  
  scanf("%ld",&n);
  
  for(i=1;i<=(long)sqrt((double)n);i++){
    temp=0;
    if(n%i==0){
      temp=i+(n/i)-2;
      if(temp<distance){
        distance=temp;
      }
    }
  }

  printf("%ld",distance);
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2], vis[N];


void solve()
{
	int x;
	cin >> x >> n;
	lop(i, 0, n) cin >> arr[i], vis[ arr[i] ] = 1;

	int y = x;

	while ( y >= 0 and vis[y] )y--;
	int ans = y;

	y = x;
	while ( vis[y] ) y++;
	int a2 = y;

	if ( abs(ans - x) > abs(a2 - x) ) ans = a2;

	cout << ans << endl;





}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3656
n,m=map(int,input().split())
h = list(map(int,input().split()))
good = [True]*n
for _ in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    if h[a] <= h[b]: good[a] = False
    if h[b] <= h[a]: good[b] = False

print(sum(good))

Measured memory_bytes: 20036
#include<iostream>
using namespace std;
int N;
bool flag;
int main(){
	cin>>N;
	int m=N;
	while(m!=0){
		int s=m%10;
		if(s==9){
			cout<<"Yes"<<endl;
			flag=1;
			break;
		}
		else m/=10;
	}
	if(!flag) cout<<"No"<<endl;
	return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    
    //電球データ
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    
    
    //電球更新処理
    while(K>0){
        
        //終了判定
        bool flg = true;
        
        //累積和
        vector<int> B(N,0);
        for(int i=0; i<N; i++){
            int x = A[i];
            if(x != N) flg = false;
            
            if(i-x>=0){
                B[i-x] ++;
            }else{
                B[0]++;
            }
            if(i+x + 1 < N){
                B[i+x + 1]--;    
            }
        }
        
        for(int i=0; i<N-1; i++){
            B[i+1] += B[i];
        }
        
        //配列の更新処理
        A = B;
        K--;
        if(flg) break;
    }
    
    for(int x: A){
        cout << x << " ";
    }cout << endl;
}


Measured memory_bytes: 4820
line = gets.split(' ').map(&:to_i)

n = line[0]
k = line[1]
s = gets.split('')

start = 0
for i in 0..n-2
  if s[i] == s[i+1] then
    start += 1
  end
end

value = 2 * k + start
if value > n-1 then
  value = n-1
end

puts value


Measured memory_bytes: 6780
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;



int main(void) {
	string s; cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include<algorithm>
#include<array>

using namespace std;

int W,N;

int main(){

	cin>>W>>N;
	array<pair<int,int>,30> p;
	char c;
	for(int i=0;i<N;i++){
		cin>>p[i].first>>c>>p[i].second;
		p[i].first--;
		p[i].second--;
	}
	int cc[30]={0};
	for(int j=0;j<W;j++){
		int co=j;
		for(int i=0;i<N;i++){
			
			if(p[i].first==co){
				co=p[i].second;
			}
			else if(p[i].second==co){
				co=p[i].first;
			}
		}
		cc[co]=j;
		//cout<<co<<endl;
	}
	for(int i=0;i<W;i++){
		cout<<cc[i]+1<<endl;
	}

	return 0;
}





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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    double ans = 0;
    rep(i, N) {
        int x;
        cin >> x;
        ans += 1.0 / x;
    }
    cout << 1 / ans << endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();

		if (a.equals("H")) {
			System.out.println(b);
		} else {
			if (b.equals("H")) {
				System.out.println("D");
			}
			if (b.equals("D")) {
				System.out.println("H");
			}
		}

	}
}


Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
	int n,m,i,b,a[10001];
	scanf("%d %d",&n,&m);
	b=0;
	for(i=0;i<m;i++){
		scanf("%d",&a[i]);
		b=b+a[i];
	}
	if(b==n){
		printf("0\n");
	}
	else if(n<b){
		printf("-1\n");
	}
	else printf("%d\n",n-b);
	return 0;
}

Measured memory_bytes: 1704
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main(void){
    int i;
    int N;
    long m = 1;
    long a[100000];
    int ng = 0;
    int zero = 0;

    scanf("%d", &N);

    for(i = 0;i < N;i++){
        long prv;
        scanf("%ld", &a[i]);
        prv = m;
        m *= a[i];
        if(prv > m || m > 1000000000000000000) ng = 1;
        if(a[i] == 0) zero = 1;
    }

    if(zero) puts("0");
    else if(ng) puts("-1");
    else printf("%ld", m);

    return 0;
}

Measured memory_bytes: 2464
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 400011;
const ll INF = 5e16;

namespace IO {

    inline char gc() {
        static char buf[100000], *p1 = buf, *p2 = buf;
        return (p1 == p2) && (p2 = (p1 = buf) +
            fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
    }

    #define dd ch = getchar()
    inline ll read() {
        R ll x = 0; R int f = 0; R char dd;
        for (; !isdigit(ch); dd) f ^= (ch == '-');
        for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
        return f? -x: x;
    }

    inline void write ( ll x ) {
        if (x < 0) x = -x, putchar('-');
        if (x > 9) write(x / 10); putchar(x % 10 | 48);
    }

    inline void wrn ( ll x ) { write(x), putchar(' '); }

    inline void wln ( ll x ) { write(x), putchar('\n'); }

    inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wrn;
using IO::wln;
using IO::read;

namespace Cesare {
	
	ll n, m, W[N], a[N], Vis[N];
	
	int main() {
		n = read();
		For ( i, 1, n ) a[i] = read() & 1;
		Rep ( i, n, 1 ) {
			ll Z = 0;
			for (R int j = i; j <= n; j += i) 
				if (Vis[j]) Z ^= 1;
			if (Z != a[i]) Vis[W[++m] = i] = 1;
		} 
		wln(m); 
		Rep ( i, m, 1 ) wrn(W[i]); return 0;
	}
	
}

int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
    return Cesare::main();
}

/*

*/







Measured memory_bytes: 8576
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int s_v_;scanf("%d", &(s_v_));vec.PB(s_v_);}while(0)
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF 1000000007

int n, m;

int main ()
{
  R2(n, m);
  printf("%s\n", n == m ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
N = int(input())
X, Y, H = [], [], []
target = (-1, -1, -1)
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h >= 1:
        target = (x, y, h)

for cx in range(101):
    for cy in range(101):
        v = target[2] + abs(target[0] - cx) + abs(target[1] - cy)
        v = max(v, 0)
        flag = True
        for x, y, h in zip(X, Y, H):
            vv = v - abs(x - cx) - abs(y - cy)
            vv = max(vv, 0)
            if h != vv:
                flag = False
                break
        if flag:
            print(cx, cy, v)
            exit()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[51], b[51];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	while (true) {
		rep(i, n)b[i] = 0;
		rep(i, n) {
			if (a[i] >= n) {
				b[i] = a[i] / n;
				a[i] %= n;
			}
		}
		int sum = 0;
		rep(i, n)sum += b[i];
		if (!sum)break;
		rep(i, n) {
			a[i] += sum - b[i];
		}
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

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

    
    int main() {
        
        string s;
        cin >> s;
         long long ans=0;
        
        if(s=="RRR")
            ans=3;
            
            else if(s=="RRS" || s=="SRR")
                ans=2;
            
            else if(s=="SSS")
                ans=0;
                
               else ans=1; 
       
        cout << ans << "\n";
        
        return 0;
        }

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

using namespace std;

#define LL long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,x) for(reg int i=Head[x]; i; i=Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N=1e5+5,M=1e5+5,mod=1e9+7;

bool MOP1;

int A[N],flag;

bool MOP2;

inline void _main(void) {
	int n=Raed(),m=Raed(),k=Raed();
	cout<<max(0,k-(n-m));
}

signed main() {
#define offline1
#ifdef offline
	freopen("chessboard.in", "r", stdin);
	freopen("chessboard.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[][] a = new int[n][m];
		int[] b = new int[m];

		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int ans = 0;

		for (int i = 0; i < n; i++) {

			long sum = 0;
			for (int j = 0; j < m; j++) {
				sum += a[i][j] * b[j];
			}
			if (sum + c > 0)
				ans++;
		}

		System.out.println(ans);

	}

}


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

int main(){
  int N;
  cin >> N;
  int ans =0;
  for (int i = 1; i < N+1; i++)
  {
    int tmp=0;
    for (int j = 1; j < i+1; j++)
    {
      if (i%j==0) tmp++;
    }
    if (tmp == 8 && i%2==1) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,k,dp[2005];
inline long long ksm(long long x,long long y)
{
    if(y<0)return 1;
	long long g=1ll;
	while(y)
	{
		if(y&1ll)g=g*x%mod;
		x=x*x%mod; y>>=1ll;
	}
	return g;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k; dp[0]=1;
	for(int i=1;i<n;i++,dp[0]=dp[1])
	for(int j=i;j>=1;j--)dp[j]=(dp[j+1]+dp[j-1])%mod;
	cout<<1ll*dp[n-k]*ksm(2ll,n-k-1)%mod<<endl;
}

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

using namespace std;

int a[500], nr = 0;
long long n;

void get_ans(long long k, int id1, int id2)
{
    if(k==1)
    {
        int i;
        cout << 2*nr << '\n';
        for(i=1; i<id1; ++i) cout << a[i] << ' ';
        for(i=id2+1; i<=100; ++i) cout << a[i] << ' ';

        for(i=nr; i; --i) cout << i << ' ';
        cout << '\n';
        return;
    }

    if(k&1LL)
    {
        a[id1] = ++nr;
        get_ans(k-1, id1+1, id2);
    }
    else
    {
        a[id2] = ++nr;
        get_ans(k/2, id1, id2-1);
    }
}

int main()
{
    cin >> n; nr = 0;
    get_ans(n+1, 1, 100);

    return 0;
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }


}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <tuple>
#include <vector>
using namespace std;
 
int main() {
    int N,x,t;
    cin >> N >> x >> t;
    cout << (N+x-1)/x*t << endl;
    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b>>1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

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

	vector<ll> A(N + 1), B(N + 1);
	repn(i, N) cin >> A[i] >> B[i];
	sort(++A.begin(), A.end());
	sort(++B.begin(), B.end());

	if (N % 2 == 1) {
		ll M = (N + 1) / 2;
		cout << B[M] - A[M] + 1 << endl;
	}

	if (N % 2 == 0) {
		ll M = N / 2;

		cout << (B[M] + B[M + 1]) - (A[M] + A[M + 1]) + 1 << endl;
	}
}


Measured memory_bytes: 6428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] str = br.readLine().split(" ");

		int r = Integer.parseInt(str[0]);
		int D = Integer.parseInt(str[1]);
		int x = Integer.parseInt(str[2]);

		for(int i = 0;i<10;i++) {
			int ans = r*x-D;
			System.out.println(ans);
			x = ans;
		}

	}

}


Measured memory_bytes: 21204
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n; cin >> n;
    int odd = 0, even = 0;
    rep(i, n){
        int a; cin >> a;
        if(a & 1) odd++;
        else even++;
    }
    if(odd & 1) {
        cout << "NO" << endl;
        return 0;
    }
    else cout << "YES" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N = int(input())

    L = [0] * 87
    L[0] = 2
    L[1] = 1
    for i in range(2, 87):
        L[i] = L[i-1] + L[i-2]
    print(L[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
h, w = map(int, input().split())
s = [["." for _ in range(w + 2)]]

for _ in range(h):
    s_ = ["."]
    s_.extend([x for x in input()])
    s_.append(".")
    s.append(s_)

s.append(["." for _ in range(w + 2)])


for x in range(h):
    for y in range(w):
        target_x = x + 1
        target_y = y + 1
        # cross check
        if s[target_x][target_y]  == "#":
            if s[target_x - 1][target_y] == "#" or s[target_x + 1][target_y] == "#" or s[target_x][target_y -1 ] == "#" or  s[target_x][target_y +1 ] == "#":
                pass
                # ok
            else:
                # ng
                print("No")
                exit()
print("Yes")



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

using namespace std;

int N, K;

long long int V[105];

int main(void) {

	cin >> N >> K;

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

	int check[55];

/*	long long int ans = 0;
	vector<long long int > W;

	for (int r = 0; r <= (K / 2); r++) {
	
		for (int M = 0; M <= min(K - r, N); M++) {
			// left
			for (int i = 1; i <= N; i++) { check[i] = 0; }
			W.clear();

			for (int i = 1; i <= M; i++) {
				W.push_back(V[i]); check[i] = 1;
			}
			//right
			int J = max(0, K - M - r);
			for (int j = N; j >= N - J + 1; j--) {
				if (j == 0) { break; }
				if (check[j] == 0) { W.push_back(V[j]); }
				else { break; }
			}
			//==

			for (int h = 0; h <= 100; h++) { W.push_back(0); }

			sort(W.begin(), W.end());
			long long int sum = 0;
			for (int h = 0; h < (int)W.size(); h++) { sum += W[h]; }

			ans = max(ans, sum);

			for (int y = 0; y <= r; y++) {
				sum -= W[y];
				ans = max(ans, sum);
			}

			cout << "r= " << r << " M= " << M << endl;
			cout << "ans= " << ans << endl;
		}


	}


		
	cout << ans << endl;*/


	vector<long long int >W;
	long long int ans = 0;

	for (int i = 0; i <= K; i++) {

		for (int j = N; j >= 0; j--) {
			if ((i + j > N) || (i+j >K)) { continue; }
			W.clear();

			//cout << "i= " << i << " j= " << j << endl;
			
			for (int y = 1; y <= i; y++) { W.push_back(V[y]); }
			for (int y = N; y >= N - j + 1; y--) { W.push_back(V[y]); }

			for (int y = 0; y <= 100; y++) { W.push_back(0); }
			sort(W.begin(), W.end());

			long long int sum = 0;
			for (int y = 0; y<(int) W.size(); y++) {
				sum += W[y];
			}

			//cout << "sum= " << sum << endl;
			ans = max(ans, sum);

			int r = K - i - j;

			for (int y = 0; y < r; y++) {
				sum -= W[y];
				ans = max(ans, sum);
			}


		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdin = new Scanner(System.in);
        int a = stdin.nextInt();
        int b = stdin.nextInt();
        int c = stdin.nextInt();
        int temp;
         
        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }
        
        if(a > c){
            temp = a;
            a = c;
            c = temp;
        }
        
        if(b > c){
            temp = b;
            b = c;
            c = temp;
        }
        System.out.println(a + " " + b + " " + c);
        
        stdin.close();
    }
     
   
}

Measured memory_bytes: 26200
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
#define ull unsigned long long
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int ESP = 1e-12;

int main(){
    fast;
    ll n;
    cin >> n;
    ll sum = 0, a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 1; i < n; ++i){
        if(a[i] < a[i - 1]){
            sum += abs(a[i] - a[i - 1]);
             a[i] = a[i - 1];
        }
    }
    cout << sum;
    return 0;
}


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


int main(){
  // freopen("a.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);

int n; 
cin >>n;
vector<int> x(n);
loop(i,n) cin>>x[i];
int ans = 1001001001;
for (int p=1; p<=100;++p){
    int now = 0;
    loop(i,n) now += (x[i]-p)*(x[i]-p);
    ans = min (ans,now);
}
cout<<ans<<endl;
return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
typedef long long ll;
using namespace std;

pair<int,int> dp[2][200001];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while(cin>>n,n){
		int a[201];
		fill(a,a+201,0);
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<=200000;i++)dp[0][i]=make_pair(-1,0);
		dp[0][0]=make_pair(0,0);
		for(int i=0;i<n;i++){
			for(int j=0;j<=200000;j++)dp[(i+1)&1][j]=make_pair(-1,0);
			for(int j=0;j<=200000;j++){
				if(dp[i&1][j].fi==-1)continue;
				int tmp=a[i]%1000;
				if(tmp<=500 && tmp>=1)
					dp[(i+1)&1][j+500-tmp]=max(make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]),dp[(i+1)&1][j+500-tmp]);
				else{
					int pay=(tmp+500)%1000;
					dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
					if(pay<=j)
						dp[(i+1)&1][j-pay]=max(make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]),dp[(i+1)&1][j-pay]);
					int pay2=(1000-tmp)%1000;
					dp[(i+1)&1][j+pay2]=max(make_pair(dp[i&1][j].fi,dp[i&1][j].se-a[i]),dp[(i+1)&1][j+pay2]);
				}
			}
		}
		pair<int,int> ans=make_pair(0,0);
		for(int i=0;i<=200000;i++){
			if(dp[n&1][i]>ans){
				ans=make_pair(dp[n&1][i].fi,dp[n&1][i].se);
			}
		}
		cout<<ans.fi<<" "<<-ans.se<<endl;
	}
	return 0;
}


Measured memory_bytes: 6184