akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	N := getStdinInt()
	X := getStdin()

	var cnt int64 = 0
	for i := 0; i < len(X); i++ {
		if X[i] == '1' {
			cnt++
		}
	}

	if cnt == 0 {
		for i := 0; i < N; i++ {
			fmt.Printf("%d\n", 1)
		}
		return
	} else if cnt == 1 {
		for i := 0; i < N; i++ {
			if X[i] == '0' {
				if i == N-1 || X[N-1] == '1' {
					fmt.Printf("%d\n", 2)
				} else {
					fmt.Printf("%d\n", 1)
				}
			} else {
				fmt.Printf("%d\n", 0)
			}
		}
		return
	}

	val0 := make(map[int]int64) // cnt - 1
	var sum0 int64 = 0          // cnt - 1
	val1 := make(map[int]int64) // cnt + 1
	var sum1 int64 = 0          // cnt + 1

	// 合計を先に求める
	for i := N - 1; i >= 0; i-- {
		if i == N-1 {
			val0[i] = 1
		} else {
			val0[i] = (2 * val0[i+1]) % (cnt - 1)
		}
		if X[i] == '1' {
			sum0 = modadd(sum0, val0[i], cnt-1)
		}
	}
	for i := N - 1; i >= 0; i-- {
		if i == N-1 {
			val1[i] = 1
		} else {
			val1[i] = 2 * val1[i+1] % (cnt + 1)
		}
		if X[i] == '1' {
			sum1 = modadd(sum1, val1[i], cnt+1)
		}
	}

	for i := 0; i < N; i++ {
		if X[i] == '0' {
			// X(i)分足す
			sum := modadd(sum1, val1[i], cnt+1)
			fmt.Printf("%d\n", pops(sum, cnt+1))
		} else {
			// X(i)分引く
			sum := modadd(sum0, -val0[i], cnt-1)
			fmt.Printf("%d\n", pops(sum, cnt-1))
		}
	}
}

// マイナスのmodに注意
func modadd(a, b, mod int64) int64 {
	var rtn int64 = 0
	if a+b < 0 {
		rtn = (a + b + mod) % mod
	} else {
		rtn = (a + b) % mod
	}
	return rtn
}

// f(num1)→f(num2)→...→0
func pops(num, mod int64) int64 {
	if mod == 1 {
		return 1
	}

	var ans int64 = 1
	for num != 0 {
		var cnt int64 = 0
		for i := 0; (1 << i) <= num; i++ {
			if num&(1<<i) != 0 {
				cnt++
			}
		}
		if cnt != 0 {
			num %= cnt
		}
		ans++
		if cnt == 0 {
			break
		}
	}
	return ans
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt4() (int, int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2], list[3]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 22936
#include<stdio.h>
#include<string.h>
int main(){
    int m,i,h,len;
    int count=0;
    char str[404],inc[203];

    while(1){
        scanf("%s",str);
        if(str[0]=='-') break;
        scanf("%d",&m);
        for(i=0;i<m;i++){
            scanf("%d",&h);
            count+=h;
        }
        len=strlen(str);
        count%=len;
        strcpy(inc,str);
        strcat(str,inc);
        strncpy(inc,str+count,len);
        printf("%s\n",inc);
        count=0;
    }

    return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  ll M;
  cin >> M;
  
  ll D=0, S=0;
  for(i=0; i<M; i++) {
    ll d, c;
    cin >> d >> c;
    D+=c;
    S+=d*c;
  }
  
  pt(D-1+(S-1)/9);
  
  
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a;
    int temp;
    int max_1 = 0;
    int max_2 = 0;
    int max_num;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        a.push_back(temp);
        if (max_1 <= temp) {
            max_2 = max_1;
            max_1 = temp;
            max_num = i;
        }
        if (max_2 <= temp && temp < max_1) {
            max_2 = temp;
        }
    }


    for (int i = 0; i < n; i++) {
        if (i != max_num)cout << max_1 << endl;
        else cout << max_2 << endl;
    }
    

    return 0;
}

Measured memory_bytes: 2548
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
d = 0
if n == k:
    print(max(0,sum(a)))
    exit()
for i in range(k,n):
    if a[i] > 0:
        d += a[i]
now = 0

for i in range(n):
    now += a[i]
    if i >= k:
        now -= a[i-k]
        if a[i] >= 0:
            d -= a[i]
        if a[i-k] >= 0:
            d += a[i-k]
        ans = max(ans,d+max(0,now))
    
print(ans)

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,L;
int X[333333],T[333333];

