akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(ll i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N,X,Y;
    cin>>N>>X>>Y;

    ll diff;
    v ans(N,0);
    rep(s,1,N+1)rep(g,s+1,N+1){
        diff = min(g-s,abs(s-X)+1+abs(g-Y));
        ans[diff]++;
    }
    rep(i,1,N)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int B[N-1];
  
  rep(i,N-1) cin >> B[i];

  int A[N];
  for (int i=N-1;i>=0;i--){
    if (i==N-1) A[N-1] = B[N-2];
    else if (i==0) A[0] = B[0];
    else A[i] = min(B[i],B[i-1]);
  }

  int retval = 0;
  rep(i,N) retval += A[i];
  cout << retval << endl;

  // cout << fixed << setprecision(6);
  return 0;
}


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

int main(){
  char p = '-';
  for(int i = 0; i < 4; i++){
    char c;
    scanf("%c", &c);
    if(p == c){
      printf("Bad");
      return 0;
    }
    p = c;
  }
  printf("Good");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
fgets(STDIN);
$numArray = explode(" ", trim(fgets(STDIN)));
$c = 0;
while(true){
    foreach($numArray as &$num){
        if($num % 2 == 1){
            echo $c;
            exit;
        }
        $num /= 2;
    }
    $c++;
}



Measured memory_bytes: 4604
#include <iostream>
#include <queue>
#include <string>

typedef struct Input {
    std::string name;
    int value;
} Input;

int main(){
    std::queue<Input> que;
    int n;
    int q;
    std::cin >> n;
    std::cin >> q;

    for(int i = 0; i < n; i++){
        Input in;
        std::cin >> in.name;
        std::cin >> in.value;
        que.push(in);
    }
    int timeElapsed = 0;

    while(!que.empty()){
        Input tmp = que.front();
        que.pop();
        if(tmp.value <= q){
            std::cout << tmp.name << ' ' << timeElapsed + tmp.value << "\n";
            timeElapsed += tmp.value;
        }
        else {
            tmp.value -= q;
            que.push(tmp);
            timeElapsed += q;
        }

    }

    return 0;
}



Measured memory_bytes: 6356
n = int(input())
P = list(map(int,input().split()))

k=0
bc=0
c=0
i=0
while k < n :
    if P[k]!=i+1 :
        bc+=1
    else:
        i+=1
        c+=1
    k+=1

if c==0 :
    bc = -1

print(bc)




Measured memory_bytes: 32316
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    if(a == c) cout << b << endl;
    if(b == c) cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j,n,m,t,k,ans,x,dp[200001][2],B,a[200001],Min1,Min2;
int main () {
    cin>>n;
    for (i=1;i<=n;i++) {
        cin>>a[i];
    }
    B=1e16;
    dp[2][1]=abs(a[2]-a[1]);
    dp[3][0]=abs(a[3]-a[1]);
    for (i=2;i<=n;i++) {
        if (dp[i][0]==0) dp[i][0]=B;
        if (dp[i][1]==0) dp[i][1]=B;
    }
    for (i=2;i<=n;i++) {
        Min1=min(dp[i-2][0],dp[i-2][1]);
        Min2=min(dp[i-1][0],dp[i-1][1]);
        if (a[i-2]!=0)
        dp[i][0]=Min1+abs(a[i]-a[i-2]);
        if (a[i-1]!=0)
        dp[i][1]=Min2+abs(a[i]-a[i-1]);
    }
    ans=min(dp[n][0],dp[n][1]);
    if (ans==B) cout<<"0"<<endl;
    else
    cout<<ans<<endl;
    return 0;
}

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

const int inf = 1000000000;
int dp[1000];

int main() {
  int N,M,vt,dt,lt;
  while(cin>>N>>M) {
    string s;
    vector<int> v(N),d(N),l(N),c(N);
    for(int i=0; i<N; ++i) {
      cin.ignore();
      getline(cin, s);
      cin>>c[i]>>v[i]>>d[i]>>l[i];
    }

    int ans = 0;
    for(int i=0; i<1000; ++i) dp[i] = 0;
    for(int i=0; i<=M; ++i) {
      for(int j=0; j<N; ++j) {
    if(i+c[j] > M) continue;
    if(dp[i+c[j]] < dp[i]+v[j]) dp[i+c[j]] = dp[i]+v[j];
      }
    }

    ans = max(ans, *max_element(dp, dp+M+1));

    for(int i=0; i<1000; ++i) dp[i] = 0;
    for(int i=0; i<=M; ++i) {
      for(int j=0; j<N; ++j) {
    if(i+c[j] > M) continue;
    if(dp[i+c[j]] < dp[i]+d[j]) dp[i+c[j]] = dp[i]+d[j];
      }
    }

    ans = max(ans, *max_element(dp, dp+M+1));

    for(int i=0; i<1000; ++i) dp[i] = 0;
    for(int i=0; i<=M; ++i) {
      for(int j=0; j<N; ++j) {
    if(i+c[j] > M) continue;
    if(dp[i+c[j]] < dp[i]+l[j]) dp[i+c[j]] = dp[i]+l[j];
      }
    }

    ans = max(ans, *max_element(dp, dp+M+1));

    cout<<ans<<endl;
  }
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if (s[k-1] == 'A')
    {
        s[k-1] = 'a';
    }
    else if (s[k-1] == 'B')
    {
        s[k-1] = 'b';
    }
    else if (s[k-1] == 'C')
    {
        s[k-1] = 'c';
    }
    cout << s << endl;
}

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

const int N = 300;
int n, a[N], dp[N][N];

int main(){
	cin >> n;
	n += n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	
	sort(a + 1, a + n + 1);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n / 2; ++j)
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i + 1]);	
		for(int j = 1; j <= n / 2; ++j)
			dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j]);	
	}
	cout << dp[n][0];
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int n;
long long T = 0, A = 0;
vector<long long> t, a;

