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

int main()                   
{
    int n,k;
    cin>>n>>k;
    vector<int> A(n);
    vector<bool> dp(k+1, false);                    //dp[i] represents whether a player who sees i number of stones will win or not.
    for(int i=0; i<n; i++)
        cin>>A[i];
    sort(A.begin(), A.end());
    int mini = A[0];
    for(int i=mini; i<=k; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(A[j]<=i and dp[i-A[j]]==false)
            {   dp[i] = true;
              break;
            }
        }
    }

    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n, m, r;
    scanf("%d%d", &n, &m);
    if((n==1&&m==1)||(n==0&&m==0)) printf("%d", 0);
   else if(n<=1){
        r = ((m*(m-1))/2);
         printf("%d", r);
    }
    else if(m<=1){
        r= ((n*(n-1))/2);
         printf("%d", r);
    }
    else
    {
        r = ((n*(n-1))/2)+((m*(m-1))/2);
        printf("%d", r);
    }
    return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

int popcnt(int x) {
    int r = 0;
    foreach (i; 0 .. 22) if (x & (1 << i)) r++;
    return r;
}

void main() {
    int N, Hx, Hy, Dx, Dy;
    int[] Y, X;
    bool input() {
        scanf("%d %d %d %d %d\n", &N, &Hx, &Hy, &Dx, &Dy);
        if (N == 0) return false;
        Y = new int[N + 2];
        X = new int[N + 2];
        Y[0] = Hy;
        X[0] = Hx;
        foreach (i; 1 .. N + 1) {
            scanf("%d %d\n", &X[i], &Y[i]);
        }
        Y[N + 1] = Dy;
        X[N + 1] = Dx;
        return true;
    }
    double Distance(int a, int b) {
        double dy = Y[a] - Y[b],
               dx = X[a] - X[b];
        return sqrt(dy * dy + dx * dx);
    }
    void solve() {
        static float[int] cache[22];
        cache.clear;
        bool dfs(int v, int used, float t) {
            //writefln("%d %0" ~ (N + 2).to!string ~ "b %f", v, used, t);
            if (used == (1 << (N + 1)) - 1) return true;
            if (cache[v].get(used, cast(float)1e4) <= t) return false;
            if (v <= N - 8) {
                cache[v][used] = t;
            }
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (Distance(v, i) + t >= Distance(N + 1, i)) return false;
            }
            foreach (i; 1 .. N + 1) {
                if (used & (1 << i)) continue;
                if (dfs(i, used | 1 << i, t + Distance(v, i))) return true;
            }
            return false;
        }
        writeln(dfs(0, 1, 0) ? "YES" : "NO");
    }
    while (input) solve;
}

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

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

typedef long long int   ll;
typedef long double     ld;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define file_io         freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;

ll n, now, timer;
string s;
vector<pll> E;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> s;
    n = s.size();
    if (s[0] == '0' || s[n - 1] == '1')
        kill(-1);
    for (ll i = 1; i <= n - 1; i++) {
        if (s[i - 1] != s[n - i - 1])
            kill(-1);
    }
    E.emplace_back(1, 2);
    now = 2; timer = 3;
    for (ll i = 2; i <= n - 1; i++) {
        if (s[i - 1] == '1') {
            E.emplace_back(now, timer++);
            now = timer - 1;
        }
        else {
            E.emplace_back(now, timer++);
        }
    }
    for (pll e : E) {
        cout << e.X << sep << e.Y << endl;
    }

    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
void input(vector<auto>& a,int n);
int n;


signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int t;
    cin >> n >> t;
    vec(a,n);
    int ans = max_int;
    REP(i,n){
        int x,y;
        cin >> x >> y;
        if(y <= t){
            ans = min(ans,x);
        }
    }
    if(ans == max_int){
        print("TLE");
    }
    else{
        print(ans);
    }



    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int main(){
	int i,j;
	string s;
	cin >> s;
	string s1,s2;
	s1=s[0];
	s2=s[s.length()-1];
	cout << s1 << s.length()-2 << s2;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

void swap(int& a, int& b) {
  int tmp = a;
  a = b;
  b = tmp;
}

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

  cin >> a >> b >> c;

  if(a > b)
    swap(a, b);
  if(b > c)
    swap(b, c);
  if(a > b)
    swap(a, b);

  cout << a << " " << b << " " << c << endl;
}



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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 6e3 + 41;

