akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef pair<int,pii>pipii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

string brd[51];

int dis[51][51];
const int inf=1e7;

int main(){
  int h,w;
  string ss,st;
  cin>>h>>w>>ss>>st;
  char s=ss[0],t=st[0];
  rep(i,h){
    cin>>brd[i];
  }
  priority_queue<pipii,vector<pipii>,greater<pipii> > que;
  int sx=-1,sy=-1;
  rep(i,h){
    rep(j,w){
      if(brd[i][j]==s){
	sx=i;
	sy=j;
	break;
      }
    }
  }
  que.push(pipii(0,pii(sx,sy)));
  rep(i,51)rep(j,51)dis[i][j]=inf;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  while(!que.empty()){
    pipii dt=que.top();que.pop();
    int d=dt.first;
    pii t=dt.second;
    if(dis[t.first][t.second]<=d)continue;
    dis[t.first][t.second]=d;
    char cur=brd[t.first][t.second];
    rep(dir,4){
      if(cur=='|'&&dir%2==1)continue;
      if(cur=='-'&&dir%2==0)continue;
      int nx=t.first+dx[dir],ny=t.second+dy[dir];
      if(nx<0||nx>=h||ny<0||ny>=w)continue;
      if(brd[nx][ny]=='.')continue;
      if(brd[nx][ny]=='|'&&dir%2==1)continue;
      if(brd[nx][ny]=='-'&&dir%2==0)continue;
      int cos=(brd[nx][ny]=='o'?1:0);
      int nd=d+cos;
      que.push(pipii(nd,pii(nx,ny)));
    }
  }
  rep(i,h)rep(j,w){
    if(brd[i][j]==t){
      cout<<dis[i][j]/2<<endl;
    }
  }
  if(0){
    rep(i,h)rep(j,w){
      if(brd[i][j]>='A'&&brd[i][j]<='Z'){
	cerr<<brd[i][j]<<" "<<dis[i][j]<<endl;
      }
    }
  }
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

std::vector<int> enum_div(int n)//nの約数を列挙
{
    std::vector<int> ret;
    for(int i=1 ; i*i<=n ; ++i)
    {
        if(n%i == 0)
        {
            ret.push_back(i);
            if(i!=1 && i*i!=n)
            {
                ret.push_back(n/i);
            }
        }
    }
    ret.pb(n);
    return ret;
}

signed main(){start();
    int a,b;
    cin>>a>>b;
    cout<<a-b+1<<endl;
    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 a = sc.nextInt();
		int b = sc.nextInt();
		int c = b + 2;
		
		String stArray[] = new String[a];
		for (int i = 0; i < a;i ++ ){
				
				stArray[i] = sc.next();
		}

		String s = "";
		
		for (int i = 0; i < c ;i ++ ){
			s = s + "#" ;
		}
		System.out.println(s);
		
		String t = "";		
		for (int i = 0; i < a ;i ++ ){
			t = t + "#" + stArray[i] + "#" ;
			System.out.println(t);
			t = "" ;
		}
		System.out.println(s);

	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
           int n;
			cin>>n;
			int h[200000];
			for(int i=0;i<n;i++)
				cin>>h[i];
			int cost[200000];
			cost[0]=0;
			cost[1]=abs(h[1]-h[0]);
			for(int i=2;i<n;i++)
			{
				cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]));
			}
		cout<<cost[n-1];
}

Measured memory_bytes: 1024
# educational DP contest A
n,k=map(int,input().split())
h=list(map(int,input().split()))
def changemin(a,b):
    if a>b:
        a=b
        return a
    return a
dp=[]
dp.append(0)
for i in range(1,n):
    dp.append(100000000000)
for m in range(n):
    for j in range(1,min(k+1,n-m)):
        dp[m+j]=changemin(dp[m+j],dp[m]+abs(h[m]-h[m+j]))
print(dp[n-1])
        