signed main(){
    cin>>N>>L;
    rep(i,N)cin>>X[i];
    rep(i,N)cin>>T[i];


    int ans=0;
    rep(i,N){
        ans+=T[i]/(2*L)*2*L;
    }
    ans+=2*L;
    if(T[N-1]%(2*L)>2*(L-X[N-1]))ans+=2*L;
    N--;

    deque<int>l,r;
    deque<int>a;

    rep(i,N){
        int x=X[i];
        int y=L-X[i];
        int t=T[i]%(2*L);

        if(t==0)continue;
        ans+=2*L;
        if(t>2*x&&t>2*y)continue;
        if(t<=2*x&&t<=2*y)a.pb(i);
        else if(t<=2*x){
            r.pb(i);
        }
        else{
            l.pb(i);
        }
    }

    while(r.size()){
        if(a.size()==0)break;
        if(r.back()>a.back()){
            r.pop_back();
            continue;
        }
        r.pop_back();
        a.pop_back();
        ans-=2*L;
    }
    while(l.size()){
        if(a.size()==0)break;
        if(l.front()<a.front()){
            l.pop_front();
            continue;
        }
        l.pop_front();
        a.pop_front();
        ans-=2*L;
    }

    ans-=2*L*(a.size()/2);

    cout<<ans<<endl;
    /*
    dp[0][0]=0;
    rep(i,N){
        for(int j=0;j<=N;j++){
            int x=X[i];
            int y=L-x;
            int t=T[i];

            int r=t%(2*L);
            if(j)chmin(dp[i+1][j-1],dp[i][j]+2*L*(r>2*y)+2*L);
            chmin(dp[i+1][j],dp[i][j]+2*L*(r>0));


            chmin(dp[i+1][j+1],dp[i][j]+2*L*(r>2*x));
            chmin(dp[i+1][j],dp[i][j]+2*L*(r>0));

        }
    }
    cout<<ans+dp[N][0]<<endl;
    */
    return 0;
}


Measured memory_bytes: 7680
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
	string s; cin >> s;
	s = "." + s + ".";

	int N = s.size();

	V<V< int >> edge(N, V< int >(26, LINF));
	V<P<int, string>> dp(N, { LINF,"" });

	int idx;
	REP(i,26){
		char ch = char(int(i + 'a'));
		idx = N-1;
		for (int j = N-2; 0 <= j; --j) {
			edge[j][i] = idx;
			if (s[j] == ch)idx = j;
		}
	}

	dp[0] = { 0,"" };

	REP(i,N-1){
		REP(j,26){
			int cnt = dp[i].first+1;
			char ch = char(int(j + 'a'));
			string str = dp[i].second;
			str.push_back(ch);
			int to = edge[i][j];
			if ((cnt < dp[to].first) || (cnt == dp[to].first && str < dp[to].second)) {
				dp[to].first = cnt;
				dp[to].second = str;
			}
		}
		dp[i].second = "";
		dp[i].second.shrink_to_fit();
	}

	cout << dp[N-1].second << endl;
	return 0;
}



Measured memory_bytes: 40780
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

int main(void) {
	using namespace std;
	char x, y;
	cin >> x >> y;
	if (x > y) {
		cout << '>' << endl;
	}
	else if (x < y) {
		cout << '<' << endl;
	}
	else {
		cout << '=' << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string S;
	cin>>S;
	long long sum=0,formula=0;
	for(int i=0;i<(1<<(S.length()-1));i++)
	{
		for(int j=0;j<S.length();j++)
		{
			formula=formula*10+S[j]-'0';
			if((i>>j)&1)
				sum+=formula,
				formula=0;
		}
		sum+=formula;
		formula=0;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace abc164_b
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputMonsterData = Console.ReadLine().Split(' ');

            Console.WriteLine(ObtainBattleResult(inputMonsterData));
            Console.Read();
        }

        private static string ObtainBattleResult(string[] humanData)
        {
            var takahachiMonsterHp = int.Parse(humanData[0]);
            var takahachiMonsterAtk = int.Parse(humanData[1]);

            var aokiMonsterHp = int.Parse(humanData[2]);
            var aokiMonsterAtk = int.Parse(humanData[3]);

            while (takahachiMonsterHp > 0)
            {
                aokiMonsterHp -= takahachiMonsterAtk;

                if (aokiMonsterHp <= 0)
                {
                    return "Yes";
                }

                takahachiMonsterHp -= aokiMonsterAtk;
            }

            return "No";
        }
    }
}

Measured memory_bytes: 27140
mod = 1000000007


def fexp(x, y):
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = ans * x % mod
        x = x * x % mod
        y //= 2
    return ans


fac = [1]
rev = [1]

for i in range(1, 2006):
    fac.append(fac[-1] * i % mod)
    rev.append(fexp(fac[-1], mod - 2))


