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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++){v.at(i)=i+1;}
    int ans = accumulate(v.begin(), v.end(), 0);
    cout << ans;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 4e2 + 10;
ll dp[MAX_N][MAX_N], cost[MAX_N][MAX_N];
ll a[MAX_N], b[MAX_N];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, c;
    cin >> n >> c;
    for(ll i = 0; i < n; i ++) {
        cin >> a[i];
    }
    for(ll i = 0; i < n; i ++) {
        cin >> b[i];
    }
    for(ll i = 0; i < n; i ++) {
        for(ll j = a[i]; j <= b[i]; j ++) {
            ll pw = 1;
            for(ll k = 0; k <= c; k ++) {
                cost[i][k] += pw;
                fix(cost[i][k]);
                pw *= j;
                fix(pw);
            }
        }
    }
    dp[0][0] = 1;
    for(ll i = 0; i < n; i ++) {
        for(ll k = 0; k <= c; k ++) {
            for(ll help = 0; k + help <= c; help ++) {
                dp[i + 1][k + help] += (dp[i][k] * cost[i][help]);
                fix(dp[i + 1][k + help]);
            }
        }
    }
    cout << dp[n][c] << endl;;
    return 0;
}




Measured memory_bytes: 2816
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <stack>
#include <cstdio>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <iterator>
#include <sstream>
#define popcount(x) __builtin_popcount(x)
#define oddparity(x) __builtin_parity(x)
#define clz(x) __builtin_clz(x)
#define ctz(x) __builtin_ctz(x)
#define sf scanf
#define pf printf
#define ll long long int
using namespace std;

int i, ans, x, n;
string s;

