akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define MOD 1000000007

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 ll INF = 1LL << 60;



//大文字小文字気をつけろ


int main(){
  int a[100];
  FOR(i,5){
    cin >> a[i];
  }
  int v,mini=1000;
  FOR(i,5){
      v=a[i]%10;
      if(v!=0)a[i]+=(10-v);
      if(v!=0){
        chmin(mini,v);
      }
  }
  int x;
  if(mini==1000){
    x=0;
  }else{
    x=10-mini;
  }
int ans=0;
  FOR(i,5){
    ans+=a[i];
  }

  cout << ans-x << endl;

  
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
double V = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	
	return;
}


int main(void) {
	double x_;
	double max_ = 0;
	double min_ = 0;

	scanf("%lf", &max_);
	min_ = max_;

	while (scanf("%lf", &x_) != EOF) {
		if (x_ > max_) {
			max_ = x_;
		}
		if (x_ < min_) {
			min_  = x_;
		}
	}

	CO max_ - min_ E
	

	return 0;
}

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

int main() {
    
    while (1) {
        int a[15][6]{};
        int h;
        cin >> h;
        if (h == 0) break;
        for (int i = h-1; i >= 0; i--) {
            for (int j = 0; j < 5; j++) cin >> a[i][j];
        }
        int ans = 0, t = 1;
        while (1) {
            bool flag = false;
            for (int i = 0; i < h; i++) {
                t = 1;
                for (int j = 0; j < 5; j++) {
                    if (a[i][j] == a[i][j + 1])
                        t++;
                    else {
                        if (t >= 3) {
                            flag = true;
                            for (int k = 0; k < t; k++) {
                                ans += a[i][j - k];
                                a[i][j - k] = 0;
                            }
                            
                        }
                        t = 1;
                    }
                    if(a[i][j]==0)t=1;
                }
            }
            if(!flag)break;
            for(int i=0;i<h;i++){
                for(int j=0;j<5;j++){
                    if(a[i][j]==0){
                        int k = i+1;
                        while(1){
                            if(k>h || a[k][j]>0){
                                a[i][j] = a[k][j];
                                a[k][j] = 0;
                                break;
                            }
                            k++;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3068
#include <stdio.h>
#include <string.h>
int getlen(char *,int);
int main(){
  char s[11];
  int len,max;
  scanf("%s",s);
  len=strlen(s);
  max=getlen(s,0);
  for (int i=1;i<len;i++) {
    if (max<getlen(s,i)) max=getlen(s,i);
  }
  printf("%d\n",max);
  return 0;
}

int getlen(char *s,int i){
  if (s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C') return 1+getlen(s,i+1);
  else return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int X;
    cin >> X;
    int a = X % 100, b = X / 100;
    int c = (a + 4) / 5;
    if(b >= c)cout << 1 << endl;
    else cout << 0 << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        final int N = scanner.nextInt();
        final int K = scanner.nextInt();
        final int div = 1000000000 + 7;
        int[] count = new int[K+1];
        int[] memo = new int[K+1];
        for(int i=K; i>=1; i--){
            int n = K/i;
            if(memo[n]>0){
                count[i] = memo[n];
            }else{
                long c = 1;
                for(int j=0; j<N; j++){
                    c = c*n;
                    c = c%div;
                }
                count[i] = (int)c;
                memo[n] = (int)c;
            }
            for(int k=2; k<=n; k++){
                count[i] = count[i] + div - count[i*k];
                count[i] = count[i] % div;
            }
        }
        long res = 0;
        for(int i=1; i<=K; i++){
            long add = ((long)count[i]*(long)i) % div;
            res = (res + add) % div;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 36904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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


int main() {



  int A,B,K;
  scanf("%d %d %d\n",&A,&B,&K );
  int flag=0;

  for (size_t i = 0; i < K; i++) {
    if (flag==0) {
      if (A%2==0) {
        B=B+A/2;
        A=A/2;

      }else{
        A=A-1;
        B=B+A/2;
        A=A/2;
      }
      flag=1;
    }else{
      if (B%2==0) {
        A=A+B/2;
        B=B/2;

      }else{
        B=B-1;
        A=A+B/2;
        B=B/2;
      }
      flag=0;
    }
  }
    printf("%d %d \n",A,B );
    return 0;
  }


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def add(a, b):
  return (a + b) % MOD
def sub(a, b):
  return (a - b) % MOD
def mul(a, b):
  return ((a % MOD) * (b % MOD)) % MOD
def div(a, b):
  return ( (a % MOD) * (power(b, MOD)) ) % MOD
def power(a, b):
  return pow(a, b, MOD)


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
N = 10 ** 5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

n, k = map(int, input().split())
an = list(map(int, input().split()))

an.sort()
cnt = 0
for i, a in enumerate(an):
  cnt += mul(cmb(i, k-1, MOD), a)
  cnt -= mul(cmb(n-i-1, k-1, MOD), a)
cnt = cnt % MOD
print(cnt)

Measured memory_bytes: 26580
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = Console.ReadLine().Split(' ');
            var s = int.Parse(sw[0]);
            var w = int.Parse(sw[1]);
            if(s > w) { Console.WriteLine("safe"); }
            else { Console.WriteLine("unsafe"); }
        }
    }
}


Measured memory_bytes: 27532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var ps = Input().ToInt();
		var n = ps[0];
		var m = ps[1];
		int min = -1;
		int max = 999999999;
		for(int i = 0; i < m; i++)
		{
			ps = Input().ToInt();
			min = Math.Max(ps[0], min);
			max = Math.Min(ps[1], max);
		}
		if(max<min)
			Console.WriteLine(0);
		else
			Console.WriteLine(max - min+1);
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 15292
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var s string
	fmt.Fscanf(r, "%s\n", &s)

	var q int
	fmt.Fscanf(r, "%d\n", &q)

	type op struct {
		t int
		f int
		c byte
	}

	var ops []op
	for i := 0; i < q; i++ {
		o := op{}
		fmt.Fscanf(r, "%d", &o.t)
		if o.t != 1 {
			fmt.Fscanf(r, "%d %c", &o.f, &o.c)
		}
		fmt.Fscanf(r, "\n")
		ops = append(ops, o)
	}

	rev := 0
	var beg, end []byte
	for i := q - 1; i >= 0; i-- {
		o := ops[i]
		if o.t == 1 {
			rev ^= 1
		} else {
			o.f = (o.f - 1) ^ rev
			if o.f == 0 {
				beg = append(beg, o.c)
			} else {
				end = append(end, o.c)
			}
		}
	}

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fprintf(w, string(beg))
	if rev == 1 {
		for i := len(s) - 1; i >= 0; i-- {
			fmt.Fprintf(w, "%c", s[i])
		}
	} else {
		fmt.Fprintf(w, s)
	}
	for i := len(end) - 1; i >= 0; i-- {
		fmt.Fprintf(w, "%c", end[i])
	}
	fmt.Fprintln(w, "")
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    vec<ll> A(N);
    map<ll,ll> lmp;
    map<ll,ll> rmp;
    rep(i,N) {
        cin >> A[i];
        ++lmp[A[i]+i+1];
        ++rmp[i+1-A[i]];
    }
    
    ll ans = 0;
    for(auto [f,s]:lmp){
        ans += s*(rmp[f]);
    }
    
    cout << ans << endl;
}


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

int main(void){
    long long a,b,tmp,x,r;
    cin>>a>>b;
    
    x = a * b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    cout<<x/b<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll M;
  cin >> M;
  ll ans = 24 + (24 - M);
  cout << ans << endl;
  return 0;
}

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

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

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int k[50],s[200][200],p[200],res=0;
long long int swi[30]={},light[30]={};



long long int sousa(long long int id,long long int pattern){
    swi[id]=pattern;
    return 0;
}
//ビット全探索(n択m個)
void bit_tannsaku(long long int n,long long int m,long long int x){
    long long int number[50]={1};
    for(int i=0;i<50;i++){
        number[i+1]=n*number[i];
    }
    for(int i=0;i<number[m];i++){

        for(int j=0;j<25;j++){
            swi[j]=0;
            light[j]=0;
        }


        for(int j=0;j<m;j++){
            long long int tmp=i;
            sousa(j,(tmp/number[j])%n);
        }
        long long int light_num=0;
        for(int j=0;j<x;j++){
            long long int ppp=0;
            for(int p=0;p<k[j];p++){
                if(swi[s[j][p]]==1){
                    ppp++;
                }
            }
            if(ppp%2==p[j]){
                light_num++;
            }
        }
        if(light_num==x){
            res++;
        }
    }
    return ;
}


int main() {
	const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    long long int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    bit_tannsaku(2,n,m);
    cout<<res;
} 


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

int main(){
	string S; cin >> S;
	if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi"){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
    int n;
    cin >> n;

    map<long long,long long,greater<long long>> m;
    rep(i,n){
        long long a;
        cin >> a;
        m[a]++;
    }

    long long edge = -1, ans = 0;
    for(auto it:m){
        if(it.second >= 4){
            ans = max(ans, edge * it.first);
            ans = max(ans, it.first * it.first);
        }else if(it.second >= 2 && edge == -1){
            edge = it.first;
        }else if(it.second >= 2 && edge != -1){
            ans = max(ans, edge * it.first);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
import sys

K = int(sys.stdin.readline().rstrip())

def gcd(a, b):
	while b > 0:
		r = a % b
		a = b
		b = r
	return a

cache = [[gcd(a, b) for b in range(K + 1)] for a in range(K + 1)]
  
sum = 0

for a in range(K):
	for b in range(K):
		ab = cache[a + 1][b + 1]
		for c in range(K):
			sum += cache[ab][c + 1]

print(sum)


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <regex>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 1145141919;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int n, l;
	while (cin >> n >> l,n)
	{
		vector<P> v;
		REP(i, n)
		{
			char c; int p;
			cin >> c >> p;
			v.push_back(P(c == 'L' ? -1 : 1, p));
		}
		int res = n;
		int cnt = 0;
		P lastl,lastr;
		while (res)
		{
			cnt++;
			map<int, vector<int>> m;
			REP(i, v.size())
			{
				v[i].second += v[i].first;
				m[v[i].second].push_back(i);
				if (v[i].second == 0)
				{
					lastl = P(cnt, i);
					res--;
				}
				if (v[i].second == l)
				{
					lastr = P(cnt, i);
					res--;
				}
			}
			REP(i, l)
			{
				if (m[i].size() == 2)
				{
					swap(v[m[i][0]].first, v[m[i][1]].first);
				}
			}
		}
		cout << cnt << " " << (lastl.first >= lastr.first ? lastl.second + 1 : lastr.second + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
n = int(input())
graph = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
L = list(map(int,input().split()))
L.sort()
used = [0]*n
ans = [0]*n
used[0] = 1
ans[0] = L[n-1]
next = graph[0]
cur = n-2
while len(next) > 0:
    t = next.pop()
    ans[t] = L[cur]
    cur -= 1
    used[t] = 1
    for i in range(len(graph[t])):
        if used[graph[t][i]] != 1:
            next.append(graph[t][i])
print(sum(L)-L[n-1])
print(' '.join(map(str,ans)))


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

using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    bool ans = 0;
    for (int i = 1; i < 1500; i++) {
        if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
            cout << i << "\n";
            ans = 1;
            break;
        }
    }
    if (!ans) puts("-1");
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
#define MOD 1000000007
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


int main(){
	ll n,k,memo,cnt = 0,ans = 0;
	vector<ll> vec;
	bool flag[1000010] = {false};
	
	cin >> n >> k;
	
	ll a[n];
	
	rep(i,0,n){
		cin >> a[i];
	}
	
	rep(i,0,n){
		memo = 0;
		rep(j,i,n){
			memo += a[j];
			vec.push_back(memo);
		}
	}
	
	sort(vec.begin(),vec.end(),greater<ll>());
	
	rep(j,0,vec.size()){
		flag[j] = true;
	}
	
	rep(i,0,40){
		cnt = 0;
		ll r,l;
		l = (ll)pow(2,40-i);
		r = (ll)pow(2,39-i);
		
		rep(j,0,vec.size()){
			
			if(l > vec[j] && r <= vec[j]){
				if(flag[j]){
					cnt++;
				}
			}
		}
		
		if(cnt >= k){
			rep(j,0,vec.size()){
				if(l > vec[j] && r <= vec[j]){
					vec[j] -= r;
				}
				else{
					flag[j] = false;
				}
			}
			
			ans += r;
		}
		else{
			rep(j,0,vec.size()){
				if(vec[j] >= r) vec[j] -= r;
			}
		}
		
		/*
		rep(j,0,vec.size()){
			cout << flag[j] << " ";
		}
		cout << endl;
		*/
		
		//cout << r << " " << l << endl;
	}
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>vec,vec2;
ll cnt[1000009];
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    n=1000000;
    for(i=1;i<=n;i++)
    {
        /*a=i*i;
        if(a<=n)
        {
            cnt[a]++;
        }*/
        for(j=i;j<=n;j+=i)
        {
            cnt[j]++;
        }
    }
    cin>>n;
    x=0;
    for(i=1;i<n;i++)
    {
        x+=cnt[i];
    }
    cout<<x<<endl;
}


Measured memory_bytes: 11444
import java.util.*;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		System.out.println(Math.min(A,B)+Math.min(C,D));
		sc.close();
	}

}

Measured memory_bytes: 21844
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter O3 '(optimize (speed 3) (safety 0) (debug 0)))
  (defparameter O2 '(optimize (speed 3) (safety 1))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(defun char-digit (c) (- (char-code c) 48))
(deftype dignum nil `(integer 0 9))

(defun to-int (arr pos1 pos2)
  (loop for exponent = 1 then (* exponent 10)
       for idx from pos2 downto pos1
     sum (* exponent (aref arr idx))))

(defun sum-of-sum (arr pos1 pos2 len sum)
  (if (>= pos2 len)
      (if (= pos1 pos2) sum 0)
      (let ((term (to-int arr pos1 pos2)))
	(+ (sum-of-sum arr pos1 (1+ pos2) len sum)
	   (sum-of-sum arr (1+ pos2) (1+ pos2) len (+ sum term))))))

(defun main ()
  (let ((arr (coerce (map 'list #'char-digit (read-line))
		     '(simple-array dignum (*)))))
    (print-line (sum-of-sum arr 0 0 (length arr) 0))))

#-swank(main)


;; Für Test
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (get-clipbrd)))
    (main)))


;; Für Benchmark
(defparameter *file-path* *load-pathname*)
(defparameter *dir-path* (pathname (directory-namestring *file-path*)))
(defparameter *dat-path* (merge-pathnames "test.dat" *dir-path*))

#+swank
(defun gendat ()
  (with-open-file (out *dat-path*
		       :direction :output :if-exists :supersede)
    ))

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 8680
#include<iostream>

using namespace std;
int main(void){
    
    char o[100], e[100], out[200];

    cin >> o >> e;

    for(int i=0;i < 200; i+=2){
        out[i]=o[i/2];
        out[i+1]=e[i/2];
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100001
int A[MAX],n;
int main(){
  int i,j,r,x,n,p,c,k,q;

  scanf("%d",&n);
  for(i=0;i < n;i++){
    scanf("%d",&A[i]);
  }
  r=n-1;
  x=A[r];
  q=par(0,n-1);
 
  for(k=0;k < n ;k++){
    if(k)printf(" ");
    if(k==q)printf("[");
    printf("%d",A[k]);
    if(k==q)printf("]");
  }
  printf("\n");
  return 0;
}
int par(int p,int r){
  int x,i,c,j;
  x=A[r];
  
  i=p-1;
  for(j=p; j < r ;j++){
    if(A[j]  <=x){
      i++;
      c=A[i];
      A[i]=A[j];
      A[j]=c;
    }
  }
  c=A[i+1];
  A[i+1]=A[r];
  A[r]=c;
  return i+1;
}



Measured memory_bytes: 2072
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t N,K,ans=0;
  cin>>N>>K;
  vector<int64_t> A(N);
  for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  sort(A.begin(),A.end());
  for (int i = 0; i < K; i++) { ans+=A[i];}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}


Measured memory_bytes: 3624
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

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


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);} 


int32_t main()
{
	ll n;
	cin >> n;
	ll ans = max(n*(n+1)/2 - n,0LL);
	cout <<ans<<endl;
	
}

Measured memory_bytes: 3656
N = int(input())
A = list(map(int, input().split()))

ans = [0] * N
tmp = 0

for i in range(N) :
    #print(tmp)
    if i % 2 == 0 :
        tmp += A[i]
    else :
        tmp -= A[i]

ans[0] = tmp

for i in range(1, N) :
    ans[i] = 2 * A[i - 1] - ans[i - 1]

for i in range(N-1) :
    print(ans[i], end=" ")
print(ans[N-1])


Measured memory_bytes: 14032
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    cin >> a[i];
  }
  sort(a, a + n);

  int ans = 0, count = 0;
  while(count < n) {
    int cc = a[count], f = 0;
    while(count < n && a[count] == cc) f++, count++;
    ans += f % 2;
  }

  cout << ans << endl;
}


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

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, x, y, s, t;

signed main() {
	cin >> n >> m;
	rep(i,n) {
		cin >> x;
		(s += x*(-n+2*i+1)) %= mod;
	}
	rep(i,m) {
		cin >> y;
		(t += y*(-m+2*i+1)) %= mod;
	}
	cout << s*t %mod;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll ans[51];
ll ar[51][51];
void mult(ll a1[51][51], ll b1[51][51])
{
	ll tmp[51][51];
	ll n = 51;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			ll sum = 0;
			for(int k=0;k<n;k++)
			{
				ll xx = a1[i][k]*b1[k][j];
				sum = (sum+xx)%mod;
			}
			tmp[i][j] = sum;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			a1[i][j] = tmp[i][j];
	}
}
ll power(ll x, ll a)
{
    ll sum=1;
    while(a>0)
    {
        if(a&1==1)
        {
            sum=x*sum;
            sum%=mod;
        }
        a>>=1;
        x=x*x;
        x%=mod;
    }
    return sum;
}
ll matrixexp(ll n)
{
	ll s1 = 0;

	ll sum[51][51];
	memset(sum,0,sizeof(sum));
	for(int i=0;i<51;i++)
	{
		sum[i][i] = 1;;
	}
	while(n>0)
	{
		
		if(n&1==1)
		{
			mult(sum,ar);
		}
		n>>=1;
		mult(ar,ar);
	}	
	ll an = 0;
	for(int i=0;i<51;i++)
	{
		for(int j=0;j<51;j++)
			s1 = (s1 + sum[i][j] * ans[j])%mod;
	}
	return s1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n>>k;
    	ll s2 = 0;
    	for(int i=0;i<n;i++)
    	{
    		for(int j=0;j<n;j++)
    			cin>>ar[j][i];
    	}
    	memset(ans,0,sizeof(ans));
		for(int i=0;i<n;i++)
		{
			ll s1 = 0;
			for(int j=0;j<n;j++)
			{
				s1 += ar[i][j]; 
				if(ar[i][j])
					s2++;
			}
			ans[i] = s1;
		}
		if(k==1)
		{
			cout<<s2<<endl;
			return 0;
		}

		ll sum = matrixexp(k-1);
    	cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int h;
  int a;
  
 
  scanf("%d",&h);
  scanf("%d",&a);
  
  if(h%a==0){
    printf("%d",h/a);
  }else{
    printf("%d",h/a+1);
  }
  
  return 0;
}


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

int N, D1, D2;
using P = pair<int, int>;

void bfs(int i, int j, vector<P> NG, vector<vector<int> >& color)
{
    queue<P> list;
    list.push(make_pair(i*(2*N)+j, color[i][j]));
    while (!list.empty())
    {
        P p = list.front();
        list.pop();
        for (auto ng : NG)
        {
            int x = p.first / (2*N) + ng.first;
            int y = p.first % (2*N) + ng.second;
            if (x < 0 || x >= 2*N || y < 0 || y >= 2*N) continue;
            if (color[x][y] < 0)
            {
                color[x][y] = 1 - p.second;
                list.push(make_pair(x*(2*N)+y, color[x][y]));
            }
        }
    }
    return;
}

int main()
{
    cin >> N >> D1 >> D2;

    vector<P> NG1, NG2;
    for (int i = 0; i < 2 * N; i++)
    {
        int e1 = sqrt(D1 - i * i);
        if (e1 * e1 + i * i == D1)
        {
            NG1.push_back(make_pair(i, e1));
            NG1.push_back(make_pair(i, -e1));
            NG1.push_back(make_pair(-i, e1));
            NG1.push_back(make_pair(-i, -e1));
        }
        int e2= sqrt(D2 - i * i);
        if (e2 * e2 + i * i == D2)
        {
            NG2.push_back(make_pair(i, e2));
            NG2.push_back(make_pair(i, -e2));
            NG2.push_back(make_pair(-i, e2));
            NG2.push_back(make_pair(-i, -e2));
        }
    }
    vector<vector<int> >color1(2 * N, vector<int>(2 * N, -1));
    vector<vector<int> >color2(2 * N, vector<int>(2 * N, -1));
    
    for (int i = 0; i < 2 * N; i++)
    {
        for (int j = 0; j < 2 * N; j++)
        {
            if (color1[i][j] == -1)
            {
                color1[i][j] = 0;
                bfs(i, j, NG1, color1);
            }
            if (color2[i][j] == -1)
            {
                color2[i][j] = 0;
                bfs(i, j, NG2, color2);
            }
        }
    }

    int count1 = 0;
    int count2 = 0;
    for (int i=0; i<2*N; i++)
    {
        for (int j=0; j<2*N; j++)
        {
            if (color1[i][j] == 1) count1++;
            if (color2[i][j] == 1) count2++;
        }
    }
    int pick1 = (count1>2*N*N) ? 1 : 0;
    int pick2 = (count2>2*N*N) ? 1 : 0;
    
    int points = 0;
    for (int i=0; i<2*N; i++)
    {
        for (int j=0; j<2*N; j++)
        {
            if (color1[i][j] == pick1 && color2[i][j] == pick2)
            {
                cout << i << " " << j << endl;
                // cout << color1[i][j] << " " << color2[i][j] << endl;
                points++;
                if (points == N*N) return 0;
            }
        }
    }
    return 0;
}

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

int main() {
    int n, T; cin >> n >> T;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }

    vector<vector<int>> dp_l(n + 1, vector<int>(T + 1, -1));
    vector<vector<int>> dp_r(n + 1, vector<int>(T + 1, -1));
    dp_l[0][0] = dp_r[n][0] = 0;
    for(int i = 0; i < n; ++i) {
        dp_l[i + 1] = dp_l[i];
        for(int j = 0; j <= T; ++j) {
            if(dp_l[i][j] == -1 || j + a[i] > T) continue;
            dp_l[i + 1][j + a[i]] = max(dp_l[i + 1][j + a[i]], dp_l[i][j] + b[i]);
        }
    }
    for(int i = n; i >= 1; --i) {
        dp_r[i - 1] = dp_r[i];
        const int idx = i - 1;
        for(int j = 0; j <= T; ++j) {
            if(dp_r[i][j] == -1 || j + a[idx] > T) continue;
            dp_r[i - 1][j + a[idx]] = max(dp_r[i - 1][j + a[idx]], dp_r[i][j] + b[idx]);
        }
    }
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j < T; ++j) {
            dp_l[i][j + 1] = max(dp_l[i][j + 1], dp_l[i][j]);
            dp_r[i][j + 1] = max(dp_r[i][j + 1], dp_r[i][j]);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        for(int t1 = 0; t1 < T; ++t1) {
            ans = max(ans, dp_l[i][t1] + dp_r[i + 1][T - t1 - 1] + b[i]);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
const int MAX = 200;
using UC = unsigned char;
int a[MAX][MAX];
int s[MAX][MAX];

int query(UC u,UC d,UC l,UC r){
  assert(u<=d&&l<=r);
  return (s[u][l]+s[d][r])-(s[u][r]+s[d][l]);
}


UC lg[MAX]={};
int calc(UC u,UC d,UC l,UC r){
  return (d*(d-1)/2+u)*(185*186/2)+(r*(r-1)/2+l);
}

UC dp[296012025]={};
UC dfs(UC u,UC d,UC l,UC r){
  if(query(u,d,l,r)==0) return 0;
  if(query(u,d,l,r)==(int)(d-u)*(r-l)) return 0;
  
  int st=calc(u,d,l,r);
  if(dp[st]) return dp[st];  
  UC &res=dp[st];
  res=lg[d-u]+lg[r-l]; 
  
  {
    int L=u,R=d;
    while(L+1<R){
      int M=(L+R)>>1;
      UC y=M;
      UC a=dfs(u,y,l,r);
      UC b=dfs(y,d,l,r);
      if(min(a,b)+1>=res) break;
      chmin(res,max(a,b)+1);
      if(a>=b) R=M;
      else L=M;
    }
  }
  {
    int L=l,R=r;
    while(L+1<R){
      int M=(L+R)>>1;
      UC x=M;
      UC a=dfs(u,d,l,x);
      UC b=dfs(u,d,x,r);
      if(min(a,b)+1>=res) break;
      chmin(res,max(a,b)+1);
      if(a>=b) R=M;
      else L=M;
    }
  }
  return res;
}

signed main(){    
  int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  for(int i=2;i<MAX;i++) while((1<<lg[i])<i) lg[i]++;
  
  memset(a,0,sizeof(a));
  memset(s,0,sizeof(s));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      a[i][j]=st[i][j]=='.';
    
  for(int i=0;i+1<MAX;i++)
    for(int j=0;j+1<MAX;j++)
      s[i+1][j+1]=s[i+1][j]+a[i][j];
  
  for(int i=0;i+1<MAX;i++)
    for(int j=0;j<MAX;j++)
      s[i+1][j]+=s[i][j];
  
  cout<<(int)dfs(0,h,0,w)<<endl;
  return 0;
}


Measured memory_bytes: 289664
abcd=list(map(int,input().split()))
count=1
while(abcd[0]>0 and abcd[2]>0):
    if((count%2)==1):
        abcd[2]-=abcd[1]
    else:
        abcd[0]-=abcd[3]
    count+=1
if(abcd[0]>0 and abcd[2]<=0):
        print('Yes')
if(abcd[0]<=0 and abcd[2]>0):
    print('No')
        



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

int main(){
    int N;
    int ans = 0;
    cin >> N;
    int a;
    for (int i=0; i < N; i++) {
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	vector<vector<pii>> g(n);
	vector<pii> ed(m);
	REP(i, m) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		g[a].push_back({ b,c });
		g[b].push_back({ a,c });
		ed[i] = { a,b };
	}
	priority_queue<pair<pii, int>, vector<pair<pii, int>>, greater<pair<pii, int>>> que;
	REP(i, k) {
		int a;
		scnaf("%d", &a);
		a--;
		que.push({ { 0,a },-1 });
	}
	vector<int> al(n,-1);
	while (que.size()) {
		pair<pii,int> cur = que.top();
		que.pop();

		if (~al[cur.first.second])
			continue;
		al[cur.first.second] = cur.first.first;

		for (auto itr : g[cur.first.second]) {
			if(!~al[itr.first])
				que.push({ {cur.first.first + itr.second, itr.first}, cur.first.second});
		}
	}
	int ans = 0;
	REP(i, m) {
		int len;
		for (auto itr : g[ed[i].first]) {
			if (itr.first == ed[i].second) {
				len = itr.second;
				break;
			}
		}
		int susu = abs(al[ed[i].first] - al[ed[i].second]);
		len -= susu;
		ans = max(ans,(len + 1) / 2 + max(al[ed[i].first], al[ed[i].second]));
	}
	printf("%d\n", ans);
	return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n =  sc.nextInt();
	String[] s = new String[n];
	int max = 0;
	int count=0;
	Map<String,Integer> Hash = new HashMap<>();
	ArrayList<String> list = new ArrayList<String>();
	for(int i=0;i<n;i++) {
		s[i] = sc.next();
	}

	 for(String a:s) {
         if(Hash.containsKey(a)) {
        	 count = Hash.get(a)+1;
        	 Hash.replace(a, count);
         }
         else {
        	 Hash.put(a, 1);
         }
	 }

	 for(String b:Hash.keySet()) {
		 max = Math.max(Hash.get(b),max);
	 }

	 for(String c:Hash.keySet()) {
		 if(Hash.get(c)==max) {
			 list.add(c);
		 }
	 }
	 Collections.sort(list);
	 for(int i=0;i<list.size();i++) {
	 System.out.println(list.get(i));
	 }
  }
}

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

using namespace std;

#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define fr(n) for(int i=n-1;i>=0;i--)
#define chlo(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
#define vs vector<string>
#define int long long int
#define all(a) (a).begin(),(a).end()

#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define zerbits(x) __builtinctzll(x)
#define mod 1000000007
#define sz(x) (int)x.size()
#define inf 1e18
#define W(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define INT_SIZE 32
#define pr pair<int,int>
void aeh()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("aana.txt", "r", stdin);
	freopen("jj.txt", "w", stdout);
#endif
}

int32_t main()
{

	int n;
	cin >> n;
	vi a(n);
	fi(n)
	cin >> a[i];
	int dp[n] {0}; //dp[i]would give the minimum cost to reach ith step
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i - 2] - a[i]));
	}
	cout << dp[n - 1] << endl;

}

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

int main(){
    int n,r;
    cin >> n >> r;
    if(n < 10) cout << 100*(10 - n)+r << endl;
    else cout << r << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    vector<pair<ull,ull>> BA(N);
    for(int i=0; i<N; i++) {
        cin >> BA[i].second >> BA[i].first;
    }
    sort(BA.begin(), BA.end());

    ull cum = 0;
    for(int i=0; i<N; i++) {
        cum += BA[i].second;
        if(i<N-1 && BA[i].first==BA[i+1].first) 
            continue;

        if(BA[i].first < cum) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define maxn 100005
#define error {puts("-1");return 0;}
#define ll long long
using namespace std;

map <ll,int> mp;

struct edge{
	int to,nxt;
}e[maxn<<1];

struct node{
	ll dis;int id;
	bool operator < (const node &A) const {return dis>A.dis;}
}a[maxn];

struct uv{
	int u,v;
	bool operator < (const uv &A) const {return u==A.u?v<A.v:u<A.u;}
}ans[maxn];

int cnt,head[maxn],n;ll dis[maxn],size[maxn];

void add(int u,int v){
	e[++cnt]=(edge){v,head[u]};
	head[u]=cnt;
}

void dfs(int u,int fa,int dep){
	dis[a[n].id]+=dep;size[u]=1;
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa) continue;
		dfs(v,u,dep+1);
		size[u]+=size[v];
	}
}

void dfs(int u,int fa){
	for(int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa) continue;
		dis[v]=dis[u]+n-size[v]*2;
		dfs(v,u);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i].dis);
		a[i].id=i;
		mp[a[i].dis]=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) size[i]=1;
	for(int i=1;i<n;i++){
		int u=a[i].id;
		ll tmp=n-size[u]*2;
		if(tmp<=0||!mp.count(a[i].dis-tmp)) error
		int fa=mp[a[i].dis-tmp];
		size[fa]+=size[u];
		add(u,fa);add(fa,u);
		ans[i].u=min(u,fa);
		ans[i].v=max(u,fa);
	}
	sort(ans+1,ans+n);
	dfs(a[n].id,0,0);
	dfs(a[n].id,0);
	for(int i=1;i<=n;i++) if(dis[a[i].id]!=a[i].dis) error
	for(int i=1;i<n;i++) printf("%d %d\n",ans[i].u,ans[i].v);
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  int sum=0;
  for(int i=0; i<N; ++i){
    cin >> X[i];
    sum += X[i];
  }
  int S1=0;
  int S2= sum;
  int diff = 0;
  int ans = sum;
  for(int i=0; i<N; ++i){
    S1 += X[i];
    S2 -= X[i];
    diff = abs(S2-S1);
    if(diff < ans) ans = diff;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,SUM=0;
vector<int>A;

int main()
{
	cin>>N;
	A.push_back(0);

	for(int i=1;i<=N;i++)
	{
		int p;
		cin>>p;
		A.push_back(p);
		SUM+=abs(A[i-1]-A[i]);
	}
	SUM+=abs(A[N]-0);
	A.push_back(0);

	for(int i=1;i<=N;i++)
	{
		int ts=SUM;
		if(!((A[i-1]<=A[i]&&A[i]<=A[i+1])||A[i-1]>=A[i]&&A[i]>=A[i+1]))
		{
			ts=SUM+(-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]));
		}
		cout<<ts<<endl;
	}
}

Measured memory_bytes: 1784
#include<iostream>
#include<vector>

using namespace std;

class DisjointSet{
public:
  vector<int> rank, p;

  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; i++) {
      makeSet(i);
    }
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;

  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; i++) {
    cin >> t >> a >> b;
    if (t == 0) {
      ds.unite(a, b);
    } else if (t == 1) {
      if (ds.same(a, b)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }

  return 0;
}


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

int main(){
    int x;
    cin >> x;
    if (x>=1800) {cout << 1 << endl;}
    else if (x>=1600) {cout << 2 << endl;}
    else if (x>=1400) {cout << 3 << endl;}
    else if (x>=1200) {cout << 4 << endl;}
    else if (x>=1000) {cout << 5 << endl;}
    else if (x>=800) {cout << 6 << endl;}
    else if (x>=600) {cout << 7 << endl;}
    else  {cout << 8 << endl;}

}


Measured memory_bytes: 3624
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
string ans="";
// void solve(string s,string w,int m,int n)
// {
// 	if(m==0 || n==0)
// 		return ;
// 	if(s[m-1]==w[n-1])
// 	{
// 		ans=ans+s[m-1];
// 		solve(s,w,m-1,n-1);
// 	}
// 	else{
// 	solve(s,w,m-1,n);
// 	solve(s,w,m,n-1);}
// }
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	string s,w;
	cin>>s>>w;

	m=s.length();
	n=w.length();
	ll dp[m+1][n+1];
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			else if(s[i-1]==w[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	h=dp[m][n];
	string ans="";
	i=m;j=n;
	while(i>0 && j>0)
	{
		if(s[i-1]==w[j-1])
		{
			ans=ans+s[i-1];
			i--;j--;h--;
		}
	
	else if(dp[i-1][j]>dp[i][j-1])
		i--;
	else j--;
   }
   reverse(ans.begin(),ans.end());
   cout<<ans;

}



	

		

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

int main() {
  string a, b;
  cin >> a >> b;
  
  if ((a.at(0) == b.at(2))&&(a.at(2) == b.at(0))&&(a.at(1) == b.at(1)))
    cout << "YES" << endl;
   else cout << "NO" << endl;
  }

Measured memory_bytes: 256