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

///THEOVE46

#define PI  2*acos(0.0)
#define pf  printf
#define sf  scanf
#define ff  first
#define ss  second
#define mp  make_pair
#define pb  push_back
#define gap " "
#define nn  "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef vector<long long> vll ;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define sc(n)       sf("%d",&n);
#define pc(n)       pf("%d",n);
#define scf(f)      sf("%f",&f);
#define pcf(f)      pf("%f",f);
#define FOR(a,n)  for(int i=a; i<n; i++)
#define RFOR(a,n)  for(int i=a; i>n; i--)
#define TEST(test)  for(int ove=0; ove<test; ove++)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define all(x) (x).begin(), (x).end()
#define fap(x) cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const ll INF = 2000000000000000000LL;
const int inf = 0x3f3f3f3f;
const long double EPS = 1e-9;

///THEOVE46

int main()
{
    FastIO;
    ll n, i, j, t, x;
    cin >> n;
    ll a[n+1]={0};
    for(t=0; t<n-1; t++)
    {
        cin >> x;
        a[x]++;
    }
    for(i=1; i<=n; i++)
        cout << a[i] << nn;


    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 5168
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct cake {
	ll h[3], A;
	bool operator < (const cake& b) const {
		return A > b.A;
	}
};
cake C[1010];
int r[3];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> C[i].h[0] >> C[i].h[1] >> C[i].h[2];
	}
	ll ans = 0;
	for (int i = 0; i < (1 << 3); i++) {
		int bit = i;
		for (int j = 0; j < 3; j++) {
			r[j] = bit % 2;
			bit /= 2;
		}
		for (int j = 0; j < N; j++) C[j].A = 0;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < N; k++) {
				if (r[j] > 0) C[k].A += C[k].h[j];
				else C[k].A -= C[k].h[j];
			}
		}
		sort(C, C + N);
		ll sum = 0;
		for (int j = 0; j < 3; j++) {
			ll num = 0;
			for (int k = 0; k < M; k++) {
				if (r[j] > 0) num += C[k].h[j];
				else num -= C[k].h[j];
			}
			sum += abs(num);
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lld long long 
lld p(lld z)
{
	lld res=1;
	for(int i=1;i<=z;i++)res*=10;
	return res;
}
lld min(lld a,lld b){return a<b?a:b;}
map<pair<int,int> ,int> m;
void dfs(vector<vector<int> > &v,int s,int par[])
{
	int cnt=1;
	for(auto i: v[s])
	{
		if(i==par[s])continue;
		else
		{
			if(par[s]!=-1)
			{
				if(m[{s,par[s]}]==cnt) cnt++;
			}
			par[i]=s;
			m[{s,i}]=cnt;
			m[{i,s}]=cnt;
			cnt++;
			dfs(v,i,par);
		}
	}
}
int main()
{
	int n; cin>>n;
	vector<vector<int> > v(n+1);
	int f=0;
	int e[n-1][2];
	for(int i=1;i<n;i++)
	{
		int a,b; cin>>a>>b;
		e[i-1][0]=a;
		e[i-1][1]=b;
		v[a].push_back(b);
		v[b].push_back(a);
		f=max(f,(int)v[a].size());
		f=max(f,(int)v[b].size());
	}
	printf("%d\n",f);
	int par[n+1];
	memset(par,-1,sizeof(par));
	dfs(v,1,par);
	for(int i=0;i<n-1;i++)
		cout<<m[{e[i][0],e[i][1]}]<<endl;
	return 0;
}

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

using namespace std;
#define long long long

int const N = 3e3 + 10;

char s[N], t[N];
int ns, nt;
struct unit {
    int val, type;
    // type : 0_both, 1_up, 2_down
};
unit f[N][N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> s + 1 >> t + 1;
    ns = strlen(s + 1), nt = strlen(t + 1);

    for (int i = 1; i <= ns; ++i)
        for (int j = 1; j <= nt; ++j) {
            if (s[i] == t[j]) f[i][j] = {f[i - 1][j - 1].val + 1, 0};
            else
                if (f[i - 1][j].val > f[i][j - 1].val) f[i][j] = {f[i - 1][j].val, 1};
                else f[i][j] = {f[i][j - 1].val, 2};
        }

    vector<char> res;
    int i = ns, j = nt;
    while (i && j) {
        if (!f[i][j].type) {
            res.push_back(s[i]);
            --i, --j;
            continue;
        }

        if (f[i][j].type == 1) --i;
        else --j;
    }

    for (i = f[ns][nt].val - 1; i >= 0; --i) cout << res[i];

    return 0;
}


Measured memory_bytes: 70784
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    println(problem142d(a, b))
}