def C(n, k):
    if n < k:
        return 0
    return fac[n] * rev[k] % mod * rev[n - k] % mod


def distribute(n, m):
    return C(n - 1, m - 1)


n = int(input())
if n < 3:
    print(0)
else:
    ans = 0
    parts = 1
    while n - parts * 2 >= 0:
        rest = n - parts * 2
        ans += distribute(rest, parts)
        ans %= mod
        parts += 1
    print(ans)

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int cnt = 0;
    for(auto& x : a){
        cin >> x;
        cnt += (x >= k);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long A, long long B, long long C, long long X, long long Y){
	ll final=LLONG_MAX;
	{
		ll xy=min(X,Y);
		ll xl=X-xy;
		ll yl=Y-xy;
		ll ans=xy*2*C+xl*A+yl*B;
		chkmin(final,ans);
	}
	{
		chkmin(final,X*A+Y*B);
	}
	{
		chkmin(final,max(X,Y)*2*C);
	}
	printf("%lld\n",final);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long A;
	long long B;
	long long Y;
	long long C;
	long long X;
	scanf("%lld",&A);
	scanf("%lld",&B);
	scanf("%lld",&C);
	scanf("%lld",&X);
	scanf("%lld",&Y);
	solve(A, B, C, X, Y);
	return 0;
}



Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/24
// Problem:B- Contiguous Repainting b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int INF = 1e9 + 1;
static const int MAX_N = 1;

int main()
{
  CIN(N, K);
  vector< ll > t(N + 1, 0ll);
  // 全体の累積和
  vector< ll > a(N + 1, 0ll);
  // 正の数字だけを取った時の累積和
  vector< ll > b(N + 1, 0ll);
  REP(i, N) {
    cin >> t[i + 1];
    a[i + 1] = a[i] + t[i + 1];
    b[i + 1] = b[i] + max(0ll, t[i + 1]);
  }

  /*
  REP(i, N) {
    printf("a[%d] = %d\nb[%d] = %d\n", i + 1, a[i + 1], i + 1, b[i + 1]);
  }
  */

  ll ans = -INF;

  // a[i + 1]: i番目までの累積和
  REP(i, N - K + 1) {
    ll sum = 0ll;
    // [i, i + K] = [0, i + K - 1] - [0, i - 1] = a[i + K] - a[i];
    ll tmp = a[i + K] - a[i];

    sum += max(0ll, tmp);
    // [0, i - 1] = [0, i - 2] = b[i - 1];
    sum += b[i];
    // [i + K, N] = [0, N + 1 - 1] - [0, i + K + 1 - 1] = b[N] - b[i + K] 
    sum += b[N] - b[i + K];
    ans = max(ans, sum);
  }
  
  printf("%lld\n", ans);
  
  return 0;
}



Measured memory_bytes: 2560
import math

a, b, C = [int(i) for i in input().split()]

S = a * b * math.sin(math.radians(C)) / 2
L = a + b + math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(C)))
h = b * math.sin(math.radians(C))

print(S)
print(L)
print(h)

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> data(n);
  int minData;
  int allCount = 0;
  for (int i = 0; i < n; i++) {
    cin >> data[i];
    allCount += data[i];
    if (i == 0) {
      minData = data[i];
    } else {
   	  minData = min(minData, data[i]);
    }
  }

  x -= allCount;
  int result = n + x / minData;

  cout << result << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias W = Tuple!(long, "a", long, "b");

