akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N, W = readi(2)
    vs, ws = zip(*readi(N, 2))
    dp = arr(N + 1, W + 1)
    for i in range(N):
        for j in range(W + 1):
            if j - ws[i] >= 0:
                dp[i + 1][j] = max(
                    dp[i + 1][j], dp[i][j - ws[i]] + vs[i], dp[i + 1][j - ws[i]] + vs[i]
                )
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

    print(dp[N][W])


if __name__ == "__main__":
    main()



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

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

int main() {
    long long int A, B, C, D;
    cin >> A >> B >> C >> D;

    long long int lcm = C * D / gcd(C, D);

    long long int numC = 0;
    long long int numD = 0;
    long long int numLcm = 0;

    if(A == B) {
      if(B % C == 0 || B % A == 0) {
        cout << 0 << endl;
      } else {
        cout << 1 << endl;
      }
    } else {
      numC = B / C - (A-1) / C;
      numD = B / D - (A-1) / D;
      numLcm = B / lcm - (A-1) / lcm;

      cout << B - A + 1 - numC - numD + numLcm << endl;
    }

    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[,,] dp = new int[11, 331, 1 << 10];

            MakeDP(dp);

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int n = int.Parse(temp[0]);
                int s = int.Parse(temp[1]);

                if (s > 330)
                {
                    sb.AppendLine("0");
                    continue;
                }

                int sum = 0;

                for (int i = 0; i < 1 << 10; i++)
                {
                    sum += dp[n, s, i];
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }

        static void MakeDP(int[,,] dp)
        {
            dp[0, 0, 0] = 1;

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 331; j++)
                {
                    for (int k = 0; k < 1 << 10; k++)
                    {
                        if (dp[i, j, k] == 0) continue;

                        for (int l = 0; l < 10; l++)
                        {
                            if ((~k & 1 << l) == 0) continue;

                            dp[i + 1, j + (i + 1) * l, k | 1 << l] += dp[i, j, k];
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 23740
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long int ll;
ll n;

ll solve()
{
	ll m = 0, total = 0;

	for(ll a = 1; a < sqrt(n); a++)
	{
		if(n%a != 0) continue;

		m = n/a-1;
		if(m <= a) continue;
		total += m;
	}
	return total;
}

int main()
{
	scanf("%lld", &n);
	printf("%lld\n", solve());
}

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

#define pb push_back
#define all(a) a.begin(), a.end()
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repl(i, a, n) for (long long i = a; i < n; i++)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vl vector<long long>
#define vvi vector<vector<int>>

#define tcases \
  int t;       \
  cin >> t;    \
  while (t--)

typedef long long ll;

// for debugging output uncomment below line
// #define DBG
//NOTE : COMMNET ABOVE LINE BEFORE SUBMITTING

#ifdef DBG
#define dout \
  if (true)  \
  cout
#define dfor \
  if (true)  \
  rep
#else
#define dout \
  if (false) \
  cout
#define dfor \
  if (false) \
  rep
#endif

using namespace std;

#define MOD 1000000007

void optimizeIO()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//==================================================================================///////////////////
///                  CLASHER
//////////////==========================================================//////////////////////////////
int mx = 0;
int n, m;
int dfs(vector<vector<char>> &ar, int i, int j, vvi &dir)
{
  int narr[n][m];
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      narr[i][j] = 1e9;
    }
  }
  queue<pair<pair<int, int>, int>> q;
  q.push(make_pair(make_pair(i, j), 0));
  while (q.size())
  {
    auto fnt = q.front();
    q.pop();
    int i = fnt.first.first, j = fnt.first.second;
    if (narr[i][j] < 1e9)
      continue;
    narr[i][j] = fnt.second;

    for (int x = 0; x < dir.size(); x++)
    {
      int a, b;
      a = i + dir[x][0];
      b = j + dir[x][1];
      if (a >= 0 && a < n && b >= 0 && b < m && ar[a][b] != '#')
      {
        q.push(make_pair(make_pair(a, b), fnt.second + 1));
      }
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (narr[i][j] != 1e9)
      {
        mx = max(mx, narr[i][j]);
      }
    }
  }
  return mx;
}

int main()
{
  // ifstream cin("input.txt");
  //for optimizing input output
  optimizeIO();
  vvi dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
  cin >> n >> m;
  vector<vector<char>> ar(n, vector<char>(m));

  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++)
    {
      ar[i][j] = s[j];
    }
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if (ar[i][j] == '.')
      {
        dfs(ar, i, j, dir);
      }
    }
  }
  cout << mx;
  return 0;
}


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