int main() {
	cin >> n;
	t.resize(n);
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
	}
	T = t[0];
	A = a[0];
	for (int i = 1; i < n; i++) {
		if (T <= t[i] && A <= a[i]) {
			T = t[i];
			A = a[i];
			continue;
		}
		else {
			long long var = max((T - 1) / t[i] + 1, (A - 1) / a[i] + 1);
			T = t[i] * var;
			A = a[i] * var;
		}
	}
	cout << T + A << endl;
//	cin >> n;
	return 0;
}

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

ans = 2 * (x[-1] - x[0])
for i in range(n - k + 1):
    a, b = x[i], x[i + k - 1]
    if a * b < 0:
        ans = min(ans, min(abs(a), abs(b)) + b - a)
    else:
        ans = min(ans, max(abs(a), abs(b)))

print(ans)


Measured memory_bytes: 62576
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

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



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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N, d;
    cin >> N;
    set<int> s;
    REP(i, N){
        cin >> d;
        s.insert(d);
    }
    PRINT(s.size());
    return 0;
}

Measured memory_bytes: 256
//author-micheal corleone
//the godfather
#include <bits/stdc++.h>
#include <set> 
#include<algorithm>

#include <set> 
#include<algorithm>
#define ll long long int

const int MOD = 1e9+7;
#define f(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
 
using namespace std;
 
 bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[1] < v2[1]; 
}
 ll mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}
 

ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
    if(n==1 || r==0)return 1;
  //  ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=((((ans * n)%MOD )*modinv(i,MOD))%mod);n--;sum+=ans;sum%=mod;}return sum;
}
const int maxn=2e5+100;
vector<int>v[maxn];
ll vv[maxn];
ll vis[maxn]={0};

void dfs(ll x)
{
	vv[x]=1;
	for(int i=0;i<v[x].size();i++)
	{
		if(vv[v[x][i]]==0) dfs(vv[v[x][i]]);
	}
}