Measured memory_bytes: 56544
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	wtr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	a := make([]uint, n)

	for i := 0; i < n; i++ {
		a[i] = uint(scanInt())
	}

	ans := uint(0)

	for i := 0; i < 61; i++ {
		c := uint(0)
		for j := range a {
			c += (a[j]>>uint(i))&1
		}

		ans = (ans+(c*(uint(n)-c)%mod)*((1<<uint(i))%mod))%mod
	}

	fmt.Println(ans)
}

const mod = 1000000007


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	int a,b;
	cin>>a>>b;
	cout<<max(0,a-2*b);
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    map<ll, int> b;
    rep(i, n) {
        b[i+1+a[i]]++;
    }
    vll c(n);
    rep(i, n) c[i] = (i+1) - a[i];
    ll ans = 0;
    rep(i, n) {
        ans += b[c[i]];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 29044
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> v){
  cout<<endl;
  rep(i,v.size()){
    cout<<v.at(i)<<" ";
  }
  cout<<endl;
}

template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->emplace_back(count,A->at(i));
        count = 1;
      }
    }else{
      R->emplace_back(count,A->at(i));
    }
  }
}


//---------------------------------------------------------------
int main(){
  int N;
  cin>>N;
  vec A,B;
  rep(i,N){
    int v;
    cin>>v;
    if((i+1)%2==1)A.push_back(v);
    else B.push_back(v);
  }

  vector<pair<int,int>> Ac;
  vector<pair<int,int>> Bc;

  count_vector(&A,&Ac);
  count_vector(&B,&Bc);

  sort(Ac.begin(),Ac.end(),greater<pair<int,int>>());
  sort(Bc.begin(),Bc.end(),greater<pair<int,int>>());

  int ans = 0;
  if(Ac.at(0).second==Bc.at(0).second){
    int ans_a,ans_b;
    ans_a = ans_b = 0;
    if(Ac.size()==1){
      ans_a+= A.size();
      ans_a+= B.size()-Bc.at(0).first;
    }else{
      ans_a+= A.size()-Ac.at(1).first;
      ans_a+= B.size()-Bc.at(0).first;
    }
    if(Bc.size()==1){
      ans_b+= B.size();
      ans_b+= A.size()-Ac.at(0).first;
    }else{
      ans_b+= B.size()-Bc.at(1).first;
      ans_b+= A.size()-Ac.at(0).first;
    }
    ans = min(ans_a,ans_b);

  }else{
    ans+= A.size()-Ac.at(0).first;
    ans+= B.size()-Bc.at(0).first;
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 1784
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int data[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> data[i];
    }
    int max = *max_element(data, data + 3);
    REP(i, 3)
    {
        data[i] -= max;
    }
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        while (!(data[i] == -1 || data[i] == 0))
        {
            data[i] += 2;
            ans++;
        }
    }
    while (!(data[0] == data[1] && data[1] == data[2]))
    {
        (*min_element(data, data + 3))++;
        (*min_element(data, data + 3))++;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


int main(){
    string s; cin >> s;
    if((int)(s[6]-'0') + (int)(s[5]-'0') * 10 >= 5) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::{i32, i64, i128, u32, u64, u128, f64};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
#[allow(unused_imports)]
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        k: usize,
        s: String,
    }
    if s.len() <= k { println!("{}", s); }
    else { println!("{}", s[..k].to_string() + &"...".to_string() ); }
}


Measured memory_bytes: 2200
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

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

	string S;

	cin >> S;

	int ans = 0;

	for(int i = 0; i < S.size() / 2; i++){
		if(S[i] != S[S.size() - 1 - i]){
			ans++;
		}
	}

	cout << ans << endl;


	Never To return 0;
}


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

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

    public static void hoge()
    {
        var n = int.Parse(System.Console.ReadLine());

        var ans = 0;

        for(int i = 1; i <= 10; i++)
        {
            if(1000 * i - n < 1000 && 1000 * i - n >= 0)
            {
                ans = 1000 * i - n;
                break;
            }
        }

        System.Console.WriteLine(ans);

    }
}