fun problem142d(a: Long, b: Long): Int {
    /**
     * 最大公約数
     * @param big 2つの値の大きな方
     * @param small 2つの値の小さな方
     */
    fun computeGreatestCommonDivisor(big: Long, small: Long): Long {
        val rest = big % small
        return if (rest == 0L) small else computeGreatestCommonDivisor(small, rest)
    }
    /**
     * 素因数分解
     */
    fun computePrimeFactorList(n: Long): List<Pair<Long, Long>> {
        val p = mutableListOf<Pair<Long, Long>>()
        var primeFactor = n
        for (i in 2..(Math.sqrt(n.toDouble()) + 1).toLong()) {
            if (primeFactor % i != 0L) continue
            var count = 0L
            while (primeFactor % i == 0L) {
                primeFactor /= i
                count++
            }
            p.add(i to count)
        }
        if (primeFactor != 1L) p.add(primeFactor to 1L)
        return p
    }
    val list = listOf(a, b)
    val g = computeGreatestCommonDivisor(list.max()!!, list.min()!!)
    val p = computePrimeFactorList(g)
    return p.map { it.first }.count() + 1
}

Measured memory_bytes: 35948
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long,Long> map = new HashMap<>();
        ArrayList<Long> a = new ArrayList<>();
        long sum = 0;
        for(int i = 0; i < n; i++) {
            long key = sc.nextLong();
            a.add(key);
            if(map.containsKey(key)) {
                sum += map.get(key);
                map.put(key, map.get(key) + 1);
            }else {
                map.put(key, 1l);
            }
        }
        for(int i = 0; i < n; i++){
            System.out.println(sum - (map.get(a.get(i)) - 1));
        }
    }
}


Measured memory_bytes: 77572
def solve(S):
    chars = [chr(c) for c in range(ord("a"), ord("z") + 1)]
    cs = dict((c, S.count(c)) for c in chars)
    l = len(S) 
    if l < len(chars):
        return S + sorted(c for c, n in cs.items() if n == 0)[0]
    for i in range(2, l + 1):
        sl = S[:l - i]
        sc = S[l - i]
        sr = S[l - i + 1:]
        msrs = [c for c in sr if c > sc]
        if msrs:
            return sl + sorted(msrs)[0]
    return -1

S = input()
print(solve(S))


Measured memory_bytes: 3188
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-D: Shell Sort

#include <algorithm>
#include <cstdio>

static void print_ints(const int as[], const unsigned int n, const char* sep = " ")
{
  auto out_sep = "";
  for (auto i = 0u; i < n; ++i) {
    std::printf("%s%u", out_sep, as[i]);
    out_sep = sep;
  }
  std::printf("\n");
}

static void print_int(const unsigned int n)
{
  std::printf("%u\n", n);
}

static unsigned int cnt = 0u;

static void insert(int as[], const unsigned int i, const unsigned int d)
{
  const auto asi = as[i];
  auto j = i;
  while (j >= d && asi < as[j-d]) {
    as[j] = as[j-d];
    j -= d;
    ++cnt;
  }
  as[j] = asi;
}

static void insertion_sort(int as[], const unsigned int n, const unsigned int d)
{
  for (auto i = d; i < n; ++i) {
    insert(as, i, d);
  }
}

unsigned int next_g(const unsigned int g) { return 3*g + 1; }

unsigned int gen_m(const unsigned int n)
{
  auto m = 1u;
  for (auto g = 1u;;) {
    g = next_g(g);
    if (n < g) break;
    ++m;
  }
  return m;
}

static void shell_sort(int as[], const unsigned int n)
{
  cnt = 0;

  auto m = gen_m(n);
  int gs[m];
  for (auto g = 1u, i = 0u; i < m; ++i) {
    gs[m-1-i] = g;
    g = next_g(g);
  }
  print_int(m);
  print_ints(gs, m);

  for (auto i = 0u; i < m; ++i) {
    insertion_sort(as, n, gs[i]);
  }
  
  print_int(cnt);
}

int main()
{
  unsigned int n;
  std::scanf("%u", &n);
  int as[n];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%d", &as[i]);
  }

  shell_sort(as, n);
  print_ints(as, n, "\n");
}

// eof

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));
    vector<ll> Bs;
    Bs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Bs));
    vector<ll> Cs;
    Cs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Cs));

    sort(begin(As), end(As));
    sort(begin(Cs), end(Cs));

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        auto a_it = lower_bound(begin(As), end(As), Bs[i]);
        auto c_it = upper_bound(begin(Cs), end(Cs), Bs[i]);
        ans += distance(begin(As), a_it) * distance(c_it, end(Cs));
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 2560
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll MAX_N = 1000000;
 
 
// m>=nを想定している
ll gcd(ll m, ll n){
    if(n==0) return m;
    return gcd(n,m%n);
}
 
 
/*map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2; i*i<=n; i++){
        while(n%i==0){
            res[i]++;
            n /= i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}*/
 
