akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {

    vi v(3);
    int ans=0;
    cin>>v[0]>>v[1]>>v[2];
    Sort(v);
    v[0]+=v[2]-v[1];
    ans+=v[2]-v[1];
    v[1]=v[2];

    if((v[1]-v[0])%2==0)ans+=(v[1]-v[0])/2;
    else {
        ans+=(v[1]-v[0])/2+2;
    }
    fin(ans);
}



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

struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *root, int key)
{
	while (root != NIL && key != root->key)
	{
		if (key < root->key) root = root->left;
		else root = root->right;
	}
	return root;
}

void insert(int key)
{
	Node *x = root;
	Node *y = NIL;
	Node *z = new Node();

	z->key = key;
	z->left = NIL;
	z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}

	z->parent = y;
	if (y == NIL) root = z;
	else
	{
		if (z->key < y->key) y->left = z;
		else y->right = z;
	}
}

void inorder(Node *root)
{
	if (root == NIL) return;
	inorder(root->left);
	cout << " " << root->key;
	inorder(root->right);
}

void preorder(Node *root)
{
	if (root == NIL) return;
	cout << " " << root->key;
	preorder(root->left);
	preorder(root->right);
}

int main()
{
	int n, key;
	string str;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str;
		if (str == "find")
		{
			cin >> key;
			Node *t = find(root, key);
			if (t != NIL) cout << "yes" << endl;
			else cout << "no" << endl;
		}
		else if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}

	return 0;
}

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

using namespace std;

#define td typedef
td long long ll;

ll in()
{
    ll a;
    scanf("%lld",&a);
    return a;
}

bitset <2005*2005> ase[2];

int main()
{
    int n=in(),a[2005],sum=0;
    for(int i=0;i<n;i++){
        a[i]=in();
        sum+=a[i];
    }
    ase[0].set(0);
    for(int i=1;i<=n;i++)
        ase[i&1]=ase[(i-1)&1]|(ase[(i-1)&1]<<a[i-1]);
    for(int i=(sum+1)/2;i<=2005*2005;i++)
    {
        if(ase[n&1][i])
        {
            printf("%d\n",i);
            return 0;
        }
    }
}


Measured memory_bytes: 2688
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)					// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl << msec << " msec " << endl;
}

#endif

class AGC034A
{
public:
	AGC034A()
	{
		cin >> n >> a >> b >> c >> d;
		a--;
		b--;
		c--;
		d--;
		cin >> s;
	}
	void Run(void)
	{
		bool ans = true;

		CheckFalse(ans);

		if (ans)
			cout << "Yes";
		else
			cout << "No";
	}
private:
	void CheckFalse(bool& ans)
	{
		if (d < c)
			if (!CheckSpace3(b-1, d))
			ans = false;

		if (CheckIwa2(a, c))
			ans = false;
		else if (CheckIwa2(b, d))
			ans = false;
	}
	bool CheckSpace3(ll l, ll r)
	{
		rep(i, l, r)
		{
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')
			{
				return true;
			}
		}

		return false;
	}
	bool CheckIwa2(ll l, ll r)
	{
		rep(i, l+1, r-1)
		{
			if (s[i] == '#' && s[i + 1] == '#')
			{
				return true;
			}
		}
		return false;
	}
	ll n;
	ll a;
	ll b;
	ll c;
	ll d;
	string s;
};