int n;
char s[MAX];

vector<string> vs;
vector<string> vb;

string getbesta(string s) {
	vi va, vb;
	fi(0, sz(s) - 1) {
		if (s[i] == 'a') {
			va.pb(i);
		} else {
			vb.pb(i);
		}
	}
	assert(sz(va) == sz(vb));
	vi d(sz(va), 0);
	fdi(sz(va) - 1, 0) {
		d[i] = 1;
		fj(i + 1, sz(va) - 1) {
			if (vb[i] > va[j]) continue;
			d[i] = max(d[i], d[j] + 1);
		} 
	}
	int q = (*max_element(d.begin(), d.end()));
	string res;
	fi(1, q) {
		res += "ab";
	}
	return res;
}

string getbestb(string s) {
	vi va, vb;
	fi(0, sz(s) - 1) {
		if (s[i] == 'a') {
			va.pb(i);
		} else {
			vb.pb(i);
		}
	}
	assert(sz(va) == sz(vb));
	int x = vb[0];
	fi(0, sz(va) - 1) {
		va[i] -= x;
		vb[i] -= x;
	}
	vi c(sz(s), -1);
	string res = "";
	fdi(sz(vb) - 1, 0) {
		c[vb[i]] = 'b';
		c[va[i]] = 'a';
		string cur = "";
		fj(0, sz(c) - 1) {
			if (c[j] != -1) {
				cur += (char) c[j];
			}
		}
		res = max(res, cur);
	}	
	return res;
}

void solve() {
	int b = 0;
	string cur;
	fi(1, n * 2) {
		if (s[i] == 'a') {
			b++;
		} else {
			b--;
		}
		cur += s[i];
		if (b == 0) {
			vs.pb(cur);
			cur = "";
		}
	}

	fi(0, sz(vs) - 1) {
		if (vs[i][0] == 'a') {
			vb.pb(getbesta(vs[i]));
		} else {
			vb.pb(getbestb(vs[i]));
		}
	}	

/*
  fi(0, sz(vs) - 1) {
  	err("%s = %s\n", vs[i].c_str(), vb[i].c_str());
  }
*/

	int p = -1;
	fdi(sz(vb) - 1, 0) {
		if (vb[i][0] == 'b') {
			p = i;
			break;
		}
	}
	
	string ans = "";
	fdi(p, 0) {
		string v1 = vb[i];
		string v2 = vb[i] + ans;
		ans = max(ans, max(v1, v2));
	}
	fi(p + 1, sz(vb) - 1) {
		ans += vb[i];
	}
	printf("%s\n", ans.c_str());
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  scanf(" %s", s + 1);
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 640
using System;
    class c
    {
        static void Main()
        {
            var kx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int k = kx[0], x = kx[1];
            if (500 * k >= x) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    } 

Measured memory_bytes: 27108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

int a[5];
int main(){
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		if(s[0]=='A') a[0]++;
		else if(s[0]=='W') a[1]++;
		else if(s[0]=='T') a[2]++;
		else if(s[0]=='R') a[3]++;
	}
	printf("AC x %d\n",a[0]);
	printf("WA x %d\n",a[1]);
	printf("TLE x %d\n",a[2]);
	printf("RE x %d\n",a[3]);
}

Measured memory_bytes: 3252
fun main(args: Array<String>) = abc156b()

fun abc156b() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }

    var curr = 1L

    for (i in 1..10000) {
        curr *= k
        if (curr > n) return println(i)
    }
}


