akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(int n) {
        const long long MOD = 1000000007;
        string t = "AGC";
        string A = "ACGT";

        int MX = 4;
        auto good = [&](string& s) {
            if (s.length() < 3) {
                return true;
            }
            if (s.length() <= MX) {
                if (s.find(t) != string::npos) {
                    return false;
                }
                int n = s.length();
                for (int i = 0; i + 1 < n; ++i) {
                    swap(s[i], s[i + 1]);
                    if (s.find(t) != string::npos) {
                        return false;
                    }
                    swap(s[i], s[i + 1]);
                }
                return true;
            }
            return false;
        };

        vector<string> que;
        que.emplace_back("");
    
        for (int i = 0; i < que.size(); ++i) {
            string s = que[i];
            // cout << s << endl;
            for (auto c : A) {
                string ns = s + c;
                if (good(ns)) {
                    que.emplace_back(ns);
                }
            }
        }
        int m = que.size();
        vector<vector<int>> nexts(m, vector<int>(4, -1));
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < A.length(); ++j) {
                string ns = que[i];
                ns += A[j];
                if (ns.length() > MX) {
                    ns = ns.substr(1);
                }
                for (int k = 0; k < m; ++k) {
                    if (que[k] == ns) {
                        nexts[i][j] = k;
                        break;
                    }
                }
            }
        }
        vector<long long> dp(m + 1, 0);
        dp[0] = 1;

        auto ndp = dp;
        for (int i = 0; i < n; ++i) {
            fill(ndp.begin(), ndp.end(), 0);
            for (int j = 0; j < m; ++j) {
                if (dp[j] == 0) {
                    continue;
                }
                for (int k = 0; k < A.length(); ++k) {
                    int nj = nexts[j][k];
                    if (nj >= 0 && nj < m) {
                        (ndp[nj] += dp[j]) %= MOD;
                    }
                }
            }
            swap(dp, ndp);
        }

        long long res = 0;
        for (int i = 0; i < m; ++i) {
            res += dp[i];
        }
        res %= MOD;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    Solution sol;
    cout << sol.solve(n) << "\n";


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    #ifdef UJJWAL_HOME
        freopen("000.txt","r",stdin);
    #endif

    ll n,i,j,k,t,a[100001];
    map<ll,ll> m;
    cin>>n;

    fo(i,n)
    {
        cin>>a[i];
        m[a[i]]++;
    }

    sort(a,a+n);
    ll l=0,r=0;
    fo(i,n)
    {
        if(m[a[n-i-1]]>1)
        {
            m[a[n-i-1]]-=2;
            l=a[n-i-1];
            break;
        }
    }
    fo(i,n)
    {
        if(m[a[n-i-1]]>1)
        {
            m[a[n-i-1]]-=2;
            r=a[n-i-1];
            break;
        }
    }

    cout<<l*r;
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k,p;

  cin>>n>>k;
  p=n%k;
  if(p==0)
    cout<<"0\n";
  else
      cout<<min(p,abs(p-k))<<"\n";

  return 0;
}


Measured memory_bytes: 256
package main

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

var (
	edges  map[int]map[int]int
	colors []int
)

func dfs(v, d int) {
	if colors[v-1] > 0 {
		return
	}
	colors[v-1] = d + 2
	for u, w := range edges[v] {
		if w > 0 {
			dfs(u, (d+w)%2)
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	edges = make(map[int]map[int]int, n)
	for i := 1; i <= n; i++ {
		edges[i] = make(map[int]int)
	}
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n-1; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		w, _ := strconv.Atoi(sc.Text())
		edges[u][v] = w
		edges[v][u] = w
	}

	colors = make([]int, n)
	dfs(1, 0)

	for _, v := range colors {
		fmt.Println(v - 2)
	}
}


Measured memory_bytes: 40960
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
vector<int> v(n+1),visited(n+1,0),dist(n+1,0);
FOR(i,1,n+1) cin>>v[i];
int count = 0,start=1;
while(visited[start]!=1) {
    dist[start] = count;
    visited[start] = 1;
    start = v[start];
    count++;
}
if(visited[1] && visited[2]) cout<<dist[2]-dist[1];
else cout<<-1;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 2560
n = int(input())
r = 0

for i in range(n):
    c = 0

    for j in range(i + 1):
        if (i + 1) % (j + 1) == 0:
            c += 1

    if (i + 1) % 2 != 0 and c == 8:
        r += 1

print(r)


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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> arr;
    for (int i = 0; i < N; i++) {
        string n;
        int s;
        cin >> n >> s;
        arr.push_back(make_pair(make_pair(n, s * -1), i + 1));
    }
    sort(arr.begin(), arr.end());

    for (auto& var: arr) {
        cout << var.second << endl;
    }

    return 0;
}


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

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