int main(void)
{
	AGC034A agc034a;
	agc034a.Run();

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>//文章中にその言葉が使われた数を出す//
#include<stdlib.h>
#include<string.h>

int check(char [],int);

int main (void){

	int i,count=0,counter=0,pod;
	char get,search[100];
	
	for(i=0;;i++){//探す文字を入力//
		get=getchar();
		if(get=='\n'){
			search[i]='\0';
			break;
		}
		search[i]=get;
		count++;

	}
	while(1){
		pod=check(search,count);
		if(pod==-1)
			break;
		counter+=pod;
	}
	printf("%d\n",counter);
	
	return 0;
}
	
int check(char search[],int count){

	int i,j,len,len2;
	char word[1000],out[100]="END_OF_TEXT";

	scanf("%s",word);
	if(strcmp(out,word)==0){//入力された文字がEND_OF_TEXTなら-1を返して終了する//
		return -1;
	}
	len=strlen(word);
	len2=strlen(search);
	if(len!=len2)//探す文字と文章の単語の長さが違ったら0を返す//
		return 0;
	for(i=0;i<len;i++){
		for(j=0;j<count;j++){
			if(word[i] != search[j]&&
			word[i] + 32 != search[j]&&
			word[i] - 32 != search[j]){//探していた文字の大文字でも小文字でもなかったらflagを建てる//
				return 0;
			}
			else i++;
		}
	}
	return 1;
}

Measured memory_bytes: 552
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;
	string str;
	list <int> lst;
	list<int>::iterator it;
	cin >> n;
	while (n--){
	cin >> str;
		if (str == "insert"){
			cin >> x;
			lst.push_front(x);
  }else if (str == "deleteFirst") lst.pop_front();		
   else if (str == "deleteLast")  lst.pop_back();			
			
   else{    cin >> x;
         	for (it = lst.begin(); it!=lst.end(); ++it){
		   		 if (*it == x){
					  lst.erase(it); break;
			    	}				 	
			  }
	    }
	}
	for (it = lst.begin(); it != --lst.end(); ++it){
		cout << *it<<" ";
	}cout <<*it<<endl;
	return 0;
}

Measured memory_bytes: 32476
N = gets.to_i
aa = gets.split.map(&:to_i)
aa.sort!

x = Array.new(aa.max + 2, 0)

aa.each do |a| 
  x_can = a
  x[x_can - 1] += 1 if x_can > 0
  x[x_can] += 1
  x[x_can + 1] += 1
end

X = x.index(x.max)
ans = aa.count(X - 1) + aa.count(X) + aa.count(X + 1)
p ans

Measured memory_bytes: 8884
# recursively find all one-stroke paths
def findPaths(start, used):
	# if all vertices used, return 1 path found
	if len(used) == n:
		return 1

	# traverse all connections to unused vertices
	tot = 0
	for v in conn[start]:
		if v not in used:
			used.append(v)
			tot += findPaths(v, used)
			used.pop()

	# return total number of one-stroke paths found
	return tot

# get number of vertices N and edges M
n, m = map(int, raw_input().split())

# build a dict where key is start vertex and value is list of connected vertices
conn = {}
for i in range(m):
	a, b = map(int, raw_input().split())
	if a in conn:
		conn[a].append(b)
	else:
		conn[a] = [b]
	if b in conn:
		conn[b].append(a)
	else:
		conn[b] = [a]

# recursively start at vertex 1 with corresponding visited queue and find all one-stroke paths
print (findPaths(1, [1]))

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

int main()
{
  int s,m,h;
  int S,M;
  cin >> s;

  if(0 <= s && s < 86400)
    {
      m = s / 60;
      h = m /60;
      S = s % 60;
      M = m % 60;
      cout << h << ":"<< M <<":"<< S << endl;
    }
  else
    {}
  
  return 0;
}


Measured memory_bytes: 3112
n = int(input())
A = list(map(int, input().split()))

cnt = 0
money = 1000
b = 0
for i in range(n-1):
    if cnt == 0 and A[i] < A[i+1]:
        cnt += money//A[i]
        money %= A[i]
        b = A[i]
    else:
        money += cnt * A[i]
        cnt = 0
        if A[i] < A[i+1]:
            cnt += money//A[i]
            money %= A[i]
            b = A[i]
if cnt > 0:
    money += cnt * max(b, A[-1])
print(money)

Measured memory_bytes: 9200
n,m = map(int,input().split())
x = list(map(int,input().split()))
if n >= m:
    print(0)