int main()
{
	ios_base::sync_with_stdio(0);
   cin.tie(0);
    cout.tie(0);
    
    
     ll t;
     //cin>>t;
     t=1;
   while(t--)
    {
        ll n,i1,i2,k,m,j,j1,a1,f,i31,i3,j2,i5,i4,i6,i7,i;
        i4=INT_MIN,i1=0;
        f=0;
        ll res,res1,ans;
        ans=1,res=0;
        res1=0;
        ll s1,s2,s3;
        s2=0;    
        s1=0;
        ll q;
        i31=1;
        s3=-1;
        ll x;
        ll cnt=0;
         cin>>n;
         ll a[n];
         f(i,0,n-1)
         {
         	cin>>a[i];
         	vis[a[i]]++;
		 }
		 for(i=1;i<=n;i++)
		 {
		 	cout<<vis[i]<<endl;
		 }
         
	
         
	
	}
}
		

Measured memory_bytes: 11392
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    int64_t n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int64_t, int64_t>> shop_list(n);
 
    for (int64_t i=0; i<n; ++i) {
        int64_t a, b;
        std::cin >> a >> b;
        shop_list.at(i) = std::make_pair(a, b);
    }

    std::sort(shop_list.begin(), shop_list.end(), [](const std::pair<int64_t, int64_t>& left, const std::pair<int64_t, int64_t>& right){
        return left.first < right.first;
    });
 
    int64_t cost = 0;
    for (auto& shop : shop_list) {
        if (m >= shop.second) {
            cost += shop.first * shop.second;
            m -= shop.second;
        } else {
            cost += shop.first * m;
            break;
        }
    }

    std::cout << cost << std::endl;
 
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc125d()
}