// 素因数分解
vector<pair<ll, int>> factoring(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i * i <= n; ++i) {
        int k = 0;
        while (n % i == 0){
            n /= i;
            k++;
        }
        if(k != 0) res.push_back({i, k});
    }
    if(n != 1) res.push_back({n, 1});
    return res;
}
 
 
int main(void){
    // 入力
    ll a,b;
    cin >> a >> b;
 
    // a,bのGCDを求める
    ll gcd_of_ab;
    if(a>=b) gcd_of_ab = gcd(a,b);
    else gcd_of_ab = gcd(b,a);
 
    // 求めたいのはGCD以下のGCDを割り切る素数の個数
    ll ans=1;
    auto m = factoring(gcd_of_ab);
    ans += m.size();
 
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  while (b <= a)
  {
    b *= 2;
    k--;
  }
  while (c <= b)
  {
    c *= 2;
    k--;
  }
  if (k < 0)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    int N;
    string S;
    cin >> N >> S;

    ll R = 0, G = 0, B = 0;
    REP(i, N) {
        if (S[i] == 'R') ++R;
        if (S[i] == 'G') ++G;
        if (S[i] == 'B') ++B;
    }

    ll ans = R*G*B;
    REP (i, N) {
        FOR (j, i, N) {
            int k = 2 * j - i;
            if (k < N) {
                if (S[i] == S[j]) continue;
                if (S[j] == S[k]) continue;
                if (S[i] == S[k]) continue;
                ans--;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

# define INF (int)10e9

long int dfs(long int n,long int now){
    if(now > n) return 0;

    long int ret=0;
    string tmp=to_string(now);
    if(tmp.find('3')!=string::npos && tmp.find('5')!=string::npos && tmp.find('7')!=string::npos){
        ret++;
    }

    ret+= dfs(n,now*10+3);
    ret+= dfs(n,now*10+5);
    ret+= dfs(n,now*10+7);
    return ret;
}

int main()
{
    long int n;cin >> n ;
    p(dfs(n,0))
}

Measured memory_bytes: 256
from sys import stdin

if True:

    n = int(stdin.readline().strip())
    a = list(map(int, stdin.readline().strip().split()))

    if n == 1:
        print(1)
        exit()

    a.sort()

    dp = [True] * (a[-1] + 1)
    ans = 0

    for i in range(n):

        if a[i] == a[i-1]:
            continue

        if dp[a[i]]:

            for j in range(2 * a[i], a[-1] + 1, a[i]):
                dp[j] = False

            if i == n-1 or a[i] != a[i+1]:
                ans += 1

    print(ans)

Measured memory_bytes: 32240
import bisect
from itertools import accumulate

n, m, k = map(int, input().split())
A = list(accumulate([0]+list(map(int, input().split()))))
B = list(accumulate([0]+list(map(int, input().split()))))
ans = 0
for i, a in enumerate(A):
    if a > k:
        break
    j = bisect.bisect_right(B, k-a)-1
    temp = i+j
    ans = max(ans, temp)
print(ans)

Measured memory_bytes: 42608
#include <cstdio>

int sfound[26];
int tfound[26];
int sindex[200000];
int tindex[200000];

int main()
{
  char s[200001];
  scanf("%s", s);
  int index = 1;
  int i = 0;
  for (char *p = s; *p; ++p)
  {
    if (sfound[*p - 'a'] == 0)
    {
      sfound[*p - 'a'] = index++;
    }
    sindex[i++] = sfound[*p - 'a'];
  }

  scanf("%s", s);
  index = 1;
  i = 0;
  for (char *p = s; *p; ++p)
  {
    if (tfound[*p - 'a'] == 0)
    {
      tfound[*p - 'a'] = index++;
    }
    tindex[i++] = tfound[*p - 'a'];
  }
  --i;
  while (i >= 0)
  {
    if (sindex[i] != tindex[i])
    {
      puts("No");
      return 0;
    }
    --i;
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 1920
from numpy import *
from scipy.sparse.csgraph import *
N,M = map(int,input().split())
E = [list(map(int,input().split())) for m in range(M)]
G1 = zeros((N,N))
ans = 0

for a,b in E:
  G1[a-1][b-1]+=1
  G1[b-1][a-1]+=1

for a,b in E:
  G2 = G1.copy()
  G2[a-1][b-1]-=1
  G2[b-1][a-1]-=1
  D = floyd_warshall(G2)
  if inf in D:
    ans+=1

print(ans)

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

int main(){
	int N, M;
	cin >> N >> M;
	char A[N][N];
	char B[M][M];
	rep(i,N)rep(j,N) cin >> A[i][j];
	rep(i,M)rep(j,M) cin >> B[i][j];
	rep(k,N-M+1)rep(l,N-M+1) {
		bool flag = true;
		rep(i,M){
			rep(j,M) {
				if (A[k+i][l+j] != B[i][j]) {
					flag = false;
					break;
				}
			}
			if (!flag) break;
		}

		if (flag) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main()
{


        long long n,m,a,b,c,d,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=0,y=-1,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        scanf("%lld %lld",&m,&n);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a);  x=x+a;
        }


        printf("%lld\n",max(y,m-x));











    return 0;
}





Measured memory_bytes: 3792
#include <stdio.h>
#include <stdlib.h>

int main(){
    long long n,k;
    long long tmp = 0;
    scanf("%ld %ld",&n,&k);
    while(1){
        if(n <= k){
            tmp = n - k;
            if(tmp < 0){
                tmp = -1 * tmp;
            }
        }else{
            tmp = n % k;
        }
        if(tmp < n){
            n = tmp;
        }else{
            printf("%ld",n);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#define MAX_H 400
#define MAX_W 400
using namespace std;

struct Point {
    int i, j;
    char prev_color;
};

bool used[MAX_H][MAX_W];

long calc(string s[], int h, int w, int i, int j) {
    long black = 0, white = 0;

    stack<Point> st;
    st.push(Point {i, j, ' '});
    while (!st.empty()) {
        Point p = st.top();
        st.pop();
        i = p.i;
        j = p.j;
        if (i < 0 || h <= i || j < 0 || w <= j || used[i][j] || p.prev_color == s[i][j])
            continue;
        used[i][j] = true;
        if (s[i][j] == '#')
            black++;
        else
            white++;
        st.push(Point {i - 1, j, s[i][j]});
        st.push(Point {i + 1, j, s[i][j]});
        st.push(Point {i, j - 1, s[i][j]});
        st.push(Point {i, j + 1, s[i][j]});
    }
    return black * white;
}

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            used[i][j] = false;
        }
    }
    long ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (used[i][j])
                continue;
            ans += calc(s, h, w, i, j);
        }
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n)　for(int i=(k);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ss s;
    cin >> s;
    vector<char> t;
    rep(i,SIZE(s)){
        if(s[i] != 'B')t.push_back(s[i]);
        else{
            if(!t.empty())t.pop_back();
        }
    }
    rep(i,SIZE(t))cout << t[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    vector<pair<int,int>> b(n);
    int cnt=0;
    rep(i,n){
        cin>>a[i].first;
        b[i].first=a[i].first;
        a[i].second=(i+1)%2;
    }
    sort(all(a));
    sort(all(b));

    rep(i,n){
        b[i].second=(i+1)%2;
    }
    rep(i,n){
        //a[i].first%=2;
        if(b[i].second!=a[i].second){
            cnt++;
        }
    }
    //debug(cnt);
    cout<<(cnt+2-1)/2<<endl;
    
    

}


Measured memory_bytes: 1792
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
const int N=1000+5;
string str;

int main()
{
    int n,x,y,_min;
    scanf("%d%d",&n,&x);
    _min=x;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&y);
        _min=min(_min,y);
        x-=y;
    }
    printf("%d\n",n+x/_min);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;


int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	long a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	long x, y;
	scanf("%lld %lld", &x, &y);
	long res = 0;
	if(2*c < a+b)
	{
		if(x > y) res += y*(2*c) + (x-y)*min(a,2*c);
		else res += x*(2*c) + (y-x)*min(b,2*c);
	}
	else res = a*x + b*y;
	printf("%lld\n", res);
}





Measured memory_bytes: 384
program main
implicit none
integer :: n, m, c, nc, s, i, j
integer , allocatable :: a( :, : ), b( : )

read(*,*) n, m, c
allocate( a(n,m) )
allocate( b(m) )
read(*,*) b(1:m)
nc = 0
do i = 1, n
   read(*,*) a(i,1:m)
   s = 0
   do j = 1, m
      s = s + a(i,j)*b(j)
   end do
   if( s+c > 0) then
      nc = nc + 1
   end if
end do
write(*,'(i0)') nc

end program main


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int A,B,C,D,E,F,a,b,all=0;
	cin>>A>>B>>C>>D>>E>>F;
	all+=(max(E,F)+A+C+D+B);
	a=min(A,B);
	b=min(C,D);
	all-=min(a,b);
	cout<<all<<endl;
	return 0;
}
//5:29,047クリア



Measured memory_bytes: 3040
import itertools
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
b = list(itertools.accumulate(a))
ans = 0
for i in range(n):
    ans += ((a[i] * (s - b[i])) % (10**9+7))
ans %= (10**9+7)
print(ans)

Measured memory_bytes: 31132
import string


lowercase = string.ascii_lowercase

s = input()
K = int(input())

substrings = []

stack = list(lowercase)[::-1]

while len(substrings) < K:
    # print(stack)
    v = stack.pop()
    if v in s:
        substrings.append(v)
        for c in list(lowercase)[::-1]:
            stack.append(v+c)

print(substrings[K-1])


Measured memory_bytes: 3772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <utility>
#include <queue>
#include <string>

using namespace std;

#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

ll n;
map<int,int> haha;

int main()
{
	ios::sync_with_stdio(false);
	ll MOD = 1000000007;
	cin >> n;
	bool stat = true;
	for(int i=0;i<n;i++)
	{
		int temp;
		cin >> temp;
		haha[temp]++;
		if(haha[temp]>2) stat = false;
	}
	if(n%2==0)
	{
		for(int i=1;i<n;i+=2) if(haha[i]!=2) stat = false;
	}
	else
	{
		if(haha[0]!=1) stat = false;
		for(int i=2;i<n;i+=2) if(haha[i]!=2) stat = false;
	}
	//stat = true;
	ll ans = 1;
	if(stat)
	{
		for(int i=1;i<=n/2;i++)
		{
			ans = ans*2;
			ans%=MOD;
		}
	}
	else ans = 0LL;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++) {
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());
    int sum = accumulate(L.begin(), L.end()-1, 0);
    if(sum > L.at(N-1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  int n, m, yen = 0;//yen答え、マイナスになるくらいなら適当なやつ言って0円
  cin >> n;
  map<string, int> s;//値は基本1もしダブったら数増やす
  for (int i = 0; i < n; i++) {
    string si;
    cin >> si;
    if (s.count(si)) s[si]++; 
    else s[si] = 1;
  }
  cin >> m;
  map<string, int> t;//値は基本-1ダブったら数減らす
  for (int i = 0; i < m; i++) {
    string ti;
    cin >> ti;
    if (t.count(ti)) t[ti]--; 
    else t[ti] = -1;
  }
  for (auto p: s) {
    if (!t.count(p.first)) yen = max(yen, p.second);
    else yen = max(yen, p.second + t[p.first]);
  }
  cout << yen;
}

Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), m = in(), x = in();
	vector<bool>road(n + 1, false); REP(i, m)road[in()] = true;
	cout << min(count(road.begin(), road.begin() + x, true), count(road.begin() + x + 1, road.end(), true)) << endl;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ld r;
  cin >> r;
  cout << 2.0 * PI * r << endl;;
  return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	char C; cin >> C;
	cout << char(C+1) << endl;	

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        long a[] = new long[n+1];
        long b[] = new long[n];
        for(int i = 0;i < n+1;i++) {
            a[i] = stdIn.nextLong();
        }
        for(int i = 0;i < n;i++){
            b[i] = stdIn.nextLong();
        }
        long count = 0;
        for(int i = 0;i < n;i++) {
            if(a[i] < b[i]){
                count += a[i];
                b[i] -= a[i];
                if(a[i+1] >= b[i]) {
                    count += b[i];
                    a[i+1] -= b[i];
                }else{ 
                    count += a[i+1];
                    a[i+1] = 0;
                }
            }else {
                count += b[i];
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 88380
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=1e6;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int mx[N],sum[N],m;
vector<int>v[N];
#define lc (i<<1)
#define rc (lc|1)
inline void modify(int i,int l,int r,int k,int t) {
	if (l==r) mx[i]+=t,sum[i]+=t;
	else {
		int mid=(l+r)>>1;
		k<=mid?modify(lc,l,mid,k,t):modify(rc,mid+1,r,k,t);
		sum[i]=max(sum[lc]+sum[rc],-1<<28);
		mx[i]=max(mx[rc],mx[lc]+sum[rc]);
	}
}
inline void build(int i,int l,int r) {
	if (l==r) sum[i]=mx[i]=l<m?-1:0;
	else {
		int mid=(l+r)>>1;
		build(lc,l,mid);
		build(rc,mid+1,r);
		sum[i]=max(sum[lc]+sum[rc],-1<<28);
		mx[i]=max(mx[rc],mx[lc]+sum[rc]);
	}
}
int main()
{
	int n=gi(),i,k,ans=max(0,n-(m=gi()));
	while (n--) k=gi(),v[k].push_back(gi());
	build(1,1,++m);
	for (i=0;i<m;modify(1,1,m,++i,-1<<28)) {
		for (int t:v[i])
			modify(1,1,m,t,1);
		ans=max(ans,mx[1]-i);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 34560
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    int n, a =0, b = 0, c = 0, d = 0;
    cin >> n;
    string arr[n];
    for( int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for( int i = 0; i < n; i++)
    {
        if (!arr[i].compare("AC"))
            a++;
        else if (!arr[i].compare("WA"))
            b++;
        else if (!arr[i].compare("TLE"))
            c++;
        else //if (!arr[i].compare("RE"))
            d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}

Measured memory_bytes: 6728
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	string s;
	cin >> s;
	int cnt = 0;
	if(s[0] == '1') ++cnt;
	if(s[1] == '1') ++cnt;
	if(s[2] == '1') ++cnt;
	cout << cnt << endl;
}

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

int main(){
	int sum = 0;
	for(int i = 0; i < 5; i++){
		int a;
		cin >> a;
		if(a < 40) sum += 40;
		else sum += a;
	}
	cout << sum / 5 << endl;
	return 0;
}


Measured memory_bytes: 3096
h, w = [int(w) for w in input().split()]
ls = [input() for _ in range(h)]


def search(th, tw):
    t = 0
    for i in range(-1, 2):
        for j in range(-1, 2):
            if i == j == 0:
                continue
            if not 0 <= th+i < h:
                continue
            if not 0 <= tw+j < w:
                continue
            if ls[th+i][tw+j] == "#":
                t += 1
    return t


ans = ""
for i in range(h):
    for j in range(w):
        if ls[i][j] == "#":
            ans += "#"
        else:
            ans += str(search(i, j))
    ans += "\n"

print(ans)


Measured memory_bytes: 9168
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Tue Oct  3 20:13:23 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
#define MAX_N 50
#define MAX_VAL 50

static uint64_t dp[MAX_N + 1][MAX_N + 1][MAX_N * MAX_VAL + 1];
static vector<int32_t> values;

int32_t main()
{
  int64_t N, A;
  cin >> N >> A;

  values.push_back(0);
  int32_t max_val = 0;
  for (uint32_t i = 0; i < N; i++) {
    int32_t a;
    cin >> a;
    values.push_back(a);
    max_val = max(a, max_val);
  }

  for (uint32_t j = 0; j <= N; j++) {
    for (uint32_t k = 0; k <= N; k++) {
      for (int32_t s = 0; s <= N * max_val; s++) {
        if (j >= 1 && s < values[j]) {
          dp[j][k][s] = dp[j - 1][k][s];
        } else if (j >= 1 && k >= 1 && s - values[j] >= 0) {
          dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - values[j]];
        } else {
          if (j == 0 && k == 0 && s == 0) {
            dp[j][k][s] = 1;
          } else {
            dp[j][k][s] = 0;
          }
        }
      }
    }
  }

  uint64_t count = 0;
  for (uint32_t k = 1; k <= N; k++) {
    count += dp[N][k][k * A];
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 51072
S = list(input())
L = len(S)
ob = 0
ow = 0
eb = 0
ew = 0
for i in range(L):
    if S[i] == '0' and i % 2 == 0:
        ob += 1
    elif S[i] == '0':
        eb += 1
ow = (L + 1) // 2 - ob
ew = L // 2 - eb
# print(ob, ow, eb, ew)
print(min(ob + ew, ow + eb))


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 100 + 5;
int n;
int t[N], l[N], m[N], r[N];
double ans;
int cur;

double f(int i) {
    double lm = l[i];
    double rm = r[i];
    double ll = max(l[i], r[i]), rr = m[i];
    double t1, t2;
    while (ll + 1e-8 < rr) {
        double mm = (ll + rr) / 2;
        t1 = abs(mm - lm);
        t2 = abs(mm - rm);
        if (t1 + t2 <= t[i]) {
            ll = mm;
        } else {
            rr = mm - 1e-8;
        }
    }
    // cout << lm << ' ' << m[i] << ' ' << rm << " # " << ll << endl;
    t1 = abs(ll - lm);
    t2 = abs(ll - rm);
    return (t[i] - t1 - t2) * ll + (ll + l[i]) / 2 * t1 + (ll + r[i]) / 2 * t2;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> m[i];
        l[i] = r[i] = m[i];
    }
    r[n - 1] = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (i < n - 1) {
            r[i] = min(r[i], l[i + 1]);
        }
        l[i] = min(l[i], r[i] + t[i]);
    }
    l[0] = 0;
    for (int i = 0; i < n; ++i) {
        if (i > 0)
            l[i] = min(l[i], r[i - 1]);
        r[i] = min(r[i], l[i] + t[i]);
    }
    for (int i = 0; i < n; ++i) {
        ans += f(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<chrono>
                             
using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
const ll mod=10000007;
const int MX=0x3f3f3f;

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

int main(){
    IOS;
    ll a,b;
    cin>>a>>b;
    cout<<a*(b/gcd(a,b));
    return 0;
}

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

#define int long long
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

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

    int a,b,c;
    cin >> a >> b >> c;
    if (a+b+c >= 22) {
        cout << "bust\n";
    }
    else cout << "win\n";

    return 0;
    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int sagasita[210];
int mituketa;
int kotae = 0;
vector<int> eda[210];

int sagasu(int oya) {
	rep(i, eda[oya].size()) {
		if (sagasita[eda[oya][i]] == 0) {
			sagasita[eda[oya][i]] = 1;

			if (mituketa == 0) {
				if (eda[oya][i] == 201) {
					mituketa = 1;
					kotae++;
					eda[oya].erase(eda[oya].begin() + i);
					return 1;
				}
				else if (sagasu(eda[oya][i])) {
					int kari = eda[oya][i];
					eda[oya].erase(eda[oya].begin() + i);
					eda[kari].push_back(oya);
					return 1;
				}
			}
		}
	}
	return 0;
}


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

	int N, a[100], b[100], c[100], d[100];
	cin >> N;
	rep(i, N) cin >> a[i] >> b[i];
	rep(i, N) cin >> c[i] >> d[i];

	rep(i, N) {
		rep(ii, N) {
			if (a[i] < c[ii] && b[i] < d[ii]) eda[i].push_back(ii + 100);
		}
		eda[200].push_back(i);
		eda[i + 100].push_back(201);
	}

	mituketa = 1;
	while (mituketa) {
		mituketa = 0;
		memset(sagasita, 0, sizeof(sagasita));
		sagasita[200] = 1;
		sagasu(200);
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
var
 n,i,j,s,t:longint;
 a:array[1..200] of longint;
begin
 readln(n);
 for i:=1 to 2*n do read(a[i]);
 for i:=1 to 2*n-1 do
  for j:=i+1 to 2*n do
   if a[i]>a[j] then
   begin
   t:=a[i];a[i]:=a[j];a[j]:=t;
   end;
   for i:=1 to n do
   s:=s+a[(i-1)*2+1];
   writeln(s);
end.

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
  int n,i,sum=0;
  cin>>n;
  int a[n-1];
  cin>>a[0];
  for(i=1;i<n-1;i++){
    cin>>a[i];
    sum=sum+min(a[i],a[i-1]);
  }
  cout<<sum+a[0]+a[i-1];
  return 0;
}

Measured memory_bytes: 256
def solve(n, x, l):
    ans = 1
    d = 0
    for i in range(n):
        d += l[i]
        if d <= x:
            ans += 1
    return ans

n, x = map(int, input().split())
l = list(map(int, input().split()))
print(solve(n, x, l))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5;

int n;
int a[MAX_N + 5];
int s = 0;

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        s ^= a[i];
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d ", s^a[i]);
    }
    return 0;
}


Measured memory_bytes: 4496
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int x; cin >> x;
    if (x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(100001)
N, M, K = map(int, input().split())

label = [-1] * N
n_label = [0] * N

F, B = {}, {}
for i in range(N):
    F[i] = set()
    B[i] = set()

for _ in range(M):
    x, y = map(int, input().split())
    F[x - 1].add(y - 1)
    F[y - 1].add(x - 1)

for _ in range(K):
    x, y = map(int, input().split())
    B[x - 1].add(y - 1)
    B[y - 1].add(x - 1)


def dfs(v, lab):
    if label[v] != -1:
        return 0
    label[v] = lab
    n_label[lab] += 1
    for n in F[v]:
        dfs(n, lab)
    return 1


# labeling
count = 0
for i in range(N):
    count += dfs(i, count)
n_label = n_label[:count]

# calc friend candidate
blocked = 0
for b in B[0]:
    if label[b] == label[0]:
        blocked += 1
print(n_label[label[0]] - 1 - len(F[0]) - blocked, end='')
for i in range(1, N):
    print(' ', end='')
    blocked = 0
    for b in B[i]:
        if label[b] == label[i]:
            blocked += 1
    print(n_label[label[i]] - 1 - len(F[i]) - blocked, end='')
print('')


Measured memory_bytes: 102672
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

int main() {
  long long int N, cnt = 0;
  string S;
  vector<long long int> a_v, b_v, c_v, k_v(26, 0), d_v;
  std::map<std::string, int> mp;
  int flag = 0;
  cin >> N;
  for (int i = 0 ; i < N; i++) {
    long long int p;
    cin >> p;
    d_v.push_back(p);
  }
  sort(d_v.begin(), d_v.end());
  if (N%2 == 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < N/2; i++) {
    
  }
  int i =( N/2) -1;
  int diff = d_v[i+1] - d_v[i];
  cout << diff << endl;
  
  // for (int i = 0; i < N; i++) {
  //   //cout << i << endl;
  //   long long int t;
  //   cin >> t;
  //   a_v.push_back(t);
  // }
  // sort(a_v.begin(), a_v.end());
  // for (int i = 0; i < N; i++) {
  //   //cout << i << endl;
  //   long long int t;
  //   cin >> t;
  //   b_v.push_back(t);
  // }
  // sort(b_v.begin(), b_v.end());
  // for (int i = 0; i < N; i++) {
  //   //cout << i << endl;
  //   long long int t;
  //   cin >> t;
  //   c_v.push_back(t);
  // }
  // sort(c_v.begin(), c_v.end());

  // int min_j = 0, max_k = N;
  // long long int sum = 0, a_cnt = 0, c_cnt = 0;
  // for (int i = 0; i < N; i++) {//b
  //   a_cnt = c_cnt = 0;
  //   for (int j = N-1; j >= 0; j--) { // a
  //     if (a_v[j] >= b_v[i]) {
  //       break;
  //     }
  //     else {
  //       a_cnt++;
  //     }
  //   }

  //   for (int k = 0; k < N; k++) { // c
  //     if (c_v[k] <= b_v[i]) {
  //       break;
  //     }
  //     else {
  //       c_cnt++;
  //     }
  //   }
  //   sum += a_cnt*c_cnt;
  // }

  // cout << sum << endl;
  // // int min_j = 0, min_k = 0;
  // // for (int i = 0; i < N; i++) {//c
  // //   int flag = -1;
  // //   for (int j = 0; j < N; j++) {//b
  // //     if (c_v[i] < b_v[j]) {
  // //       flag = 0;
  // //       min_j = j;
  // //       for (int k = 0; k < N; k++) {//a
          
          
  // //       }
  // //     }
  // //   }
  // // }
  // // if (N == 1) {
  // //   printf("%lld", t_v[0]);
  // //   return 0;
  // // }
  // // long long int mul = lcm(t_v[0], t_v[1]);
  // // //printf("%lld\n", mul);

  // for (int i = 2; i < N; i++) {
  //   mul = lcm(mul, t_v[i]);
  //   //printf("%d %lld\n", i, mul);
  //   // cout << i << " " <<  mul << endl;
  // }
  // cout << mul << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

char NumToSuit(int n)
{
    char suit;
    switch (n)
    {
    case 0:
        suit = 'S';
        break;
    case 1:
        suit = 'H';
        break;
    case 2:
        suit = 'C';
        break;
    case 3:
        suit = 'D';
        break;
    default:
        break;
    }

    return suit;
}

int  SuitToNum(char suit)
{
    int suitIndex;
    switch (suit)
    {
    case 'S':
        suitIndex = 0;
        break;
    case 'H':
        suitIndex = 1;
        break;
    case 'C':
        suitIndex = 2;
        break;
    case 'D':
        suitIndex = 3;
        break;
    default:
        break;
    }

    return suitIndex;
}

int main() {
    constexpr int suitLen = 4;
    constexpr int numLen = 13;

    int n;
    cin >> n;

    auto cards = array<array<bool, numLen>, suitLen>();
    
    int num;
    char c;
    for (int i = 0; i < n; ++i)
    {
        cin >> c >> num;

        int suitIndex = SuitToNum(c);

        cards[suitIndex][num - 1] = true;
    }

    for (int i = 0; i < suitLen; ++i)
    {
        char suit = NumToSuit(i);

        for (int j = 0; j < numLen; ++j)
        {
            if (!cards[i][j])
                cout << suit << " " << j + 1 << endl;
        }
    }

    return 0;
} 

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

using namespace std;

int main() {
    int n,k,suma=0,x;
    priority_queue<int,vector<int>, greater<int>> q;
    cin>>n>>k;
    while(n--){
        cin>>x;
        q.push(x);
    }
    while(k--){
        suma+=q.top();
        q.pop();
    }
    cout<<suma;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int n, a[200010];
int poss(int len)
{
	if (len == 1)
	{
		for (int i = 1; i < n; i++)
		{
			if (a[i] <= a[i-1]) return 0;
		}
		return 1;
	}
	deque<pair<int, int> > str;
	int prevlen = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] > prevlen)
		{
			str.emplace_back(1, a[i]-prevlen);
			prevlen = a[i];
		}
		else
		{
			while (prevlen > a[i])
			{
				prevlen -= str.back().second;
				if (prevlen < a[i])
				{
					int type = str.back().first;
					str.pop_back();
					str.emplace_back(type, a[i]-prevlen);
					prevlen += a[i] - prevlen;
				}
				else str.pop_back();
			}
			assert(prevlen == a[i]);
			// Increase by 1
			int pushbacktoback = 0;
			while (str.size() && str.back().first == len)
			{
				pushbacktoback += str.back().second;
				str.pop_back();
			}
			if (str.empty()) return 0;
			int type = str.back().first;
			int am = str.back().second;
			str.pop_back();
			if (am != 1) str.emplace_back(type, am-1);
			str.emplace_back(type+1, 1);
			if (pushbacktoback) str.emplace_back(1, pushbacktoback);
		}
	/*	deque<pair<int, int> > print = str;
		while (print.size())
		{
			printf("%d %d - ", print.front().first, print.front().second);
			print.pop_front();
		}
		printf("\n");*/
	}
	return 1;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) 
	{
		scanf("%d", &a[i]);
	}
	int s = 1;
	int e = 1e9;
	while (s != e)
	{
		int m = (s+e)/2;
		if (poss(m)) e = m;
		else s = m+1;
	}
	assert(poss(s));
	printf("%d\n", s);
}

Measured memory_bytes: 2720