else:
    count = m-n
    x.sort()
    y = []
    for i in range(m-1):
        y.append(abs(x[i+1]-x[i]))
    y.sort()
    print(sum(y[:count]))

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

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    rep(i, N - 1) {
        ans *= K - 1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n_n = count(s.begin(), s.end(), 'N');
    int n_s = count(s.begin(), s.end(), 'S');
    int n_e = count(s.begin(), s.end(), 'E');
    int n_w = count(s.begin(), s.end(), 'W');
    bool flag = true;
    if (n_n > 0 && n_s == 0) flag = false;
    if (n_s > 0 && n_n == 0) flag = false;
    if (n_e > 0 && n_w == 0) flag = false;
    if (n_w > 0 && n_e == 0) flag = false;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<int> D(N, 0);
	for (int i=0; i<N; i++)
		cin >>D.at(i);
	int M;
	cin >>M;
	vector<int> T(M, 0);
	for (int i=0; i<M; i++)
		cin >>T.at(i);
	sort(D.begin(), D.end());
	sort(T.begin(), T.end());
	int id=0;
	for (int it=0; it<M; it++) {
		while((id<N)&&(D.at(id)<T.at(it)))
			id++;
		if (id==N) {
			cout <<"NO" <<endl;
			return 0;
		}
		if (D.at(id)!=T.at(it)) {
			cout <<"NO" <<endl;
			return 0;
		}
		id++;
	}
	cout <<"YES" <<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cout << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << ", "; cerr << "\n}\n"; }
#define dbm(map) cerr << #map << ":"; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "\n";
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mli = map<ll, int>; using mll = map<ll, ll>;

int main() {
	int n, m; cin >> n >> m;
	vector<int> c(m); rep(i, m) cin >> c.at(i);
	vi dp(n + 1); // dp[j]:(i種類目までのコインで)j円を支払うのに必要なコインの枚数
	rep(i, n + 1) dp[i] = i; // コインが1を含むので
	rep(i, m) {
		// db(i); dbl(c[i]);
		rep2(j, c[i], n + 1) { // この順なら解けそう
			// db(j);
			if (c[i] <= j) dp[j] = min(dp[j], dp[j - c[i]] + 1);
			else break;			
		}
		// dbv(dp);
	}
	cout << dp[n] << endl;
}



Measured memory_bytes: 3196
S=[]
H=[]
C=[]
D=[]
n = gets.to_i
n.times do
    i = gets
    t = i.split[0]
    r = i.split[1].to_i
    S[r] = 1 if t == "S"
    H[r] = 1 if t == "H"
    C[r] = 1 if t == "C"
    D[r] = 1 if t == "D"
end
13.times do |x|
    x += 1
    print 'S'," ",x,"\n" if S[x] != 1
end
13.times do |x|
    x += 1
    print 'H'," ",x,"\n" if H[x] != 1
end
13.times do |x|
    x += 1
    print 'C'," ",x,"\n" if C[x] != 1
end
13.times do |x|
    x += 1
    print 'D'," ",x,"\n" if D[x] != 1
end



Measured memory_bytes: 6876
#! -*- coding: utf-8-unix -*-
import math

if __name__=='__main__':
  # lines = [x.strip() for x in sys.stdin.readlines() if x != '' and x != '\n']
  # n = int(lines[0])
  n = int(raw_input())
  for i in xrange(n):
    # x1, y1, x2, y2, x3, y3, x4, y4 = map(float, lines[i+1].split(' '))
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().strip().split(' '))
    # if x1 == x2 or x3 == x4:
    #   if x1 == x2 and x3 == x4:
    #     print 'YES'
    #   else:
    #     print 'NO'
    #   continue
    # elif y1 == y2 or y3 == y4:
    #   if y1 == y2 and y3 == y4:
    #     print 'YES'
    #   else:
    #     print 'NO'
    #   continue
    # else:
      # if (y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1):
    if math.fabs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10:
      print 'YES'
    else:
      print 'NO'
      # a1 = (y2 - y1) / (x2 - x1)
      # b1 = y1 - a1 * x1
      # a2 = (y4 - y3) / (x4 - x3)
      # b2 = y3 - a2 * x3
      # if (a1 == a2):# and (b1 != b2):
      #   print 'YES'
      # else:
      #   print 'NO'
    # except:
    #   break

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

int num_sum(int n){
	int s=0;
	int dig;
	while(n){
		dig = n%10;
		s = s+dig;
		n = n/10;
	}
	
	return s;
}