W[10^^5*2] WS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        auto ab = readln.split.to!(long[]);
        WS[i] = W(ab[0], ab[1]);
    }
    sort!"a.b < b.b"(WS[0..N]);
    long t;
    foreach (w; WS[0..N]) {
        t += w.a;
        if (w.b < t) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

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

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

    ll ans =(N-1) * N / 2;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else {
			int x = i;
			while ((x % 10) != 3 && x != 0) {
				x /= 10;
			}
			if (x != 0) {
				cout << " " << i;
			}
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <string>	

using namespace std;
struct color
{
	string str;
	int RGB[3];
};

void solve()
{
	color Color[8];
	Color[0].str = "black";
	Color[0].RGB[0] = 0;	Color[0].RGB[1] = 0;	Color[0].RGB[2] = 0;
	Color[1].str = "blue";
	Color[1].RGB[0] = 0;	Color[1].RGB[1] = 0;	Color[1].RGB[2] = 255;
	Color[2].str = "lime";
	Color[2].RGB[0] = 0;	Color[2].RGB[1] = 255;	Color[2].RGB[2] = 0;
	Color[3].str = "aqua";
	Color[3].RGB[0] = 0;	Color[3].RGB[1] = 255;	Color[3].RGB[2] = 255;
	Color[4].str = "red";
	Color[4].RGB[0] = 255;	Color[4].RGB[1] = 0;	Color[4].RGB[2] = 0;
	Color[5].str = "fuchsia";
	Color[5].RGB[0] = 255;	Color[5].RGB[1] = 0;	Color[5].RGB[2] = 255;
	Color[6].str = "yellow";
	Color[6].RGB[0] = 255;	Color[6].RGB[1] = 255;	Color[6].RGB[2] = 0;
	Color[7].str = "white";
	Color[7].RGB[0] = 255;	Color[7].RGB[1] = 255;	Color[7].RGB[2] = 255;

	string str;
	while(cin >> str, str[0] != '0')
	{
		int C[3] = {0};
		for(int i = 0; i < 3; ++i)
		{
			if('a' <= str[2 * i + 1] && str[2 * i + 1] <= 'f')
			{
				C[i] += (str[2 * i + 1] - 'a' + 10) * 16;
			}
			else if('0' <= str[2 * i + 1] && str[2 * i + 1] <= '9')
			{
				C[i] += (str[2 * i + 1] - '0') * 16;
			}
		}
		for(int i = 1; i < 4; ++i)
		{
			if('a' <= str[2 * i] && str[2 * i] <= 'f')
			{
				C[i - 1] += str[2 * i] - 'a' + 10;
			}
			else if('0' <= str[2 * i] && str[2 * i] <= '9')
			{
				C[i - 1] += str[2 * i] - '0';
			}
		}
		int index = 0;
		int dist = 0;
		int min = 999999999;
		for(int i = 0; i < 8; ++i)
		{
			dist = (C[0] - Color[i].RGB[0]) * (C[0] - Color[i].RGB[0])
				 + (C[1] - Color[i].RGB[1]) * (C[1] - Color[i].RGB[1])
				 + (C[2] - Color[i].RGB[2]) * (C[2] - Color[i].RGB[2]);
			if(dist < min)
			{
				min = dist;
				index = i;
			}
		}
		cout << Color[index].str << endl;
	}
}

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

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	for (int i = n; i >= 0; i--)
	{
		double tmp = i;
		tmp = sqrt(tmp);
		if (tmp == ceil(tmp))
		{
			ANS((ll)(tmp * tmp));
			return 0;
		}
	}
}

Measured memory_bytes: 256
// I think of what the world could be, A vision of the one I see, A million dreams is all it's gonna take

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 1100, mod = 1e9 + 7, inf = 1e9 + 10;

bool a[maxn][maxn];

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

    int n, m;
    cin >> n >> m;
    int N = max(n, m);
    for(int i = 1; i <= N; i++){
	for(int x = 0; x < (1<<i); x++)
	    for(int y = 0; y < (1<<i); y++)
		a[x][y] = a[x & ((1<<(i-1))-1)][y & ((1<<(i-1))-1)] ^ ( bit(x, i-1) && bit(y, i-1) );
    }    
    for(int i = 1; i < (1<<n); i++){
	for(int j = 1; j < (1<<m); j++)
	    cout << (a[i][j] ^  a[i-1][j] ^ a[i][j-1] ^ a[i-1][j-1]);
	cout << "\n";
    }
    return 0;
}


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

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


Measured memory_bytes: 256
#!/usr/bin/perl
use strict;
use List::Util qw /min max /;

my $n = <>;
my @x = split (/ /,<>);
chomp(@x);
my @all_min;

for (my $i = 0; $i <= 100; $i++) {
  for (my $j = 0; $j <= $#x; $j++) {
     $all_min[$i] += ($x[$j] - ($i+1))**2;
  }
}