fun abc125d() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    // Kotlin1.0.0だとこのコードはコンパイルできない
    //    val abs = a.map { abs(it) }
    //    if (a.count { it < 0 } % 2 == 0) {
    //        println(abs.sum())
    //    } else {
    //        println(abs.sum() - abs.min()!! * 2)
    //    }
    val abs = a.map { if (it < 0) it * -1 else it }
    var min = abs.first()
    var sum = 0L
    abs.forEach {
        if (min > it) {
            min = it
        }
        sum += it
    }
    if (a.count { it < 0 } % 2 == 0) {
        println(sum)
    } else {
        println(sum - min * 2)
    }
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void go(int loc, int par, auto& adj, auto &ans) {
    for (auto p : adj[loc]) if (p.first != par) {
        ans[p.first] = ans[loc] ^ p.second;
        go(p.first, loc, adj, ans);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;
    vector<vector<pair<int, bool>>> adj(N);
    for (int i = 0, u, v, w; i < N - 1; i++) {
        cin >> u >> v >> w;
        adj[u-1].emplace_back(v-1, w&1);
        adj[v-1].emplace_back(u-1, w&1);
    }

    vb par(N);
    go(0, 0, adj, par);
    for (int i = 0; i < N; i++) {
        cout << par[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 9472
# ワーシャルフロイド法っぽい

INF = 100000000

loop do
  n,k = gets.split(" ").map(&:to_i)
  break if n == 0 && k == 0
  inputs = Array.new(k) { gets.split(" ").map(&:to_i) }

  d = Array.new(n) { Array.new(n) {INF} }
  0.upto(n-1) {|i| d[i][i] = 0}

  inputs.each do |input|
    if input[0] == 0
      if d[input[1]-1][input[2]-1] == INF
        puts -1
      else
        puts d[input[1]-1][input[2]-1]
      end
    else
      # 運賃を更新する
      a = input[1]-1
      b = input[2]-1
      if d[a][b] <= input[3]
        next
      else
        d[a][b] = input[3]
        d[b][a] = input[3]
      end
      # ここでワーシャルフロイドっぽい
      for i in 0...n do
        for j in 0...n do
          d[i][j] = [d[i][j],d[i][a]+d[a][b]+d[b][j],d[i][b]+d[b][a]+d[a][j]].min
        end
      end
    end
  end
end

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

typedef long long ll;
ll a=-1e18,b=-1e18,c;
int n,op=1;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(cin>>n;n --> 0;){
		int x;char s[10];cin>>x>>s;x*=op;a+=x;b-=x;c+=x;
		if(x<0)a=max(a,b),b=max(b,c);c=max(b,c);b=max(a,b);
		if(s[0]=='-')op=-1;else op=1;
	}
	cout<<c<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> divs;
    for (int i = 1; i * i <= m; ++i)
    {
        if (m % i == 0)
        {
            divs.push_back(i);
            if (m / i != i)
                divs.push_back(m / i);
        }
    }
    sort(all(divs));
    reverse(all(divs));
    for (int x : divs)
    {
        int s = m / x;
        if (s >= n)
            return cout << x, 0;
    }
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,i=1,sum=0; cin>>n; 
    vector <int> res;
    while (true){
        int l=1,r=n,in;
        while (l<=r){
            int m=(l+r)>>1;
            if ((m*(m+1))/2>=n){
                in=m; r=m-1;
            }
            else l=m+1;
        }
        n -= in;
        res.pb(in);
        if (n==0) break;
    }
    for (auto &it: res) cout << it << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1 = scan.next();
		String s2 = scan.next();
		String s3 = scan.next();
		
		System.out.println("" + s1.charAt(0) + "" + s2.charAt(0) +"" + s3.charAt(0));
	}
}

Measured memory_bytes: 38988
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	double x1,x2,xp,y1,y2,yp,slope,ansx,ansy;
	int q;
	bool X_FLG = false,Y_FLG = false;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	scanf("%d",&q);

	if(y1 == y2){
		X_FLG = true;
	}else if(x1 == x2){
		Y_FLG = true;
	}else{
		slope = (y2-y1)/(x2-x1);
	}

	for(int i=0;i<q;i++){
		scanf("%lf %lf",&xp,&yp);
		if(X_FLG){
			printf("%.10lf %.10lf\n",xp,y1);
		}else if(Y_FLG){
			printf("%.10lf %.10lf\n",x1,yp);
		}else{
			ansx = (yp*(x2-x1)*(y2-y1)+xp*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			ansy = ((x1-x2)*ansx+yp*(y2-y1)+xp*(x2-x1))/(y2-y1);
			printf("%.10lf %.10lf\n",ansx,ansy);
		}

	}

	return 0;
}



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

int main(){
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n){
    int num;
    cin >> num;
    mp[num]++;
  }
  int evenCnt = 0;
  for(p : mp){
    if(p.second % 2 == 0) evenCnt++;
  }
  if(evenCnt % 2 == 0){
    cout << mp.size() << endl;
  }else{
    cout << mp.size()-1 << endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

const int MAXN = 1e5;
const int MAX = 200;

int H, W, N;
int a[MAXN];
int c[MAX][MAX];

void advance(int &x, int &y) {
  if (x % 2) --y;
  else ++y;

  if (y < 0 || y >= W) {
    y = max(y, 0);
    y = min(y, W - 1);
    ++x;
  }
}

int main(void) 
{
  scanf("%d%d%d", &H, &W, &N);
  REP(i, N) scanf("%d", &a[i]);

  int x = 0, y = 0;
  REP(i, N) {
    while (a[i]) {
      c[x][y] = i + 1;
      a[i] -= 1;
      advance(x, y);
    }
  }

  REP(i, H) {
    REP(j, W) {
      printf("%d%c", c[i][j], " \n"[j + 1 == W]);
    }
  }

  return 0;
}




Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> n(5);
  for(int i=0; i<5; i++) cin >>n[i];
  sort(n.begin(),n.end());
  for(int i=4; i>=0; i--){
    cout <<n[i];
    if(i>0) cout <<" ";
    else cout <<endl;
  }
  return 0;
}

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

int main(){
  
  string s;
  cin >> s;
  int n=s.size();
  int ans=abs(((int)(s[0]-'0')*100+(int)(s[1]-'0')*10+(int)(s[2]-'0'))-753);
  for(int i=0; i<n-2; i++){
    int a=(int)(s[i]-'0');
    int b=(int)(s[i+1]-'0');
    int c=(int)(s[i+2]-'0');
    int d=(a*100+b*10+c);
    ans=min(ans,abs(753-d));
  }
  cout << ans << endl;
}
            
    



Measured memory_bytes: 3592
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++) {
		
		if (s[i] == '9') s[i] = '1';
		else if (s[i] == '1') s[i] = '9';

	}

	cout << s << "\n";

	return 0;
}

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