int main(){
	int n;
	int min = 1000000;
	cin >>n;
	
	for(int i=1;i<n;i++){
			int temp = num_sum(i) + num_sum(n-i);
			if(temp <min )min = temp;
		
	}
	cout <<min<<endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        string[] input1 = Console.ReadLine().Split(' ');
        int N = int.Parse(input1[0]);
        int M = int.Parse(input1[1]);
        int[] sum = new int[M];
        for (int i = 0; i < N; i++)
        {
            string[] input2 = Console.ReadLine().Split(' ');
            int K = int.Parse(input2[0]);
            for(int j = 0; j < K; j++)
            {
                sum[int.Parse(input2[j + 1])-1]++;
            }
        }
        int answer = 0;
        for(int i = 0; i < M; i++)
        {
            if (sum[i] == N) { answer++; }
        }
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
     int r,c;
     cin >> r >> c;
     int a[r][c];
     
     rep(i,r){
     	rep(j,c){
     		cin >> a[i][j];
     	}
     }
     int sum = 0;
     rep(i,r){
     	rep(j,c){
     		cout << a[i][j] << ' ';
     		sum += a[i][j];
     		if(j==c-1){
     			cout << sum << '\n';
     			sum = 0;
     	     }
     	}
     }
     
     sum = 0;
     int all = 0;
     rep(i,c){
     	rep(j,r){
     		sum+=a[j][i];
     		if(j==r-1){
     			cout << sum << ' ';
     			all+=sum;
     			sum = 0;
     		}
     	}
     }
     cout << all << '\n';
     
     return 0;
    }


Measured memory_bytes: 3124
n = int(input())
lst = list(map(int,input().split()))

ans = 1
lst_min = []
for i in range(n):
    if i == 0:
        lst_min.append(lst[i])
    else:
        lst_min.append(
            min(lst_min[i-1], lst[i])
        )
        if lst_min[i] == lst[i]:
            ans += 1
print(ans) 

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

vector<int> maxvec(vector<int> &a, vector<int> &b) {
  if (a[0] > b[0]) return a;
  if (a[0] < b[0]) return b;

  for (int i = 9; i >= 1; i--) {
    if (a[i] > b[i]) return a;
    if (a[i] < b[i]) return b;
  }

  return a;
}

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

  vector<int> A = { 0,2,5,5,4,5,6,3,7,6 };
  vector<int> Acheck(10, 0);
	for (int i = 0; i < M; i++) {
		int Ai; cin >> Ai;
		Acheck[Ai] = 1;
	}
  for (int i = 0; i < 10; i++) A[i] *= Acheck[i];


  vector<vector<int>> dp(N + 1, vector<int>(10, -1));
  dp[0] = { 0,0,0,0,0,0,0,0,0,0 };
  for (int i = 0; i <= N; i++) {
    vector<int> vec = { INT_MIN };
    for (int j = 0; j < 10; j++) {
      if (A[j] != 0 and i - A[j] >= 0) {
        if (dp[i - A[j]][0] != -1) {
          vector<int> tmp = dp[i - A[j]];
          tmp[0]++;
          tmp[j]++;
          vec = maxvec(vec, tmp);
        }
      }
    }
    dp[i] = maxvec(dp[i], vec);
  }


  for (int i = 9; i >= 1; i--) {
    for (int j = 0; j < dp[N][i]; j++) {
      cout << i;
    }
  }
  cout << endl;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int D = scanner.nextInt();

        int tmpD = 2 * D + 1;

        if(N % tmpD == 0){
            System.out.println(N/tmpD);
        }else{
            System.out.println(N/tmpD + 1);
        }

    }
}


Measured memory_bytes: 21844
S = input()
L = len(S)
index = L-1
flag = 0
searching = 0

while index> 0:
    if S.rfind('dreamer',0,index+1) == index-6 and S.rfind('dreamer',0,index+1) != -1:
        index = index - 7
        #print('0 index = '+ str(index))
        if index == -1 :
            flag = 1
            break;
        
    elif S.rfind('eraser',0,index+1) == index-5 and S.rfind('eraser',0,index+1) != -1:

        index = index - 6
        #print('1 index = '+ str(index))
        if index == -1 :
            flag = 1
            break;
    else:
        s1 = S.rfind('dream',0,index+1)  
        s2 = S.rfind('erase',0,index+1)
        if (s1 != -1 or s2 != -1 )and(s1==index-4 or s2 ==index-4):
            

            index = index -5
            #print('2 index = '+ str(index))
            if index  == -1 :
                flag = 1
                break;
        else :
            break;


if flag == 1:
    print('YES')