int main()
{
    sf("%d", &n);
    cin >> s;
    for (i = 0; i < n; i++) {
        if (s[i] == 'I') x++;
        else x--;
        if (x > ans) ans = x;
    }
    pf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]
    AB = sorted(AB, key=lambda x: x[0])
    flag = AB[0][1]
    cnt = 1
    for i in range(M):
        if AB[i][0] >= flag:
            flag = AB[i][1]
            cnt += 1
        elif AB[i][1] > flag:
            continue
        else:
            flag = AB[i][1]
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29928
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n;
	vector<pair<int,int>> v;
	cin >> n;
	for(int i=0;i<n;i++){
		char c;
		int a;
		cin >> c >> a;
		if(c=='S') c=0;
		if(c=='H') c=1;
		if(c=='C') c=2;
		if(c=='D') c=3;
		v.push_back(make_pair((int)c,a));
	}
	for(int i=0;i<4;i++){
		for(int j=1;j<=13;j++){
			if(find(v.begin(),v.end(),make_pair(i,j)) == v.end()){
				if(i==0) cout << "S " << j << endl;
				if(i==1) cout << "H " << j << endl;
				if(i==2) cout << "C " << j << endl;
				if(i==3) cout << "D " << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3140
let () =
  let line = read_line () in
  let capitalize str =
    let len = String.length str in
    let rec loop i = match i with
        i when i=len -> ""
      | i -> (Char.uppercase str.[i] |> String.make 1)^(loop (i+1))
    in loop 0
  in capitalize line |> print_endline;;

Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	int x;
	cin >> x;
	x -= 400;
	x /= 200;
	x += 1;
	cout << 9 - x << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
//using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647    //int値の最大値
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                            //vectorヘの挿入
#define MP make_pair                            //pairのコンストラクタ
#define F first                                 //pairの一つ目の要素
#define S second                                //pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

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

    int n, d;
    cin >> n >> d;
    vector<vector<double>> x(n, vector<double>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    
    int total = 0;
    vector<int> ans;

    rep(i, n-1){ for (int j = i + 1; j < n; j++){int sum = 0;
    rep(k, d) {
        
        sum += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
        
    }
    ans.push_back(sum);
        }}

   rep(i,ans.size()){
       rep(j,10000){
           if (ans[i] == j * j) {
               total++;
               break;
           }
       }
   }
   cout << total << endl;
}


Measured memory_bytes: 3784
#include "bits/stdc++.h"

using namespace std;
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; }

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

ll n;
ll a[200020];

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

	ll res = 0;
	int t = 0;
	ll sum = 0;
	for(int s = 0; s < n; s++) {
		while(t < n && (sum ^ a[t]) == (sum + a[t])) sum += a[t++];

		res += t - s;
		if(s == t) t++;
		else sum -= a[s];
	}

	cout<< res <<endl;
	
	return 0;
}

Measured memory_bytes: 1792
from functools import reduce
MOD = 10**9 + 7


def cmb(N, A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
a %= MOD
b %= MOD


print((pow(2, n, MOD) - 1 - cmb(n, a) - cmb(n, b)) % MOD)

Measured memory_bytes: 3572
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    map<string, int> ma;
    string prev = "unti";
    rep(i, N) {
        string s;
        cin >> s;
        if (i != 0) {
            if (ma[s] != 0) {
                cout << "No" << endl;
                return 0;
            }
            if (prev.back() != s.front()) {
                cout << "No" << endl;
                return 0;
            }
        }
        ma[s]++;
        prev = s;
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define ll long long
const int inf = 1000000000; // 10^9

int main(){
    char s[10];
    rep(i,6) cin >> s[i];

    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;



    return 0;
}

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

namespace ABC087C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A1N = Console.ReadLine()
                .Split(' ')
                .Select(a => int.Parse(a))
                .ToList();
            var A2N = Console.ReadLine()
                .Split(' ')
                .Select(a => int.Parse(a))
                .ToList();
            var max = 0;
            for (var i = 0; i < N; i++)
            {
                var a1Total = A1N.Take(i + 1).Sum();
                var a2Total = A2N.Skip(i).Take(N - i).Sum();
                var total = a1Total + a2Total;
                max = Math.Max(max, total);
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 28296
l, r = map(int, input().split())

l_quo = l // 2019
r_quo = r // 2019
l_mod = l % 2019
r_mod = r % 2019

if l_quo < r_quo:
	print(0)
else:
	min = 2020
	for i in range(l_mod, r_mod+1):
		for j in range(i+1, r_mod+1):
			if (i*j)%2019 < min:
				min = (i*j)%2019
				
	print(min)

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(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 yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    vector<double> speed;

    vector<int> t(N);

    int T = 0;
    REP(i,N){
        cin >> t[i];
        T += t[i];
    }

    speed.push_back(0);
    REP(i,N){
        double v;
        cin >> v;

        chmin(speed[speed.size()-1],v);
        REP(j,t[i]*2) speed.push_back(v);
    }
    speed[2*T]=0;

    for(int i=0  ;i<2*T;i++) chmin(speed[i+1],speed[i]+0.5);
    for(int i=2*T;i>0  ;i--) chmin(speed[i-1],speed[i]+0.5);

    double ans = 0;
    REP(i,2*T) ans += (speed[i]+speed[i+1])*0.5/2.0;

    printf("%.12f\n",ans);

    return 0;
}


Measured memory_bytes: 892
N = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
S = gets.chomp.chars

def solve
  if N % 2 != 0
    print "No\n"
    return
  end
  # Now, N is odd

  ans = true
  0.upto(N/2 - 1).each do |i|
    if (S[i] != S[i + N/2])
      ans = false
      break
    end
  end

  if ans
    print "Yes\n"
  else
    print "No\n"
  end
end

solve


Measured memory_bytes: 1788
import * as fs  from 'fs';

//in
// A
//out
// T

//in
// G
//out
// C

const main = (inp: string) => {
    const tables :{[s:string]:string}= {
        'A': 'T',
        'T': 'A',
        'G': 'C',
        'C': 'G'
    };

    console.log(tables[inp]);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


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

typedef struct
{
  int w, v;
  double vdw;
} Goods;

class GreaterVDW
{
public:
  bool operator() (const Goods& lhs, const Goods& rhs)
  {
    return lhs.vdw > rhs.vdw;
  }
};

int main()
{
  int N, W;
  while (cin >> N >> W) {
    double ans = 0.0;
    vector<Goods> goods;
    goods.reserve(N);
    for (int i = 0; i < N; ++i) {
      int w, v;
      scanf("%d %d", &w, &v);
      if (w >= 0 && v <= 0) {
	continue;
      } else if (w <= 0 && v >= 0) {
	W -= w;
	ans += v;
      } else {
	Goods g;
	g.w = w;
	g.v = v;
	if (g.w < 0 && g.v < 0) {
	  g.w = -g.w;
	  g.v = -g.v;
	  W += g.w;
	  ans -= g.v;
	}
	g.vdw = v / (w * 1.0);
	goods.push_back(g);
      }
    }
    sort(goods.begin(), goods.end(), GreaterVDW());

    for (unsigned int i = 0; i < goods.size(); ++i) {
      if (W < goods[i].w) {
	ans += (W / (goods[i].w * 1.0)) * goods[i].v;
	break;
      } else {
	ans += goods[i].v;
	W -= goods[i].w;
      }
    }
    printf("%.6f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
    int c;
    while((c = getchar()) != EOF) {
        if(c >= 'a' && c <= 'z') {
            putchar(c - 'a' + 'A');
        } else if(c >= 'A' && c <= 'Z') {
            putchar(c - 'A' + 'a');
        } else {
            putchar(c);
        }

        if(c == '\n') {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2100
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

res = 0
for i in range(N):
    s = 0
    for j in range(i + 1):
        s += A[0][j]
    for k in range(i, N):
        s += A[1][k]
    res = max(res, s)
print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int eq_max = 0;
    for(int i = 0; i <= s.length() - t.length(); i++){
        int j = 0, eq = 0;
        for(int k = i; k < i + t.length(); k++){
            if(s[k] == t[j]) eq++;
            j++;
        }
        eq_max = max(eq_max, eq);
    }
    cout << t.length() - eq_max << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define inf 1000000000
#define mod 1000000007
using namespace std;
map<ll, ll> mp;
int main () {
	ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
	scanf("%lld", &a);
	for (i = 1; i <= a; i++) {
		scanf("%lld", &b);
		mp[b]++;
	}
	auto it = mp.end(); it--;
	c = d = 0;
	while (true) {
		while (it->se >= 2) {
			if (c == 0) {
				c = it->fi; it->se -= 2;
			}
			else if (d == 0) {
				d = it->fi;
				break;
			}
		}
		if (c && d) break;
		if (it == mp.begin()) break;
		it--;
	}
	printf("%lld\n", c * d);
	return 0;
}

Measured memory_bytes: 6528
H, W = map(int, input().split())

A = [[int(j) for j in input().split()] for i in range(H)]
s_min = 25 * 25 * 1000
for i in range(H):
    for j in range(W):
        s = 0
        for y in range(H):
            for x in range(W):
                s += A[y][x] * min(abs(x - j), abs(y - i))
        if s < s_min:
            s_min = s

print(s_min)



Measured memory_bytes: 5608
import math
def main():
    A_1 = list(map(int, input().split()))
    A_2 = list(map(int, input().split()))
    A_3 = list(map(int, input().split()))

    A = [A_1, A_2, A_3]


    N = int(input())

    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = 0

    if sum(A[0]) == 0:
        print("Yes")
    elif sum(A[1]) == 0:
        print("Yes")
    elif sum(A[2]) == 0:
        print("Yes")
    elif (A[0][0] == 0) and (A[1][0] == 0) and (A[2][0] == 0):
        print("Yes")
    elif (A[0][1] == 0) and (A[1][1] == 0) and (A[2][1] == 0):
        print("Yes")
    elif (A[0][2] == 0) and (A[1][2] == 0) and (A[2][2] == 0):
        print("Yes")
    elif (A[0][0] == 0) and (A[1][1] == 0) and (A[2][2] == 0):
        print("Yes")
    elif (A[0][2] == 0) and (A[1][1] == 0) and (A[2][0] == 0):
        print("Yes")
    else:
        print("No")

    return 0
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    r = Number(tmp0[0]);
    D = Number(tmp0[1]);
    x = Number(tmp0[2])
   
    beforex = x
    for(var i=0; i<10; i++){
        newx = r * beforex - D
        console.log(newx)
        beforex = newx
    }
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   Main("4 40 60\n");

Measured memory_bytes: 21320
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    int dp[n][2];
    mem(dp,0);

    dp[0][0]=0,dp[0][1]=v[0];
    dp[1][0]=max(v[0],v[1]);

    for(int i=2;i<n;++i)
    {
        if(i%2==0)
        {
            dp[i][0]=max(dp[i-1][0],dp[i-2][0]+v[i]);
            dp[i][1]=dp[i-2][1]+v[i];
        }
        else
            dp[i][0]=max(dp[i-1][1],dp[i-2][0]+v[i]);
    }

    cout<<dp[n-1][0];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 7916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  char c[55][55];
  int H, W, cnt;
  cin >> H >> W;
  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
      cin >> c[i][j];
  }
  for (int i = 1; i <= H; i++)
  {
    for (int j = 1; j <= W; j++)
    {
      if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#')
        cnt++;
    }
  }
  if (cnt == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

using namespace std;

int R[100009];
int n;

int partition(int q, int r){
    int x = R[r];
    int i = q - 1;
    for(int j = q; j < r; j ++){
        if( R[j] <= x){
            i = i + 1;
            int temp = R[i];
            R[i] = R[j];
            R[j] = temp;
        }
    }
    int temp = R[r];
    R[r] = R[i + 1];
    R[i + 1] = temp;
    return i + 1;
}

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> R[i];
    }
    int r = partition(0, n-1);
    for(int i = 0; i < n-1; i++){
        if(i == r){
            cout << "[" << R[r] << "]" << " ";
            continue;
        }
        cout << R[i] << " ";
    }
    cout << R[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{     
    static int Bisect(long[] data, long value)
    {
        int ret = -1;
        for(int start = 0, end = data.Length - 1; start <= end;)
        {
            int mid = (start + end) / 2;
            if(data[mid] == value)
                return mid;
            else if(data[mid] > value)
            {
                end = mid - 1;
            }
            else
            {
                start = mid + 1;
                ret = mid;
            }
        }
        return ret;
    }
    public void Slove()
    {
        string[] inputs = Console.ReadLine().Split();
        int a = int.Parse(inputs[0]);
        int b = int.Parse(inputs[1]);
        int q = int.Parse(inputs[2]);
        long[] shrines =
            Enumerable.Range(0, a)
            .Select(x => long.Parse(Console.ReadLine()))
            .OrderBy(x => x)
            .ToArray();
        long[] temples = 
            Enumerable.Range(0, b)
            .Select(x => long.Parse(Console.ReadLine()))
            .OrderBy(x => x)
            .ToArray();
        long[] result =
            Enumerable.Range(0, q)
            .Select(x =>
            {
                long start = long.Parse(Console.ReadLine());
                int al = Bisect(shrines, start);
                int ar = al + 1;
                int bl = Bisect(temples, start);
                int br = bl + 1;
                long[] d = new long[]
                {
                    al >= 0 && bl >= 0 ? Math.Max(start - shrines[al], start - temples[bl]) : long.MaxValue,
                    ar < shrines.Length && br < temples.Length ? Math.Max(shrines[ar], temples[br]) - start : long.MaxValue,
                    al >= 0 && br < temples.Length ? (start - shrines[al]) * 2 + (temples[br] - start) : long.MaxValue,
                    al >= 0 && br < temples.Length ? (start - shrines[al]) + (temples[br] - start) * 2 : long.MaxValue,
                    ar < shrines.Length && bl >= 0 ? (start - temples[bl]) * 2 + (shrines[ar] - start) : long.MaxValue,
                    ar < shrines.Length && bl >= 0 ? (start - temples[bl]) + (shrines[ar] - start) * 2 : long.MaxValue,
                };
                //System.Console.WriteLine(string.Join(" ", d));
                return d.Min();
            }
            ).ToArray();
        System.Console.WriteLine(string.Join("\n", result));
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 32456
'use strict';
var Main = function(stdin) {
  var line = stdin.split('\n');
  var param = line[0].split(' ').map(Number);
  var result = (function(width,height,x,y,r) {
  	return [
  		y + r > height
  		,y - r < 0
  		,x - r < 0
  		,x + r > width
  	].some(function(v){
  		return v;
  	}) ? 'No' : 'Yes' ;
  }(
  	param[0],param[1],param[2],param[3],param[4]
  ));
  console.log(result);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7384
A,B,C,X,Y = map(int,input().split())

if A+B<=C*2:
  print(A*X+B*Y)

else:
  if X<=Y:
    d = Y-X
    print(min((Y-d)*2*C+B*d,Y*2*C))
  else:
    d = X-Y
    print(min((X-d)*2*C+A*d,X*2*C))

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

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

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

fastio _fast_io;

const int N = 1e7 + 1;
int n;
int a[N];

int main() {
    cin >> n;
    for (int i = 2; i < n; ++i) {
        for (int j = i + i; j <= n; j += i) {
            ++a[j];
        }
    }
    ll res = 0;
    for (int i = 2; i <= n; ++i) {
        res += 1LL * i * (a[i] + 2);
    }
    ++res;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 42704
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  int dp[n+1][m+1];
  memset(dp,0,sizeof(dp));
  for (int i=1;i<=n;i++)
  {
    for (int j=1;j<=m;j++)
    {
      if (s[i-1]==t[j-1])
       dp[i][j]=dp[i-1][j-1]+1;
      else 
       dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  
  int i=n,j=m;
    string ans = "";
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            ans += s[i-1];
            i--,j--;
        }
        else
        {
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }
 
    reverse(ans.begin() , ans.end());
    cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 35456
from math import atan,pi
a,b,x=map(int,input().split())

if x/a > a*b/2:
  theta=atan(2*(a*b-x/a) / (a**2))
else:
  theta=pi/2 - atan((2*x) / (a*b*b))
print(180*theta/pi)

Measured memory_bytes: 3060
#include<iostream>
#include<unordered_set>

int main(void)
{
	int n = 0;
	std::cin >> n;

	int order = 0;
	int preOrder = -1;
	std::unordered_set<int> bonus;
	for (int count = 0; n > count; ++count)
	{
		std::cin >> order;
		if (1 == order - preOrder)
		{
			bonus.emplace(preOrder);
		}
		preOrder = order;
	}
	int sum = 0;
	int satisfaction = 0;
	for (int count = 0; n > count; ++count)
	{
		std::cin >> satisfaction;
		sum += satisfaction;
	}
	for (int index = 1; n > index; ++index)
	{
		std::cin >> satisfaction;
		if (bonus.end() != bonus.find(index))
		{
			sum += satisfaction;
		}
	}
	std::cout << sum;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const int numcon = 26;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int D; cin>>D;
    vector<ll> C(numcon),last(numcon,0);
    vector<vector<ll> > S(D, vector<ll>(numcon));
    REP(i,numcon){
        cin>>C[i];
    }
    REP(i,D){
        REP(k,numcon){
            cin >> S[i][k];
        }
    }
    vector<ll> T(D);
    REP(i,D){
        cin >> T[i];
        T[i]--;
    }

    ll ans = 0;
    vector<ll> ansans(D);

    REP(i,D){
        ans += S[i][T[i]];
        last[T[i]] = i+1;
        REP(k,numcon){
            ans -= C[k] * (i+1 - last[k]);
        }
        ansans[i] = ans;
    }

    REP(i,D){
        cout << ansans[i] << endl;
    }
    
}

Measured memory_bytes: 3752
n = STDIN.gets.chomp.to_i

def digits(int)
  int.to_s.length
end

def f(a, b)
  digits_a = digits(a)
  digits_b = digits(b)
  digits_a > digits_b ? digits_a : digits_b
end

def main(n)
  ans = digits(n)
  i = 2

  while i**2 <= n
    if n % i == 0
      f_a_b = f(i, n/i)
      ans = ans < f_a_b ? ans : f_a_b
    end
    i += 1
  end

  puts ans
end

main(n)


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n;
	cin >> n;
	rep(i,1, n+1) {
		int temp = i;
		if (temp % 3 == 0)cout << " "<< i ;
		else {
			bool flag = false;
			while (temp != 0) {
				if (temp % 10 == 3 && !(flag)) {
					cout << " " << i;
					flag = true;
				}
				temp /= 10;
			}
		}
	}
	cout << endl;
	//system("pause");
	return 0;
}


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

int main(){
    int N, ans=0;
    cin >> N;
    vector<int> hight(N);
    
    for (int i=0; i<N; i++){
        cin >> hight.at(i);
    }
    int p=0;
    //iで対象、ｋで前全部
    for (int i=0; i<N; i++){
        for (int k=0; k<=i; k++){
            if (hight.at(i) >= hight.at(k)){
                p++;
            }
            
        }

        if (p == i+1){
            ans++;
        }
      p=0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A * N, B) << endl;

	return 0;
}


Measured memory_bytes: 256
import collections

N, Q = map(int, input().split())
lst = [[] for _ in range(N)]
ans = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    lst[b-1].append(a-1)
    lst[a-1].append(b-1)
for j in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x
               
q=collections.deque()
q.append(0)
flag = [0]*N
while q:
    y = q.pop()
    flag[y] = 1
    for k in lst[y]:
        if flag[k] == 1:
            continue
        ans[k] += ans[y]
        q.append(k)
print(*ans)

Measured memory_bytes: 56080
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<unordered_map>

#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

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

int main() {
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N) {
    int i;
    for(i = 0; i < N; i++) {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int j, i, v;
    for(i = 1; i< N; i++) {
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main() {
    int N, i, j;
    int A[100];

    scanf("%d" ,&N);
    for(i = 0; i < N; i++) scanf("%d" , &A[i]);

    trace(A, N);
    insertionSort(A, N);
    return 0;
}



Measured memory_bytes: 2688
def gcd(m,n):
	x=max(m,n)
	y=min(m,n)
	if x%y==0:
		return y
	else:
		while x%y!=0:
			z=x%y
			x=y
			y=z
		else:
			return z

def lcm(m,n):
	return int(m*n/gcd(m,n))
	
	
a,b=map(int,input().split())
print(lcm(a,b))

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  int A, B;
  cin >> A >> B;
  cout << max(0, A - 2 * B) << endl;
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define R register

inline void read(int &x){
	static int ch; static bool flag;
	for(flag=0,ch=getchar(); ch>'9'||ch<'0'; ch=getchar()) flag |= ch=='-';
	for(x=0; ch>='0'&&ch<='9'; ch=getchar()) x = (x<<1) + (x<<3) + ch-48;
	x = flag ? -x : x;
}

bool die[402];
bitset<402>s[402];
int N,M,Ans,x[100002],y[100002];

int main()
{
	read(N),read(M);
	for(R int i=1;i<=M;++i) read(x[i]),read(y[i]);
	for(R int i=1;i<=N;++i){
		s[i][i]=1;
		for(R int j=M;j;--j)
			if(s[i][x[j]] && s[i][y[j]]){die[i]=1;break;}
		else if(s[i][x[j]]) s[i][y[j]]=1;
		else if(s[i][y[j]]) s[i][x[j]]=1;
	}
	for(R int i=1;i<N;++i)
		if(!die[i])
			for(R int j=i+1;j<=N;++j)
				if(!die[j])
					if((s[i]&s[j]).none()) Ans++;
	printf("%d\n",Ans);
	return 0;
}


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

namespace CSharpSample01
{
    

    class Program
    {
        
        static int MatrixChainMultiplicaltion(int n, int[] p)
        {
            int[,] MCM = new int[n + 1, n + 1];

            for(int i = 1; i <= n; i++)
            {
                MCM[i, i] = 0;
            }
            
            for(int len = 2; len <= n; len++)
            {
                for(int i = 1; i <= n - len + 1; i++)
                {                    
                    int j = i + len - 1;  //M(i)～M(j)までのMの長さはj - i + 1 = len
                    
                    int min_mcm = 1000000000;

                    for(int k = i; k < j; k++)
                    {
                        min_mcm = Math.Min(min_mcm, MCM[i, k] + MCM[k + 1, j] + p[i - 1] * p[k] * p[j]);
                    }

                    MCM[i, j] = min_mcm;

                }
            }

            return MCM[1, n];
        }



        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] p = new int[n + 1];

            for(int i = 0; i < n; i++)
            {
                if(i == 0)
                {
                    string[] s_in = Console.ReadLine().Split(' ');
                    p[0] = int.Parse(s_in[0]);
                    p[1] = int.Parse(s_in[1]);
                }
                else
                {
                    string[] s_in = Console.ReadLine().Split(' ');
                    p[i + 1] = int.Parse(s_in[1]);
                }
            }

            Console.WriteLine(MatrixChainMultiplicaltion(n, p));
            
        }
    }
}


Measured memory_bytes: 15992
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 200005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll n,ans=0,i,j;
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=1;i*j<=n;j++)
		if(n-i*j>0)ans++;
	}
	cout<<ans;
}


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

int main(){
  string S,D;
  int Q,i;
  bool b = true;
  cin >> S >> Q;
  for(i=0;i<Q;++i){
    int que = 0;
    cin >> que;
    if(que==1)
      if(b)
        b = false;
      else
        b = true;
    else{
      int F = 0;
      char C;
      cin >> F >> C;
      if(F==1){
        if(b){
          D.push_back(C);
        }else{
          S.push_back(C);
        }
      }else{
        if(b)
          S.push_back(C);
        else{
          D.push_back(C);
        }
      }
    }
  }
  if(!b){
    reverse(S.begin(),S.end());
    cout << S << D;
  }else{
    reverse(D.begin(),D.end());
    cout << D << S;
  }



}


Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N, K; cin >> N >> K;
  V H(N+1);
  rep(i, N) cin >> H[i+1];

  VVll dp(N+1, Vll(K+1, INFll));
  rep(k, K+1) dp[0][k] = 0;

  rep(i, N) rep(k, K+1) {
    rep(j, k+1) {
      if (i-j < 0) continue;
      chmin(dp[i+1][k], dp[i-j][k-j] + max(H[i+1] - H[i-j], 0));
      // cout << (i+1) << " " << k << " " << j << ": " << dp[i+1][k] << endl;
      // if (k-j-1 < 0) continue;
      // // chmin(dp[i+1][k], dp[i-j][k-j-1]);
      // cout << (i+1) << " " << k << " " << j << ": " << dp[i+1][k] << endl;
    }
    // cout << (i+1) << " " << k << ": " << dp[i+1][k] << endl;
  }
  ll ans = INFll;
  rep(k, K+1) chmin(ans, dp[N-K+k][k]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(n-2):
  if p[i] <= p[i+1] and p[i+1] <= p[i+2]:
    count += 1
  if p[i] >= p[i+1] and p[i+1] >= p[i+2]:
    count += 1
    
print(count)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
using namespace std;
int a;
int main(){
	scanf("%d",&a);
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==a){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    char s;
    cin >> s;

    bool b = ('A' <= s && s <= 'Z');
    cout << (b ? "A" : "a") << endl; 
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	map<int,int> uno,dos;
	int total = N/2;
	forn(i,1,N+1){
		int x; cin >> x;
		if(i&1){
			uno[x]++;
		}else{
			dos[x]++;	
		}
	}
	int r1 = 0;
	int r2 = 0;
	int a = 0;
	int b = 0;
	for(auto &x : uno){
		if(x.se >= r1){
			a = x.fi;
		}
		r1 = max(r1,x.se);
	}
	for(auto &x : dos){
		if(x.se >= r2){
			b = x.fi;
		}
		r2 = max(r2,x.se);
	}
	if(a == b){
		int r3 = 0;
		for(auto &x : uno){
			if(x.fi == a)continue;
			r3 = max(r3,x.se);
		}
		for(auto &x : dos){
			if(x.fi == a)continue;
			r3 = max(r3,x.se);
		}
		cout << (total-r1)+(total-r3) << '\n';
		return 0;
	}
	cout << (total-r1)+(total-r2) << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define int   long long int  
#define pb push_back
#define BOOST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debugL(i)  cout<<"line no-> "<<i<<" working"<<endl
#define debugVL(i,l)  cout<<"val at line no."<<i<< " ->"<<l<<endl
const int M=1e9 + 7;
using namespace std;
int N=100000+1;
struct node{
	int incr;
	int val;
};
void dfs(vector<int> g[],int st,node* nd)
{   
    nd[st].val+=(nd[st].incr);
	for(int i=0;i<g[st].size();i++)
	{
		nd[g[st][i]].incr+=(nd[st].incr);
		dfs(g,g[st][i],nd);
		
	}
}
int32_t main() {
    //int q;cin>>q;
    int n,q;cin>>n>>q;
    vector<int> g[n+1];
    for(int i=0;i<n-1;i++)
    {
    	int x,y;cin>>x>>y;
    	g[x].pb(y);
	}
	node* nd=new node[n+1];
	for(int i=1;i<=n;i++)
	{
		nd[i].val=0;
		nd[i].incr=0;
		
	}
	for(int i=0;i<q;i++)
	{
		int id,inc;cin>>id>>inc;
		nd[id].incr+=(inc);
	}
	 dfs( g,1,nd);
	 for(int i=1;i<=n;i++)
	 {
	 	cout<<nd[i].val<<endl;
	 }
    return 0;
}













Measured memory_bytes: 26112
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    string s, t;
    cin >> n >> s >> t;

    string ans = "";
    rep(i, n)ans += s[i], ans += t[i];
    cout << ans <<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
	int A, B;
	cin >> A >> B;

	if (A + B >= 10) {
		cout << "error" << endl;
	} else {
		cout << (A + B) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, max, sum = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  max = vec.back();
  for(int i = 0; i < N - 1; i++) sum += vec[i];
  if(sum > max) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>cl(N + 1);
  int A, B;
  cin >> A >> B;
  for (int i = 0; i < N; i ++) cin >> cl[i];
  cl[N] = 1e9 + 7;
  sort(cl.begin(), cl.end());
  int mi_A = 0;
  int ma_A = N - 1;
  int mi_B = 0;
  int ma_B = N;
  while (mi_A != ma_A) {
    int mu = (mi_A + ma_A) / 2;
    if (cl[mu] >= A) ma_A = mu;
    else mi_A = mu + 1;
  }
  while (mi_B != ma_B) {
    int mu = (mi_B + ma_B) / 2;
    if (cl[mu] >= B) ma_B = mu;
    else mi_B = mu + 1;
  }
  cout << N - (mi_B - mi_A) << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int ice[10];
		memset(ice, 0, sizeof(ice));
		for (int i = 0; i < n; ++i)
		{
			int w;
			scanf("%d", &w);
			++ice[w];
		}
		for (int i = 0; i < 10; ++i)
		{
			if (ice[i])
				while (ice[i]--)
					putchar('*');
			else
				putchar('-');
			putchar('\n');
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<vector>
#include<queue>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define read(x) scanf("%d",&x)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
const int N = 606;
int n,v[N][N];
char str[N][N];
int m(int x) {return x<=n?x:x-n;}
bool ck(int x, int y) {
	per(i,n,1) {
		if (v[x][y]<i) return 0;
		x=m(x+1); y=m(y+1);
	}
	return 1;
}
int main() {
	read(n);
	rep(i,1,n) scanf("%s",str[i]+1);
//	per(i,2*n,1) per(j,2*n,1) str[i][j]=s
	rep(i,1,n) rep(j,1,n)
		for (v[i][j]=1; v[i][j]<=n; v[i][j]++)
			if (str[m(i+v[i][j]-1)][j]!=str[i][m(j+v[i][j]-1)]) {
				v[i][j]--; break;
			}
	int res=0;
	rep(i,1,n) rep(j,1,n) res+=ck(i,j);
	cout<<res;
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int R;
  cin >> R;
  cout << R * R << '\n';
  return 0;
}

Measured memory_bytes: 3600
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const adjLists = Array.from(Array(n), () => []);
  const d = [];
  lines.forEach((l, i) => l.split(' ').splice(2).forEach(e => adjLists[i].push(e-1)));
  bfs(adjLists, d);
  for (let i = 0; i < n; i++) {
    console.log(i + 1, d[i]);
  }
})();

function bfs(adjLists, d) {
  const WHITE = 0, GRAY = 1, BLACK = 2;
  const color = Array.from(adjLists, () => WHITE);
  d[0] = 0;
  for (let i = 1; i < adjLists.length; i++) d[i] = -1;
  queue = [0];
  let u;
  while ((u = queue.shift()) !== undefined) {
    adjLists[u].forEach(v => {
      if (color[v] === WHITE) {
        color[v] = GRAY;
        d[v] = d[u] + 1;
        queue.push(v);
      }
    });
    color[u] = BLACK;
  }
}



Measured memory_bytes: 18284