akhauriyash/Code-Regression huggingface dataset:
// 5/29
// 2-5-5 わーシャルフロイド
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

// 二頂点間の距離を格納する隣接行列
vector<vector<int>> dist;
vector<int> r;

void warshall_floyed(int N) {
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                // bool must_visit = false;
                // rep(l, r.size()) {
                //     if(r[l] == k) must_visit = true;
                // }

                // if (must_visit) dist[i][j] = min(INF, dist[i][k] + dist[k][j]);
                // else dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main() {
    int N;  // 与えられた有向グラフの頂点の数
    int M;  // 同辺の数（辺の重みは負の場合がある）
    int R;
    cin >> N >> M >> R;

    // vector<int> r(R);
    r.resize(R);
    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }

    dist.assign(N, vector<int>(N, INF));
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        
        // int match = 0;
        // rep(i, R) {
        //     if (a == r[i]) match++;
        //     if (b == r[i]) match++;
        // }
        // if (match == 2) dist[a][b] = dist[b][a] = c;

        dist[a][b] = dist[b][a] = c;
    }

    warshall_floyed(N);

    int ans = INF;
    // // rep(i, N) {
    // //     rep(j, N) {
    // //         ans = min(ans, dist[i][j]);
    // //     }
    // // }
    // rep(i, R) {
    //     rep(j, R) {
    //         ans = min(ans, dist[r[i]][r[j]]);
    //     }
    // }

    sort(r.begin(), r.end());
    do {
        int cost = 0;
        rep(i, R - 1) cost += dist[r[i]][r[i + 1]];
        ans = min(ans, cost);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;


int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i=0;i<n;i++) cin>>a[i];
    ll sum=0;
    vector<ll> even(1,0);
    vector<ll> odd(1,0);
    for(int i=0;i<n;i++){
        sum+=a[i];
        if(i%2==0){
            even.push_back(*even.rbegin()+a[i]);
        }else{
            odd.push_back(*odd.rbegin()+a[i]);
        }
    }

    vector<ll> b(n,0);
    for(int i=0;i<n;i++){
        if(i%2==0){
            b[i]+=*even.rbegin();
            b[i]-=even[(i+2)/2-1];
            b[i]+=odd[(i+2)/2-1];
        }else{
            b[i]+=*odd.rbegin();
            b[i]-=odd[(i+2)/2-1];
            b[i]+=even[(i+2)/2];
        }
        b[i]*=2;
        b[i]-=sum;
    }
    for(int i=0;i<n;i++) cout<<b[i]<<" ";
    cout<<endl;

}