else :
    print('NO')



        

Measured memory_bytes: 3316
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  map<char,ll>M;
  string s;cin>>s;
  rep(i,s.size())M[s[i]]++;
  //cout<<M['N']<<" "<<M['S'}<<endl;
  if((M['N']>0&&M['S']==0)||(M['S']>0&&M['N']==0)||(M['W']>0&&M['E']==0)||(M['E']>0&&M['W']==0)){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n, k; cin >> n >> k;
  int now = 1;
  rep(i, n) {
    if (now * 2 < now + k) now *= 2;
    else now += k;
  }

  cout << now << endl;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(){
    int i,n;
    int a[10001];
    int max = -1000001, min = 1000001;
    double sum = 0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]>=max) max = a[i];
        if(a[i]<=min) min = a[i];
        sum += a[i];
    }
    printf("%d %d %.0lf\n", min, max, sum);
}



Measured memory_bytes: 2056
from sys import stdin

def mod(n):
    return n % 2

def div(n):
    return n / 2

n = int(stdin.readline().rstrip() )
a = list(map(int, stdin.readline().rstrip().split()))
ans = 0

while True:
    if sum(list(map(mod, a))) == 0:
        a = list(map(div, a))
        ans = ans + 1
    else:
        break

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
const int mod=1e9+7;
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chadd(T1 &x,T2 b) {x+=b;if(x>=mod) x-=mod;};
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
int a[1005];

int main()
{
//	freopen("input.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int res=0;
	for(int i=0;i<k;i++)
	{
		res+=a[i];
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int maxn=2e5+9;
struct edge{
    int to,nex;
}edges[maxn<<1];
bool mark[maxn];
int head;
void addedge(int to,int no){
    edges[no].to=to;
    edges[no].nex=head;
    head=no;
}
int main(){
    ll a;
    ios::sync_with_stdio(0);
    while(cin>>a){
        /*if(a<=1e5){
            cout<<2<<endl;
            if(a&1){
                cout<<a/2<<' '<<(a/2)+3ll<<endl;
            }
            else{
                cout<<(a/2)+1ll<<' '<<(a/2)+1ll<<endl;
            }
            continue;
        }*/
        cout<<50<<endl;
        ll ans=49*50;
        ans+=a;
        ll e=ans/50,f=ans%50;
        ll arr[55];
        for(int i=0;i<50;i++){
            arr[i]=e;
        }
        while(f){
            for(int i=0;i<50;i++){
                if(i==f)arr[i]+=50;
                else arr[i]--;
            }
            f--;
        }
        cout<<arr[0];
        for(int i=1;i<50;i++)cout<<' '<<arr[i];
        cout<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string rotate(string s);

int main(){
  string s,t;
  cin >> s >> t;
  
  int n=s.length();
  for (int i=0;i<n;++i){
    if (s==t){
      puts("Yes");
      return 0;
    }
    s=rotate(s);
  }
  puts("No");
  return 0;
}

string rotate(string s){
  return s.substr(1)+s[0];//s.substr(1)は1番目に書かれ文字以降の文字列を表している。abcdeという文字列があったらbcde+aにしてる感じ。
}
  

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if((a+b)==c||(a+c)==b||a==(b+c)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
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;
            }
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }
 
    }
}


Measured memory_bytes: 34532
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<ll> B(N - 1);
    REP(i, N - 1) { cin >> B[i]; }
    ll ans = 0;
    ans += B[0];
    for(int i = 0; i < N - 2; i++) {
        ans += min(B[i], B[i + 1]);
    }
    ans += B[N - 2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define NIL -1
#define MAX 100005

struct Node {
    int parent, left, right, depth;
};

int n;
Node T[MAX];

void rec(int i, int d) {
    T[i].depth = d;
    if (T[i].right != NIL) rec(T[i].right, d);
    if (T[i].left != NIL) rec(T[i].left, d + 1);
}

void print(int i) {
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, T[i].depth);

    if (T[i].parent == NIL) printf("root, [");
    else if (T[i].left == NIL) printf("leaf, [");
    else printf("internal node, [");

    for (int j = 0, c = T[i].left; c != NIL; j++, c = T[c].right) {
        if (j) printf(", ");
        printf("%d", c);
    }

    printf("]\n");
}


int main(void) {
    int i, j, v, d, c, l, rt;
    scanf("%d", &n);
    for (i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

    for (i = 0; i < n; i++) {
        cin >> v >> d;
        for (j = 0; j < d; j++) {
            cin >> c;
            if (j == 0) T[v].left = c;
            else T[l].right = c;
            l = c;
            T[c].parent = v;
        }
    }

    for (i = 0; i < n; i++) {
        if (T[i].parent == NIL) rt = i;
    }

    rec(rt, 0);

    for (i = 0; i < n; i++) print(i);

    return 0;
}

Measured memory_bytes: 5912
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
#include <set>
using namespace std;
typedef long long ll;


int main()
{
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++) cin >> a[i][j];
  }
 
  int dp[n+1][4];
  for(int i=0;i<3;i++) dp[0][i]=a[0][i];
  
  for(int i=1;i<n;i++){
     dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
     dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
     dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
  }
  int ans;
  ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ans;
  
}