Measured memory_bytes: 38180
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        x: usize,
        y: usize
    }
    let mut cheat = y - x;

    let mut min_dist = vec![vec![0; n + 1]; n + 1];

    let mut dist_count = vec![0; n];

    for i in 1..n + 1 {
        for j in i + 1..n + 1 {
            if j <= x || i >= y {
                min_dist[i][j] = j - i;
            } else {
                let normal_dist = j - i;
                let special_dist = if i >= x {
                    if j <= y {
                        (i - x) + 1 + (y - j)
                    } else {
                        (i - x) + 1 + (j - y)
                    }
                } else {
                    if j <= y {
                        (x - i) + 1 + (y - j)
                    } else {
                        (x - i) + 1 + (j - y)
                    }
                };

                min_dist[i][j] = cmp::min(normal_dist, special_dist);
            }

            //println!("{} {} {}", i, j, min_dist[i][j]);

            dist_count[min_dist[i][j]] += 1;
        }
    }

    //println!("{:?}", min_dist);

    for i in 1..n {
        println!("{}", dist_count[i]);
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 49532
import sys
sys.setrecursionlimit(10**7)
def dfs(p):
  for edge in g[p]:
    if x[edge[0]] is not None:
      if x[edge[0]]-x[p]!=edge[1]:
        print('No')
        exit()
    else:
      x[edge[0]]=x[p]+edge[1]
      dfs(edge[0])
n,m=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(m):
  l,r,d=map(int,input().split())
  g[r-1].append((l-1,d))
  g[l-1].append((r-1,-d))
x=[None]*n
for i in range(n):
  if x[i]==None:
    x[i]=0
    dfs(i)
print('Yes')

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int n;
    cin>>n;
    map<string,int> mp;
    while(n--){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<_sz(mp);
    return 0;
}


Measured memory_bytes: 19252
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m = list(map(int,ipti().split()))
    uf = UnionFind(n)
    grouped_set = set()

    for i in range(m):
        x, y, z = list(map(int,ipti().split()))
        x ,y = x - 1, y - 1
        uf.union(x,y)
        grouped_set.add(x)
        grouped_set.add(y)

    print(uf.group_count())

if __name__ == '__main__':
    main()


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

#define ll long long;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long x,a,b;
	cin>>x;
	a= x/500;
	b= (x%500)/5;
	long sum = a*1000 + b*5;
	cout<< sum;
	
	

	return 0;
}

Measured memory_bytes: 256
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll a,b,ans;
    cin>>a>>b;
    if(-b*2+a>0) cout<<-b*2+a<<endl;
    else cout<<"0"<<endl;
}


Measured memory_bytes: 256
//
// Created by kapildd on 10/5/17.
//

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