bool solve() {
  int N; cin >> N;
  vector<int> a(N), b(N);
  rep(i, 0, N) cin >> a[i];
  rep(i, 0, N) cin >> b[i];
  long long S = 0;
  rep(i, 0, N) S += (b[i] - a[i]);
  if(S < 0) return false;
  long long A = 0, B = 0;
  rep(i, 0, N) {
    if(a[i] < b[i]) {
      A += (b[i] - a[i]) / 2;
    } else {
      B += a[i] - b[i];
    }
  }
  return A >= B;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll res=0;
    const ll mod=1000000007;
    for(ll i=k;i<=n+1;i++)
    {
        ll x=(i*(i-1)/2);
        x%=mod;
        ll y=(n*(n+1)/2)-((n-i)*(n-i+1)/2);
        y%=mod;
        res=(res+(y-x+1))%mod;
    }
    res=(res+mod)%mod;
    printf("%lld\n",res);
    return 0;
}


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

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

using namespace std;

vector<string> split(const string &str, char delim){
  vector<string> res;
  size_t current = 0, found;
  while((found = str.find_first_of(delim, current)) != string::npos){
    res.push_back(string(str, current, found - current));
    current = found + 1;
  }
  res.push_back(string(str, current, str.size() - current));
  return res;
}

int main()
{
	string s;
	vector<string> ans;
	while(cin >> s)
	{
		rep(i,s.size())
		{
			if(s[i] == ',')
			{
				s[i] = '.';
			}
		}
		vector<string> a = split(s,'.');
		rep(j,a.size())
		{
			if(2 < a[j].size() && a[j].size() < 7)
			{
				ans.push_back(a[j]);
			}
		}
	}

	rep(i,ans.size())
	{
		if(i == ans.size()-1)
		{
			cout << ans[i] << endl;
		}
		else
		{
			cout << ans[i] << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 1180
def resolve():
    h, w = map(int, input().split())
    dy = h // 2 if h != 1 else 1
    if h == 1 or w == 1:
        count = 1
    elif h % 2 == 1:
        count = w * dy + (w - (w // 2))
    else:
        count = w * dy

    print(count)


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
in_red = [tuple(map(int, input().split())) for _ in range(N)]
in_blu = [tuple(map(int, input().split())) for _ in range(N)]
in_red = sorted(in_red, key=lambda x: x[1], reverse=True)
in_blu = sorted(in_blu)

# print(in_red)
# print(in_blu)

ans = 0
for ei,x in enumerate(in_blu):
    x,y = x
    # print("x: {}, x,y: {}, {}".format(x,x,y))

    idx = 0
    found = False
    for e,p in enumerate(in_red):
        # print("\tp: {}, {}".format(p[0], p[1]))
        if p[0] < x and p[1] < y:
            idx = e
            found = True
            break
    if found:
        ans += 1
        in_red.pop(idx)
print(ans)


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Verified: AOJ-DSL1A, AGC002D
class UFSet {
 private:
  vector<int> ranks;
  vector<int> prevs;
  vector<int> sizes;

 public:
  UFSet(int n) : ranks(n), prevs(n), sizes(n) {
    for (int i = 0; i < n; i++) prevs[i] = i;
    for (int i = 0; i < n; i++) sizes[i] = 1;
  }

  // Returns an ID of a set which x belongs to.
  int Find(int x) {
    if (x != prevs[x]) prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
      sizes[x_root] += sizes[y_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
      sizes[y_root] += sizes[x_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
      sizes[x_root] += sizes[y_root];
    }
  }

  // Returns a size of a set which x belongs to.
  int Size(int x) {
    return sizes[Find(x)];
  }
};

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

  int n, q;
  cin >> n >> q;
  UFSet uf_set(n);
  for (int q_index = 0; q_index < q; q_index++) {
    int t, v1, v2;
    cin >> t >> v1 >> v2;
    if (t == 0) {
      uf_set.Union(v1, v2);
    } else {
      if (uf_set.Find(v1) == uf_set.Find(v2)) {
        cout << 1 << "\n";
      } else {
        cout << 0 << "\n";
      }
    }
  }
}

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

const ll INF = 1LL << 60;

ll N, K;
string S;
int main() {
    cin >> N >> K >> S;

    // 1 0 1 0 1 と連続している数の配列を作る
    vector<int> nums;

    int num = 1;
    int cnt = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == (char)(num + '0')) {
            cnt++;
        } else {
            // 切り替え
            // 1 -> 0
            // 0 - > 1
            nums.push_back(cnt);
            num = 1 - num; 
            cnt = 1;
        }
    }

    if (cnt != 0) {
        nums.push_back(cnt);
    }

    // 1 の数 0をたす
    if (nums.size() % 2 == 0) nums.push_back(0);

    // rep(i, nums.size()) {
    //     cout << nums[i] << " ";
    // }
    // cout << endl;

    int add = 2 * K + 1;
    int ans = 0;

    // 1. for ループの外側にleft, right を持つ
    int left = 0;
    int right = 0;
    int tmp = 0; // [left, right) の sum

    for (int i = 0; i < nums.size(); i += 2) {
        // 2. 次の left, right を決める
        int next_left = i;
        int next_right = min((int)nums.size(), i + add);

        // 3. 計算する
        while (next_left > left) {
            tmp -= nums[left];
            left++;
        }

        while (next_right > right) {
            tmp += nums[right];
            right++;
        }

        // cout << i << " " << right << endl;
        // for (int j = i; j < right; j++) {
        //     tmp += nums[j];
        // }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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

int main() {
  int n, m;
  cin>>n>>m;
  if (n % 2 == 1) {
    for (int i=1; i<=m; i++) {
      cout<<i<<" "<<n - i<<endl;
    }
    return 0;
  }
  int d = (n - 1) / 2;
  int start = 1;
  int cnt = 0;
  for (int i=d; i>0; i-=2) {
    cout<<start<<" "<<start+i<<endl;
    ++start;
    ++cnt;
    if (m == cnt) {
      return 0;
    }
  }
  start = 1 + d + 1;
  for (int i=d-1; i>0; i-=2) {
    cout<<start<<" "<<start+i<<endl;
    ++start;
    ++cnt;
    if (m == cnt) {
      return 0;
    }
  }
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n;
  cin >> n;

  ll i = 0, ans = 0;

  while (true) {
    i++;
    if (i * i > n) {
      i--;
      break;
    }
  }
  cout << i * i << "\n";
}

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

long long h, m = 1, s = 1;

int main()
{
	cin >> h;

	h /= 2;

	while (h > 0) {
		m *= 2;
		s += m;
		h /= 2;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 3/9/2019, 11:03:51 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

ll A, B;

ll F(ll x)
{
  if (x < 0)
  {
    return 0;
  }
  ll ans = ((x + 1) / 2) % 2;
  if (x % 2 == 0)
  {
    ans ^= x;
  }
  return ans;
}

int main()
{
  cin >> A >> B;
  cout << (F(A - 1) ^ F(B)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  int now=0,i=0,j=0,k=0;
  string sa,sb,sc;
  cin >>sa >> sb >> sc;
  while(true){
    switch(now){
      case 0:
        if(i==sa.size()){
          cout <<"A\n";
          return 0;
        }
        now = sa[i++]-'a';
        break;
      case 1:
        if(j==sb.size()){
          cout <<"B\n";
          return 0;
        }
        now = sb[j++]-'a';
        break;
      case 2:
        if(k==sc.size()){
          cout <<"C\n";
          return 0;
        }
        now = sc[k++]-'a';
        break;
    }
  }
}


Measured memory_bytes: 256
n=int(input())
w=[input()for i in range(n)]
w_set=set(w)
if len(w_set)!=n:
    print("No")
    exit()
for i in range(1,n):
    if w[i-1][-1]!=w[i][0]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
//istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
//ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void){
    int h,w,k;cin>>h>>w>>k;
    mint dp[h+2][w];
    rep(i,h)rep(j,w) dp[i][j]=0;
    dp[0][0]=1;
    rep(i,h)rep(j,w){
        int a=0,b=0,c=0;
        for(int tmp=0;tmp<1<<(w-1);tmp++){
            bitset<8> s(tmp);
            bool jud=false;
            rep(l,w-2)if(s[l]==s[l+1]&&s[l]==1){
                jud=true;
                break;
            }
            if(jud)continue;
            if(s[j-1]==1)a++;
            else if(s[j]==1)c++;
            else b++;
        }
        //cout<<a<<" "<<b<<" "<<c<<endl;
        if(j!=0)dp[i+1][j-1]+=(mint)a*dp[i][j];
        if(j!=7)dp[i+1][j+1]+=(mint)c*dp[i][j];
        dp[i+1][j]+=(mint)b*dp[i][j];
    }
    mint res=dp[h][k-1];
    cout<<res.x<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int k;
  scanf("%d%d",&n,&k);
  int a[n];
  int count=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(k<=a[i])
      count++;
  }
  printf("%d",count);
}
  

Measured memory_bytes: 2064
#include <iostream>
#include <string>
#include <vector>
#include <map>

#include <algorithm>
#include <queue>
#include <cctype>
#include <numeric>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define debugos cerr
#define debug(v) do {debugos << "L" << __LINE__ << " " << #v << " > ";debugos<<(v)<<newl;} while (0)
#define debugv(v) do {debugos << "L" << __LINE__ << " " << #v << " > ";for(auto e:(v)){debugos<<e<<" ";}debugos<<newl;} while (0)
#define debuga(m,w) do {debugos << "L" << __LINE__ << " " << #m << " > ";for(int x=0;x<(w);x++){debugos<<(m)[x]<<" ";}debugos<<newl;} while (0)
#define debugaa(m,h,w) do {debugos << "L" << __LINE__ << " " << #m << " > \n";for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){debugos<<(m)[y][x]<<" ";}debugos<<newl;}} while (0)

int X,Y,ans;

int main() {
    cin >> X >> Y;
    if (X == 3) {
        ans += 100000;
    } else if (X == 2) {
        ans += 200000;
    } else if (X == 1) {
        ans += 300000;
    }
    if (Y == 3) {
        ans += 100000;
    } else if (Y == 2) {
        ans += 200000;
    } else if (Y == 1) {
        ans += 300000;
    }
    if (X == 1 && Y == 1) {
        ans += 400000;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.split( " " ).map { |val| val.to_i }
q = gets.to_i
t = gets.split( " " ).map { |val| val.to_i }
t.sort!

cnt = 0
for i in ( 0 ... q )
	low = 0
	high = n - 1
	while low <= high
		m = ( low+high )/2
		if t[i] < s[m]
			high = m - 1
		elsif s[m] < t[i]
			low = m + 1
		else t[i] == s[m]
			cnt += 1
			break
		end
	end
end

puts( cnt )

Measured memory_bytes: 15564
#include<stdio.h>
int main()
{
  int num,temp,factor=1;
  scanf("%d",&num);
  temp=num;
  while(temp)
    {
      temp=temp/10;
      factor = factor*10;
    }
  int c, f=0;
  while(factor>1)
    {
      factor = factor/10;
      c= (num/factor);
      if (c==7)
      {
        printf ("Yes");
        f++;
        break;
      }
      num = num % factor;
    }
  if (f==0)
    printf ("No");

  return 0;

}

Measured memory_bytes: 2152
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    if (a + b >= c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        int[] nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] v = Console.ReadLine().Split().Select(long.Parse).OrderByDescending(x => x).ToArray();
        long[] take = v.Take(nab[1]).ToArray();
        Console.WriteLine(take.Average().ToString("G20"));
        long res = 0;
        long last = take.Last();
        if (take.Distinct().Count() != 1)
        {
            res = combination(v.Count(x => x == last), take.Count(x => x == last));
        }
        else
        {
            int lastcount = v.Count(x => x == last);
            for (int i = nab[1]; i <= Math.Min(lastcount, nab[2]); i++)
            {
                res += combination(lastcount, i);
            }
        }
        Console.WriteLine(res);
    }
    static long combination(int n, int r)
    {
        long res = 1;
        for (int i = 1; i <= r; i++)
        {
            res *= (n - i + 1);
            res /= i;
        }
        return res;
    }
}


Measured memory_bytes: 13536
A = input()
op_cnt = len(A)-1
for j in range(2**op_cnt):
  op = ['-'] * op_cnt
  for k in range(op_cnt):
    if (j>>k) & 1:
      op[op_cnt - 1 - k] = '+'
      
  formula = ''
  for p_n, p_o in zip(A, op + ['']):
    formula += (p_n + p_o)
  if eval(formula) == 7:
    print(formula + '=7')
    break

Measured memory_bytes: 9012
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let [n,m,x]=tnn(3)
  let l=0,r=0
  for(let i=0;i<m;i++){
    if(tn()>x)r++
    else l++
  }
  to(min(r,l))
}
main()


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int rain=0;

    for(int i=0 ; i<3 ; i++)
    {
        if(s[i]=='R')
            rain++;
    }
    if(s[1]=='S' && rain>0)
    cout<<1;
    else
    cout<<rain;

    return 0;
}


Measured memory_bytes: 3160
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    for i in range(k):
        if s[i] != "1":
            res = s[i]
            break
    else:
        print(1)
        exit()

    print(res)


if __name__ == '__main__':
    resolve()


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

int main() {
  int mod = 1000000007;
  int N;
  cin >> N;
  vector<int> A(N);
  long long sum = 0;
  rep(i, N) {
    cin >> A.at(i);
    sum += A.at(i);
    sum %=  mod;
  }
  long long ans = 0;
  rep(i, N) {
    sum -= A.at(i);
    if (sum < 0) sum += mod;
    ans += A.at(i) * sum;
    ans %= mod;
  }
  cout << ans;
}


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

long long keta = 1;
vector<int> cnt(1,0);

string res(long long N){
    string ans = "";
    string alp = "abcdefghijklmnopqrstuvwxyz";
    while (N>0) {
        N-=1;
        ans = alp.at(N%26)+ans;
        N = N/26;
    }
    return ans;
}

int main() {
    long long N;
    cin >> N;
    cout << res(N);
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc =new Scanner(System.in);

        int N = sc.nextInt();


          if (N % 2 == 0){
            System.out.println(N);
          }else {
            System.out.println(N * 2);
          }
      
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#define maxn (ll)1e6+10

using namespace std;

typedef long long ll ;

ll mod=1e9+7;
int h,w,a,b;
ll inv[maxn],inv_jc[maxn],jc[maxn];
ll ans,tmp;
ll c(int A,int B) {
	if (B==0||B==A)
		return 1LL;
	long long res=jc[A]*inv_jc[B];
	res%=mod;
	res*=inv_jc[A-B];
	res%=mod;
	//printf("%lld %lld %lld %d %d\n",jc[A],inv_jc[B],inv_jc[A-B],A,B);
	return res;
}
int main() {
	scanf("%d %d %d %d",&h,&w,&a,&b);
	inv_jc[1]=jc[1]=inv[1]=1;
	for (int i=2;i<maxn;i++) {
		inv[i]=-(mod/i)*inv[mod%i];
		inv[i]%=mod ;
		while (inv[i]<0)
			inv[i]+=mod;
		inv_jc[i]=(inv_jc[i-1]*inv[i])%mod;
		jc[i]=(jc[i-1]*i)%mod;
	}
	int i=h-a,j=b+1;
	ans=0LL;
	while (1) {
		if (i<=0||j>w)
			break;
		tmp=c(i+j-2,i-1)*c(h-i+w-j,h-i);
		tmp%=mod;
		ans+=tmp;
		ans%=mod;
		i--; j++;
	}
	while (ans<0)
		ans+=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N,X,Y;cin>>N>>X>>Y;
    X--,Y--;
    Graph G(N);
    for(int i=0;i<N-1;i++){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);

    vector<int> ans(N,0);
    for(int i=0;i<N;i++){
        vector<int> dist(N,-1);
        queue<int> que;

        dist[i]=0;
        que.push(i);

        while(!que.empty()){
            int v=que.front();
            que.pop();

            for(int nv:G[v]){
                if(dist[nv]!=-1)continue;
                dist[nv]=dist[v]+1;
                ans[dist[nv]]++;
                que.push(nv);
            }
        }

    }
    for(int i=1;i<N;i++)cout<<ans[i]/2<<endl;

}


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

using namespace std;
#define int long long
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim>
struct rge {
    c b, e;
};

sim> rge<c> range(c i, c j) { return rge<c>{i, j}; }

sim> auto dud(c *x) -> decltype(cerr << *x, 0);

sim> char dud(...);

struct debug {
#ifndef LOCAL

    ~debug() {
        cerr << endl;
    }

    eni(!=) cerr << boolalpha << i;
        ris;
    }

    eni(==) ris << range(begin(i), end(i));
    }

    sim, class b dor(pair<b, c> d) {
        ris << "(" << d.first << ", " << d.second << ")";
    }

    sim dor(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        ris << "]";
    }

#else
    sim dor(const c &)
    {
        ris;
    }
#endif
};

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define int long long

void solve();

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    test
    solve();
    return 0;
}

const int mxn = 2e5 + 5;
int n, m;
vector<int> adj[mxn];
bool vis[mxn];
int x;

void dfs(int u) {
    if (!vis[u]) {
        vis[u] = true;
        x++;
        for (auto v: adj[u]) {
            if (!vis[v])
                dfs(v);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    set<pair<int, int>> s;
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (s.count({a, b}) == 0) {
            adj[a].push_back(b);
            adj[b].push_back(a);
            s.insert({a, b});
            s.insert({b, a});
        }
    }
    memset(vis, false, sizeof vis);
    int ans = INT_MIN;
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            x = 0;
            dfs(i);
            ans = max(ans, x);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 45996
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    rep(i, Q) cin >> A[i] >> B[i] >> C[i] >> D[i];
    vector<vector<int>> vecs;
    queue<string> que;
    rep(i, M) {
        string s = "";
        s += (i + '1');
        que.push(s);
    }
    while(!que.empty()) {
        auto p = que.front();
        que.pop();
        if(p.size() == N) {
            vector<int> vec(N);
            rep(i, p.size()) { vec[i] = p[i] - '0'; }
            vecs.pb(vec);
            continue;
        }
        for(int i = (p.back() - '0'); i <= M; i++) {
            string ns = p + (char)(i + '0');
            que.push(ns);
        }
    }
    int res = 0;
    rep(i, vecs.size()) {
        int tmp = 0;
        rep(j, Q) {
            if(vecs[i][B[j] - 1] - vecs[i][A[j] - 1] == C[j])
                tmp += D[j];
        }
        res = max(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10244
import math
n, d = list(map(int, input().split(' ')))
tmp = []
for _ in range(n):
    res = list(map(int, input().split(' ')))
    tmp.append(res)
ans = 0
for i in range(n):
    for j in range(i+1, n):
        dis = 0
        for x, y in zip(tmp[i], tmp[j]):
            dis += pow((x-y), 2)

        root = int(math.sqrt(dis))
        if root * root == dis:
            ans += 1

print(ans)

Measured memory_bytes: 38256
from math import gcd
N = 1000001
sieve = [-1] * (N + 1)
sieve[0] = sieve[1] = 0
for i in range(N + 1):
    if sieve[i] != -1:
        continue
    else:
        index = i * i
        while True:
            if index > N:
                break
            sieve[index] = i
            index += i

isCounted = [0] * 1000001
isPairwiseCoprime = True
M = int(input())
A = list(map(int,input().split()))
for i in range(M):
    elem = A[i]
    if elem == 1:
        continue
    primeList = []
    while sieve[elem] != -1:
        primeList.append(sieve[elem])
        elem //= sieve[elem]
    primeList.append(elem)
    for elem1 in primeList:
        if isCounted[elem1] != 0:
            isPairwiseCoprime = False
            break
    if not isPairwiseCoprime:
        break
    for elem1 in primeList:
        isCounted[elem1] += 1
if isPairwiseCoprime:
    print("pairwise coprime")
else:
    curGcd = A[0]
    for elem in A:
        curGcd = gcd(elem,curGcd)
    if curGcd == 1:
        print("setwise coprime")
    else:
        print("not coprime")


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

const int N = (1 << 16) + 20;
const int mod = 1e9 + 7;

int n, m, a[20];
int dp[20][N];
int npartition[N];
int fact[N];
int ifact[N];

void add(int &x, int y) {
	x += y; while(x >= mod) x -= mod; while(x < 0) x += mod;
}

int binpow(int a, int b) {
	int ret = 1;
	while(b) {
		if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ret;
}

int C(int n, int k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return 1LL * fact[n] * (1LL * ifact[k] * ifact[n - k] % mod) % mod;
}

void prepare() {
	fact[0] = 1; for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i - 1] * i % mod;
	ifact[0] = 1; for (int i = 1; i < N; ++i) ifact[i] = binpow(fact[i], mod - 2);

	npartition[0] = 1;
	for (int mask = 1; mask < (1 << n); ++mask) {
		int prv = (mask & -mask);
		npartition[mask] = 1LL * npartition[mask ^ prv] * C(mask, prv) % mod;
	}
}

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

	cin >> n >> m;
	for (int i = 1; i <= m; ++i) cin >> a[i];
	reverse(a + 1, a + m + 1);
	prepare();

	dp[0][0] = 1;
	for (int i = 1; i <= m; ++i) {
		for (int mask = 0; mask < (1 << n); ++mask) {
			if (!dp[i - 1][mask]) continue;
			
			int rem = (1 << n) - a[i] + 1 - mask;
			add(dp[i][mask], dp[i - 1][mask]);
			for (int j = 0; j < n; ++j) if (!(mask >> j & 1)) {
				add(dp[i][mask ^ (1 << j)], 1LL * dp[i - 1][mask] * C(rem - 1, (1 << j) - 1) % mod);
			}
		}
	}

	int res = 0;
	for (int mask = 0; mask < (1 << n); ++mask) {
		int cur = 1LL * dp[m][mask] * npartition[((1 << n) - 1) ^ mask] % mod;
		if (__builtin_popcount(mask) & 1) add(res, -cur);
		else add(res, cur);
	}

	for (int i = 0; i < n; ++i) {
		res = 1LL * res * fact[1 << i] % mod;
	}
	res = 1LL * res * (1 << n) % mod;

	printf("%d\n", res);
}

Measured memory_bytes: 4608
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

int N;
int A[2];
int ans = 1;
int ok;

int main() {
	register int i;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i) {
		scanf("%d", A + (i & 1));
		if(i > 1) {
			if(A[i & 1] == A[i & 1 ^ 1]) continue;
			if(ok) {if(ok == 1 && A[i & 1] < A[i & 1 ^ 1] || ok == -1 && A[i & 1] > A[i & 1 ^ 1]) ok = 0, ++ans;}
			else ok = A[i & 1] > A[i & 1 ^ 1] ? 1 : -1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

const int mod = (int)1e9 + 7;

class modulo_combination {
 private:
  vector<int> factrial, inverse;
  int pow(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return pow((long long)x * x % mod, y / 2);
    return (long long)x * pow(x, y - 1) % mod;
  }

 public:
  modulo_combination(int n) : factrial(n + 1), inverse(n + 1) {
    inverse[0] = factrial[0] = 1;
    for (int i = 1; i <= n; i++) {
      factrial[i] = (long long)factrial[i - 1] * i % mod;
      inverse[i] = pow(factrial[i], mod - 2);
    }
  }
  int operator()(int n, int k) { return (long long)factrial[n] * inverse[k] % mod * inverse[n - k] % mod; }
  int f(int n) { return factrial[n]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(m);
  for (auto &e : a) cin >> e;
  for (auto &e : b) cin >> e;
  sort(begin(a), end(a));
  sort(begin(b), end(b));

  if (unique(begin(a), end(a)) != end(a) || unique(begin(b), end(b)) != end(b)) {
    cout << 0 << endl;
    return 0;
  }

  modulo_combination c(n * m + 1);

  ll r = 1;
  int p = 0;
  for (int i = 0, j = 0; i < n || j < m;) {
    ll cn, ck, fn;
    p++;
    if (i < n && j < m && a[i] == b[j]) {
      cn = a[i] - p;
      ck = (n - i - 1) + (m - j - 1);
      fn = ck;
      i++;
      j++;
    } else if (!(j < m) || i < n && a[i] < b[j]) {
      cn = a[i] - p;
      ck = m - j - 1;
      fn = ck + 1;
      i++;
    } else {
      cn = b[j] - p;
      ck = n - i - 1;
      fn = ck + 1;
      j++;
    }
    if (cn - ck < 0) {
      r = 0;
      break;
    }
    r *= (ll)c(cn, ck) * c.f(fn) % mod;
    r %= mod;
    p += ck;
  }
  cout << r << endl;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

const int MAX = 310;

int main() {
    int h, w, k;
	cin >> h >> w >> k;

    vector<string> board(h);
	rep(i, h) {
        cin >> board[i]; 
    } 
    
    vector<bool> empty(MAX, true);
	rep(i, h) {
		rep(j, w) {
            if(board[i][j] == '#') {
                empty[i] = false;
            } 
        } 
	}

    vector<vector<int>> ans(MAX, vector<int>(MAX));

	int cnt = 0;
	rep(i, h) {
		if(empty[i]) {
            continue;
        } 
		rep(j, w) {
			if(board[i][j] == '#') {
                ans[i][j] = ++cnt;
            } 
		}
		rep(j, w) {
			if(ans[i][j] == 0 && j > 0 && ans[i][j-1] != 0) {
                ans[i][j] = ans[i][j-1];
            } 
		}
		for(int j = w-2; j >= 0; j--) {
			if(ans[i][j] == 0 && ans[i][j+1] != 0) {
                ans[i][j] = ans[i][j+1];
            } 
		}
	}

	for(int i = 1; i < h; i++) {
		if(empty[i] && !empty[i-1]) {
			empty[i] = false;
			rep(j, w) {
                ans[i][j] = ans[i-1][j];
            } 
		}
	}

	for(int i = h-2; i >= 0; i--) {
		if(empty[i] && !empty[i+1]) {
			empty[i] = false;
			rep(j, w) {
                ans[i][j] = ans[i+1][j];
            } 
		}
	}

	rep(i, h) {
		rep(j, w) {
            cout << ans[i][j];
            if(j < w-1) {
                cout << " ";
            }
		}
        cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 1280
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0

    k = min(A[0], B[0])
    ans += k
    A[0] -= k
    B[0] -= k

    for i in range(1,N):
        k = min(A[i], B[i-1])
        ans += k
        A[i] -= k
        B[i-1] -= k

        k = min(A[i], B[i])
        ans += k
        A[i] -= k
        B[i] -= k

    k = min(A[-1], B[-1])
    ans += k

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 107616
a, b, k = map(int, input().split())

if k * 2 > (b - a):
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range(b - k + 1, b + 1):
        print(i)


Measured memory_bytes: 3060
import math

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

if a * a * b // 2 <= x:
	y = a * a * b - x
	h = y * 2 / a / a
	t = math.atan2(h, a)
else:
	h = x * 2 / a / b
	t = math.pi / 2 - math.atan2(h, b)

print(math.degrees(t))


Measured memory_bytes: 38384
#coding:utf-8

N = input()
a = [input() for i in range(N)]
#print a # [a1, a2, a3, ..., aN]

sum = 0

for i in range(0,len(a)):
	sum += a[i]

if not sum % 10 == 0:
	print sum
else:
	while True:
		
		if len(a) == 0:
			print 0
			break
		
		item = a.pop(a.index(min(a)))
		temp_score = sum - item
		
		if not temp_score % 10 == 0:
			print temp_score
			break



Measured memory_bytes: 2568
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N)]

AB.sort()

ans = 0
cnt = 0
for a,b in AB:
    ans += a * min(b, M-cnt)
    cnt += b
    if cnt >= M:
        break

print(ans)

Measured memory_bytes: 16896
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc111/tasks/arc103_a
n=ii()
arr=limii()
arra=[]
arrb=[]

for i in range(n):
    if i%2==0:
        arra.append(arr[i])
    else:
        arrb.append(arr[i])
    
r=list(Counter(arra).most_common(2))
s=list(Counter(arrb).most_common(2))

if len(r)==1 and len(s)==1:
    if r[0][0]==s[0][0]:
        print(len(arra))
        exit()
    else:
        print(0)
        exit()

if r[0][0]==s[0][0]:
    if r[0][1]==s[0][1]:
        print(len(arra)-max(r[0][1],s[0][1]) + len(arra)-max(r[1][1],s[1][1]))
        exit()
    else:
        print(len(arra)-max(r[0][1],s[0][1]) + len(arra)-max(r[1][1],s[1][1]))
        exit()
else:
    print(len(arra)-r[0][1]+len(arra)-s[0][1])
    exit()

#print(n-(c+d))


Measured memory_bytes: 88952
#include <bits/stdc++.h>
#define ll     long long int 
#define pb     push_back
#define umap   unordered_map
#define mod    1000000007
#define all(x) (x).begin(), (x).end()
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
const int MAX = 5000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
  int n;cin>>n;
  int  nq;cin>>nq;
  int a[n];
  for(int i=0;i<n;i++){cin>>a[i];} 
    Query queries[nq]; 
  int l1,r1;
  for(int i=0;i<nq;i++)
    {
      cin>>l1>>r1;
      l1--,r1--;
      queries[i].l=l1;
      queries[i].r=r1;
      queries[i].idx=i;
    }
    sort(queries, queries+nq, cmp); 
    answeringQueries(a, n, queries, nq); 
} 

Measured memory_bytes: 35016
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
struct myhash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<string,ll> psl;
typedef vector<psl> vpsl;
typedef vector<int> vi;

#define fur(i,a,b) for(ll (i)=(a);i<(b);++(i))
#define revf(i,a,b) for(ll (i)=(a)-1;(i)>=(b);--(i))
#define mp make_pair
#define mod 1000000007
#define inf 2000000007
#define pb push_back
#define eps 1e-5
#define X first
#define Y second


ll modpow(ll base, ll exp, ll modulus) {
  base %= modulus;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

ll modinv(ll a, ll m) { 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    } 
    if (x < 0)
       x += m0;
    return x;
}


int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
  ll W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<setprecision(8)<<((((ld)1.0)*W*H)/2.0f)<<" ";
  if(W%2==0&&H%2==0)
  if(W/2==x&&H/2==y){
    cout<<1;
    return 0;
  }
  cout<<0;
  return 0;


	return 0;
}


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

class Program {
    static void Main(string[] args) {
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        Array.Sort(a);
        Console.WriteLine(a[0] * a[1] * a[2] % 2 * a[0] * a[1]);
    }
}

Measured memory_bytes: 13396
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

ll f(ll a, ll x) {
  if (a < 0) return 0;
  return a / x + 1;
}

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  cout << f(b, x) - f(a - 1, x) << endl;
  return 0;
}

Measured memory_bytes: 3628