Measured memory_bytes: 2944
K = int(input())

sevens = 0
count = 0
repeat = True

if {K%10} & {0,2,4,5,6,8}:
    count = -1
    repeat = False

while repeat:
    sevens = sevens % K * 10 + 7
    count += 1
    if sevens % K == 0:
        repeat = False

print(count)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n,k,a[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  sort(a+1,a+1+n);LL ans=0;
	for(int i=1;i<=k;i++)ans+=a[i];
		cout<<ans<<endl;
 	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int W, H, M;
    cin >> W >> H >> M;
    int xl = 0, xr = W, yl = 0, yr = H;
    int x, y, a;
    for (int i = 0; i < M; i++) {
        cin >> x >> y >> a;
        if (a == 1) xl = max(x, xl);
        else if (a == 2) xr = min(x, xr);
        else if (a == 3) yl = max(y, yl);
        else if (a == 4) yr = min(y, yr);
    }
    int dx = xr - xl, dy = yr - yl;
    if (dx <= 0 || dy <= 0) cout << 0 << '\n';
    else cout << dx * dy << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        int[] NK = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = NK[0];
        int K = NK[1];
        char[] chars = Console.ReadLine().ToCharArray();

        char c = chars[K - 1];
        string tmp = "" + c;
        tmp = tmp.ToLower();

        c = tmp[0];

        chars[K - 1] = c;

        string ans = new string(chars);

        Console.WriteLine(ans);
        
        
        

    }

    static long calcGCD(long num1, long num2)
    {
        if(num1 < num2)
        {
            var tmp = num1;
            num1 = num2;
            num2 = tmp;
        }

        while(true)
        {
            long res;
            long div = Math.DivRem(num1, num2, out res);

            if (res == 0)
            {
                return num2;
            }
            else
            {
                num1 = num2;
                num2 = res;
            }
        }
    }
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}




Measured memory_bytes: 11348
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main()
{
	int a, b, c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;

	if ((a < c && c < b) || (b < c && c < a))
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,p,data[50],i,d,result;
  while(1){
    cin >> n >> p;
    d=p;
    if(n==0&&p==0) break;
    for(i=0;i<n;i++) data[i]=0;
    i=0;
    while(1){
      if(p>0){
	p--;
        data[i]++;
	if(data[i]==d){
	  result=i;
	  break;
	}
      }else if(p==0){
        p=data[i];
        data[i]=0;
      } 
      if(i+1==n) i=0;
      else i++;
    }
    cout << result << endl;
  }
  return 0;
}

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

int main(){
    string s;
    int count[26] = {};
    int i;
    while(getline(cin, s)){
        for( i = 0; i < s.size(); i++ ){
            if( s[i] >= 'a' && s[i] <= 'z') count[s[i] - 'a']++;
            else if( s[i] >= 'A' && s[i] <= 'Z') count[s[i] - 'A']++;
        }
    }

    for( i = 0; i < 26; i++ ){
        cout << (char)( 'a' + i ) << " : " << count[i] << endl;
    }
    return 0;
}





Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
lint ans = 1000000007;
void solve(lint H, lint W)
{
  for (lint i = 1; i <= H; i++)
  {
    lint SA = i * W;
    lint mid = W / 2;
    lint SB = (H - i) * mid;
    lint SC = (H - i) * (W - mid);
    lint Max = max(SA, SB);
    Max = max(Max, SC);
    lint Min = min(SA, SB);
    Min = min(Min, SC);
    lint dif = Max - Min;
    ans = min(ans, dif);
  }
}
void solve2(lint H, lint W)
{
  for (lint i = 1; i <= H; i++)
  {
    lint SA = i * W;
    lint mid = (H - i) / 2;
    lint SB = W * mid;
    lint SC = W * (H - i - mid);
    lint Max = max(SA, SB);
    Max = max(Max, SC);
    lint Min = min(SA, SB);
    Min = min(Min, SC);
    lint dif = Max - Min;
    ans = min(ans, dif);
  }
}