ll dp[200005]; // dp[i] := i 番目まで食べたときの摂取カロリー
ll dpmax[200005];
ll dp2[200005];
ll dp2max[200005];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,C;
    cin >> N >> C;
    vector<ll> x(2*N+1),v(2*N+1);
    rep(i,N){
        cin >> x[i] >> v[i];
        x[i+N] = C - x[i];
        v[i+N] = v[i];
    }
    //0からスタートして右に行くか
    //Nからスタートして左に行くかの2通り試す
    ll ans = 0;
    //0からスタートして右に行く場合dp[i]:=i個取った時の摂取カロリー
    rep(i,N){
        if(i==0){
            dp[1] = v[0] - x[0];
            dpmax[1] = max(0LL,dp[1]);
        }
        else{
            dp[i+1] = dp[i] + v[i] - (x[i]-x[i-1]);
            dpmax[i+1] = max(dp[i+1],dpmax[i]);
        }
    }
    //Nからスタートして左に行く
    //dp2[i] := 左にi個取った場合の摂取カロリー
    for(int i=2*N-1;i>=N;i--){
        if(i==(2*N)-1){
            dp2[2*N - i] = v[i] - x[i];
            dp2max[2*N-i] = max(0LL,dp2[2*N-i]);
        }else{
            dp2[2*N-i] = dp2[2*N-i-1] + v[i] - (x[i]-x[i+1]);
            dp2max[2*N-i] = max(dp2[2*N-i],dp2max[2*N-i-1]);
        }
    }
    for(int i=0;i<=N;i++){
        ll t = dpmax[i] + dp2max[N-i];
        ll dis  = 0;
        if(i>0)dis = x[i-1];
        ans = max(ans,dpmax[i]+dp2max[N-i]-dis);
    }
    for(int i=0;i<=N;i++){
        ll t = dpmax[N-i] + dp2max[i];
        ll dis  = 0;
        if(i>0)dis = x[2*N-i];
        ans = max(ans,t-dis);
    }
    cout << ans << endl;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if(10 > A & A > 0 & 10 > B & B > 0){
        cout << A*B << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

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


void solve(long long N, std::vector<std::string> s, std::vector<long long> t, std::string X){
    ll ans = 0;
    bool sleep = false;
    REP(i, N){
        if(sleep){
            ans += t.at(i);
        }
        if(s.at(i) == X){
            sleep = true;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
        scanf("%lld",&t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


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

using ll = long long;
using namespace std;

int main() {
  int n, k, d;
  int as[105] = {};
  int index;
  cin >> n >> k;
  rep(i, k) {
    cin >> d;
    rep(j, d) {
      cin >> index;
      as[index]++;
    }
  }
  int count = 0;
  for (int j = 1; j <= n; j++) {
    if (as[j] == 0) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

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

  int n, x;
  cin >> n >> x;
  vector<int> d(n+1);
  int ans = n + 1;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    int l;
    cin >> l;
    d[i+1] = d[i] + l;
    if (!flag && d[i+1] > x) {
      ans = i + 1;
      flag = true;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;

int main()
{
	migmig ;
int n ; 
cin>> n ; 
int a[n] ; 
int sum = 0 ; 
for(int i = 0 ; i < n ; i++) cin>>a[i] ; 
sort( a ,a + n ) ;
for(int i = 0 ; i < n-1 ; i++) sum += a[i] ;  
if(sum > a[n-1]) cout<<"Yes" ; 
else cout<<"No" ; 
}

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



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

int main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int tate=0,yoko=0;
    for (int i = 0; i <= h; i+=a) {
        tate=i;
    }
    for (int i = 0; i <= w; i+=b) {
        yoko=i;
    }
    cout<<h*w-tate*yoko<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
#include <unordered_map>
#include <sstream>
#include <istream>
#include <iterator>
#include <numeric>
using namespace std;

int main()
{
	int N, T, A;
	cin >> N >> T >> A;

	int ans = 1;
	double err = 1e9;
	for (int i = 1; i <= N; i++)
	{
		int h;
		cin >> h;

		auto t = T - 0.006 * h;
		auto curr_err = abs(A - t);
		if (curr_err < err)
		{
			ans = i;
			err = curr_err;
		}
	}

	cout << ans;
}

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

#define lli long long int
#define ld long double
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

////////////////////////////////////////////////////////    By: Umang Srivastava

/*
lli extgcd(lli a, lli b, lli *x , lli *y)
{
	if(a==0)
	{
		*x=0;
		*y=1;
		return b;
	}
	lli x1 , y1;
	lli gcd = extgcd(b%a , a , &x1 , &y1);
	*x=y-(b/a)*x1;
	*y=x1;
	return gcd;
}

lli modinv(lli a, lli m)
{
	lli x,y;
	lli g = extgcd(a,m,&x,&y);
	if(g!=1)
		return -1;
	return (x%m+m)%m;
}

lli moddiv(lli a, lli b, lli m)
{
	a=a%m;
	lli inv = modinv(b,m);
	if(inv!=-1)
		return ((a*inv + m)%m);
	else
		return -1;
}
*/
// lli binpow(lli a, lli b, lli m)
// {
// 	lli res=1;
// 	a=a%m;
// 	while(b>0)
// 	{
// 		if(b & 1)
// 		{
// 			res = (res * a)%m;
// 		}
// 		b=b>>1;
// 		a=(a*a)%m;
// 	}
// 	return res;
// }
/*
lli gcd(lli a, lli b)
{
    // if(b<a)
    // {
    //     lli t=a;
    //     a=b;
    //     b=t;
    // }
    if(a==0)
        return b;
    return gcd(b%a,a);
}
*/
/////////////////////////////////////////////////////////

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c, b*d)))<<endl;

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << "\t";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> a;
    vector<ll> sum;
    ll sum_cnt = 0;
    sum.push_back(0);
    rep(i, n){ 
        int tmp; cin >> tmp; 
        a.push_back(tmp);    
        sum_cnt += a[i];
        sum.push_back(sum_cnt);
    }
    vector<ll> sum_list;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n+1; j++)
        {
            sum_list.push_back(sum[j]-sum[i]);
        }        
    }
    //show(sum);
    //show(sum_list);

    vector<bool> use(sum_list.size(), false);
    int max_bit = 0;
    for(int bit = 40; bit >= 0; bit--){
        int cnt = 0;
        int cnt_true = 0;
        rep(i, sum_list.size()){
            if (((sum_list[i]>>bit)&1) == 1) {
                cnt++;
                if (use[i]) cnt_true++;
            }
        }
        if (cnt < k){
            continue;
        } else {
            if (max_bit == 0){
                max_bit = bit;
                rep(i, sum_list.size()){
                    if ((sum_list[i]>>bit)&1 == 1) use[i] = true;
                }
            } else {
                if (cnt_true >= k){
                    rep(i, sum_list.size()){
                        if ((((sum_list[i]>>bit)&1) == 0) && use[i]) use[i] = false;
                    }
                }
            }
        }
        //rep(i, sum_list.size()) cout << use[i] << "\t";
        //cout << bit << ":"<< cnt_true << endl;
    }
    ll sum_bit = (1ll<<40) - 1;
    rep(i, sum_list.size()){
        if (use[i]) sum_bit&=sum_list[i];
    }
    cout << sum_bit << endl;
}


Measured memory_bytes: 6264
N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
E = Array.new(1001, 0)

sum = 0

1.upto(1001) do |n|
  sum += n

  E[n] = Rational(sum, n)
end

RUI = [0]

P.each do |v|
  RUI << RUI.last + E[v]
end

ans = 0

(N - K + 1).times do |i|
  rate = RUI[i + K] - RUI[i]

  ans = rate if ans < rate
end

puts ans.to_f


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

int main() {
  int A, B, C ,D;
  cin >> A >> B >> C >> D;

  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else if ((A + B) < (C + D)){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int mxn = 1e6+5;

void solve()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> freq(mxn);
    for (int i=0; i<n; i++) {
        cin>>a[i];
        freq[a[i]]++;
    }   
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (a[i]==1 && freq[1]==1) {
            cnt++;
            continue;
        }
        if (freq[a[i]]>1 || freq[1]>=1) {
            continue;
        }
        bool ok = true;
        for (int j=2; j*j<=a[i]; j++) {
            if (a[i]%j==0 && (freq[j] || freq[a[i]/j])) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cnt++;
        }
    }
    cout << cnt << "\n";
}

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

Measured memory_bytes: 7928
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char S[100];
    scanf("%s", S);
    int a;
    a = strlen(S);
    int i;
    i = 0;
    while (i < a)
    {
        i++;
        cout << "x";
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
		}
		boolean approved = true;
		for(int a : A){
			if(a % 2 == 0){
				if(a % 3 == 0 || a % 5 == 0){
					
				}else{
					approved = false;
					break;
				}
			}
		}
		if(approved){
			System.out.println("APPROVED");
		}else{
			System.out.println("DENIED");
		}
	}
}


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

