akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  ll N, M; std::cin >> N >> M;

  std::set<ll, std::greater<>> divisor;
  for(int i=1; i<=std::ceil(std::sqrt(M)); i++){
    if ( M % i == 0 ) {
      divisor.insert(i);
      divisor.insert(M/i);
    }
  }

  for(auto& k : divisor) {
    if ( M/k >= N ) {
      std::cout << k << std::endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;
int NextInt() { int x; cin >> x; return x; }
#define sort(X) sort(X.begin(),X.end())

int N, K;

int main()
{
	cin >> N >> K;
	vector<int> V(N);
	for (int i = 0; i < N; i++)V[i] = NextInt();
	vector<int> reV(N);
	for (int i = 0; i < N; i++)reV[i] = V[N - i - 1];
	int ans = 0;
	for (int a = 0; a <= N; a++)
		for (int b = 0; b <= N; b++) {
			int out_cost = K - (a + b);
			if (a + b > N || out_cost < 0)break;
			vector<int> sum(100);
			for (int i = 0; i < a; i++) sum.push_back(V[i]);
			for (int i = 0; i < b; i++) sum.push_back(reV[i]);
			sort(sum);
			int minus = 0;
			for (int i = 0; i < out_cost; i++)minus += sum[i];
			//cout << a << " " << b << " : " << sum << endl;
			ans = max(ans, accumulate(sum.begin(), sum.end(), 0) - minus);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int z;
	while(cin>>z,z){
		int mnum=0;
		for(int x=1;;x++){
			for(int y=1;;y++){
				if(x*x*x+y*y*y>z*z*z)break;
				mnum=max(mnum,x*x*x+y*y*y);
			}
			if(x*x*x>z*z*z)break;
		}
		cout<<z*z*z-mnum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

bool comp(const tuple<int, int> &t1, const tuple<int, int> &t2)
{
  return get<1>(t1) < get<1>(t2);
}

int main()
{
  int n;
  vector<tuple<int, int> > a;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int a1;
    cin >> a1;
    a.push_back(make_tuple(i+1, a1));
  }

  sort(a.begin(), a.end(), comp);

  for (int i = 0; i < n; i++) {
    cout << get<0>(a[i]) << ' ';
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 1780
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

ll n,x;
ll l[51],p[51];

ll res(ll a,ll b){
    if(b==0) return 0;
    if(a==0) return 1;
    ll ans=0;
    if(b<=l[a-1]+1){
        ans=res(a-1,b-1);
    }
    else if(b==l[a-1]+2){
        ans=(p[a-1]+1);
    }
    else{
        ans=(p[a-1]+res(a-1,b-2-l[a-1])+1);
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>x;
    l[0]=1,p[0]=1;
    rep(i,n){
        l[i+1]=l[i]*2+3;
        p[i+1]=p[i]*2+1;
    }
    cout <<res(n,x)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

int main(void)
{
    int dices_count, selection;
    vector<double> expects;

    cin >> dices_count >> selection;

    for(int i = 0; i < dices_count; i++){
        int surface;
        cin >> surface;

        expects.push_back(double(surface + 1) / 2);
    }

    double current_exp_sum = 0;
    // initial sum
    for(int i = 0; i < selection; i++){
        current_exp_sum += expects[i];
    }

    double max_exp_sum = current_exp_sum;

    for(int i = selection; i < dices_count; i++){
        current_exp_sum += expects[i];
        current_exp_sum -= expects[i - selection];

        if(max_exp_sum < current_exp_sum){
            max_exp_sum = current_exp_sum;
        }
    }

    cout << setprecision(10) << max_exp_sum << endl;

    return 0;
}

Measured memory_bytes: 2420
class OfficialHouse:
    def __init__(self):
        self.room = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
    def inout(self, b, f, r, v):
        self.room[b-1][f-1][r-1] += v
    def output(self):
        for i in range(4):
            for j in range(3):
                s = ""
                for k in range(10):
                    s += " %d" % (self.room[i][j][k])
                print s
            if i != 3:
                print "####################"

if __name__ == "__main__":
    oh = OfficialHouse()

    n = int(raw_input())
    for i in range(n):
        b, f, r, v = map(int, raw_input().split())
        oh.inout(b,f,r,v)
    oh.output()

Measured memory_bytes: 6416
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main() {
	int N=0, K=0;
	cin >> N >> K;

	double P = 0;
	
	double Pdice = (double)1 / N;
	for (int ii = 1; ii <= N; ii++) {
		if (ii >= K) {
			P += Pdice;
			continue;
		}

		double cnt = (double)log((double)K / ii) / log(2);

		double cnt_tmp = (double)(int)cnt;
		if (cnt > cnt_tmp) cnt_tmp = cnt_tmp + 1.0;

		int cnt_int = (int)cnt_tmp;

		P += Pdice*pow(((double)1 / 2), cnt_int);
	}

	cout << setprecision(12) << P << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<double, ll> P;
struct edge { ll to, cost; };
ll inf = 1e18;

ll xs, ys, xt, yt, n, x[1010], y[1010], r[1010];

vector<P> G[100010];
double d[100010];

void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + n, inf);
    d[s] = 0;
    que.push(P(0, s));
    
    while (!que.empty()) {
        P p = que.top();  que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            P e = G[v][i];
            if (d[e.second] > d[v] + e.first) {
                d[e.second] = d[v] + e.first;
                que.push(P(d[e.second], e.second));
            }
        }
    }
}

double expose(int p, int q) {
    return max(0.0, sqrt(pow(x[p] - x[q], 2) + pow(y[p] - y[q], 2)) - r[p] - r[q]);
}

int main() {
    cin >> xs >> ys >> xt >> yt;
    cin >> n;
    x[n] = xs;  y[n] = ys;  r[n] = 0;
    x[n + 1] = xt;  y[n + 1] = yt;  r[n + 1] = 0;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];

    n += 2;
    //vector<pair<int, double> > G[1010];
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            G[i].emplace_back(expose(i, j), j);
            G[j].emplace_back(expose(i, j), i);
            //cout << i << " " << j << " " << expose(i, j) << endl;
        }
    }


    dijkstra(n - 2);
    cout << setprecision(12) << d[n - 1] << endl;

    //for (int i = 0; i < n; i++) cout << i << " " << d[i]  << endl;

}

/* 
g++ -std=c++14 _main.cpp
*/

Measured memory_bytes: 25108
#include <iostream>

using namespace std;

int main() {
    char vhod[6];
  	cin >> vhod;
  	if(vhod[2]==vhod[3] && vhod[4]==vhod[5]){
 		cout << "Yes";
  	}
    else
      cout << "No" << endl;
  
     
    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  if(A%3==0 || B%3==0 || (A+B)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
s = input()
n = len(s)
ans = 0
f = 0
b = -1
while True:
    if f - b > n - 1:
        break
    if s[f] != s[b]:
        if "x" in (s[f], s[b]):
            ans += 1
            f += "x" == s[f]
            b -= "x" == s[b]
        else:
            ans = -1
            break
    else:
        f += 1
        b -= 1
print(ans)


Measured memory_bytes: 9184
import numpy as np
s = input()
n = len(s)
ans = 0
for i in range(n // 2 + 1):
	if 2 * i == n:
		break
	if s[2 * i] == "0":
		ans += 1
	if 2 * i + 1 == n:
		break
	if s[2 * i + 1] == "1":
		ans += 1
print(min(ans, n - ans))

Measured memory_bytes: 13216
from bisect import bisect_left, bisect_right
from itertools import combinations

n = int(input())
l = sorted(map(int, input().split()))
ans = 0

for l1, l2 in combinations(enumerate(l[:-1]), 2):
    (i1, a), (i2, b) = l1, l2
    i3s = bisect_right(l, b - a, i2 + 1)
    i3e = bisect_left(l, a + b, i3s)
    ans += i3e - i3s

print(ans)


Measured memory_bytes: 45404
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
if len(s) < len(t):
    if s <= t[:len(s)]:
        print("Yes")
    else:
        print("No")
else:
    if s < t:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
/*
* @author:  codancer
* @createTime:  2020-08-29, 22:41:12
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
#define deb(x) cerr<<#x<<" = "<<(x)<<"\n"
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll Rand(ll B) {
	return (ull)rng() % B;
}
int main(){
	ll D,S,T;
	cin>>D>>S>>T;
	cout<<(S*T>=D?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3588
let s = read_line ()
let t = read_line ()
let s' = ref s
let n = String.length s
let _ = for i = 1 to n do if !s' = t then (print_endline "Yes"; exit 0); s' := String.make 1 !s'.[n - 1] ^ String.sub !s' 0 (n - 1) done;
  print_endline "No"

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int n;
bool g[50][50];
bool visited[50];

void dfs(int v) {
    visited[v] = true;
    rep (i, n) {
        if (g[v][i] == false) continue;
        if (visited[i] == true) continue;
        dfs(i);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    int ans = 0;
    vector<int> a(m), b(m);
    rep (i, n) {
        rep (j, n) {
            g[i][j] = false;
        }
    }
    rep (i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }
    rep (i, m) {
        g[a[i]][b[i]] = g[b[i]][a[i]] = false;
        rep (j, n) visited[j] = false;
        dfs(0);
        bool bridge = false;
        rep (j, n) {
            if (visited[j] == false) bridge = true;
        }
        if (bridge) ans++; 
        g[a[i]][b[i]] = g[b[i]][a[i]] = true;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    ll n,m;cin>>n>>m;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll sm=0;rep(i,0,n-1)sm+=a[i];
    ll c=0;
    rep(i,0,n-1){
        if(4*m*a[i]>=sm)c++;
    }
    if(c>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 256
n=gets.to_i
x=Array.new(4){Array.new(3){Array.new(10){0}}}
while line=gets
  (b,f,r,v)=line.split().map(&:to_i)
  x[b-1][f-1][r-1] += v
end
x.each_with_index do |bb,i|
  bb.each do |ff|
    puts " "+ff.join(" ")
  end
  puts "####################" if i != 3
end

Measured memory_bytes: 6112
using System;

namespace _0008
{
    class Program
    {
        static void Main(string[] args)
        {
            const int MAX_NUMBER = 9;
            while (true)
            {
                var input = Console.ReadLine();

                if (string.IsNullOrEmpty(input)) { break; }

                var number = int.Parse(input);
                var answer = 0;

                for (int first = 0; first<= MAX_NUMBER; first++)
                {
                    for (int second = 0; second <= MAX_NUMBER; second++)
                    {
                        for (int third = 0; third <= MAX_NUMBER; third++)
                        {
                            for (int fouth = 0; fouth <= MAX_NUMBER; fouth++)
                            {
                                int sum = first+second+third+fouth;
                                if (sum == number)
                                {
                                    answer++;
                                }
                            }
                        }
                    }
                }
                Console.Write(answer.ToString()+"\n");
            }
        }
    }
}

Measured memory_bytes: 5588
import sys
sys.setrecursionlimit(2*10**5)
N = int(input())
A = [int(input()) for _ in range(N-1)]
if len(set(A)) == N - 1:
    print(N - 1)
    sys.exit()
H = [[] for _ in range(N+1)]
for i, a in enumerate(A, 2):
    H[a].append(i)

def depth(x):
    if not H[x]:
        return 0
    k = len(H[x])
    return max([k - i + j for i, j in zip(range(k), sorted([depth(x) for x in H[x]]))])

print(depth(1))


Measured memory_bytes: 193140
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
			System.out.println("Possible");
		else
			System.out.println("Impossible");
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri, 2) {
    {
      int cnt = 0;
      rep(i, n) {
        if (s[i] == 'R') cnt++;
        else {
          ans[i] += cnt/2;
          ans[i-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i, n) {
      if(s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }   
  }
  rep(i, n) {
    cout << ans[i] << " ";
  } 
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y,i;
main(){cin>>n>>k;r=n-1;
for(i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
while(k){x=a[l]*a[l+1],y=a[r]*a[r-1];
if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
else ans*=y%M,ans%=M,r-=2;
k-=2;}cout<<(ans+M)%M<<endl;
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a == b && a != c) cout<<"Yes"<<endl;
  else if(b == c && b  != a) cout<<"Yes"<<endl;
  else if(a == c && b != c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

#define MOD 998244353
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec L(K), R(K);
  rep(i, K){
    cin >> L[i] >> R[i];
  }
  llvec dp(N, 0);
  llvec a(N, 0);
  dp[0]=1;
  rep(i, N){
    if(i>0)a[i]=mod(a[i]+a[i-1],MOD);
    dp[i]=mod(dp[i]+a[i],MOD);
    rep(j, K){
      if(L[j]+i<N)a[i+L[j]]=mod(a[i+L[j]]+dp[i],MOD);
      if(i+R[j]+1<N)a[i+R[j]+1]=mod(a[i+R[j]+1]-dp[i],MOD);
    }
  }
  cout << dp[N-1];
  return 0;
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
    double p[6], q[6];
    for(int i = 0; i< 6; i++) cin >> p[i], p[i] /= 100;
    for(int i = 0; i< 6; i++) cin >> q[i], q[i] /= 100;
    double lo = 0, hi = 1;
    function<double(double)> compute = [&](double x){
        double ret = 0;
        for(int i = 0; i < 6; i++) ret += max(p[i] * x, q[i] * (1 - x));
        return ret;
    };
    while(abs(hi - lo) > 1e-14){
        double mid1 = (2 * lo + hi) / 3.;
        double mid2 = (lo + 2 * hi) / 3.;
        if(compute(mid1) < compute(mid2)){
            hi = mid2;
        } else lo = mid1;
    }
    printf("%.10lf\n", compute(lo));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
int n, a[M], bit[M];

void update(int i)
{
	for(; i < M; i |= (i + 1))
		bit[i]++;
}

int query(int i)
{
	int sum = 0;
	for(; i > 0; i = (i & (i + 1)) - 1)
		sum += bit[i];
	return sum;
}


int32_t main() 
{
    	ios_base::sync_with_stdio(0);   cin.tie(0);     cout.tie(0);
    	cin >> n;
    	int ans = 0;
    	for(int i = 1; i <= n; i++)	
    	{
    		cin >> a[i];
    		update(a[i]);
    		if(query(M) - query(a[i] - 1) == i)
    			ans++;
    	}
    	cout << ans;
    	return 0;
}

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

signed main(void)
{
	int n, d, cnt;
	cin >> n >> d;
	ll x[n], y[n];
	rep(i, n) cin >> x[i] >> y[i];
	cnt = 0;
	rep(i, n)
	{
		if ((ll)d * d >= x[i] * x[i] + y[i] * y[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	int n;cin >> n;
	for(int i  = 0 ; i<n;i++)
	{
		char c;
		cin >> c;
		if(c=='Y')
		{cout<<"Four"<<endl;return 0;}
	}
	cout<<"Three"<<endl;
	return 0;
}

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

#define MAX_N 110
#define MAX_V 100100

#define INF (1<<30)


int dp[MAX_N][MAX_V];	//[数][価値]  重量

int weight[100], value[100];

int main(){
	for(int i=0;i<MAX_N;i++){
		for(int j=0;j<MAX_V;j++) dp[i][j]=INF;
	}
	int n,w;	cin>>n>>w;
	for(int i=0;i<n;i++)cin>>weight[i]>>value[i];

	dp[0][0]=0;

	for(int i=0;i<=n;i++){
		for(int sumV=0;sumV<=100100;sumV++){
			if(sumV-value[i]>=0){
				dp[i+1][sumV]=min(dp[i+1][sumV], dp[i][sumV-value[i]] + weight[i]);
			}

			dp[i+1][sumV]=min(dp[i+1][sumV], dp[i][sumV]);
		}
	}

	//for(int i=0;i<=n;i++){
	//	for(int j=0;j<=150;j++){
	//		printf("%3d ",dp[i][j]);
	//	}
	//	cout<<endl;
	//}

	int ans=0;
	for(int sumV=0; sumV<MAX_V; sumV++){
		if(dp[n][sumV]<=w) ans=sumV;
	}

	cout<<ans<<endl;




	return 0;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int a,b;
	cin >> a >> b;
	P((a+b)%24);
}

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


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
count = 1
for i in range(min(a)-1, max(a)+1):
    count = max(count, b.get(i-1,0)+b.get(i, 0)+b.get(i+1, 0))
print(count)


Measured memory_bytes: 14556
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */
 
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 998244353 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
set<ll> st;
int main(){
	ll n = read();
	ll x = n;
	if(n == 2) {
		cout<<1;
		return 0;
	} 
	st.insert(n);
	for(ll i = 2;i <= sqrt(x+1);++i){
		if(x%i==0){
			ll k = x;
			while(!(k%i)) k/=i;
			if(k==1||k%i==1) st.insert(i);
			if(x/i!=i){
				k = x;
				while(!(k%(x/i))) k/=(x/i);
				if(k == 1||k%(x/i)==1) st.insert(x/i);
			}
		}
	}
	
	n --; 
	st.insert(n);	
	for(ll i = 2;i<=sqrt(n+1);++i){
		if(n%i==0){
			st.insert(i);
			if(i!=n/i) st.insert(n/i);
		}
	}
	cout<<st.size();
} 

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

int main() {
    map<int, P> m;
    rep(i, 3) {
        rep(j, 3) {
            int k;
            cin >> k;
            m[k] = make_pair(i, j);
        }
    }
    int n;
    cin >> n;
    vector<vector<bool>> bingo(3, vector<bool>(3, false));
    rep(i, n) {
        int j;
        cin >> j;
        if(m.count(j)) {
            P col = m.at(j);
            bingo.at(col.first).at(col.second) = true;
        }
    }

    rep(i, 3) {
        bool h = true;
        bool v = true;
        rep(j, 3) {
            h = h & bingo.at(i).at(j);
            v = v & bingo.at(j).at(i);
        }
        if(h || v) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    bool up = true;
    bool down = true;
    rep(i, 3) {
        up = up && bingo.at(i).at(i);
        down = down && bingo.at(2-i).at(i);
    }
    if(up || down) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
//C - Sentou: 
//Assunto: 
#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()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, t, ans = 0, last;
    cin >> n >> t;
    vector<int> time(n);
    loop(i, 0, n) cin >> time[i];
    last = time[0] + t;
    loop(i, 1, n) {
        if(time[i] < last) ans += time[i] - time[i-1];
        else ans += t;
        last = time[i] + t;
    }
    ans += t;
    cout << ans << "\n";
}

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

using namespace std;

const int N = 3e3 + 3;
double dp[N];

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

	dp[0] = 1;
	double p;
	for(int i = 1; i <= n; i++){
		cin >> p;
		for(int j = i; j >= 0; j--)
			dp[j] = (j == 0 ? 0 : dp[j - 1] * p) + dp[j] * (1 - p);
	}

	double ans = 0;
	for(int i = 0; i <= n; i++)
		if(i > n - i)
			ans += dp[i];

	cout << fixed << setprecision(10);	
	cout << ans << "\n";
}

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




int main()
{
	int i,j,k;
	int n,m;
	int sum;
	int winner;
	int p;

	while(1)
	{
		scanf("%d %d %d",&n,&m,&p);
		if((n==0)&&(m==0)&&(p==0)){break;}
		else
		{
			sum=0;
			winner=0;
			for(i=0;i<n;i++)
			{
				int x;
				scanf("%d",&x);
				sum+=x;
				if((i+1)==m){winner=x;}
			}
		}
		if(winner==0){printf("0\n");}else{
			printf("%d\n",(sum*(100-p)/winner));}
	}
	return 0;
}
	

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e15;
const int LG = 21;

int arr[N];

struct DSU
{
	int connected;
	vector<int> par, sz;

	void init(int n) 
	{
		par = sz = vector<int> (n + 1, 0);
		for(int i = 1; i <= n; i++)
			par[i] = i, sz[i] = 1;
		connected = n;
	}

	int getPar(int u)
	{
		while(u != par[u])
		{
			par[u] = par[par[u]];
			u = par[u];
		}
		return u;
	}

	int getSize(int u)
	{
		return sz[getPar(u)];
	}

	void unite(int u, int v)
	{
		int par1 = getPar(u), par2 = getPar(v);

		if(par1 == par2)
			return;

		connected--;

		if(sz[par1] > sz[par2])
			swap(par1, par2);

		sz[par2] += sz[par1];
		sz[par1] = 0;
		par[par1] = par[par2];
	}
};

void solve()
{
	int n, m;
	cin >> n >> m;
	int ret = 0;
	DSU D;
	D.init(n);
	for(int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		D.unite(a, b);
	}
	for(int i = 1; i <= n; i++) ret = max(ret, D.getSize(i));
	cout << ret << endl;
}

 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = map(int, input().split())

prev = -1
cnt = 0
ans = 0
for a in As:
    if a == prev:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
    prev = a
ans += cnt // 2
print(ans)



Measured memory_bytes: 7880
#include <iostream>
#include <cmath>
#include <iomanip>

const double RAD = std::acos(-1) / 180.0;

int main(int argc, const char **argv)
{
	double sb = 0, lb = 0, hour = 0, min = 0;
  
  	std::cin >> sb >> lb >> hour >> min;
  	
  	double deg = 30 * (hour - min * 11 / 60.0);
  	double dist = sb * sb + lb * lb - 2 * sb * lb * cos( deg * RAD );
  	std::cout << std::fixed << std::setprecision(20) << std::sqrt(dist) << std::endl;

  	return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
long long a[200001],b[200001];
int main()
{
	long long x,y,z;
	int	n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%lld",&a[i]);
	b[0]=0;
	for(i=1;i<=n;i++){
		z=b[i-1]+a[i-1];
		b[i]=z%1000000007;
	}
	// for(i=0;i<=n;i++) printf("%lld.",b[i]);
	x=0;y=0;
	for(i=1;i<=n-1;i++){
		x=b[i]*a[i];
		x=x%1000000007;
		y=y+x;
		y=y%1000000007;
	}
	printf("%lld\n",y);
	return 0;
}

Measured memory_bytes: 4860
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
//    var pre = 2
//    var aaaaaa = 0
////    out.println("1:" +pre)
//    out.println(pre)
//    for (i in 1..12) {
//        aaaaaa += pre
//        val tmp = pre * pre % 1001
//
//
//        out.println("${i}:" + aaaaaa)
//        out.println(tmp)
//        pre = tmp
//    }
////    out.println(aaaaaa)
//    out.println()

    val (n, x, m) = readLongList()

    val indexMap = mutableMapOf<Long, Int>()
    var cur = x
    var curIndex = 0
    while (indexMap.containsKey(cur) == false) {
        indexMap[cur] = curIndex
        curIndex++
        cur = (cur % m) * (cur % m) % m
    }

    val loopFrom = indexMap[cur]!!

//    val ans = if (n <= loopFrom) {
//        var ans = 0L
//        var pre = x
//        repeat(n.toInt()) {
//            ans += pre
//            pre = (pre % m) * (pre % m) % m
//        }
//        ans
//    } else {
//        val firstSum = indexMap.filter { it.value < loopFrom }.keys.sum()
//        val loopSum = indexMap.filter { it.value >= loopFrom }.keys.sum()
//        val loopCount = indexMap.count() - loopFrom
//
//        var ans = firstSum
//
//        val remain = max(0, n - loopFrom)
//        val aaa = remain / loopCount
//        val modRemain = remain % loopCount
//
//        ans += aaa * loopSum
//
//        var pre = cur
//        repeat(modRemain.toInt()) {
//            ans += pre
//            pre = (pre%m) * (pre%m) % m
//        }
//        ans
//    }

    val firstSum = indexMap.filter { it.value < loopFrom }.keys.sum()
    val loopSum = indexMap.filter { it.value >= loopFrom }.keys.sum()
    val loopCount = indexMap.count() - loopFrom

    val remain = max(0, n - loopFrom)
    val aaa = remain / loopCount
    val modRemain = remain % loopCount

    var ans = if (n <= loopFrom) 0 else firstSum + aaa * loopSum
    var pre = if (n <= loopFrom) x else cur
    val bbb = if (n <= loopFrom) n.toInt() else modRemain.toInt()
    repeat(bbb) {
        ans += pre
        pre = (pre%m) * (pre%m) % m
    }

    out.println(ans)
    return
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 47908
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;
long long w[1010],s[1010],v[1010],dp[1010][20010] = {},ans = 0;
pair<pair<int,int>,int> p[1010];
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> w[i] >> s[i] >> v[i];
		p[i] = {{w[i]+s[i],-v[i]},i};
	}
	sort(p,p+n);
	for(i=1;i<=n;i++){
		int x = p[i-1].second;
		for(j=0;j<=20000;j++){
			dp[i][j] = max(dp[i][j],dp[i-1][j]);
			if(j>s[x] || w[x]+j>20000) continue;
			dp[i][w[x]+j] = max(dp[i][w[x]+j],dp[i-1][j] + v[x]);
		}
	}
	for(i=0;i<=20000;i++){
		ans = max(ans,dp[n][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 157952
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (n, r) = readIntList()
    val res = if (n < 10) {
        r + 100 * (10 - n)
    } else {
        r
    }
    println(res)
}

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

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

  vector<int> a(n);
  int sum1 = 0, sum2 = 0, f, c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum1 += a[i];
  }

  f = floor(sum1 / (double)n);
  c = ceil(sum1 / (double)n);

  sum1 = sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum1 += pow(a[i] - f, 2);
    sum2 += pow(a[i] - c, 2);
  }

  cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 256
n , k = map(int,input().split(' '))

x = [list(map(int,input().split(' '))) for i in range(n)]

y = []
ans = 0
for i in range(k):
    b = int(input())
    y.append(b)

for i in range(n):
    ans = 0
    for v in range(k):
        ans = ans + x[i][v] * y[v]
    print(ans, end='\n')



Measured memory_bytes: 6024
# coding: utf-8
# Your code here!

a={'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}


while True:
    n=int(input())
    if n==0:
        break
    
    else:
        N=list(format(n,"o"))   #8進法
        
    for i in range(len(N)):
        print(a[N[i]],end="")
    print()


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
  i32 n = input();
  auto cnt = make_vector(2, 100001, 0);
  
  range(i, 0, n) {
    cnt[i & 1][input()]++;
  }

  vector< pair<i32, i32> > od, ev;
  range(i, 0, 100001) {
    ev.emplace_back(cnt[0][i], i);
    od.emplace_back(cnt[1][i], i);
  }

  rwhole(sort, ev);
  rwhole(sort, od);

  i32 ans = n;
  if (ev[0].second == od[0].second) {
    ans -= max(ev[0].first + od[1].first, ev[1].first + od[0].first);
  } else {
    ans -= ev[0].first + od[0].first;
  }

  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 3444
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0

for i in range(1, n-1):
    for j in range(i):
        k = bisect.bisect_left(l, l[j]+l[i])
        ans += k - i - 1

print(ans)

Measured memory_bytes: 43944
#include <stdio.h>

int main(int argc, char* argv[]) {

	long x, y;
	int count = 0;
	long m;

	scanf("%ld %ld", &x, &y);

	m = x;
	while(m <= y) {
		m = m * 2;
		count++;
	}

	printf("%d", count);

	return 0;
}

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

int main(void){
  int A,B,K;
  cin>>A>>B>>K;
  int a[101];
  for(int k=0;k<101;k++)a[k]=0;
  if(A>=B){
    for(int i=A;i>=1;i--){
      if(A%i==0&&B%i==0)a[i]=i;
    }
  }
  else{
    for(int t=B;t>=1;t--){
      if(A%t==0&&B%t==0)a[t]=t;
    }
  }
  sort(a,a+101);
  cout<<a[101-K];

}


Measured memory_bytes: 256
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
bob = 0
i = 0
while 2*i + 1 < len(a):
    a[2*i + 1] = -a[2*i + 1]
    i += 1

print(sum(a))

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;

#define rep(i,N) for(int (i)=0; (i)<(N); (i)++)
#define revrep(i,N) for(int (i)=(N)-1; (i)>=0; (i)--)
#define dump(vec) for(int i = 0; i < (vec).size(); i++){cout << vec.at(i) << ",";}cout << endl

typedef long long ll;

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

    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Map <Long,Long> mapX = new HashMap<Long,Long> ();
		Map <Long,Long> mapY = new HashMap<Long,Long> ();
		Map <Long,Long> mapX2 = new TreeMap<Long,Long> ();
		Map <Long,Long> mapY2 = new TreeMap<Long,Long> ();
 
		Scanner sc = new Scanner(System.in);
		String s,s1,s2,result;
		// 整数の入力
			int index1,index2,num;
			s = sc.next();
			sc.close();
			
			result="Yes";
			loop1: for(index1=0;index1<3;index1++) {
				s1=s.substring(index1,index1+1);
				num=0;
				for(index2=0;index2<4;index2++) {
					s2=s.substring(index2,index2+1);
					if(s1.equals(s2)) {
						num=num+1;
						}
					}
				if(num!=2) {
					result="No";
					break loop1;
				}			
			}
			
			System.out.println(result);
			
 
			// 出力
 
	}
}

Measured memory_bytes: 21844
#Python
import sys

S = raw_input()

if len(S)%2==1:
	S=S[0:len(S)-1]

if S[0:len(S)/2]==S[len(S)/2:]:
	S=S[0:len(S)-2]

#print S
cnt=len(S)
while cnt>1:
	#print "cnt:::"+str(cnt)
	S1=S[0:len(S)/2]
	S2=S[len(S)/2:]
	#print S1
	#print S2
	if S1==S2:
		print len(S)
		sys.exit()

	S=S[0:len(S)-2]
	cnt-=2


Measured memory_bytes: 2568
S = input()
T = input()

match_n = 0
for i in range(len(S)):
    match_n_sub = 0
    if i <= len(S)-len(T):
        for j in range(0, len(T)):
            if S[i+j] == T[j]:
                match_n_sub += 1
    match_n = max(match_n, match_n_sub)

print(len(T)-match_n)

Measured memory_bytes: 8904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    string s, t;
    cin >> s >> t;
    s += t.bk;
    cout << (s == t ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll A, B, C;
    ll answer = 0;
    cin >> A >> B >> C;

    ll max_abc = max({A, B, C});
    answer = max_abc * 10 + A + B + C - max_abc;
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256