int main()
{
  lint H, W;
  cin >> H >> W;
  solve(H, W);
  solve(W, H);
  solve2(H, W);
  solve2(W, H);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

s_list = []
h_list = []
c_list = []
d_list = []

def mk_list(cards_list):
    for j in range(1, 14):
        if j == y:
            cards_list.append(y)
        else:
            continue
    return cards_list

for i in range(n):
    x, y = input().strip().split()
    y =int(y)

    if x is 'S':
        mk_list(s_list)
    elif x is 'H':
        mk_list(h_list)
    elif x is 'C':
        mk_list(c_list)
    elif x is 'D':
        mk_list(d_list)

def check_card(symble, cards_list):
    for k in range(1, 14):
        if k not in cards_list:
            print('{} {}'.format(symble, k))
        else:
            continue

check_card('S', s_list)
check_card('H', h_list)
check_card('C', c_list)
check_card('D', d_list)


Measured memory_bytes: 5600
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  int i=0,check=1; 
  string s;	
  getline(cin,s);
  for (i=0; i<3; i++)
    {
      if (s[i+1]==s[i]) 
        {
          check=0; break;
        }
    }
  if (!check) cout << "Bad";
   else cout << "Good";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		// 1オリジン
		int[]A = new int[H + 1];
		for(int i = 0; i < H; i++) {
			A[i + 1] = scan.nextInt();
		}
		scan.close();
		for(int i = 1; i <= H; i++) {
			System.out.print("node " + i + ": key = " + A[i] + ", ");
			if(parent(i) >= 1) {
				System.out.print("parent key = " + A[parent(i)] + ", ");
			}
			if(left(i) <= H) {
				System.out.print("left key = " + A[left(i)] + ", ");
			}
			if(right(i) <= H) {
				System.out.print("right key = " + A[right(i)] + ", ");
			}
			System.out.println();
		}
	}
	static int parent(int i) {return i / 2;}
	static int left(int i) {return 2 * i;}
	static int right(int i) {return 2 * i + 1;}
}