Measured memory_bytes: 27536
#2019/10/03
N = int(open(0).read())
cnt=0
for j in range(6):
#     print(j)
#     print('N= ', N)
    if (N // 2 == 0):
        break
    else:
        N //= 2
#         print('N= ', N)
        cnt+=1
# print('cnt= ', cnt)
print(2 ** cnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (i=a;i<n;i++)
#define per(i,a,n) for (i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE 1000001
//#define ONLINE_JUDGE
//#define rd
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
auto clk=clock(); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

int main(){
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(20);
	/*#ifdef rd
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/	

	/*
		Write here
	*/

	int n;
	bool ans=false;
	cin>>n;
	while(n){
		if(n%10==7){
			ans=true;
			break;
		}
		n=n/10;
	}
	if(ans) cout<<"Yes";
	else cout<<"No";


	/*#ifdef ONLINE_JUDGE
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif*/
	return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int n=in();
    string s=stin();
    char tmp=s[0];
    int ans=1;
    for(int i=1;i<n;i++){
        if(s[i]==tmp)continue;
        else{
            ans++;
            tmp=s[i];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	string s[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };

	string in;
	cin >> in;

	for (int i = 0; i < 7; i++)
	{
		if (in == s[i])
		{
			cout << 7 - i;
			break;
		}
	}
	
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	string str;
	cin>>str;
	if(str=="MON")
		cout<<6<<endl;
	else if(str=="SUN")
		cout<<7<<endl;
	else if(str=="TUE")
		cout<<5<<endl;
	else if(str=="WED")
		cout<<4<<endl;
	else if(str=="THU")
		cout<<3<<endl;
	else if(str=="FRI")
		cout<<2<<endl;
	else if(str=="SAT")
		cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto &__VA_ARGS__:(c))
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
using point = pair<ll,ll>;
using circle = pair<pair<ld,ld>,ld>;

circle circleFromTwoPoints(point p1,point p2) {
  auto x1 = p1.x;
  auto y1 = p1.y;
  auto x2 = p2.x;
  auto y2 = p2.y;
  auto dx=x2-x1;
  auto dy=y2-y1;
  auto x=x1+(ld)dx/2;
  auto y=y1+(ld)dy/2;
  return {{x,y},sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))/2};
}

circle circleFromThreePoints(point p1,point p2,point p3) {
  auto x1 = p1.x;
  auto y1 = p1.y;
  auto x2 = p2.x;
  auto y2 = p2.y;
  auto x3 = p3.x;
  auto y3 = p3.y;

  auto a = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2;
  if (a==0) {
	  return {{0,0},-1};
  }

  ld b = (ld)(x1 * x1 + y1 * y1) * (y3 - y2)
        + (ld)(x2 * x2 + y2 * y2) * (y1 - y3)
        + (ld)(x3 * x3 + y3 * y3) * (y2 - y1);

  ld c = (ld)(x1 * x1 + y1 * y1) * (x2 - x3)
        + (ld)(x2 * x2 + y2 * y2) * (x3 - x1)
        + (ld)(x3 * x3 + y3 * y3) * (x1 - x2);

  ld x = -b / (2 * a);
  ld y = -c / (2 * a);

  return {{x,y},sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1))};
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int n;
	cin>>n;
	vector<point> p(n);
	fore(p,i) cin>>i.first>>i.second;

	ld res=-1;
	rep(i,0,n) rep(j,i+1,n) {
		auto c=circleFromTwoPoints(p[i],p[j]);
		if (c.second<0) continue;

		ld x,y,tmp;
		tmp=c.second;
		x=c.first.x;
		y=c.first.y;
		fore(p,l) tmp=max(tmp,sqrt((x-l.x)*(x-l.x)+(y-l.y)*(y-l.y)));

		if (res<0 || res>tmp) res=tmp;
	}

	rep(i,0,n) rep(j,i+1,n) rep(k,j+1,n) {
		auto c=circleFromThreePoints(p[i],p[j],p[k]);
		if (c.second<0) continue;

		ld x,y,tmp;
		tmp=c.second;
		x=c.first.x;
		y=c.first.y;
		fore(p,l) tmp=max(tmp,sqrt((x-l.x)*(x-l.x)+(y-l.y)*(y-l.y)));

		if (res<0 || res>tmp) res=tmp;
	}

	if (res<0) {
		ld d=0;
		rep(i,0,n) {
			ld x=p[i].x,y=p[i].y;
			fore(p,l) d=max(d,sqrt((x-l.x)*(x-l.x)+(y-l.y)*(y-l.y)));
		}
		res=d/2;
	}

	cout<<res<<'\n';
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;
typedef long double ld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	vector<int> h(n);
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	int ans =1;
	int maxh=h[0];
	for(int i=1; i<n; i++) {
		if(h[i]>=maxh) {
			ans++;
			maxh=h[i];
		}
	}
	cout<<ans<<"\n";
    return 0;
}