print min @all_min;

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main( void )
{
  double PI = 3.14159265358979323846264338327950288;
  double x=0,y=0,d,a,b=PI/2;
  char c;
  while( 1 ){
    cin >> d >> c >> a;
    if( d == 0 && a == 0 ) break;
    x += d * cos(b);
    y += d * sin(b);
    b -= a / 360 * 2 * PI;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

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

sum_ = sum(p[0:k])
max_ = sum(p[0:k])
for i in range(k, n):
    sum_ += p[i] - p[i - k]
    max_ = max(sum_, max_)

print((max_ + k) / 2)

Measured memory_bytes: 71792
package main

import "fmt"

func main() {
	var N, M, X int
	fmt.Scanf("%d %d %d", &N, &M, &X)

	C := make([]int, N)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
		fmt.Scanf("%d", &C[i])
		for j := 0; j < M; j++ {
			fmt.Scanf("%d", &A[i][j])
		}
	}

	NMAX := 1000000000000
	min := NMAX

	for bit := 0; bit < 1<<N; bit++ {
		understand := make([]int, M)
		cost := 0
		for i := 0; i < N; i++ {
			if bit>>i&1 == 1 {
				for j := 0; j < M; j++ {
					understand[j] += A[i][j]
				}
				cost += C[i]
			}
		}
		success := true
		for i := 0; i < M; i++ {
			if understand[i] < X {
				success = false
				break
			}
		}
		if success {
			if cost < min {
				min = cost
			}
		}
	}
	if min == NMAX {
		fmt.Println(-1)
		return
	}
	fmt.Println(min)
}


Measured memory_bytes: 2220
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  unordered_map<string, int> tc;
  while (n--) {
    string t; cin >> t;
    if (t == "WA") tc["WA"]++;
    if (t == "AC") tc["AC"]++;
    if (t == "TLE") tc["TLE"]++;
    if (t == "RE") tc["RE"]++;
  }
  cout << "AC x " << tc["AC"] << endl;
  cout << "WA x "  << tc["WA"] << endl;
  cout << "TLE x "  << tc["TLE"] << endl;
  cout << "RE x "  << tc["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int x;
	std::cin >> x;
	int y=1;
	while(true) {
		if((360*y)%x==0) {
			print(360*y/x);
			return 0;
		}
		y++;
	}
}


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

/*
ABC132 C
https://atcoder.jp/contests/abc132/tasks/abc132_c
*/

int compare(const void *p0, const void *p1)
{
  return *(int *)p0 - *(int *)p1;
}

int main(void)
{
  int N;
  int pattern = 0;
  int count   = 0;
  int *array;

  scanf("%d", &N);

  count = N / 2;

  /*動的配列"array"を宣言*/
  array = (int *)malloc(sizeof(int) * 100000);
  if (array == NULL) {
    exit(0);
  }

  /*初期化*/
  for (size_t i = 0; i < 100000; i++) {
    array[i] = 0;
  }

  /*読み込み*/
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &array[i]);
  }

  /*ソート*/
  qsort(/*配列*/array, /*要素数*/N, /*要素のバイト数*/sizeof (array[0]), /*比較方法*/compare);
  pattern = array[count] - array[count - 1];

  /*出力*/
  printf("%d\n", pattern);

  /*解放*/
  free(array);
  return 0;
}


Measured memory_bytes: 1020
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int K, S;
int cnt = 0;