int main() {
    int n;
    cin>>n;
    vector< vector<int> > dist(n, vector<int>(n));
    vector< vector<int> > adj(n, vector<int>(n, 0));
    vector< vector<int> > dist2(n, vector<int>(n, INT_MAX));
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            cin>>dist[i][j];
            adj[i][j] = dist2[i][j] = dist[i][j];
        }
    }
    for(int k=0; k<n; k++) {
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
    int poss = 1;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(dist[i][j] != dist2[i][j]) {
                poss = 0;
            }
        }
    }
    if(!poss) {
        cout << -1 << endl;
        return 0;
    }
    for(int k=0; k<n; k++) {
        for(int i=0; i<n; i++) {
            for(int j=0; j<n; j++) {
                if(adj[i][k]==0 || adj[k][j]==0 || adj[i][j]==0) continue;
                if(adj[i][j] == adj[i][k] + adj[k][j]) {
                    adj[i][j] = 0;
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            ans += adj[i][j];
        }
    }
    cout << ans << endl;
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define sc1(a)  scanf("%d",&a)

int main(){
    int n;
    sc1(n);
    int a[n];
    rep(i,n) sc1(a[i]);
    rep(i,n) {
        int t=i;
        while (t>0) {
            if (a[t]<a[t-1]) {
                int tmp;
                tmp=a[t];
                a[t]=a[t-1];
                a[t-1]=tmp;
            }
            t--;
        }
        rep(j,n) printf("%d%c",a[j],j<n-1?' ':'\n');
    }
    return 0;
}



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b) swap(a, b);

    if(a < c && c < b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	double ans = 0.0; 
	for(int i = 0; i < N; i++){
		string u; 
		double x; 
		cin >> x >> u; 
		if(u == "JPY") ans += x; 
		else ans += x * 380000.0; 
	}
	cout.precision(17); 
	cout << ans << endl; 
}

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

int main()
{
	int n;
	long long int v = 100000;

	cin >> n;
	for (int i = 0; i < n; i++) {
		v += v / 20;
		if (v % 1000) {
			v -= v % 1000;
			v += 1000;
		}
	}
	cout << v << endl;
}


Measured memory_bytes: 1156
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/01 20:29:36 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=200010;
int dp[maxn][20];
int lg[maxn];

void init(int n)
{
    lg[0]=-1;
    for (int i=1;i<=n;++i)
    {
        lg[i]=((i&(i-1))==0)?lg[i-1]+1:lg[i-1];
    }
    for (int j=1;j<=lg[n];++j)
    {
        for (int i=1;i+(1<<j)-1<=n;++i)
        {
            dp[i][j]=min(dp[i][j-1],dp[i+(1<<(j-1))][j-1]);
        }
    }
}

int rmq(int x,int y)
{
    int len=lg[y-x+1];
    return min(dp[x][len],dp[y-(1<<len)+1][len]);
}

int queryl(int l,int r,int x)
{
    if (l==r) return -1;
    if (rmq(l,r)==x) return -1;
    while (l+1<r)
    {
        int mid=(l+r)/2;
        if (rmq(mid,r)<x) l=mid;
        else r=mid;
    }
    return l;
}

int queryr(int l,int r,int x)
{
    if (l==r) return -1;
    if (rmq(l,r)==x) return -1;
    while (l+1<r)
    {
        int mid=(l+r)/2;
        if (rmq(l,mid)<x) r=mid;
        else l=mid;
    }
    return r;
}

int main()
{
    int n;
    scanf("%d",&n);
    for (int j=1;j<=n;++j)
    {
        scanf("%d",&dp[j][0]);
    }
    init(n);
    LL ans=0;
    for (int j=1;j<=n;++j)
    {
        int l=queryl(1,j,dp[j][0]);
        int r=queryr(j,n,dp[j][0]);
        if (l==-1) l=0;
        if (r==-1) r=n+1;
        l=j-l;
        r=r-j;
        ans+=(LL)dp[j][0]*l*r;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16640
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

long long N, M, H,K,W,re;
long long A[200001];
long long C[200001];
bool B[200001] = {};
string S[100];
bool OK = true;
bool f=false;
vector <long long>vl;

int main() {
	cin >>N;
	M = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		M += A[i];
		if (i > 0) {
			if (A[i] > A[i - 1]) {
				M -= A[i-1];
				if (A[i] - A[i - 1] >= 2) {
					f = true;
				}
			}
		}
	}

	if (f || A[0]!=0) {
		cout << -1 << endl;
	}
	else {
		cout << M << endl;
	}

	
	return 0;
}


Measured memory_bytes: 1792
import math

a,b,x = map(int,input().split())

q = a*b*b/2/x
w = (2*b-2*x/a**2)/a

if 2*x/a/b <= a:
  print(math.degrees(math.atan(q)))
else:
  print(math.degrees(math.atan(w)))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;
typedef pair<int,int> P;
int N;
P A[500000];
bool compare_y(P a, P b) {
  return a.second < b.second;
}

int closest_pair(P *a ,int n) {
  if(n <= 1) return 2 << 27;
  int m = n /2;
  int x = a[m].first;
  int d = min(closest_pair(a,m),closest_pair(a + m, n - m));
  inplace_merge(a, a + m, a + n, compare_y);

  vector<P> b;
  for(int i = 0; i < n; i++) {
    if(abs(a[i].first - x) >= d) continue;
    for(int j = 0; j < b.size(); j++) {
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break;
      d = min(d,(dx * dx + dy * dy));
    }
    b.push_back(a[i]);
  }
  return d;
}

void solve() {
  sort(A,A + N);
  printf("%d\n", closest_pair(A,N));
}

int main() {
  cin >> N;
  for(int i = 0; i < N; i++) {
    int x, y;
    cin >> x;
    cin >> y;
    A[i] = P(x,y);
  }
  solve();

}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int i, v, w; };

int main() {
	int M; cin >> M;
	vector<int> dp(M, INF);
	queue<int> q;
	for (int d = 1; d < 10; d++) {
		dp[d % M] = min(dp[d % M], d);
		q.push(d % M);
	}
	while (!q.empty()) {
		int x = q.front(); q.pop();
		rep(d, 10) {
			int y = (x * 10 + d) % M;
			if (dp[y] > dp[x] + d) {
				dp[y] = min(dp[y], dp[x] + d);
				q.push(y);
			}
		}
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 2176
import math
from decimal import *

nums = [int(i) for i in input().split()]
a = nums[0]
b = nums[1]
h = nums[2]
m = nums[3]
l = 0

getcontext().prec = 11
angleh = Decimal(2 * math.pi * (h / 12.0 + m / 60.0 / 12.0))
anglem = Decimal(2 * math.pi * m / 60.0)


angle = anglem - angleh
getcontext().prec = 28
l = a ** 2 + b ** 2 - 2 * a * b * Decimal(math.cos(angle))
print(Decimal(l).sqrt())


Measured memory_bytes: 10344
#define ll long long int
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
using namespace std;
const ll y = 1000;
const ll INF = y*y*y*y*y*y;
int main() {
	ll n, w;
	cin >> n >> w;
	vector <pair<ll, ll>> a(n);
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second; sum += a[i].second;
	}
	vector <vector <ll>> dp(n + 1, vector <ll>(sum + 1, INF));
	dp[0][0] = 0;
	int max1 = 0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 0; j <= sum; j++) {
			if (j >= a[i - 1].second) { dp[i][j] = min(dp[i][j], dp[i-1][j - a[i - 1].second] + a[i - 1].first); }
			dp[i][j] = min(dp[i][j],dp[i - 1][j]);
			if (j > max1 && dp[i][j] <= w) { max1 = j; }
		}
	}
	cout << max1;
}

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