int main() {
  long long n,m;
  cin>>n>>m;
  vector<int>nagasa(n);
  for(int i=0;i<n;i++){
    cin>>nagasa[i];
  }
  sort(nagasa.begin(),nagasa.end());
  int sa=INT_MAX;
  int dai=0;
  int shou=INT_MAX;
  for(int i=0;i<n-m+1;i++){
    shou=nagasa[i];
    dai=nagasa[i+m-1];
    sa=min(sa,dai-shou);
    //cout<<" shou"<<shou<<" dai"<<dai<<" sa"<<sa<<endl;
  }
  cout<<sa<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 1000000007
#define INF 10000000000
using namespace std;

typedef long long ll;

int main()
{
    int n;
    int v[20] = {};
    int c[20] = {};

    cin >> n;
    FOR(i, 0, n)
    cin >> v[i];
    FOR(i, 0, n)
    cin >> c[i];

    int r = 0;
    FOR(i,0,n)
    {
        if(v[i]-c[i]>0)
            r += (v[i]-c[i]);
    }
    cout << r << "\n";
    return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define INF (1000000010)

int main(){
    int n,m;
    int amax = -INF;
    int bmin = INF;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >>a >> b;
        if(a>amax){
            amax = a;
        }
        if(b<bmin){
            bmin = b;
        }
    }
    cout <<  max(bmin -amax +1,0)<<endl;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 0;
  ans = max(ans,10*a+b+c);
  ans = max(ans,a+10*b+c);
  ans = max(ans,a+b+10*c);
  cout << ans << endl;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
for i in range(h):
    a[i] = [aij % 2 for aij in a[i]]

cnt, ans = 0, []
for i, ai in enumerate(a):
    for j in range(w):
        if i % 2 == 1:
            j = w - 1 - j
        if cnt == 1:
            ans.append([bi + 1, bj + 1, i + 1, j + 1])
            ai[j] = ai[j] + 1
        cnt = int(ai[j] == 1)
        bi, bj = i, j

print(len(ans))
for q in ans:
    print(*q)


Measured memory_bytes: 99008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,L; cin >> N >> L;
    string S[N];
    rep(i,N) cin >> S[i];
    string T;
    sort(S,S+N);
    rep(i,N) T+=S[i];
    cout << T << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
int A[100];
int main() {
  int max=1, min=1000000000;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(min >= A[i]) min = A[i];
    if(max <= A[i]) max = A[i];
  }
  cout << max - min;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long n,k;
  long a[200000]={0};
  long flag[200000]={0};
  long loop,loopstart,loopend,next;
  long i,j;
  
  scanf("%ld %ld",&n,&k);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  loop=1;
  next=1;
  while(1){
    if(flag[next-1]==0){
	    flag[next-1]=loop;
    	next=a[next-1];
    }else{
      loopend=loop;
      loopstart=flag[next-1];
      break;
    }
    loop++;
  }
  
  if(k>loopstart){
    k=k-loopstart;
    k=k%(loopend-loopstart);
    k=k+loopstart;
  }
  
  next=1;
  for(i=0;i<k;i++){
    next=a[next-1];
  }
  
  /*
  printf("loops:%ld\n",loopstart);
  printf("loope:%ld\n",loopend);
  */
  printf("%ld",next);
}

Measured memory_bytes: 4856
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<cmath>
#include<utility>
#include<tuple>
#include<iomanip>
 
using namespace std;
 
int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
	{
		cout << "Yay!"<< endl;
	}
	else
	{
		cout << ":(" << endl;
	}
 
}

Measured memory_bytes: 256
import java.io.*;
import java.sql.PreparedStatement;
import java.util.*;

public class Main {
    private static class Task {
        public void solve(InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long a = n        * (n + 1)           / 2;
            long b = (n / 3)  * (n - n % 3  + 3)  / 2;
            long c = (n / 5)  * (n - n % 5  + 5)  / 2;
            long d = (n / 15) * (n - n % 15 + 15) / 2;
            out.println(a - b - c + d);
        }
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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

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