Measured memory_bytes: 5560
#include <cstdio>
#include <algorithm>
int a[1000][1000];
int main()
{
    int n, m;
    char deal;
    scanf("%d%d", &n, &m);
    getchar();
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            deal = getchar();
            if (deal == '.')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
        getchar();
    }
    int pos = n;
    for (int i = 0; i < n; i++)
    {
        if (a[i][0] == 0)
        {
            pos = i;
            break;
        }
    }
    for (int i = pos + 1; i < n; i++)
        a[i][0] = 0;
    pos = m;
    for (int i = 0; i < m; i++)
    {
        if (a[0][i] == 0)
        {
            pos = i;
            break;
        }
    }
    for (int i = pos + 1; i < m; i++)
        a[0][i] = 0;
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < m; j++)
        {
            if (a[i][j])
            {
                a[i][j] = a[i][j - 1] + a[i - 1][j];
                a[i][j] %= 1000000007;
            }
        }
    }
    printf("%d", a[n - 1][m - 1]);
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
    boolean[][] array;
    int n;
    void run() {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        int even4 = 0;
        int even2 = 0;
        int odd = 0;
        for (int i = 0; i < n; i++) {
            int num = scan.nextInt();
            if (num % 4 == 0)
                even4++;
            else if (num % 2 == 0)
                even2++;
            else
                odd++;
        }
        if (even2 != 0)
            odd++;
        System.out.println(even4 >= odd - 1?"Yes":"No");
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MAXN = 30;
long long a[MAXN][MAXN];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            int w = __gcd(i, j);
            if (w == 1)
            {
                ans += n;
            }
            else
            {
                for (int k = 1; k <= n; k++)
                {
                    ans += __gcd(w, k);
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3584
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
 
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

N = int(input())
S = input()
value = 0
for c in S:
    if c == ".":
        value += 1
ans = value
for i in range(N):
    if S[i] == ".":
        value -= 1
    else:
        value += 1
    ans = min(ans,value)
print(ans)

Measured memory_bytes: 6828
#include <iostream>

using namespace std;

void sort(int* array, int N)
{
    bool flag = true;
    int count = 0;
    while(flag)
    {
        flag = false;
        for(int i=N-1;i>0;--i)
        {
            if(array[i] < array[i-1])
            {
                swap(array[i], array[i-1]);
                ++count;
                flag = true;
            }
        }
    }

    for(int i=0;i<N;++i)
    {
        if(i) cout << " ";
        cout << array[i];
    }
    cout << endl << count << endl;
}

int main()
{
    int array[100];
    int N;
    cin >> N;
    for(int i=0;i<N;++i)
    {
        cin >> array[i];
    }
    sort(array, N);
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> count(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        count.at(A.at(i))++;
    }

    ll sum = 0;
    for (int i = 0; i < N + 1; i++) {
        ll c = count.at(i);
        sum += c*(c-1)/2;
    }

    for (int i = 0; i < N; i++) {
        cout << sum - (count.at(A.at(i))-1) << endl;
    }
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,n,m=0;
	char s[100000];
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<(n/2)+(n%2);i++){
		if(s[i]=='p' && s[n-i-1]=='q'){
			m++;
		}
		else if(s[i]=='q' && s[n-i-1]=='p'){
			m++;
		}
		else if(s[i]=='d' && s[n-i-1]=='b'){
			m++;
		}
		else if(s[i]=='b' && s[n-i-1]=='d'){
			m++;
		}
	}
	if((n/2)+(n%2)==m){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<math.h>
using namespace std;
int main()
{
	int n;
	vector<int> stork;
	cin >> n;
	stork.resize(n + 1);
	stork[0] = 0;
	for (int e = 1; e < n+1; e++)
		cin >> stork[e];

    int answer=0;
    int e=3;
    int run[n+1];
    run[2] = abs(stork[2]-stork[1]);
    while(e<=n){
            run[e] = min(run[e-2]+abs(stork[e]-stork[e-2]),run[e-1]+abs(stork[e]-stork[e-1]));
            e++;
        }
    cout<< run[n]<<endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b,x;
  cin >> a >> b >> x;

  cout << (a<=x && x<=a+b ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    a = input()
    if ord(a) < ord("a"):
        print("A")
    else:
        print("a")

if __name__ == '__main__':
    main()


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

int main() {
	long long  a, b;
	cin >> a >> b;
	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	} else if (a < 0 && b < 0) {
		int tmp = b - a;
		if (tmp % 2 == 0) {
			cout << "Negative" << endl;
		} else {
			cout << "Positive" << endl;
		}
	} else {
		cout << "Zero" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;

using namespace std;

inline int input(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template

int main() {
    cin.tie(0);
    // source code
    int N, Q;
    cin >> N;
    vector<int> S(N);
    rep(i, N){
        cin >> S[i];
    }
    cin >> Q;
    vector<int> T(Q);
    rep(i, Q){
        cin >> T[i];
    }
    
    int ret = 0;
    rep(i, Q){
        int l = 0, r = N;
        while (l < r) {
            int mid = (l + r) / 2;
            if (S[mid] > T[i]) {
                r = mid;
            }
            else if(S[mid] == T[i]){
                ret++;
                break;
            }
            else{
                l = mid + 1;
            }
        }
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3268
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] >= b[i]:
        cnt += b[i]
    elif a[i] < b[i] and a[i] + a[i+1] >= b[i]:
        cnt += b[i]
        a[i+1] = a[i+1] - (b[i] - a[i])
    else:
        cnt += (a[i] + a[i+1])
        a[i+1] = 0
print(cnt)

Measured memory_bytes: 24120
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<usize>();
    let n = v[0];
    let q = v[1];
    let s = read::<String>().chars().collect::<Vec<char>>();
    let qs = read_vec2::<usize>(q as u32);

    let mut dp = vec![0u32; n+1];
    for r in 1..n {
        if s[r] == 'C' &&
            s[r - 1] == 'A' {
            dp[r] = dp[r - 1] + 1;
        } else {
            dp[r] = dp[r - 1];
        }
    }

    //println!("{:?}", dp);

    for lr in qs {
        let l = lr[0];
        let r = lr[1];
        let ans = {
            if l == 1 {
                dp[r - 1]
            } else if l >= 2 && s[l - 1] == 'C' &&
                s[l - 2] == 'A' {
                dp[r-1] - dp[l-2] - 1
            } else {
                dp[r-1] - dp[l-2]
            }
        };
        println!("{}", ans);
    }
}


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

int main() {
 int n;
 cin >>n;
 vector<int> a(n);
 rep(i,n) {
  cin>>a.at(i);
  }
  
  vector<int> b(n);
  vector<int> c(n);
  
  rep(i,n) {
   b.at(i) = a.at(i)+1;
   c.at(i) = a.at(i)-1;
   }
  
  a.insert(a.end(),b.begin(),b.end());
  a.insert(a.end(),c.begin(),c.end());
  
  sort(a.begin(),a.end());
  int ans = 1;
  int count = 1;
  for(int i = 0;i<a.size()-1;i++) {
    if(a.at(i) == a.at(i+1)) {
    count++;
     }
     else {
      ans = max(ans,count);
      count = 1;
      }
   }
  
  cout << ans;

}

Measured memory_bytes: 6000
#include <stdio.h>
#include <string.h>
//https://www.khanacademy.org/computing/computer-science/algorithms
//http://www.toi2015.sat.psu.ac.th/files/news/?¢???????¢????????????????-TOI11.pdf
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d %d\n",a*b,a+a+b+b);
	return 0;
}

Measured memory_bytes: 596
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	im := IntMap{}

	for i := 2; i < n+1; i++ {
		xx := i
		for x := 2; x <= xx; x++ {
			for xx%x == 0 {
				im.increment(x)
				xx = xx / x
			}
		}
	}

	var ans int64
	ans = 1
	for _, c := range im {
		ans *= int64(c + 1)
		ans %= int64(1e9 + 7)
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

// IntMap ...
type IntMap map[int]int

func (m IntMap) get(key int) int {
	if _, ok := m[key]; ok {
		return m[key]
	}
	return 0
}
func (m IntMap) increment(key int) {
	if _, ok := m[key]; ok == false {
		m[key] = 0
	}
	m[key]++
}


Measured memory_bytes: 768
/*
	################
	# Avi Kasliwal #
	# Noob Coder:( #
	################
*/

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

#define int long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)


#define deb(x) cout << "#x " << x << "\n"


#define newline cout << "\n"
#define yes cout << "Yes" << "\n"
#define no cout << "No" << "\n"
#define Yes cout << "YES" << "\n"
#define No cout << "NO" << "\n"


#define fixDeci(num, places) std::cout << std::fixed << std::setprecision(places) << num << '\n'
#define setBits(x) __builtin_popcount(x)
#define zerobits(x) __builtint_ctzll(x)
#define MOD 1000000007

#define rep(i, s, e) for (i = s; i < e; i++)
#define repr(i, s, e) for (i = s; i >= e; i--)

// GCD Function
int GCD(int a, int b) {
	if (b == 0) {
		return a;
	} else {
		return GCD(b, a % b);
	}
}

// LCM Function
int LCM(int a, int b) {
	int gcd = GCD(a, b);
	return (max(a, b) / gcd)*(min(a, b));
}

/*int p[100000001];
void Sieve() {
	p[0] = p[1] = 0;
	p[2] = 1;
	for (int i = 4; i < 100000000; i += 2) {
		p[i] = 0;
	}
	for (int i = 3; i * i < 100000000; i++) {
		if (p[i] == 1) {
			for (int j = i*i; j < 100000000; j += i) {
				p[j] = 0;
			}
		}
	}
}*/

int32_t main () {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	IOS; int i, j;

	/*######## Code Here ##########*/
	/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
	
	int t; t = 1;
	while (t--) {
		int n; cin >> n;
		int a[n];
		rep (i, 0, n) {
			cin >> a[i];
		}
		int dp[n];
		dp[0] = 0;
		dp[1] = abs(a[1] - a[0]);
		rep (i, 2, n) {
			dp[i] = min (dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
		}
		cout << dp[n - 1] << "\n";
	}

	return 0;
}

/*Timus : 294930IX */

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

using namespace std;

const int INF = 1 << 29;

struct edge
{
  int to, cost;
};

int N, M, K, P;
vector< edge > graph[1000];
int S[6], T[6];
int dp[1000][1 << 6][1 << 6];
vector< int > mc[1000];

int Dijkstra(int s, vector< int >& min_cost)
{
  min_cost.assign(N, INF);
  typedef pair< int, int > Pi;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.push(Pi(0, s));
  min_cost[s] = 0;
  while(!que.empty()) {
    int now = que.top().second;
    int cost = que.top().first;
    que.pop();
    if(cost > min_cost[now]) continue;
    for(int i = 0; i < graph[now].size(); i++) {
      edge e = graph[now][i];
      if(cost + e.cost < min_cost[e.to]) {
        min_cost[e.to] = cost + e.cost;
        que.push(Pi(min_cost[e.to], e.to));
      }
    }
  }
  return (-1);
}

int rec(int idx, int a, int b)
{
  if(b == (1 << K) - 1) return (0);
  if(~dp[idx][a][b]) return (dp[idx][a][b]);
  int ret = INF;
  for(int i = 0; i < K; i++) {
    if((a >> i) & 1) {
      if(((b >> i) & 1) == 0) {
        ret = min(ret, rec(T[i], a, b | (1 << i)) + mc[idx][T[i]]);
      }
    } else {
      ret = min(ret, rec(S[i], a | (1 << i), b) + mc[idx][S[i]]);
    }
  }
  return (dp[idx][a][b] = ret);
}

int main()
{
  scanf("%d %d %d %d", &N, &M, &K, &P);
  --P;
  while(M--) {
    int X, Y, W;
    scanf("%d %d %d", &X, &Y, &W);
    --X, --Y;
    graph[X].push_back((edge) {Y, W});
    graph[Y].push_back((edge) {X, W});
  }
  Dijkstra(P, mc[P]);
  for(int i = 0; i < K; i++) {
    scanf("%d %d", &S[i], &T[i]);
    --S[i], --T[i];
    if(mc[P][S[i]] >= INF || mc[P][T[i]] >= INF) {
      cout << "Cannot deliver" << endl;
      exit(0);
    }
    Dijkstra(S[i], mc[S[i]]);
    Dijkstra(T[i], mc[T[i]]);
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", rec(P, 0, 0));
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}


int main(void){
    int n, m;
    scanf("%d", &n);
    printf("ABC%d\n", n); 
}


Measured memory_bytes: 128
from bisect import bisect_left as bl
from itertools import accumulate as ac
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
s=[0]+list(ac(a[::-1]))
l,r=2*a[-1]*(n**2)+1,0
while l-r>1:
    t=(l+r)//2
    p=0
    for i in range(n-1,-1,-1):
        if a[i]+a[-1]>=t:
            x=bl(a,t-a[i])
            p+=n-x
        else:
            break
    if p<m:
        l=t
    else:
        r=t
c,d=0,0
w=0
for i in range(n-1,-1,-1):
    if a[i]+a[-1]>=r:
        g=bl(a,r-a[i])
        x=n-g
        c+=s[x]+x*a[i]
        w+=x
    else:
        break
print(c-r*max(0,(w-m)))


Measured memory_bytes: 15636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,M;
  	cin>>A>>B>>M;
  	vector<int>a(A);
  	vector<int>b(B);
  	vector<vector<int>>d(M,vector<int>(3));
  	vector<int>c(M);
  	for(int i=0;i<A;i++){
    	cin>>a[i];
    }
  	for(int i=0;i<B;i++){
    	cin>>b[i];
    }
  	for(int	i=0;i<M;i++){
    	cin>>d[i][0]>>d[i][1]>>d[i][2];
        
    }
  	for(int i=0;i<M;i++){
    	c[i]=a[d[i][0]-1]+b[d[i][1]-1]-d[i][2];
      	
    
    }
  	sort(a.begin(),a.end());
  	sort(b.begin(),b.end());
  	sort(c.begin(),c.end());
  	
  	cout<<min(a[0]+b[0],c[0])<<endl;

}

Measured memory_bytes: 6912
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

void execute(int test, istream &in) {
    int n;
    in >> n;
    vector<int> p(n * n);
    for (int i = 0; i < p.size(); i++) {
        in >> p[i];
        p[i]--;
    }
    vector<vector<int>> d(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        int mi = std::min(i, n - i - 1);
        for (int j = 0; j < n; j++) {
            int mj = std::min(j, n - j - 1);
            d[i][j] = std::min(mi, mj);
        }
    }
    vector<vector<char>> occ(n, vector<char>(n, 1));
    vector<vector<char>> updated(n, vector<char>(n, 0));
    int answer = 0;
    int ip[4] = { 1, -1, 0, 0 };
    int jp[4] = { 0, 0, 1, -1 };
    for (int num = 0; num < p.size(); num++) {
        int i0 = p[num] / n;
        int j0 = p[num] - i0 * n;
        answer += d[i0][j0];
        occ[i0][j0] = 0;
        priority_queue<pair<int, pair<int, int>>> q;
        q.emplace(-d[i0][j0], make_pair(i0, j0));
        while (!q.empty()) {
            i0 = q.top().second.first;
            j0 = q.top().second.second;
            int val = -q.top().first;
            q.pop();
            for (int idx = 0; idx < 4; idx++) {
                int i = i0 + ip[idx];
                int j = j0 + jp[idx];
                if (i < 0 || i >= n || j < 0 || j >= n)
                    continue;
                if (d[i][j] > val) {
                    d[i][j] = val;
                    int newVal = val + occ[i][j];
                    q.emplace(-newVal, make_pair(i, j));
                }
            }
        }
    }
    printf("%d\n", answer);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        execute(test, f);
    }
    return 0;
}


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n,m; cin >> n >> m;
  vector<string> a(n),b(m);
  for(int i=0; i<n; ++i) cin >> a.at(i);
  for(int i=0; i<m; ++i) cin >> b.at(i);

  for(int i=0; i<n-m+1; ++i) {
    for(int j=0; j<n-m+1; ++j) {
    //  if(a[i][j]==b[0][0]) {
      if(i+m-1>=n || j+m-1>=n) continue;
        int ok=1;
        bool match = true;
        for(int k=0; k<m; ++k) {
          for(int l=0; l<m; ++l) {
            if(a[i+k][j+l]!=b[k][l]) {
              ok=0; match=false;
            }
          }
        }
        if(ok) drop("Yes");
    }
  }
  cout << "No" << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){

    int N;
    cin >> N;
    
    int g = 1;
    int ans = 0;
    
    for (int i = 0; i < 6; i++) {
        
        g = g*10;
        if (i % 2 == 0 && N >= g/10) {
            if (N >= g) {
                ans += g - g/10;
            }else{
                if (N >= g/10) {
                    ans += N - g/10 + 1;
                }
                
            }
        }
        
    }
    
    
    
    cout << ans << endl;
    
    
    
    
    
    return 0;
    
}


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

int N;
int A[101] = {0};
int sum;

void dfs(int level, bool flag) {
	if (N == level) {
		if (flag)
			sum++;
	} else {
		dfs(level+1, flag || !((A[level]-1)%2));
		dfs(level+1, flag || !(A[level]%2));
		dfs(level+1, flag || !((A[level]+1)%2));
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	dfs(0, false);
	cout << sum << endl;
}


Measured memory_bytes: 256
import math
N = int(input())
ints = list(map(int,input().split()))

def gcd(x,y):
  while x%y != 0:
    x,y = y,x%y
  return y

d = ints[0]
for i in range(1, N):
  d = gcd(d, ints[i])

res = []
for i in range(1, int(math.sqrt(d)+1)):
  if d % i == 0:
    if d // i == i:
      print(i)
    else:
      print(i)
      res.append(int(d//i))

for i in res[::-1]: print(i)



Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  string s, t;
  cin >> s >> t;
  
  ll ans = 0;
  ll n = s.size();
  for (int i = 0; i < n; i++){
    if (s[i] != t[i])
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;

map<int, int> mp;
int res = 0;
map<int, int>  lemp;
int mx = 0;
int t;
int le(int a) {
	auto x = mp.find(a);
	if (a <= 0 || (x == mp.end()) || (*x).second < t - 1)return a;
	x = lemp.find(a);
	if (x == lemp.end()) {
		lemp[a] = le(a - 1);
	}
	else {
		(*x).second = le((*x).second);
	}
}
int N;
vector<int> A;
bool check(int a) {
	t = a;
	int len = 0;
	mp.clear();
	lemp.clear();
	for (int i = 0; i < N; i++) {
		if (len < A[i]) {
			len = A[i];
		}
		else {
			len = A[i];
			int k = le(A[i]);
			if (k == 0)return false;
			mp[k]++;
			if (mp.size() > 0) {
				for (auto x = --(mp.end());;) {

					if ((*x).first > k) {
						x = mp.erase(x);

						if (x == mp.begin())break;
						x--;
					}
					else {
						break;
					}
				}
			}
			//cerr << "Ok" << i << endl;

			if (lemp.size() > 0) {
				for (auto x = --(lemp.end());;) {
					//cerr << (*x).first << endl;
					if ((*x).first > k) {
						x = lemp.erase(x);
						if (x == lemp.begin())break;
						x--;
					}
					else {
						break;
					}

				}
			}
		}
	}
	return true;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	//N = 200000;
	A.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		//A[i] = 20;
	}
	bool x = true;
	for (int i = 1; i < N; i++) {
		if (A[i - 1] >= A[i]) {
			x = false;
		}
	}
	if (x) {
		cout << 1 << endl;
		return 0;
	}
	int ok = N;
	int ng = 1;

	while (ok - ng > 1) {
		int m = (ok + ng) / 2;

		if (check(m)) {
			ok = m;
		}
		else {
			ng = m;
		}
	}
	cout << ok << endl;
}

Measured memory_bytes: 1792
# solution
import io
from scipy.misc import comb

nim, mike, kite = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
print(sum(V[:mike]) / mike)
Ath_CNT = V.count(V[mike - 1])
V_than_Ath_CNT = len([v for v in V if v > V[mike - 1]])
if max(V) == V[mike - 1]:
    ans = 0
    for k in range(mike, kite + 1):
        ans += comb(Ath_CNT, k, 1)
else:
    ans = comb(Ath_CNT, mike - V_than_Ath_CNT, 1)
print(ans)


Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  vector<int> A;
  int sum = 0;
  int point = 0;
  cin >> N >> M;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    sum += a;
    A.push_back(a);
  }
  double mm = sum / (4.0 * M);
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) >= mm)
    {
      point++;
    }
  }
  //cout << mm << endl;
  //cout << point << endl;
  if (point >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    if h > 1:
        print('#' * w)
    for i in range(1, h - 1):
        if w == 1 or w == 2:
            print('#' * w)
        else:
            print('#' + '.' * (w - 2) + '#')
    print('#' * w)
    print()



Measured memory_bytes: 5612
list = input().split(' ')
for i, n in enumerate(list):
  list[i] = int(n)

change = True
while change:
    for i in range(len(list) - 1):
        change = False
        if list[i] > list [i + 1]:
            list[i], list[i + 1] = list[i + 1], list[i]
            change = True

string = ''
for i in range(len(list)):
  string += (str(list[i]) + ' ')

string = string.rstrip()

print(string) 


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long remain = N % (A + B);
        if (remain>A) {
            remain=A;
        }
        long num= N / (A + B);

        System.out.println(num*A+remain);

        sc.close();

    }
}

Measured memory_bytes: 22740
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
map<int,int>d;
int read()
{
	int res=0;char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))res=res*10+ch-'0',ch=getchar();
	return res;
}
int main()
{
	int n=read(),m;
	register int i,tmp;
	for(i=1;i<=n;i++)
	{
		tmp=read();
		d[tmp]++;
	}
	m=read();
	if(m>n){
		printf("NO");
		return 0;
	}
	for(int i=1;i<=m;i++)
	{
		tmp=read();
		if(--d[tmp]>=0)continue;
		printf("NO");
		return 0;
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 9600
table = Array.new(51, 0)

for a in 0..9 do
  for b in 0..9 do
    for c in 0..9 do
      for d in 0..9 do
        table[a + b + c + d] += 1
      end
    end
  end
end

while line = gets
  n = line.chomp.to_i
  puts table[n]
end

Measured memory_bytes: 8624
import std.stdio: writeln, stdin;
import std.algorithm, std.string, std.conv, std.range;

double cross(T)(T a, T b, T c)
{
    return (a[0] - b[0]) * (b[1] - c[1]) - (a[1] - b[1]) * (b[0] - c[0]);
}

void main()
{
    foreach(input; stdin.byLine().map!(line => line.split(",").map!(to!double).chunks(2).cycle))
    {
        double[4] cs;
        foreach(i, ref c; cs)
        {
            c = cross(input[i], input[i + 1], input[i + 2]);
        }
        if(cs[0] > 0 && cs[1] > 0 && cs[2] > 0 && cs[3] > 0 || cs[0] < 0 && cs[1] < 0 && cs[2] < 0 && cs[3] < 0)
        {
            "YES".writeln;
        }
        else
        {
            "NO".writeln;
        }
    }
}

Measured memory_bytes: 1104
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 6e5 + 5;
int t;

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

	string q = t.substr(0, t.size() - 1);

	if (s == q)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}


	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
	char buf[110],stack[110]={0},*sp,*p;
	while(fgets(buf,103, stdin),*buf!='.'){
		sp=stack+1;
		p=buf;
		for(;*p!='.';p++){
			if(*p == '(' || *p == '['){
				*sp++ = *p;
			}else if(*p == ')' || *p == ']'){
				sp--;
				if(!((*sp =='(' && *p == ')') || (*sp =='[' && *p == ']'))){
					puts("no");
					break;
				}
			}
		}
		if(*p=='.')puts(sp==stack+1?"yes":"no");
	}
}

Measured memory_bytes: 0
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let (n, mut m) = read_two::<usize>();
    let mut v: Vec<Vec<i64>> = Vec::new();
    for _i in 0..n {
        let vv: Vec<i64> = read_vec();
        v.push(vv);
    }
    let mut ans: i64 = 0;
    v.sort_by(|x, y| x[0].cmp(&y[0]));
    v.reverse();
    while m != 0 {
        let vv = v.pop().unwrap();
        if m < vv[1] as usize {
            ans += m as i64 * vv[0];
            m = 0;
        } else {
            ans += vv[0] * vv[1];
            m -= vv[1] as usize;
        }
    }
    println!("{}", ans);
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	ll a,b,m;
	cin>>a>>b>>m;
	vll A(a),B(b);
	for(int i=0;i<a;i++)
		cin>>A[i];
	for(int i=0;i<b;i++)
		cin>>B[i];
	ll ans = 1e18;
	for(int i=0;i<m;i++) {
		ll x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		ans=min(ans,A[x]+B[y]-z);
	}
	cout<<min(ans,*min_element(all(A))+*min_element(all(B)));
		

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	string s1,s2,s3,s4;
	rep(i,0,x2-x1)s1.push_back('R');
	rep(i,0,y2-y1)s1.push_back('U');
	rep(i,0,s1.size())
	{
		if(s1[i]=='U')s2+="D";
		else
		s2+="L";
	}
	s3+="D";
	rep(i,0,x2-x1+1)s3+="R";
	rep(i,0,y2-y1+1)s3+="U";
	s3+="L";
	s4+="U";
	rep(i,0,x2-x1+1)s4+="L";
	rep(i,0,y2-y1+1)s4+="D";
	s4+="R";
	cout<<s1+s2+s3+s4<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    int cnt = 0;
    for (int m = 2; m <= n; m++)
    {
      int a = (2 * n - m * m + m), b = 2 * m;
      if (a % b == 0 && a / b > 0)
      {
        cnt++;
        lout << m << endl;
      }
    }

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



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(N+1);
	ll cnt=0;
	rep1(i,N){
		ll tmp; cin>>tmp;
		if(i!=tmp) cnt++;
	}
	if(cnt==0 || cnt==2) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
    return res;
}

signed main()
{
    
    speed
    int a,b;cin>>a>>b;
    int f=0;
    for(int i=10*b;i<10*(b+1);i++){
        if((i*8/100)==a){
            cout<<i<<endl;
            f=1;
            break;
        }
    }
    if(!f)cout<<-1<<endl;

    
    
    
    return 0;
}

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

int zh(string x)
{
	int s=0;
	for (int i=0; i<x.size(); i++)
		s=s*10+(x[i]-'0');
	return s;
}

int main()
{
	string a,b;
	cin>>a>>b;
	int x=zh(a+b);
	if (int(sqrt(x))==sqrt(x))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
} 

Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = [int(e) for e in input().split(' ')]
a = Counter(v[0::2]).most_common()+[(0,0)]
b = Counter(v[1::2]).most_common()+[(0,0)]
if a[0][0] != b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(n-max(a[1][1]+b[0][1],a[0][1]+b[1][1]))



Measured memory_bytes: 20572
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let B: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    struct UnionFindTree {
        parent: Vec<usize>,
        size: Vec<i64>,
    }

    impl UnionFindTree {
        fn new(n: usize) -> UnionFindTree {
            UnionFindTree {
                parent: (0..(n + 1)).collect(),
                size: vec![1; n + 1],
            }
        }
        fn find(&mut self, x: usize) -> usize {
            if self.parent[x] != x {
                let parent_x = self.parent[x];
                self.parent[x] = self.find(parent_x);
            }
            self.parent[x]
        }
        fn same(&mut self, x: usize, y: usize) -> bool {
            self.find(x) == self.find(y)
        }
        fn size(&mut self, x: usize) -> i64 {
            let i = self.find(x);
            self.size[i]
        }
        fn union(&mut self, x: usize, y: usize) {
            let parent_x = self.find(x);
            let parent_y = self.find(y);
            if !self.same(x, y) {
                if self.size[parent_x] < self.size[parent_y] {
                    self.size[parent_y] += self.size[parent_x];
                    self.parent[parent_x] = parent_y;
                } else {
                    self.size[parent_x] += self.size[parent_y];
                    self.parent[parent_y] = parent_x;
                }
            }
        }
    }

    fn bis<P: Fn(i64) -> bool>(ok: i64, ng: i64, p: P) -> i64 {
        let mid = (ok + ng) / 2;
        if (ok - ng).abs() == 1 {
            ok
        } else if p(mid) {
            bis(mid, ng, p)
        } else {
            bis(ok, mid, p)
        }
    }

    let X = {
        let mut X = A.clone();
        X.sort();
        X
    };
    let Y = {
        let mut Y = (0..N).map(|i| (B[i], i)).collect::<Vec<_>>();
        Y.sort();
        Y
    };
    let P = A
        .iter()
        .map(|&a| Y[bis((N - 1) as i64, -1, |i| Y[i as usize].0 >= a) as usize].1)
        .collect::<Vec<_>>();
    let mut uft = UnionFindTree::new(N);
    for i in 0..N {
        uft.union(i, P[i]);
    }
    let ans = if (0..N).all(|i| X[i] <= Y[i].0)
        && (P.iter().collect::<std::collections::HashSet<_>>().len() < N || uft.size(0) < N as i64)
    {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 18168
a, b = map(int, input().split())
A = []
B = []
for i in range(a):
    A.append(b)
A = map(str, A)
A = ''.join(A)
for i in range(b):
    B.append(a)
B = map(str, B)
B = ''.join(B)
if len(A)==len(B):
    print(A)
else:
    if A[0]<B[0]:
        print(A)
    else:
        print(B)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, L, R;
vector<int> A(100010, 0);
vector<ll> fact;
vector<ll> invs;

//1!~N!を計算
vector<ll> Factorial(){
    vector<ll> v{1}; //0!
    ll f = 1;
    for(ll i = 1; i <= N + 1; ++i){
        f *= i;
        f %= MOD;
        v.push_back(f);
    }
    return v;
}

//a^bを計算
ll Pow(ll a,ll b){
    ll res = 1;
    while(b){
        if(b % 2) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

//1!~N!の逆数の計算
vector<ll> Reciprocal(){
    ll inv = Pow(fact[N + 1], MOD - 2);
    vector<ll> v(N + 2, 1);
    v[N + 1] = inv;
    for(ll i = N + 1; i > 1; --i){
        inv *= i;
        inv %= MOD;
        v[i - 1] = inv;
    }
    return v;
}

//組合せの計算
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return (fact[n] * invs[r] % MOD) * invs[n - r] % MOD;
}

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N + 1; ++i) scanf("%d", &A[i]);
	
	vector<int> v(100010, -1);
	for(int i = 0; i < N + 1; ++i){
	    if(v[A[i]] >= 0){
	        L = v[A[i]];
	        R = i;
	        break;
	    }
	    v[A[i]] = i;
	}
	
	fact = Factorial();
    invs = Reciprocal();
    
    for(int r = 1; r <= N + 1; ++r){
        ll ans = nCr(N + 1, r);
        ll sub = nCr(L + N - R, r - 1);
        if(ans - sub < 0) ans += MOD;
        printf("%lld\n", ans - sub);
    }
    
    return 0;
}


Measured memory_bytes: 3700
n,q=list(map(int, input().split()))
s=input()

t=[0]*n

s=s.replace("AC", "Ac")
#s=s.translate(str.maketrans({'AC':'aC'})) maketransは置換元一文字じゃないといけんみたい
for i in range(n):
  if s[i] == "c":
    if i !=0:
      t[i]=1+t[i-1]
    else:
      t[i]=1
  else:
    t[i]=t[i-1]

#print(t)
for _ in range(q):
  l,r=list(map(int, input().split()))
  print(t[r-1]-t[l-1])

Measured memory_bytes: 6084
#include<stdio.h>
int main(void)
{
  int a;       //入力された数
  int i,j,k=0; //カウンタ
  int sum;

  while(1){
    scanf("%d",&a);
    if(a==0)break;
    i=1;

    for(i=1;i<a;i++){
      j=i+1;
      sum=i;
      while(1){

	sum= sum+j;
	/* /\* //	printf("%d\n",sum); *\/ */
        if(sum==a){
	   k++; 
	   //printf("%d\n",i);
	  break;
	}
	if(sum>a)break;
	j++;
      }
    }
    printf("%d\n",k); 
    k=0;
  }
  return 0;
}

Measured memory_bytes: 600
#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<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--)
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;
}
int main(){
    ll n;cin>>n;
    vector<double> t(n),v(n);
    double sum[n+1];
  sum[0]=0;
  
    rep(i,0,n){
        cin>>t[i];
        sum[i+1]=sum[i]+t[i];
    }
    rep(i,0,n)cin>>v[i];
  v.insert(v.begin(),0);
    vector<pair<double,int>> w;
  double mi[80001];
  fill(mi,mi+80001,1000000000);
  rep(i,0,sum[n]*2+1){
    mi[i]=i/2.0;
  }
  rrep(i,sum[n]*2,0){
    double r=(sum[n]*2-i)/2.0;
    if(mi[i]>r){
      mi[i]=r;
    }
    else break;
  }
    rep(i,1,n+1){
      w.push_back(make_pair(v[i],i));
    }
  sort(w.begin(),w.end());
  rep(i,0,n){
    double now=w[i].first;int num=w[i].second;
    double ta=sum[num]-t[num-1];
    double tb=sum[num];
    rep(j,2*ta+1,2*tb)mi[j]=min(mi[j],v[num]);
    rrep(j,2*ta,0){
      double r=v[num]+(2*ta-j)/2.0;
      if(mi[j]>r)mi[j]=r;
      else break;
    }
    rep(j,2*tb,sum[n]*2+1){
      double r=v[num]+(j-2*tb)/2.0;
      if(mi[j]>r)mi[j]=r;
      else break;
    }
  }
  double ans=0;
  rep(i,0,sum[n]*2){
    ans+=0.25*(mi[i]+mi[i+1]);
  }
  cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 896