Measured memory_bytes: 256
s=list(map(int,list(str(input()))))
l = len(s)
bs = [0 for i in range(l)]
ws = [0 for i in range(l)]
for i in range(l):
    if i%2==0:
        bs[i]=1
    else:
        ws[i]=1
b=0
w=0
for i in range(l):
    if s[i] != bs[i]:
        b += 1
    if s[i] != ws[i]:
        w += 1
print(min(b,w))


Measured memory_bytes: 5404
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<utility>
using namespace std;
typedef pair <int ,int> P;
int main()
{
    int n,m;
    cin>>n>>m;
    P p[n];
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        p[i].first=b;
        p[i].second=a;
    }
    sort(p,p+n);
    reverse(p,p+n);
    /*for(int i=0;i<n;i++){
        cout<<p[i].first<<' '<<p[i].second<<endl;
    }*/

    //表を埋めていく
    int d[m+1];
    int N[m+1];
    for(int i=0;i<m+1;i++){d[i]=0;}
    for(int i=0;i<m+1;i++){N[i]=i+1;}
    for(int i=0;i<n;i++){
        int k=p[i].second;
        while(k<=m){
            if(d[k]==0){
                d[k]=p[i].first;
                N[p[i].second]=k+1;
                break;
            }
            k=N[k];
        }
    }
    long long ans=0;
    for(int i=1;i<=m;i++){
        ans=ans+d[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,K;cin >> N >> K;
    vector<int> D(K);
    rep(i,K)cin >> D[i];
    int res = 0;
    for(int i=N;i<=100000;i++){
        int cood = i,tmp=i;
        int flag = 1;
        while(tmp>0){
            int c = tmp%10;
            rep(j,K){
                if(c==D[j])flag=0;
            }
            tmp/=10;
        }
        if(flag){
            res = cood;
            break;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());

    cout << a[n-1] - a[0] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int x[] = new int[31];
                for (int i = 0; i < 28; i++) {
                        x[sc.nextInt()] = 1;
                }
                for (int i = 1; i <= 30; i++) {
                        if (x[i] != 1) {
                                System.out.println(i);
                        }
                }
        }
}


Measured memory_bytes: 26148
// https://atcoder.jp/contests/abc153/tasks/abc153_e

#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl;
using namespace std;
#define int long long

int dp[10000060];

signed main() {
    int H, N;
    cin >> H >> N;

    for(int i = 1; i <= 10000050; i++) {
        dp[i] = INT_MAX;
    }
    
    dp[0] = 0;
    int ans = INT_MAX;
    for(int i = 1; i <= N; i++) {
        int a, b;
        cin >> a >> b;

        // watch(a)
        // watch(b)

        for(int j = 0; j <= H; j++) {
            dp[j+a] = min(dp[j+a], dp[j]+b);
            // cout << "setting dp_" << j+a << " to " << dp[j+a] << endl;

            if(j+a >= H) {
                ans = min(ans, dp[j+a]);
            }

            // watch(dp[j])
            // cout << "we can get to " << j+a << " with " << dp[j]+b << endl;
        }
        // cout << endl;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 78464
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    int ret = 1;
    for (int i = 0; i < n; ++i) {
        if (ret < k)
            ret *= 2;
        else
            ret += k;
    }
    cout << ret << "\n";
    return 0;
}

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

int main(){
    int n,m,a,b;cin >> a >> b;
    int x[3];
    int ans = -10000000;
    x[0] = a + b;
    x[1] = a - b;
    x[2] = a * b;
    
    for(int i = 0 ; i < 3 ; i++){
        if(ans <= x[i]){
            ans = x[i];
        }
    }


    cout << ans << endl;
    return 0;
}

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


int N;
int cou1;
int cou2;
int cou4;

int main()
{
    cin >> N;
    int a;
    for(int i = 0;i < N;i++)
    {
        cin >> a;
        if(a % 4 == 0)
        {
            cou4++;
        }
        else if(a % 2 == 0)
        {
            cou2++;
        }
        else
        {
            cou1++;
        }
    }

    if(cou2 == 0)
    {
        if(cou1 <= cou4 + 1)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else
    {
        cou1 += 1;
        if(cou1 <= cou4 + 1)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = sum(a) / (n * (n + 1) // 2)
l = [a[i] - a[i - 1] - s for i in range(n)]
for i in l:
    if i % n != 0 or i > 0:
        exit(print("NO"))
print("YES")

Measured memory_bytes: 20532
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

set <int> st;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	string s;
	cin >> s;
	for(auto to : s) st.insert(to);
	if(sz(st) == 1) cout << "No";
	else cout << "Yes";
}      

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int k;
int sum=0;
set<string> t1;
vector<string> v;
void dfs(string s){
	if(t1.find(s)==t1.end());
	else return ;
	t1.insert(s);
	v.push_back(s);
	if(s.size()==10)return ;
	if(s[s.size()-1]!='0')dfs(s+(char)(s[s.size()-1]-1));
	dfs(s+s[s.size()-1]);
	if(s[s.size()-1]!='9')dfs(s+(char)(s[s.size()-1]+1));
}
inline bool cmp(string x,string y){
	if(x.size()<y.size())return 1;
	if(x.size()==y.size()&&x<y)return 1;
	return 0;
}
int main(){
	cin>>k;
	for(char c='1';c<='9';c++){
		string t="";
		t+=c;
		dfs(t);
	}
	int sum=0;
	sort(v.begin(),v.end(),cmp);
	cout<<v[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 25328
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  if(n%4==0){
    printf("Yes\n");
  }else if(n>=7&&(n-7)%4==0){
    printf("Yes\n");
  }else if(n>=14&&(n-14)%4==0){
    printf("Yes\n");
  }else if(n>=21&&(n-21)%4==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    ll n ;
    cin >> n ;
    ll A[n] ;
    ll a,now1=0,cnt1=0,now2=0,cnt2=0;
    for(int i = 0 ; i < n ; i++){
        cin >> A[i] ;
    }
    rep(i,n) {
    now1 += A[i];
    now2 += A[i];
    if (now1<=0) {
      cnt1+=abs(now1)+1;now1=1;
    }
    if (now2>=0) {
      cnt2+=abs(now2)+1;now2=-1;
    }
    swap(now1,now2);swap(cnt1,cnt2);
    }
    cout << min(cnt1,cnt2) << endl;
    return 0 ;
}

 


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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
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;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll N,K; cin >> N >> K;
    vector<int> P(N);
    vector<ll> C(N);
    REP(i,N){
        cin >> P[i];
        P[i]--;
    }
    REP(i,N){
        cin >> C[i];
    }

    ll ans = -1e16;

    REP(i,N){
        int pos = i;
        ll cyclesum = 0;
        ll cyclesize = 0;
        while(true){
            cyclesize++;
            cyclesum += C[pos];
            pos = P[pos];
            if (pos == i) break;
        }

        pos = i;
        ll cnt = 0;
        ll pathsum = 0;
        while(true){
            cnt++;
            pathsum += C[pos];
            if (cnt > K) break;
            ll cyclecount = (K - cnt) / cyclesize;
            ll nans = pathsum + max(0LL,cyclesum) * cyclecount;
            pos = P[pos];
            chmax(ans, nans);
            if (pos == i) break;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 3644
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#include <algorithm>
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() {return x * x + y * y; }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
  return a.x * b.y - a.y * b.x;
}

struct Segment {
  Point p1, p2;
};

typedef Segment Line;

class Circle {
 public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0) : c(c), r(r) {}
};

typedef vector<Point> Polygon;


#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

class EndPoint {
 public:
  Point p;
  int seg, st;
  EndPoint() {}
  EndPoint(Point p, int seg, int st): p(p), seg(seg), st(st) {}

  bool operator < (const EndPoint &ep) const {
    if (p.y == ep.p.y) {
      return st < ep.st;
    } else return p.y < ep.p.y;
  }
};

EndPoint EP[2 * 100000];

void swap(Point& a, Point& b) {
  Point tmp = a;
  a.x = b.x;
  a.y = b.y;
  b.x = tmp.x;
  b.y = tmp.y;
}

int manhattanIntersection(vector<Segment> S) {
  int n = S.size();

  for (int i = 0, k = 0; i < n; i++) {
    if (S[i].p1.y == S[i].p2.y) {
      if (S[i].p1.x > S[i].p2.x) swap(S[i].p1, S[i].p2);
    } else if (S[i].p1.y > S[i].p2.y) swap(S[i].p1, S[i].p2);

    if (S[i].p1.y == S[i].p2.y) {
      EP[k++] = EndPoint(S[i].p1, i, LEFT);
      EP[k++] = EndPoint(S[i].p2, i, RIGHT);
    } else {
      EP[k++] = EndPoint(S[i].p1, i, BOTTOM);
      EP[k++] = EndPoint(S[i].p2, i, TOP);
    }
  }

  sort(EP, EP + (2 * n));

  set<int> BT;
  BT.insert(1000000001);
  int cnt = 0;

  for (int i = 0; i < 2*n; i++) {
    if (EP[i].st == TOP) {
      BT.erase(EP[i].p.x);
    } else if (EP[i].st == BOTTOM) {
      BT.insert(EP[i].p.x);
    } else if (EP[i].st == LEFT) {
      set<int>::iterator b = BT.lower_bound(S[EP[i].seg].p1.x);
      set<int>::iterator e = BT.upper_bound(S[EP[i].seg].p2.x);
      cnt += distance(b, e);
    }
  }

  return cnt;
}

int main() {
  vector<Segment> S;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    Segment s;
    cin >> s.p1.x >> s.p1.y >> s.p2.x >> s.p2.y;
    S.push_back(s);
  }
  cout << manhattanIntersection(S) << endl;
  return 0;
}



Measured memory_bytes: 16436
#include <cstdio>
#include <algorithm>

const int MAXN = 12;
const int MAXM = (int)1e3 + 1;
const int INF = (int)1e8 + 1;

int cost[MAXM];    // cost[i] means cost of key i
int unlock_set[MAXM];  // unlock set of key i
int f[MAXM][1 << 12];  // f(i,j)表示前i个key,解锁集合j的最小花费

int solve(int n, int m) {
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j < (1 << n); ++j) {
      if (i == 0 && j == 0) f[i][j] = 0;
      else f[i][j] = INF;
    }
  }

  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < (1 << n); ++j) {
      if (f[i][j] == INF) continue;
      f[i + 1][j] = std::min(f[i + 1][j], f[i][j]);
      int &cur = f[i + 1][j | unlock_set[i + 1]];
      cur = std::min(cur, f[i][j] + cost[i + 1]);
      // printf("i=%d j=%d f=%d\n", i + 1, j | unlock_set[i + 1], cur);
    }
  }
  return f[m][(1 << n) - 1] != INF ? f[m][(1 << n) - 1] : -1;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int num, cur;
    scanf("%d %d", cost + i, &num);
    while (num--) {
      scanf("%d", &cur);
      unlock_set[i] |= (1 << (cur - 1));
    }
  }
  printf("%d\n", solve(n, m));
  return 0;
}



Measured memory_bytes: 16128
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int A, B;
    cin >> A >> B;
    int result = -2000000000;
    result = max(result, A+B);
    result = max(result, A-B);
    result = max(result, A*B);
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
from heapq import *

N=int(input())
d=list(map(int,input().split()))
h=[]
for i in d:
    heappush(h,i)
for i in range(N//2-1):
    heappop(h)
a=heappop(h)
b=heappop(h)
print(b-a if b!=a else 0)


Measured memory_bytes: 56872
#include <iostream>

using ll = long long;

int main() {
	ll a, b, x;
	std::cin >> a >> b >> x;

	ll n = 0;
	if(a == 0) {
		n = b / x + 1;
	} else {
		n = (b / x) - ((a - 1) / x);
	}
	
	std::cout << n << std::endl;

	return 0;
}

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

int main(){
  
  int n, m, a[1000], b[1000], cnt=0;

  cin>>n>>m;
  for(int i=0;i<n;i++) cin>>a[i];

  int sum=0;
  while(1){
    for(int i=0;i<m;i++){
      b[i]=a[cnt%n];
      cnt++;
    }
    sort(b, b+m);
    sum+=b[m-1]-b[0];
    if(cnt%n==0) break;
  }

  cout<<sum<<endl;
  
  
  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=30;
int n,op[N];
char s[N];
map <string,int> tot;
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	tot.clear();
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if (!((i>>j)&1))
				now+=s[j+1];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if ((i>>j)&1)
				now+=s[j+1];
//		cout << now << endl;
		tot[now]++;
	}
//	cout << endl;
	LL ans=0;
	for (int i=0;i<(1<<n);i++){
		string now="";
		for (int j=0;j<n;j++)
			if ((i>>j)&1)
				now+=s[n*2-j];
		now+="*";
		for (int j=n-1;j>=0;j--)
			if (!((i>>j)&1))
				now+=s[n*2-j];
//		cout << now << tot[now] << endl;
		ans+=tot[now];
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 73984
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int a,b,c;

    cin >> a>> b>>c;

    if(a == b) cout << c << endl;
    else if(b ==  c) cout << a << endl;
    else cout << b << endl;
}

Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	int a,b;
	cin>>a>>b;
	cout<<max(a*b,max(a+b,a-b))<<endl;
	  
}

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

Measured memory_bytes: 256
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

#[derive(Clone, Copy, Eq, PartialEq, Debug)]
enum E {
    Answer(u64),
    Less(u64),
}

use std::cmp;

fn main() {
    let n = readln();
    let xs = reads();
    let ys = reads();

    let mut zs = vec![E::Less(1000000000); n];

    let mut prev = 0;
    for (i, x) in xs.into_iter().enumerate() {
        if x > prev {
            prev = x;
            zs[i] = E::Answer(x);
        }
        else {
            zs[i] = E::Less(x);
        }
    }

    let mut prev = 0;
    let mut flag = true;
    for i in 0..n {
        let i = n - i - 1;
        let y = ys[i];

        if !flag {
            break;
        }

        if y > prev {
            prev = y;

            match zs[i] {
                E::Answer(n) if n == y => {},
                E::Less(n) if n >= y => {zs[i] = E::Answer(y);},
                _ => {flag = false;},
            }
        }
        else {
            match zs[i] {
                E::Answer(n) if y >= n => {},
                E::Less(n) => {zs[i] = E::Less(cmp::min(n, y));},
                _ =>  {flag = false;},
            }
        }
    }

    let mut res = 0;
    if flag {
        res = 1;
        for z in zs {
            if let E::Less(n) = z {
                res *= n;
                res %= 1000000007;
            }
        }
    }

    println!("{}", res);
}


Measured memory_bytes: 11512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        Arrays.sort(a);
        int max = a[n - 1];
        double mid = max / 2.0;
        int ans = 0;
        double min = max;
        for (int i = 0; i < n; i++) {
            if (min > Math.abs(a[i] - mid)) {
                min = Math.abs(a[i] - mid);
                ans = i;
            }
            if (a[i] > mid) {
                break;
            }
        }
        System.out.println(max + " " + a[ans]);
    }
}

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

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