#define INFL (1LL << 60)

using namespace std;

typedef long long ll;

int main() {
    ll n, a, m = INFL, ans = 0, cnt = 0;
    scanf("%lld", &n);
    for (ll i = 0; i < n; ++i) {
        scanf("%lld", &a);
        if (a < 0) {
            ++cnt;
            a = -a;
        }
        ans += a;
        m = min(m, a);
    }
    printf("%lld\n", ans - (cnt % 2 ? m * 2 : 0));
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int ans=0;
	char now=S[0];
	rep1(i,S.size()-1){
		if(S[i]!=now){
			ans++;
			now=S[i];
		}
	}
	prin(ans);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  ll m = 1000,k;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n-1){
    if(a[i] < a[i+1]){
      k = m/a[i];
      m += k*(a[i+1]-a[i]);
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 3568
# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(102):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)



Measured memory_bytes: 9188
#include <stdio.h>
long m,n;
long a[500000];
long b[500000];
int main(){
	scanf("%li %li",&n,&m);
	for (int i=1;i<=m;i++)
		scanf("%li %li",&a[i],&b[i]);
	sort(1,m);
	long x=n+1;
	long ans=0;
	for (int i=m;i>=1;i--)
		if (b[i]<x){
			ans++;
			x=a[i]+1;
		}		
	printf("%li",ans);
}
int sort(long x,long y){
	long l=x;
	long r=y;
	long m=a[(l+r)/2];
	long bm=b[(l+r)/2];
	while (l<r){
		while (a[l]<m||((a[l]==m)&&(b[l]<bm))) l++;
		while (a[r]>m||((a[r]==m)&&(b[r]>bm))) r--;
		if (l<=r){
			long z=a[l];
			a[l]=a[r];
			a[r]=z;
			z=b[l];
			b[l]=b[r];
			b[r]=z;
			l++;
			r--;
		}

	}
	if (l<y) sort(l,y);
	if (x<r) sort(x,r);
	return(0);
}

Measured memory_bytes: 5120
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const int N = 2e5 + 5;
ll sum[N];


bool chk(int a, int b, int c) {
    ll diff = llabs(sum[c] - sum[b] - sum[b] + sum[a]);
    b++;
    ll diff1 = llabs(sum[c] - sum[b] - sum[b] + sum[a]);
    if(diff1 < diff) return true;
    return false;
}

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", sum + i);
        sum[i] += sum[i - 1];
    }

    ll res = 1e18;
    for(int a = 1, b = 2, c = 3; b <= n - 2; b++) {
        while(chk(0, a, b)) a++;
        while(chk(b, c, n)) c++;
        ll mx = max({sum[a], sum[b] - sum[a], sum[c] - sum[b], sum[n] - sum[c]});
        ll mn = min({sum[a], sum[b] - sum[a], sum[c] - sum[b], sum[n] - sum[c]});
        res = min(mx - mn, res);
    }

    printf("%lld\n", res);
}