int main()
{
    cin >> K >> S;
    for (int X = 0; X <= K; X++) {
        // cout << X << ":";
        if (S - X > K * 2) {
            // cout << 0 << endl;
        } else if (S - X > K) {
            cnt += 2 * K - S + X + 1;
            // cout << 2 * K - S + X + 1 << endl;
        } else if (S - X >= 0) {
            cnt += S - X + 1;
            // cout << S - X + 1 << endl;
        } else {
            // cout << 0 << endl;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

using ll = long long;

int main() {
    vector<int> v;
    for (int n = 1; n * (n + 1) * (n + 2) / 6 < 1e6; n++) v.push_back(n * (n + 1) * (n + 2) / 6);
    //rep(i, v.size()) cout << v[i] << " ";
    //cout << v.size() << "\n";
    // dp[i][j] i番目の正四面体数を使ってjを作る最小数
    // dp1[i][j] 奇数だけ使う場合
    int n = v.size(), idx = 0;
    vector<vector<int>> dp(2, vector<int>(1e6, 1e9)), dp1(2, vector<int>(1e6, 1e9));
    dp[0][0] = 0;
    dp1[0][0] = 0;
    rep(i, n) {
        rep(j, 1e6) {
            dp[(i + 1) % 2][j] = dp[i % 2][j];
            dp1[(i + 1) % 2][j] = dp1[i % 2][j];
            if (j >= v[i]) dp[(i + 1) % 2][j] = min(dp[i % 2][j], dp[(i + 1) % 2][j - v[i]] + 1);
            if (v[i] % 2) {
                if (j >= v[i]) dp1[(i + 1) % 2][j] = min(dp1[i % 2][j], dp1[(i + 1) % 2][j - v[i]] + 1);
            }
        }
    }
    int x;
    cin >> x;
    while (x != 0) {
        cout << dp[n % 2][x] << " " << dp1[n % 2][x] << "\n";
        cin >> x;
    }
}


Measured memory_bytes: 22244
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
int main() {
	cin>>N;

	int R=0;
	for(int i=1;i<N+1;i++){
		if(i>=1 && i<=9){
			R++;
		}
		if(i>=100 && i<=999){
			R++;
		}
		if(i>=10000 && i<=99999){
			R++;
		}
	}
	cout<<R<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k, flag[20], t;
bool judge(int x) {
    while(x) {
        int tmp=x%10;
        if(flag[tmp]) {
            return false;
        }
        x/=10;
    }
    return true;
}
int main() {
    cin >> n >> k;
    memset(flag,0,sizeof(flag));
    for (int i = 0; i < k; ++i) {
        cin >> t;
        flag[t] = 1;
    }
    for(int i=n;;++i) {
        if(judge(i)) {
            cout << i;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i, N)
  {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  if (d.size() % 2 != 0)
  {
    cout << 0 << endl;
    return 0;
  }
  else
  {
    cout << d[N / 2] - d[N / 2 - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
    int N,L;
    scanf("%d %d",&N,&L);
    int maxsum = N*(L-1)+N*(N+1)/2-L;
    for(int i=1;i<N;i++){
        if(abs(L-1+i)>abs(L+i)){
            maxsum --;
        }
    }
    printf("%d",maxsum);
    return 0;
}

Measured memory_bytes: 128
n,m,s,t = map(int,input().split())
import collections
edge = collections.defaultdict(list)
for _ in range(m):
    u,v,a,b = map(int,input().split())
    edge[u-1].append([v-1,a,b])
    edge[v-1].append([u-1,a,b])
yen_dist = [-1 for _ in range(n)]
sunuk_dist = [-1 for _ in range(n)]

import heapq
next_point = []
heapq.heappush(next_point,(0,s-1))
while next_point:
    cost,node = heapq.heappop(next_point)
    if yen_dist[node] == -1:
        yen_dist[node] = cost
        for u,a,_ in edge[node]:
            if yen_dist[u] == -1:
                heapq.heappush(next_point,(cost+a,u))

heapq.heappush(next_point,(0,t-1))
while next_point:
    cost,node = heapq.heappop(next_point)
    if sunuk_dist[node] == -1:
        sunuk_dist[node] = cost
        for u,_,b in edge[node]:
            if sunuk_dist[u] == -1:
                heapq.heappush(next_point,(cost+b,u))

r = [0]*n
for i in range(n):
    r[-i-1] = max(r[-i],10**15-yen_dist[-i-1]-sunuk_dist[-i-1])
print(*r,sep='\n')


Measured memory_bytes: 127320
import java.util.Scanner;
    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            while(true){
                int H = sc.nextInt();
                int W = sc.nextInt();
                if(H == 0 && W == 0){
                    break;
                }else{
                for(int h=1;h<=H;h++){
                    for(int w=1;w<=W;w++){
                        System.out.printf("#");
                    }
                        System.out.printf("\n"); 
                }
                    System.out.printf("\n");
            }
            
            }
            sc.close();
        
        }
    }
        
    


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

using namespace std;

int abs(int t){ return t>0?t:-t; }

int main(){
	int m, n, d;
	while(cin >> m >> n >> d, m){
		vector< vector<int> > v(n*m, vector<int>(n*m+1,0));
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin >> v[i*m+j][n*m];
				for(int ii=0;ii<n;ii++){
					for(int jj=0;jj<m;jj++){
						int dist = abs(i-ii)+abs(j-jj);
						if(dist==0||dist==d) v[ii*m+jj][i*m+j] = 1;
					}
				}
			}
		}
		int cur = 0;
		for(int i=0;i<n*m;i++){
			int chg = cur;
			while(chg<n*m && v[chg][i]==0) chg++;
			if(chg == n*m) continue;
			swap(v[cur], v[chg]);
			for(int j=cur+1;j<n*m;j++){
				if(v[j][i]){
					for(int k=i;k<n*m+1;k++)
						v[j][k] = (v[j][k]+v[cur][k])%2;
				}
			}
			cur++;
		}
		int res = 1;
		for(int i=cur;i<n*m;i++)
			if(v[i][n*m] == 1) res = 0;
		cout << res << endl;
	}
}

Measured memory_bytes: 2444
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  string arr[n];
  map <string, int> cnt;
  int best = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    cnt[arr[i]]++;
    best = max(best, cnt[arr[i]]);
  }
  map <string, bool> used;
  vector <string> ans;
  for (int i = 0; i < n; i++) {
    if (cnt[arr[i]] == best && !used[arr[i]]) {
      ans.push_back(arr[i]);
      used[arr[i]] = 1;
    }
  }
  sort(ans.begin(), ans.end());
  //reverse(ans.begin(), ans.end());
  for (auto ti : ans) {
    cout << ti << endl;
  }
  return 0;
}


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

const int MAX_V = 310;

// 辺を表す構造体（行き先、容量、逆辺の場所(id)）
struct edge{
    int to, cap, rev;
};

vector<vector<edge>> G(MAX_V); 
int level[MAX_V]; // sからの距離
int iter[MAX_V];  // どこまで調べ終わったか

// fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap){
    G[from].emplace_back((edge){to, cap, (int)G[to].size()});
    G[to].emplace_back((edge){from, 0, (int)(G[from].size()-1)});
}

// sからの最短距離を計算する
void bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);

    while(que.size()){
        int v = que.front(); que.pop();
        for(int i=0; i<G[v].size(); i++){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスを探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i=iter[v]; i<G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }

    return 0;
}