int main(){
    long long w,h,x,y;
    cin>>w>>h>>x>>y;
    long long s=w*h;
    printf("%lld",s/2);
    if(s%2==1)
        printf(".500000");
    else
        printf(".000000");
    if(x*2==w && y*2==h)
        printf(" 1");
    else
        printf(" 0");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int h[N];
int main(){
	int n;
	cin>>n;
	int ans=0,maxn=0;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(i!=0 && h[i]<=h[i-1]){
			ans++;
		}
		else{
			ans=0;
		}
		maxn=max(maxn,ans);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3000050;
int a[N], b[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt2 = 0;
    int cnt1 = 0;
    int cnt0 = 0;
    for (int i = 0; i < n - 1; i++){
        a[i] = abs((int)s[i + 1] - s[i]);
        if (a[i] == 2) cnt2++;
        if (a[i] == 0) cnt0++;
        if (a[i] == 1) cnt1++;
    }
    n--;
    if (cnt1 == 0){
        for (int i = 0; i <= n; i++){
            int x = 2;
            while(x <= i){
                b[i] += i / x;
                x += x;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++){
            a[i] /= 2;
            int z = b[n - 1] - b[i] - b[n - i - 1];
            if (z == 0) ans ^= a[i];
        }
        cout << 2 * ans;
        return 0;
    }
    if (a[0] == 0 && cnt2 == n - 1){
        cout << 2;
        return 0;
    }
    if (a[0] == 2 && cnt0 == n - 1){
        cout << 2;
        return 0;
    }
    for (int i = 0; i <= n; i++){
        int x = 2;
        while(x <= i){
            b[i] += i / x;
            x += x;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        int z = b[n - 1] - b[i] - b[n - i - 1];
        if (z == 0) ans ^= a[i];
    }
    cout << ans % 2;
}


Measured memory_bytes: 19740
import java.util.HashSet;
import java.util.Set;

public class Main {

  private static void solve() {

    char[] s = ns();
    Set<Character> set = new HashSet<>();
    for (char c : s) {
      set.add(c);
    }
    if (set.size() >= 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

vector<pair<long long, int>> factor(long long x) {
    vector<pair<long long, int>> res;
    for (long long i = 2; i*i <= x; ++i) {
        if (x % i) continue;
        res.emplace_back(i, 0);
        while (x % i == 0) {
            x /= i;
            res.back().second++;
        }
    }
    if (x != 1) res.emplace_back(x, 1);
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    auto f = factor(n);
    cout << n << ":";
    for (auto&& p : f) {
        rep(i, p.se) cout << " " << p.fi;
    }
    cout << endl;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int N,K;
void AdjustDown(int *a, size_t root, size_t size)//下调
{//小堆
	size_t parent = root;
	size_t child = parent * 2 + 1;
	while (child < size)
	{
		if (child + 1 < size && a[child] > a[child + 1])
		{
			++child;
		}
		if (a[parent] > a[child])
		{
			swap(a[parent], a[child]);
			parent = child;
			child = parent * 2 + 1;
		}
		else//注意不满足交换条件时跳出本次循环
		{
			break;
		}
	}
}
//void CreateRetPacket(vector<int>& moneys)//创建N个数
//{
//	srand((unsigned int)time(NULL));
//	//srand(time(0));
//	moneys.reserve(N);
//	for (size_t i = 0; i<N; i++)
//	{
//		moneys.push_back(rand() % 1000);//产生N个随机值
//	}
//	for (size_t i = K; i < N; ++i)
//	{
//		moneys[i] *= 100;
//	}
//}
long long GetTopk(const vector<int>& moneys, int n, int k)//N个数中找最大的前k个数--小堆实现
{
	long long ans=0;
	assert(n>k);
	int *TopkArray = new int[k];//通过前k个元素建立含有k个元素的堆
	for (size_t i = 0; i < k; i++)
	{
		TopkArray[i] = moneys[i];
	}
	for (int i = (k - 2) / 2; i >= 0; --i)//建小堆
	{
		AdjustDown(TopkArray, i, k);
	}
	//从第k个元素开始到第n个元素分别与堆顶元素进行比较，较大数据入堆顶，再对整个堆进行下调，使堆顶存放最小元素（小堆）
	for (size_t i = k; i < n; ++i)
	{
		if (moneys[i]  > TopkArray[0])
		{
			TopkArray[0] = moneys[i];
			AdjustDown(TopkArray, 0, k);
		}
	}
	size_t count = 0;
	for (size_t i = 0; i < k; ++i)//打印k个最大数据，即堆中所有元素
	{
		ans+=TopkArray[i];
	}
	delete[] TopkArray;//注意释放TopkArray所占的内存
	TopkArray = NULL;
	return ans;
}
int main()
{
	long long sum=0;
	vector<int> v;
	cin>>N>>K;
	for (int i=1;i<=N;i++)
	{
		int x;
		cin>>x;
		v.push_back(x);
	}
	if (K>=N)
	{
		cout<<0;
		return 0;
	}
	for (int i=0;i<N;i++) sum+=v[i];
	cout<<sum-GetTopk(v,N,K);
	return 0;
}

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

int main()
{
    //input and processing part
    int input,coordinate,max = 0,min = 1000;
    cin>>input;
    
    for(int i = 0; i < input; i++)
    {
        cin>>coordinate;
        if(max < coordinate) max = coordinate;
        if(min > coordinate) min = coordinate;
    }

    //output part
    cout<<max - min;
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

class mycmp{
public:
	bool operator() (const P p1,const P p2){
		return p1.second < p2.second;
	}
};

int main(){

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;

			vector<P> order;
			map<char,int> data;		
			set<char> alpha;

			for(int j=0;j<str.size();j++){
				if(isalpha(str[j])){
					alpha.insert(str[j]);
				}
			}

			int j=0;
			for(set<char>::iterator it = alpha.begin(); it != alpha.end(); it++){
				data[*it]=j++;
			}

			for(int k=0;k<alpha.size();k++){
				for(int j=0;j+3<str.size();j+=3){
					string tmp = str.substr(j,4);
					if(tmp.substr(1,2)=="<-"){
						if(data[tmp[0]] < data[tmp[3]]){
							swap(data[tmp[0]],data[tmp[3]]);
						}
					}
					else if(tmp.substr(1,2)=="->"){
						if(data[tmp[0]] > data[tmp[3]]){
							swap(data[tmp[0]],data[tmp[3]]);
						}
					}
				}
			}

			for(map<char,int>::iterator it = data.begin(); it != data.end();it++){
				order.push_back(P(it->first,it->second));
			}

			sort(order.begin(),order.end(),mycmp());

			for(vector<P>::iterator it = order.begin(); it != order.end();it++){
				cout << it->first;
			}

			cout << endl;
		}
	}
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    int n;
    cin >> n;
    map <int, int> track;
    int arr[n+1];
    for (int i=0; i<n; i++) {
        cin >> arr[i];
        track[arr[i]]++;
    }
    ll ans = 0;
    auto it = track.begin();
    while (it != track.end()) {
        ll v = it->second;
        if (v >= 2) {
            ans += (v*(v-1)/2);
        }
        it++;
    }
    for (int i=0; i<n; i++) {
        ll v = track[arr[i]];
        ll temp = v*(v-1)/2;
        if (temp < 0)
            temp = 0;
        v--;
        ll t2 = v*(v-1)/2;
        if (t2 < 0)
            t2 = 0;
        cout << ans-temp+t2 << endl;
    }
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 8320
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if (k > a) {
		ans += a;
		k -= a;
	} else {
		cout << k << endl;
		return;
	}
	if (k > b) {
		k -= b;
	} else {
		cout << ans << endl;
		return;
	}
	cout << ans - k << endl;
}
int32_t main() {
	BOLT;
	solve();
}

Measured memory_bytes: 3652
N, Q = map(int, input().split())

row = [N - 2] * (N + 2)
col = [N - 2] * (N + 2)
ans = (N - 2)**2

miRow = N
miCol = N

for _ in range(Q):
    q, x = map(int, input().split())

    if q == 1:
        for i in range(x, miRow + 1):
            row[i] = min(row[i], miCol - 2)
        miRow = min(x, miRow)
        ans -= row[x]

    if q == 2:
        for i in range(x, miCol + 1):
            col[i] = min(col[i], miRow - 2)
        miCol = min(x, miCol)
        ans -= col[x]

print(ans)


Measured memory_bytes: 23196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long A = scanner.nextLong();
        long B = scanner.nextLong();

        long ans = 0;
        if(A %2 == B %2) {
            ans = (Math.max(A, B) - Math.min(A, B)) /2;
        }else{
            // min length
            long min = Math.min(A-1, N-B);
            ans = min + 1 + ((Math.max(A, B) - Math.min(A, B)) /2);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	string q;
	set<string> s;
	cin >> n;
	while(n--)
	{
		cin >> q;
		s.insert(q);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19232
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#define ll long long 
using namespace std;

int main(){
	ll k, t;
	ll a[101];
	ll max = 0;
	cin >> k >> t;
	for (int i = 0; i < t; ++i)
	{
		cin >> a[i];
		if(a[i] > max){
			max = a[i];
		}
	}
	if(max > k/2){
		if(k % 2 == 0){
			cout << 2 * (max - k/2) - 1 << endl;
		}else{
			cout << 2 * (max - k/2 - 1) << endl; 
		}
	}else{
		cout << 0 << endl;
	}

	
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

typedef long long ll;

vector<ll>si;
vector<ll>ti;

#define INF 1000000000000000ll


ll calc(vector<ll>& s, vector<ll>& t, ll x) {

	ll ans = INF;

	for (int i = 0; i < 2; i++) {
		vector<ll> &a = (i == 0) ? s : t;
		vector<ll> &b = (i == 0) ? t : s;

		for (int j = 0; j < 2; j++) {
			int apos = lower_bound(a.begin(), a.end(), x) - a.begin() - j;
			ll ax = a[apos];
			for (int k = 0; k < 2; k++) {
				int bpos = lower_bound(b.begin(), b.end(), x) - b.begin() - k;
				ll bx = b[bpos];
				ll d = max(x - ax, ax - x) + max(ax - bx, bx - ax);
				if (ans > d) { ans = d; }
			}
		}
	}
	return ans;

}
int main() {

	int A, B, Q;

	scanf("%d %d %d", &A, &B, &Q);

	int i;

	si.push_back(-INF);

	for (i = 0; i < A; i++) {
		ll s;
		scanf("%lld", &s);
		si.push_back(s);
	}
	si.push_back(INF);
	ti.push_back(-INF);
	for (i = 0; i < B; i++) {
		ll t;
		scanf("%lld", &t);
		ti.push_back(t);
	}
	ti.push_back(INF);

	sort(si.begin(),si.end());
	sort(ti.begin(),ti.end());

	for (i = 0; i < Q; i++) {
		ll xi;
		scanf("%lld", &xi);
		printf("%lld\n", calc(si, ti, xi));
	}

	return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  long double s=w/2*h;
  
  int other=0;
  if(x==w/2 && y==h/2)other=1;

  cout<<s<<" "<<other<<"\n";
  
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){
  int n; cin>>n;
  int a[n];
  int ans=0;

  rep(i,n){
    cin>>a[i];

    if((i+1)%2!=0 && a[i]%2!=0) ans++;
  }

  cout<<ans<<"\n";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}

/* Cherry, Please look at the stuff down */

/* 1) Did you checked special case (n==1)?
   2) Look at the code once, check whether there are some typos
   3) Cherry! Is contest over ??
   4) Do something instead of doing notthing
*/


Measured memory_bytes: 3644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    println!("{}", s.iter().filter(|&&c| c == '1').count());
}


Measured memory_bytes: 4352
///who is the king ??? *** << t.mohammad >> *** ///
/*
                  00                                                                                                            00
                 00                               00                                                                           00
            0000000000                           00                                                                           00
           0000000000   000       000           00                        000       000  000       000                       00
              00       0000     0000           00         000000         0000     0000  0000     0000   000000              00
             00       00 00   00 00    000    00        00000000        00 00   00 00  00 00   00 00  00000000       00000000
            00       00  00 00  00   00000   000000    00    000       00  00 00  00  00  00 00  00  00    000     0000000000
           00       00   000   00  00   00  00000000  00    0000      00   000   00  00   000   00  00    0000    00     0000
          00       00         00  00   00  00    00  00    00 00     00         00  00         00  00    00 00   00     00 00
         00  00   00         00   00000   00    00  00000000  00    00         00  00         00  00000000  00  000000000  00
        00  00   00         00    000    00    00   000000    00   00         00  00         00   000000    00  0000000    00
*/
#include <bits/stdc++.h>
using namespace std ;
typedef long long int ll;
typedef long double dou ;
typedef pair<ll , ll> pii;
typedef map<ll, bool> mib;
typedef pair<ll, bool> pib;
typedef map<ll , ll> mii;
#define wh while
#define str string
#define vec vector
#define fori(a1 , a2 , a3) for(ll i = a1 ; i < a2 ; i = i + a3)
#define for_i(b1 , b2 , b3) for(ll i = b1 ; i >= b2 ; i = i - b3)
#define forj(c1 , c2 , c3) for(ll j = c1 ; j < c2 ; j = j + c3)
#define for_j(d1 , d2 , d3) for(ll j = d1 ; j >= d2 ; j = j - d3)
#define fore(e1 , e2 , e3) for(ll e = e1 ; e < e2 ; e = e + e3)
#define for_e(f1 , f2 , f3) for(ll e = f1 ; e >= f2 ; e = e - f3)
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
#define setp(t) cout << setprecision(t) << fixed ;
vec <ll> v , v1 ;
int main(){
	fast ;
	ll n , p ;
	cin >> n >> p ;
	for(ll i = 2 ; i * i <= p ; i++)
	{
		if (p % i == 0)
		{
			v.pb(i) ;
			ll f = 0 ;
			wh(p % i == 0)
			{
				p = p / i ;
				f++ ;
			}
			v1.pb(f) ;			
		}

	}
	ll k = 1 ;
	if (p > 1)
	{
		v.pb(p) ;
		v1.pb(1) ;
	}
	fori(0 , v1.size() , 1)
	{
		k = k * (pow(v[i] , (v1[i] / n))) ;
	}
	cout << k ;
}


Measured memory_bytes: 256