using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;

int main(int, char**)
{
    int x, n;
    cin >> x >> n;
    vector<int> use(102, true);
    int p;
    rep(i,n) {
        cin >> p;
        use[p] = false;
    }
    int ofs = 0, ans = 0;
    while (true) {
        if (use[x-ofs]) { ans = x-ofs; break; }
        if (use[x+ofs]) { ans = x+ofs; break; }
        ofs++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    //cin.tie(0);
    deque<long long> d;
    for(int i=1; i<10;i++)
        d.push_back(i);
    int k;
    cin>>k;
    long long ans=0;
    for(int i=0;i<k;i++)
    {
        ans = d[i];
        if(ans%10 !=0)
            d.push_back(10*ans + ans%10 - 1);
        d.push_back(ans * 10 + ans % 10);
        if(ans %10 !=9)
            d.push_back(ans * 10 + ans % 10 + 1);
    }
    cout<<ans;
}


Measured memory_bytes: 2688
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if((a+b)%2==1){
			System.out.println("IMPOSSIBLE");
		}else{
			System.out.println((a+b)/2);
		}
	}
}


Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[][][][] masks = new int[5][5][5][5];

	static int solve(int start) {
		HashSet<Integer> visited = new HashSet<Integer>();
		visited.add(start);
		ArrayList<Integer> cur = new ArrayList<Integer>();
		cur.add(start);
		for (int i = 0; i < 12; ++i) {
//			System.out.println(i + " " + cur.size());
			ArrayList<Integer> next = new ArrayList<Integer>();
			for (int v : cur) {
				int zero = Integer.numberOfTrailingZeros(v);
				int r = zero / 5;
				int c = zero % 5;
				for (int er = r; er < N; ++er) {
					for (int ec = c; ec < N; ++ec) {
						int n = v ^ masks[r][c][er][ec];
						if (n == 0) return i + 1;
						if (!visited.contains(n)) {
							visited.add(n);
							next.add(n);
						}
					}
				}
			}
			cur = next;
		}
		return 13;
	}

	static boolean bit(int state, int r, int c) {
		return (state & (1 << (r * 5 + c))) != 0;
	}

	public static void main(String[] args) throws Exception {
		for (int i = 0; i < 5; ++i) {
			for (int j = 0; j < 5; ++j) {
				for (int k = i; k < 5; ++k) {
					for (int l = j; l < 5; ++l) {
						for (int r = i; r <= k; ++r) {
							for (int c = j; c <= l; ++c) {
								masks[i][j][k][l] |= (1 << (r * 5 + c));
							}
						}
					}
				}
			}
		}
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			int start = 0;
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					int v = sc.nextInt();
					if (v == 1) start += (1 << (i * 5 + j));
				}
			}
			int ans = solve(start);
			for (int j = 0; j < ans; ++j) {
				System.out.print("myon");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37000