// sからtへの最大流を求める
int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f = dfs(s, t, 1e9)) > 0){
            flow += f;
        }
    }
}

int main(){
    int n, m; cin>>n>>m;
    vector<vector<int>> allEdge(n, vector<int>(n, -1));
    for(int i=0; i<m; i++){
        int x, y; cin>>x>>y;
        x--, y--;
        allEdge[x][y] = i + 1;
        add_edge(x, y, 1);
        add_edge(y, x, 1);
    }

    int s, t; cin>>s>>t;
    s--, t--;

    cout << max_flow(s, t) << endl;

    vector<int> ansEdgeId;
    for(int i=0; i<n; i++){
        for(auto j:G[i]){
            //cout << "from " << i << " to " << j.to << " cap " << j.cap << " rev " << j.rev << endl;
            if(j.cap == 0 && G[j.to][j.rev].cap == 1){
                if(0 < allEdge[j.to][i]){
                    ansEdgeId.emplace_back(allEdge[j.to][i]);
                }
            }
        }
    }

    sort(ansEdgeId.begin(), ansEdgeId.end());
    ansEdgeId.erase(unique(ansEdgeId.begin(), ansEdgeId.end()), ansEdgeId.end());

    cout << ansEdgeId.size() << endl;
    for(auto i:ansEdgeId){
        cout << i << endl;
    }
}


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

#define ll long long

signed main() {
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
  {cout << "vowel" << endl;}
  else{cout << "consonant" << endl;}
}

Measured memory_bytes: 3552
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;

int main(){
    int n;
    cin>>n;
    ll a[n];
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i]-1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  multiset<int>a;
  rep(i,1<<n){int t;cin>>t;a.insert(t);}
  multiset<int>slime;
  bool flag=1;
  auto la=(a.lower_bound(1e9+7));
  la--;
  slime.insert(*la);
  rep(i,n)
  {
    multiset<int>dslime;
    for(auto tp:slime)
    {
      auto t=a.lower_bound(tp);
      if(t==a.begin()){flag=0;break;}
      t--;
      dslime.insert(*t);
      a.erase(t);
    }
    if(!flag)break;
    slime.insert(all(dslime));
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;



  return 0;

}


Measured memory_bytes: 18688
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    if K >= 50: A = [N] * N
    else:
        for k in range(K):
            nextL = [0] * (N + 1)
            for i, a in enumerate(A):
               left = max(0, i - a)
               right = min(N, i + a + 1)
               nextL[left] += 1
               nextL[right] -= 1
            A[0] = nextL[0]
            for i in range(1, N):
                A[i] = A[i-1] + nextL[i]
    print(*A, sep=" ")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 109304
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve():
    N = int(input())
    D = sorted(list(map(int, input().split())))
    mid = N // 2
    return D[mid] - D[mid - 1]
    

def main():
    print(solve())


if __name__ == "__main__":
    main()


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


using namespace std;

#define endl '\n'
#define PB push_back
#define MP make_pair
#define LL long long
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

typedef long long ll;

bool file=0,rt=1;
clock_t tStart ;
void FAST_IO();
////////////////////////

map<ll, ll> cnt[2];
vector< pair<ll ,ll> > a[2];
int main() {

    //FAST_IO();
    ios_base::sync_with_stdio(0);
    //cin.tie(NULL);
    cout << setprecision(5);
    cout << fixed;

    ll n, temp;


    cin >> n;

    for(int i = 0; i < n; i++) {


        cin >> temp;
        cnt[i&1][temp]++;
    }

    for(auto p: cnt[0]) a[0].push_back(make_pair(p.second, p.first));
    for(auto p: cnt[1]) a[1].push_back(make_pair(p.second, p.first));


    sort(a[0].rbegin(), a[0].rend());
    sort(a[1].rbegin(), a[1].rend());

    if(a[0][0].second != a[1][0].second) {

        cout << n - a[0][0].first - a[1][0].first << endl;
    }
    else {

        ll res = 0;

        res = max(res, a[0][1].first + a[1][0].first);
        res = max(res, a[0][0].first + a[1][1].first);

        if(a[0].size() < 2 && a[1].size() < 2) res = n/2;

        cout << n - res << endl;
    }







    return 0;
}