Measured memory_bytes: 1792
from bisect import bisect_right
exps = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841,
900, 961, 1000]
print(exps[bisect_right(exps, int(input())) - 1])

Measured memory_bytes: 3060
function Main(input) {
	var day = parseInt(input, 10);
    if (day === 22) {
      console.log('Christmas Eve Eve Eve');
    } else if (day === 23) {
      console.log('Christmas Eve Eve');
    } else if (day === 24) {
      console.log('Christmas Eve');
    } else if (day === 25) {
      console.log('Christmas');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20936
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <stdio.h>
//#define int long long
using namespace std;
#define loop(n) for(int i=0;i<n;i++)
#define endl '\n'
#define OnlineJudgec
#define F first
#define S second
#define  precision(n)  cout << fixed << setprecision(n)
#define clr(v,d ) memset(v, d, sizeof(v))
typedef long long ll;
typedef vector<int> vi;
void init()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    cout.tie(0);
    #ifdef OnlineJudge
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}
ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.
ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}
ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int dr[] = {0,0,0,1,1,1,-1,-1,-1};
int dc[] ={-1,0,1,-1,0,1,-1,0,1};
/// <<------------------------------------------------------------------------------>>
const int N = 100009;
int n,m;
int MOD = int(1e9) + 7;
int dp[N];
vector<vi>g(N);
int dfs(int node)
{
    int &rst = dp[node];
    if(~rst)
        return rst;
    rst  = 0;
    for(int neighbor : g[node])
    {
        rst =max(rst , 1 + dfs(neighbor));
    }
    return rst;
}
/// <<------------------------------------------------------------------------------>>
int main()
{
    init();
    clr(dp,-1);
    cin >> n >> m;
    loop(m)
    {
        int l ,r;
        cin >> l >> r;
        g[l].push_back(r);
    }
    int ans = 0;
    for(int i = 1 ;i <= n;i++)
    {
        ans = max(ans,dfs(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7424
n = int(input())
L = [input().split() for _ in range(n)]
li = []
for i,v in enumerate(L):
    li.append((i+1,v[0],int(v[1])))
li.sort(key = lambda x:(x[1],-x[2] ))
for i in range(n):
    print(li[i][0])

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

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 11; i <= n; i++){
        if(i % 2 == 0) continue;

        int cnt = 1;
        for(int j = 2; j <= i; j++){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(int argc, char* argv[])
{
  int i, x;
  i = 1;
  do{
    scanf("%d", &x);
    if(x != 0){
      printf("Case %d: %d\n", i, x);
      i++;
    }
  }while(x != 0);

  return(0);
}

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

void debug(const vector<array<int64_t, 2>> &A){
    for (const auto &a: A)
        cout << a[1] <<  " ";
    cout << endl;
    for (const auto &a: A)
        cout << a[0] <<  " ";
    cout << endl;
}

int main(){
    int64_t n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int64_t> A(n);
    for (int i = 0; i < n; i++){
        cin >> A[i];   
    }
    sort(A.begin(), A.end(), greater<int64_t>());
    auto check = [&](auto k){
        if (A[p - 1] > A[k] + m)
            return false;
        auto remain = m * (v - (n - k));
        if (remain <= 0)
            return true;
        int64_t border = A[k] + m;
        int i = k - 1;
        while (remain > 0){
            if (i < p - 1)
                return false;
            remain -= min(m, border - A[i]);
            i--;
        }
        return true;
    };
    v = max(1L, v - (p - 1));
    int ok = p - 1, ng = n;
    while (ng - ok > 1){
        int mid = (ok + ng) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok + 1 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[2050];
long long ans=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			int c=j;bool flag=false;
			while(c<n&&a[i]+a[j]>a[c]){c++;flag=true;
			}
			if(flag)ans+=c-j-1;
		}
	}cout<<ans<<endl; return 0;
}

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

int main() {
    int N;
    cin >> N;
    while(N > 0) {
        int S = N%10;
        if(S == 7) { cout << "Yes" << endl; return 0; }
        N /= 10;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

for _ in range(10 ** 9):
    n = int(input())
    if n == 0:
        break
    hs = [0 for _ in range(24 * 60 * 60 + 2)]
    for i in range(n):
        start, end = map(str, input().split())
        start = [int(start[0:2]), int(start[3:5]), int(start[6:8])]
        end = [int(end[0:2]), int(end[3:5]), int(end[6:8])]
        hs[start[0] * 60 * 60 + start[1] * 60 + start[2]] -= 1
        hs[end[0] * 60 * 60 + end[1] * 60 + end[2]] += 1
    hs = list(itertools.accumulate(hs))
    print(abs(min(hs)))



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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(1){
    C -= B;
    if(C <= 0){
      cout << "Yes" << endl;
      return;
    }
    A -= D;
    if(A <= 0){
      cout << "No" << endl;
      return;
    }
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N-1), Ajo(N,0);
    for (int i = 0; i < N-1; i++)
    {
        cin >> A.at(i);
        Ajo.at(A.at(i)-1)++;
    }

    /*for (int i = 0; i < N;i++)
    {
        for (int j = 0; j < N-1;j++)
        {
            if(A.at(j)==i+1)
            {
                Ajo.at(i)++;
            }
        }
    }*/
    for (int i = 0; i < N; i++)
    {
        cout << Ajo.at(i) << endl;
    }
}


Measured memory_bytes: 4724
#include <iostream>
#include <math.h>
#include <vector>
#include <iomanip>


int main() {

    std::string S;

    std::cin >> S;

    int firstBlack = 0;
    int firstWhite = 0;

    for (int i = 0; i < S.length(); i++) {

        if (i % 2 == 0) {

            if (S[i] == '0') {
                firstWhite += 1;
            } else {
                firstBlack += 1;
            }

        } else {

            if (S[i] == '0') {
                firstBlack += 1;
            } else {
                firstWhite += 1;
            }

        }
    }

    std::cout << std::min(firstBlack, firstWhite) << "\n";

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

template <class T>
class BIT {
  vector<T> data[2];
  T ZERO = 0;

  void sub_add(int p, int a, T x) {
    for (int i = a; i < (int)data[p].size(); i += (i & -i)) {
      data[p][i] = data[p][i] + x;
    }
  }

  T sub_sum(int p, int a) {
    T res = 0;
    for (int i = a; i > 0; i -= (i & -i)) {
      res += data[p][i];
    }
    return res;
  }

 public:
  BIT(int n) { init(n); }
  void init(int n) {
    for (int i = 0; i < 2; ++i) {
      data[i].assign(n + 1, ZERO);
    }
  }

  void add(int a, int b, T x) {
    sub_add(0, a, x * -(a - 1));
    sub_add(1, a, x);
    sub_add(0, b, x * (b - 1));
    sub_add(1, b, x * (-1));
  }

  T sum(int a, int b) {
    return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) -
           sub_sum(1, a - 1) * (a - 1);
  }
};

int N, Q;

int main() {
  cin >> N >> Q;
  vector<int> c(N + 1);
  repe(i, 1, N) { cin >> c[i]; }
  vector<int> left(Q), right(Q), ids(Q);
  rep(i, 0, Q) {
    cin >> left[i] >> right[i];
    ids[i] = i;
  }

  sort(ids.begin(), ids.end(),
       [&](int a, int b) { return right[a] < right[b]; });

  BIT<int> bit(N);
  vector<int> prev(N + 10, 0);
  vector<int> res(Q);
  int r = 1;
  for (auto q : ids) {
    for (; r <= right[q]; ++r) {
      bit.add(prev[c[r]] + 1, r + 1, 1);
      prev[c[r]] = r;
    }
    res[q] = bit.sum(left[q], left[q] + 1);
  }
  for (auto e : res) {
    cout << e << "\n";
  }
}


Measured memory_bytes: 19424
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,a[100010],i,p;
char s1[100],s2[100];
long long s,mod;
int main(){
    mod=1000000007;
    scanf("%d%s%s",&n,s1,s2);
    if(s1[0]==s2[0]){
        s=3;
        i=1;
        p=0;
    }else{
        s=6;
        i=2;
        p=1;
    }
    while(i<n){
        if(s1[i]==s2[i]){
            if(!p) s=(s*2)%mod;
            i++;
            p=0;
        }else{
            if(p) s=(s*3)%mod; else s=(s*2)%mod;
            i+=2;
            p=1;
        }
    }
    printf("%lld\n",s);
}


Measured memory_bytes: 128
x_1,y_1,x_2,y_2=map(int,input().split())
x_4=x_1-y_2+y_1
y_4=y_1+x_2-x_1
x_3=x_4+x_2-x_1
y_3=y_4+y_2-y_1
print(x_3,y_3,x_4,y_4)

Measured memory_bytes: 2940
#include<stdio.h>

void swap (int *x, int *y) {
	int temp;  
 	temp = *x;
	*x = *y;
	*y = temp;
}

int bubble_sort (int A[], int n, int c) {
	int i,j = 0;
	for (i = 0; i < n - 1; i++){
    	for (j = n - 1; j >= i + 1; j--){ 
			if (A[j] < A[j-1]){
				swap(&A[j], &A[j-1]);
      			c++;
      		}
    	}
	}
	return c;
}

int main (void) {
	int n ,i ,c = 0;
	scanf("%d",&n);
	int A[n];
	for(i = 0; i < n; i++){
		scanf("%d",&A[i]);
	}
	c = bubble_sort(A, n, c);
	for (i = 0; i < n; i++){
		if(i < n - 1){
			printf("%d ", A[i]);
		}
		else{
			printf("%d\n", A[i]);
		}
 	}
	printf("%d\n" ,c);

  	return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N, M;
    const int nmax = 50;
    cin >> N >> M;

    char A[nmax][nmax], B[nmax][nmax];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            cin >> B[i][j];
        }
    }

    bool exist = false;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if ((i + M - 1 >= N) || (j + M - 1 >= N)) continue;

            bool match = true;
            for (int y = 0; y < M; y++) {
                for (int x = 0; x < M; x++) {
                    if (A[i + y][j + x] != B[y][x]) match = false;
                }
            }
            if (match) exist = true;
        }
    }

    if (exist) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int x,y;
  float z,w;
  cin >> x >> y;
  if (y % 2 != 0) cout << "No";
  else
  {
    z = y/2 - x;
    w = 2*x - y/2;
    //cout << w << " " << z << "\n";
  	if (w+z == x && w >= 0 && z >= 0) cout << "Yes";  
  	else cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,a=0,cur=0;
char s[105];
int main(){
	n=read();scanf ("%s",s+1);
	for (int i=1;i<=n;++i){
		if (s[i]==')'){
			if (cur) --cur;
			else ++a;
		}
		else ++cur;
	}
	while (a--) printf ("(");
	printf ("%s",s+1);
	while (cur--) printf (")");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000001


using namespace std;

int main() {

  int n, k;
  cin >> n >> k;

  vector<int> hlist;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    hlist.push_back(h);
  }

  sort(hlist.begin(), hlist.end());
  // for (int i = 0; i < n; i++) {
  //   cout << hlist[i] << endl;
  // }
  
  int ans = INF;
  for (int i = 0; i <= n - k; i++) {
    ans = min(hlist[i+k-1] - hlist[i], ans);
    // cout << ans << endl;
  }
  cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 892
#include<string>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include <numeric>
using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i >= 1 && i <= 9) {
			ans++;
		}
		else if (i >= 100 && i <= 999) {
			ans++;
		}
		else if (i >= 10000 && i <= 99999) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int a,b; cin>> a >> b;
  int c = abs(a-b);
  if(c % 2 == 1) cout <<"IMPOSSIBLE" << endl;
  else cout << min(a,b) + c /2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 123;
int n,m;


void solve()
{
    cin >> n >> m;
    if (n < m) cout << 0;
    else cout << 10;
}

int main()
{
    solve();        
    return (0);
}




Measured memory_bytes: 256
#include <stdio.h>

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

    for(int i=0;i<=n;i+=7)
    {
        if((n-i)%4==0)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 5;

int n, a[N];
bool b[N];
bool check(int x)
{
    for(int i = 1; i < 2 * n; i++)
        b[i] = (a[i] >= x);

    if(b[n] == b[n - 1] || b[n] == b[n + 1])
        return b[n];

    int first_right = n + 1;
    while(first_right < 2 * n && b[first_right] != b[first_right - 1])
        first_right++;

    int first_left = n - 1;
    while(first_left && b[first_left] != b[first_left + 1])
        first_left--;

    if(first_left == 0)
        return b[first_right - 1];
    if(first_right == 2 * n)
        return b[first_left + 1];

    return (first_left > 2 * n - first_right) ? b[first_left] : b[first_right];
}

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

    cin >> n;
    for(int i = 1; i < 2 * n; i++)
        cin >> a[i];

    int low = 1, high = N - 1;
    while(low <= high)
    {
        int mid = (low + high) / 2;
        if(check(mid))
            low = mid + 1;
        else
            high = mid - 1;
    }

    cout << low - 1 << endl;

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;

const int NIL = -1;
const int MAX = 1 << 21;

int M[101][101];
int color[101], d[101], p[101];

int main(void)
{
	int n, u, k, v, c, mincost;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = MAX;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	for (int i = 0; i < n; i++) {
		color[i] = 0;
		d[i] = MAX;
	}
	d[0] = 0;
	p[0] = -1;
	while (1) {
		mincost = MAX;
		for (int i = 0; i < n; i++) {
			if (color[i] != 2 && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost == MAX)
			break;
		color[u] = 2;
		for (int v = 0; v < n; v++) {
			if (color[v] != 2) {
				if (d[u]+M[u][v] < d[v]) {
					d[v] = M[u][v] + d[u];
					p[v] = u;
					color[v] = 1;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,W=0,w=0;
	string b;
	cin>>a>>b;
	for (int i=0;i<a;i++)
		if (b[i]=='W')
			W++;
	for (int i=a-1;i>a-W-1;i--)
		if (b[i]=='W')
			w++;
	cout<<W-w<<endl;
	return 0;
}


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

int main() {
    int Q;
    cin >> Q;
    int64_t sm_a[2] = {0, 0};
    int64_t sm_b = 0;
    int64_t i = 0;
    multiset<int> left;
    multiset<int> right;
    while (Q--) {
        int tp;
        cin >> tp;
        if (tp == 1) {
            int64_t A, B;
            cin >> A >> B;
            if (!left.empty()) {
                int64_t mid = *left.rbegin();
                if (A > mid) {
                    right.insert(A);
                    sm_a[1] += A;
                } else {
                    left.insert(A);
                    sm_a[0] += A;
                }
            } else {
                left.insert(A);
                sm_a[0] += A;
            }
            if (left.size() < right.size()) {
                auto begr = right.begin();
                int64_t sw = *begr;
                right.erase(begr);
                left.insert(sw);
                sm_a[1] -= sw;
                sm_a[0] += sw;
            } else if (left.size() - right.size() > 1) {
                auto backl = prev(left.end());
                int64_t sw = *backl;
                left.erase(backl);
                right.insert(sw);
                sm_a[0] -= sw;
                sm_a[1] += sw;
            }
            sm_b += B;
            i++;
        } else {
            int64_t centr = *left.rbegin();
            int64_t req = (centr * (i / 2 + i % 2) - sm_a[0]) + (sm_a[1] - centr * (i / 2)) + sm_b;
            cout << centr << ' ' << req << endl;
        }
    }
}


Measured memory_bytes: 12812
#include <stdio.h>
int main(void)
{
  int H, W, i, j;
  while (1) {
    scanf("%d%d", &H, &W);
    if (H == 0 && W == 0) break;
    for (i = 0; i < H; i++) {
      for (j = 0; j < W; j++) {
        if (i == 0 | i == H - 1 | j == 0 | j == W - 1) putchar('#');
        else putchar('.');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 572
from collections import deque
#s=raw_input()

l=deque(list(input()))
q=int(input())

r=False
for i in range(0, q):
    t=input()
    if t[0] == "1":
        r = not r
        #s = s[::-1]
    else:
        if t[2] == "1" and r is False or t[2] == "2" and r is True:
            #s = t[4] + s
            l.appendleft(t[4])
        else:
            #s = s + t[4]
            l.append(t[4])

if r is True:
    #s = s[::-1]
    l = list(l)[::-1]

#print s
print("".join(l))


Measured memory_bytes: 10212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    string s;
    int k;
    cin >> k >> s;
    if (s.size() > k){
        ctn(s.substr(0,k) + "...");
    }
    else{
        ctn(s);
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define N 440
typedef long long ll;
int n;
ll a[N],memo[N][N],ps[N];

void precompute() {
    for (int i = 1 ; i <= n ; i++)
        ps[i] = ps[i - 1] + a[i];
}

ll rsum(int l , int r) {
    return ps[r] - ps[l - 1];
}

ll dp(int i , int j) {
    if (i > j) return INT_MAX;
    if (i == j) return 0;
    if (j - i == 1) return a[i] + a[j];
    ll &sol = memo[i][j];
    if (sol != -1) return sol;
    ll keep = LLONG_MAX;
    for (int k = i ; k < j ; k++) {
        keep = min(
            dp(i , k) + dp(k + 1 , j) + rsum(i , j),
            keep
        );
    }
    return sol = keep;
}

int main() {
    scanf("%d" , &n);
    for (int i = 1 ; i <= n ; i++)
        scanf("%lld" , &a[i]);
    memset (memo , -1 , sizeof memo);
    precompute();
    printf("%lld\n" , dp(1 , n));
}


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

double solve(double a,double b,double x){
	if(x>=a*a*b/2)
return (atan((a*a*b-x)/(a*a*a/2)))*180/M_PI;
else 
	return  atan(1/((x/a)*2/(b*b)))*180/M_PI;
}

int main(){
int a,b,x;
cin >> a >> b>>x;
printf("%lf\n",solve(a,b,x));	
return 0;
}


Measured memory_bytes: 384
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
      int a = int.Parse(ReadLine());
      int b = int.Parse(ReadLine());
      int c = int.Parse(ReadLine());
      int d = int.Parse(ReadLine());
      WriteLine(Math.Min(a,b)+Math.Min(c,d));
    }
}

Measured memory_bytes: 27160
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
X = []
C = [0] * N
for j in range(30):
    for i in range(N):
        X.append(((A[i]>>j)<<24) + (i << 6) + j)
X = sorted(X)[::-1]
ans = sum(A)
for a in X[:M]:
    x, i, j = a >> 24, (a >> 6) % (1<<18), a % (1<<6)
    if C[i] == j:
        C[i] += 1
        ans -= x - x//2
print(ans)

Measured memory_bytes: 142980
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    vector<ll> ABC(3);
    REP(i,3) cin >> ABC[i];
    sort(RALL(ABC));
    ll ans = ABC[1] * ABC[2];
    REP(i,3) if (ABC[i] % 2 == 0 ) ans = 0;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256