        public String nextLine() {
            String str;
            try {
                str = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }

    public static void main(String[] args) throws IOException {
        InputStream inputStream = new File("in.txt").exists() ? new FileInputStream("in.txt") : System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}


Measured memory_bytes: 32576
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())
 
#   (2^n -1 - nCa - nCb) mod MOD
# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD
#   (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD
# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (r!)^(MOD-2) )  mod MOD

a = min(a, n-a)
b = min(b, n-b)
rMAX = max(a, b)

#分子のmod
nCr_Mol_ModList = [1 for _ in range(rMAX+1)]
#分母（rの階乗）のmod
fac_ModList = [1 for _ in range(rMAX+1)]

nCr_Mol_ModList[1] = n % MOD
fac_ModList[1] = 1 % MOD

for i in range(2, rMAX+1) :
  nCr_Mol_ModList[i] = (nCr_Mol_ModList[i-1] * (n-i+1)) % MOD
  fac_ModList[i] = (fac_ModList[i-1] * i) % MOD

#(2^n - 1 mod MOD) = X
#(nCa mod MOD) = Y
#(nCb mod MOD ) = Z とする

X = pow(2,n,MOD)-1%MOD
Y = ( nCr_Mol_ModList[a] * pow(fac_ModList[a], MOD-2, MOD) )%MOD
Z = ( nCr_Mol_ModList[b] * pow(fac_ModList[b], MOD-2, MOD) )%MOD

ans = (X - Y - Z) % MOD
print (ans)


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (a + k - 1 >= b - k + 1) {
    for (int i = a; i <= b; i++) {
      cout << i << endl;
    }
  } else {
    for (int i = a; i < a + k; i++) {
      cout << i << endl;
    }
    for (int i = b - k + 1; i <= b; i++) {
      cout << i << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  cin>>n>>k;    
  
  int a=n/100,b=k/100;
  int c=b-a-1;
  
  int aaf=(a/10)/10,aab=(a/10)%10;
  int bbf=(b/10)/10,bbb=(b/10)%10;
  int af=(n%100)/10,ab=(n%100)%10;
  int bf=(k%100)/10,bb=(k%100)%10;
    
  
  if(aab*10+aaf>=n%100){
    c+=1;
  }
  if(bbb*10+bbf<=k%100){
    c+=1;
  }
  cout<<c<<endl;
  
}

Measured memory_bytes: 3540
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

//x=10111;
//x<<2 = 1011100 (右シフト),x>>2 = 101 (左シフト)
//(x>>2)&1 = 101 & 001 = 1
//iビット目は、(x>>i) & 1 でわかる(x>>i)%2 でもよい

int a[4];
int K;

int main(){
	cin>>a[0]>>a[1]>>a[2];
	cin>>K;
	sort(a,a+3);
	Rep(i,K){
		a[2]=a[2]*2;
	}
	cout<<a[0]+a[1]+a[2]<<endl;
	
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int b[100000];

int main(){
	int n;
	cin>>n;
	cout<<n+pow(n, 2)+pow(n, 3)<<endl;
	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  for(ll i=n-1; i>=0; i-=2) cout << a[i] << " ";
  for(ll i=n%2; i<n-2; i+=2) cout << a[i] << " ";
  if(n-1) cout << a[n-2] << newl;
  return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

int main(){
	int a=read(),b=read(),c=read(),n=read(),ans=0;
	For(i,0,n/a) For(j,0,(n-i*a)/b) if ((n-i*a-j*b)%c==0) ++ans;
	printf("%d\n",ans);
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int count = 0;

		for (int i = A; i < B+1; i++) {
			String s = String.valueOf(i);
			String[] array = new String[5];
			for (int j = 0; j < 5; j++) {
				array[j] = s.substring(j, j+1);
			}

			if (array[0].equals(array[4]) && array[1].equals(array[3])) {
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 40852
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int n,x,y;
bool cell[8][8];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(u,n){
		queue<P> que;
		rep(i,8) rep(j,8){
			char a; cin >> a;
			cell[i][j] = a-'0';
		}
		cin >> x >> y; x--; y--;
		que.push(P(y,x));
		cell[y][x] = 0;
		while(que.size()!=0){
			P p = que.front(); que.pop();
			for(int i = 1; i <= 3; i++){
				if(p.fi+i >= 8) break;
				if(cell[p.fi+i][p.sec]){
					cell[p.fi+i][p.sec] = 0;
					que.push(P(p.fi+i,p.sec));
				}
			}
			for(int i = 1; i <= 3; i++){
				if(p.fi-i < 0) break;
				if(cell[p.fi-i][p.sec]){
					cell[p.fi-i][p.sec] = 0;
					que.push(P(p.fi-i,p.sec));
				}
			}
			for(int i = 1; i <= 3; i++){
				if(p.sec+i >= 8) break;
				if(cell[p.fi][p.sec+i]){
					cell[p.fi][p.sec+i] = 0;
					que.push(P(p.fi,p.sec+i));
				}
			}
			for(int i = 1; i <= 3; i++){
				if(p.sec-i < 0) break;
				if(cell[p.fi][p.sec-i]){
					cell[p.fi][p.sec-i] = 0;
					que.push(P(p.fi,p.sec-i));
				}
			}
		}
		cout << "Data " << u+1 << ":" << endl;
		rep(i,8){
			rep(j,8){
				cout << cell[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1200
#include<stdio.h>
int main()
{
    int a,sum=0,n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        sum=sum+a-1;
    }
    printf("%d\n",sum);
    return 0;
    
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n, c, k;
  cin >> n >> c >> k;
  vll t(n);
  vin(t);
  sort(all(t));
  ll ans = 1, pointer = 1, first = 0; 
  while(pointer < n){
    if(t.at(pointer) - t.at(first) <= k && pointer - first + 1 <= c) pointer++;
    else{
      first = pointer;
      pointer++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var A = new long[N];
		var B = new long[N];
		long f = (N % 2 == 0) ? 2 : 1;
		for(long i = 0; i < N; i++)
		{
			A[i] = f * GetLong();
			B[i] = f * GetLong();
		}
		Array.Sort(A);
		Array.Sort(B);

		var ma = median(N, A);
		var mb = median(N, B);

		WriteLine(mb - ma + 1);
	}

	private long median(long N, long[] arr) => (N % 2 == 1) ? arr[N / 2] : (arr[(N - 1) / 2] + arr[N / 2]) / 2;
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 43780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> X;
  int A[N*N+1];
  REP(i,N*N+1) A[i]=0;
  REP(i,N){
    int a;
    cin>>a;
    X.push_back(make_pair(a,i+1));
    A[a]=i+1;
  }
  
  SORT(X);
  for(int i=0; i<N; ++i){
    if(X[i].second==1){
      if(i==N-1) break;
      ++i;
    }
    int S=X[i].second;	//現在書き換える数字
    int Snum=S-1;		//現在書き換える数字があと何回使えるか
    for(int j=1; j<=N*N; ++j){
      if(A[j]==S) CAN=false;
      else if(A[j]==0){
        A[j]=S;
        Snum--;
      }
      if(Snum==0) break;
    }
  }
  
  for(int i=N-1; i>=0; --i){
    if(X[i].second==N){
      if(i==0) break;
      --i;
    }
    int S=X[i].second;	//現在書き換える数字
    int Snum=N-S;		//現在書き換える数字があと何回使えるか
    for(int j=N*N; j>=1; --j){
      if(A[j]==S) CAN=false;
      else if(A[j]==0){
        A[j]=S;
        Snum--;
      }
      if(Snum==0) break;
    }
  }
  
  if(CAN){
    COYe;
    RREP(i,N*N) cout<<A[i]<<" ";
    cout<<endl;
  }
  else CONo;
  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
int main(void){
    int a[10000],min,max,n,i;
    long long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    max=min=a[0];
    for(i=1;i<n;i++){
    if(a[i]>max)max=a[i];
    if(a[i]<min)min=a[i];
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
ll n, k, a[N];
ll c0, cn, cp;
ll solvene() {
    vector<ll> x(a, a + cn);
    vector<ll> y(a + n - cp, a + n);
    ll lo = x[0] * y.back();
    ll hi = x.back() * y[0];
    //cerr << "lo hi "<< lo << ' '<< hi << endl;
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    //cerr << "x= "; for (ll t : x) cerr << t << ' '; cerr << endl;
    //cerr << "y= "; for (ll t : y) cerr << t << ' '; cerr << endl;
    while (lo <= hi) {
        ll mi = lo + (hi - lo) / 2;
        ll c = 0;
        for (ll i = 0, j = 0; i < x.size(); ++i) {
            for (; j < y.size() && x[i] * y[j] <= mi; ++j)
                ;
            //cerr << "i,j,x[i] " << i << ' ' << j << ' ' << x[i]<< endl;
            c += j;
        }
        //cerr << "mi, c "<< mi << ' ' << c << endl;
        if (c < k)
            lo = mi + 1;
        else
            hi = mi - 1;
    }
    return lo;
}
ll solvenp(ll k) {
    vector<ll> x(a, a + cn);
    reverse(x.begin(), x.end());
    vector<ll> y(a + n - cp, a + n);
    ll lo = LLONG_MAX;
    ll hi = LLONG_MIN;
    if (x.size() >= 2) {
        lo = min(lo, x[0] * x[1]);
        hi = max(hi, x[cn - 1] * x[cn - 2]);
    }
    if (y.size() >= 2) {
        lo = min(lo, y[0] * y[1]);
        hi = max(hi, y[cp - 1] * y[cp - 2]);
    }
    while (lo <= hi) {
        ll mi = lo + (hi - lo) / 2;
        ll c = 0;
        for (ll i = cp - 1, j = 0; i >= 0; --i) {
            for (; j < i && y[i] * y[j] <= mi; ++j)
                ;
            c += min(j, i);
        }
        for (ll i = cn - 1, j = 0; i >= 0; --i) {
            for (; j < i && x[i] * x[j] <= mi; ++j)
                ;
            c += min(j, i);
        }
        //cerr << "mi, c " << mi << ' ' << c << endl;
        if (c < k)
            lo = mi + 1;
        else
            hi = mi - 1;
    }
    return lo;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0)
            ++c0;
        else if (a[i] > 0)
            ++cp;
        else
            ++cn;
    }
    sort(a, a + n);
    ll ne = cn * cp;
    ll n0 = c0 * (c0 - 1) / 2 + c0 * (n - c0);
    ll np = cp * (cp - 1) / 2 + cn * (cn - 1) / 2;
    ll ans;
    if (k <= ne) {
        ans = solvene();
    } else if (k <= ne + n0) {
        ans = 0;
    } else {
        ans = solvenp(k - ne - n0);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=3e5+10;
const ll mod=1e9+7;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
ll n,m,k,ans;
int a[3005][3005];
ll dp[3005][3005][4];
int main()
{  cin>>n>>m>>k;
   for(int i=1;i<=k;i++)
   {  int x,y,v;
      cin>>x>>y>>v;
      a[x][y]=v;
   }
   for(int i=1;i<=n;i++)
   {  for(int j=1;j<=m;j++)
        {  ll temp=max(dp[i-1][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3])));
           ll v=a[i][j];
           dp[i][j][0]=max(dp[i][j-1][0],max(dp[i][j-1][0],temp));
           dp[i][j][1]=max(dp[i][j-1][1],max(dp[i][j-1][0]+v,temp+v));
           dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+v);
           dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+v);   
           //printf("%d ",a[i][j]); 
        }
      //printf("\n");
   }
   for(int i=0;i<=3;i++)ans=max(ans,dp[n][m][i]);
   cout<<ans;
}

Measured memory_bytes: 320488
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N),B(N);
  REP(i,N)cin>>A[i];
  REP(i,N)cin>>B[i];
  ll asum=accumulate(ALL(A),0ll),bsum=accumulate(ALL(B),0ll);
  ll acnt=0ll,bcnt=0ll;
  REP(i,N){
    ll a=A[i],b=B[i];
    if(b>a){
      bcnt+=(b-a+1)/2;
    }else if(b<a){
      acnt+=a-b;
    }
  }
  if(acnt<=bsum-asum && bcnt<=bsum-asum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384