void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //cout.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(2);
    if(rt && file){ tStart = clock(); }
    if(file){
    #ifndef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    }
}




Measured memory_bytes: 8824
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int now = 0;
    bool ok = false;
    int k = 1;
    while (now<n) {
        now += k;
        k++;
        if (now==n) {
            ok = true;
            break;
        }
    }
    if (!ok) {
        pr("No");
        return 0;
    }
    pr("Yes");
    pr(k);
    vector<vector<int>> ans(k);
    int x = 0;
    int y = 1;
    for (int i=1; i<=n; i++) {
        ans[x].pb(i);
        ans[y].pb(i);
        if (y+1<k) y++;
        else {
            x++;
            y = x + 1;
        }
    }
    rep(i, k) {
        cout << 2*n/k << " ";
        rep(j, 2*n/k) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 4164
#include<stdio.h>
#include<math.h>
#define N 100
int cnt=0;
int p[N+1],m[N+1][N+1];

void matrixChainOrder(int n){
  int i,q,l,j,k;
  for(i=1;i<=l;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=fmin(m[i][j],q);
	cnt++;
      }
    }
  }
}
   
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
  }
  matrixChainOrder(n);
  printf("%d\n",m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2052
/*#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int a,b;
    cin >> a >> b;
    cout << 'a';
    if(a<b) cout << " < ";
    else if(a>b) cout << " > ";
    else cout << " == ";
    cout << 'b' << endl;
}


Measured memory_bytes: 3072
import java.util.Scanner;

//Maximum Sum Sequence II
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n+1][n+1];
		for(int i=1;i<=n;i++)for(int j=1;j<=n;j++){
			int x = sc.nextInt();
			a[i][j] = a[i-1][j] + a[i][j-1] - a[i-1][j-1] + x;
		}
		int res = Integer.MIN_VALUE;
		for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)for(int y=1;y<=i;y++)for(int x=1;x<=j;x++)res=Math.max(res, a[i][j]-a[y-1][j]-a[i][x-1]+a[y-1][x-1]);
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 37140
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   long L = sc.nextLong();
   long ans =L;
 
   for(int i=1;i<N;i++) ans*=L-1;
   System.out.println(ans);
 }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mp(p1,p2) make_pair(p1,p2)
#define sz(a) (ll)a.size()
#define mod 1000000007
#define PI 3.14159265358979323846
#define pii pair<ll ,ll>
#define ppii pair<ll,pii>
using namespace std;
#define fast                                                                   \
 ios_base::sync_with_stdio(false);                                            \
 cin.tie(NULL);                                                               \
 cout.tie(NULL);
const ll MAXN = 3000005;
const ll inf = 1e18;
int main()
{
   fast
  ll n;
  cin >> n;
  cout << ((n)*(n-1))/2;
   return 0;      
}


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

string s;
bool ch = 1;
string t[2] = {"RUD", "LUD"};

int main() {
  cin >> s;
  for(int i = 0; i < s.size(); ++i) {
    bool now = 0;
    for(int j = 0; j < 3; ++j)
      if(t[i % 2][j] == s[i]) now = 1;
    if(!now) ch = 0;
  }
  if(ch)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data = scanner.nextLine();

			String[] arr = data.split(" ");
			int n = Integer.parseInt(arr[0]);
			int x = Integer.parseInt(arr[1]);
			int t = Integer.parseInt(arr[2]);

			int index = 0;
			int res = n;
			while(res > 0) {
				res = res - x;
				index++;
			}

			System.out.println(index * t);
		}
	}
}


Measured memory_bytes: 35672
N = int(input())
X = list(map(int,input().split()))
MIN_X = min(X)
MAX_X = max(X)
ans = 10 ** 8
for i in range(MIN_X, MAX_X + 1):
    SUM = 0
    for j in X:
        SUM += (i - j) ** 2
    if ans > SUM:
        ans = SUM

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int s = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    long MOD = (long)998244353;
    long[][] dp = new long[n][s + 1];
    dp[0][0] = 2;
    if(a[0] <= s) dp[0][a[0]] = 1;
    for(int i = 1; i < n; i++) {
      for(int j = 0; j <= s; j++) {
        dp[i][j] = (dp[i][j] + 2 * dp[i - 1][j]) % MOD;
        if(j >= a[i]) dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i]]) % MOD;
      }
    }
    System.out.println(dp[n - 1][s]);
  }
}


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

int main(){
int A ,B;
  int a,b;
  cin >> A  >>  B;
  a = max(A,B);
  b = min (A,B);
  
  if((a - b) % 2 != 0)
cout << "IMPOSSIBLE" << endl;
  else 
    cout << b + ((a - b)/2) << endl;


}

Measured memory_bytes: 256