Measured memory_bytes: 27544
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> q = new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < n; i++) {
            q.add(sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            int x = q.poll();
            x = x/2;
            q.add(x);
        }
        long ans = 0L;
        for (Integer x : q) {
            ans += (long)x;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 60496
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define forn(i,n) for(int i=0;i<n;i++)
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

int mod(long long x) {
	return ((x % M + M) % M);
}
int add(int a, int b) {
	return mod(mod(a) + mod(b));
}
int diff(int a, int b) {
	return mod(mod(a) - mod(b));
}

int mul(int a, int b) {
	return mod(mod(a) * mod(b));
}

int modPow(int a, int b) {
	if (b == 0)
		return 1;
	if (b == 1)
		return a % M;
	int res = 1;
	while (b) {
		if (b % 2 == 1)
			res = mul(res, a);
		a = mul(a, a);
		b = b / 2;
	}
	return res;
}

void solve() {

	int n; cin >> n;
	if (n == 1)
	{
		cout << 0 << endl;
		return;
	}

	if (n == 2) {
		cout << 2 << endl;
		return;
	}


	int ans = diff(add(modPow(10, n), modPow(8, n)), mul(2, modPow(9, n)));
	cout << ans << endl;



	// cout << ans << endl;

}



int32_t main() {

	fastio;

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	// int t; cin >> t;/
	int t = 1;

	while (t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt();
		int[]occeven=new int[(int)1e5+1];
		int[]occodd=new int[(int)1e5+1];
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				occeven[sc.nextInt()]++;
			}
			else {
				occodd[sc.nextInt()]++;
			}
		}
		int maxe=0;LinkedList<Integer>max=new LinkedList<Integer>();
		for(int i=0;i<occeven.length;i++) {
			if(occeven[i]>maxe) {
				maxe=occeven[i];
				max=new LinkedList<Integer>();
				max.add(i);
			}
			else {
				if(occeven[i]==maxe) {
					max.add(i);
				}
			}
		}
		int maxe2=0;
		if(maxe<n/2 && max.size()==1) {
			for(int i=0;i<occeven.length;i++) {
				if(occeven[i]>maxe2 && max.getFirst()!=i) {
					maxe2=occeven[i];
				}
			}
		}
		int ans=n-maxe;
		for(int i=0;i<occodd.length;i++) {
			if(occodd[i]>0) {
				if(max.size()>1 || i!=max.getFirst()) {
					ans=Math.min(ans,n-maxe-occodd[i]);
				}
				else {
					ans=Math.min(ans,n-maxe2-occodd[i]);
				}
			}
		}
		pw.println(ans);
		
		pw.close();
		pw.flush();
 
	}
	static int gcd(int a, int b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 36040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    a[n + 1] = 0;
    rep(i, n) cin >> a[i+1];
    vector<int> list1(n + 2), list2(n + 2);
    list1[0] = 0;
    list1[n + 1] = 0;
    list2[0] = 0;
    list2[n + 1] = 0;
    rep(i,n){
        list1[i + 1] = max(list1[i], a[i+1]);
        list2[n - i] = max(list2[n + 1 - i], a[n - i]);
    }
    rep(i,n){
        int ans = max(list1[i], list2[i + 2]);
        cout << ans << endl;
    }
}

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

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

    if(n == m){
        cout << "Yes";
    }else{
        cout << "No";
    }

    cout << endl;
}

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

int main(){
  int64_t A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  if(V*T>=(abs(B-A)+W*T)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

	
	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	   
	    int n;
	    cin>>n;
	    if(n==0){
	    	cout<<1<<endl;
	    }
	    else{
	    	cout<<0<<endl;
	    }
	    return 0;
}



	


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

int main() {
	for(;;){
		int x, y;
		cin >> x >> y;
		if(x==0 && y==0){break;}
		
		if(x<y){cout << x <<" "<<y<<endl;}
		else{cout << y<<" "<< x<< endl;}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,A,B,C;cin>>n>>A>>B>>C;
    ll a=A*gyaku(A+B);
    ll b=B*gyaku(A+B);
    a%=mod;
    b%=mod;
    ll an=beki(a,n);
    ll bn=beki(b,n);
    ll nowa=1,nowb=1;
    ll now=1;
    ll ans=n*(an+bn);
    ans%=mod;
    rep(i,1,n){
        //cout<<ans<<" ";
        now*=(n+i-1);
        now%=mod;
        now*=gyaku(i);
        now%=mod;
        nowa*=a;
        nowa%=mod;
        nowb*=b;
        nowb%=mod;
        //cout<<an<<" "<<nowb<<endl;
        ll u=(an*nowb)%mod;
        u%=mod;
        
        u+=(bn*nowa);
        u%=mod;
        u*=(n+i);
        u%=mod;
        u*=now;
        u%=mod;
        ans+=u;
        ans%=mod;
        
    }
    ans*=100;
    ans%=mod;
    ans*=gyaku(A+B);
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 384
#! python3

while True:
  a, op, b = [x for x in input().strip().split(' ')]
  if op == '?':
    break
  a = int(a)
  b = int(b)
  if op == '+':
    print(a+b)
  elif op == '-':
    print(a-b)
  elif op == '*':
    print(a*b)
  elif op == '/':
    print(a//b)

Measured memory_bytes: 7716
n = int(input())
L = []
for _ in range(n):
    x, l = map(int, input().split())
    left = x - l
    right = x + l
    L.append((left, right))

L.sort(key=lambda x: x[1])

# print(L)

ans = 1
right = L[0][1]
for i in range(1, n):
    next_left = L[i][0]
    next_right = L[i][1]

    if next_left < right:
        continue
    else:
        ans += 1
        right = next_right

print(ans)

Measured memory_bytes: 18260