akhauriyash/Code-Regression huggingface dataset:
import math


class Point:
    EPS = 1 << 10

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x+other.x, self.y+other.y)

    def __sub__(self, other):
        return Point(self.x-other.x, self.y-other.y)

    def __mul__(self, other):
        return Point(self.x*other, self.y*other)

    def __floordiv__(self, other):
        return Point(self.x/other.x, self.y/other.y)

    def __abs__(self):
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2 + self.y**2

    def __eq__(self, other):
        EPS = self.__class__.EPS
        return abs(self.x-other.x) < EPS and abs(self.x-other.x) < EPS

    def dot(self, other):
        return self.x*other.x + self.y*other.y

    def cross(self, other):
        return self.x*other.y - self.y*other.x

    def isOrthogonal(self, a, b):
        return a.dot(b) == 0.0

    def isParallel(self, a, b):
        return a.cross(b) == 0.0

    def __str__(self):
        return str(self.x)+' '+str(self.y)


class Vector(Point):
    pass


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

    def isOrthogonal(s1, s2):
        return (s1.p2-s1.p1).dot(s2.p2-s2.p1) == 0.0

    def isParallel(s1, s2):
        return (s1.p2-s1.p1).cross(s2.p2-s2.p1) == 0.0


class Line(Segment):
    pass


class Circle:
    def __init__(self, c, r):
        self.c = c
        self.r = r


class Polygon:
    def __init__(self, *points):
        self.points = points


def reflect(s, p):
    m = project(s, p)
    return (m-p)*2 + p


def project(s, p):
    base = s.p2 - s.p1
    r = (p-s.p1).dot(base) / base.norm()
    return s.p1 + base * r


x1, y1, x2, y2 = map(int, input().split())
p1, p2 = Point(x1, y1), Point(x2, y2)
s = Segment(p1, p2)

q = int(input())
for i in range(q):
    p = Point(*map(int, input().split()))
    print(reflect(s, p))



Measured memory_bytes: 5812
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);
int lex(int a[], int n);
int fact(int n) ;

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    int t, n, k=0, x, y;
    cin >> n;
    int a[n], b[n];
    fo(i,n) cin >> a[i];
    fo(i,n) cin >> b[i];
    x = lex(a, n);
    y = lex(b, n);
    cout << abs(x-y) << "\n";
}
int lex(int a[], int n){
    int sum = fact(n-1)*(a[0]-1);
    int res=0;
for(int i=1; i<n; i++){
    res  = 0;
    for(int j=0; j<i; j++){
        if(a[j]<a[i])res++;
    }
        sum += fact(n-1-i)*(a[i]-1-res);
}
return sum;
}
int fact(int n) 
{ 
    if (n == 0) 
        return 1; 
    return n * fact(n - 1); 
} 

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	vector<int> l(n), r(n);
	for (int i = 1; i < n; ++i) {
		if (s[i - 1] == 'W')
			l[i] = l[i - 1] + 1;
		else
			l[i] = l[i - 1];
	}
	for (int i = n - 1; i > 0; --i) {
		if (s[i] == 'E')
			r[i - 1] = r[i] + 1;
		else
			r[i - 1] = r[i];
	}
	int ans = 1e9;
	for (int i = 0; i < n; i++) {
		ans = min(ans, l[i] + r[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6116
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nc = Input.ar;
        var stc = Input.twodim(nc[0]);
        const int NUM = 200002;
        var res = new int[NUM];
        for (var i = 0; i < nc[1]; i++)
        {
            var imos = new int[NUM];
            for(var j = 0; j < nc[0]; j++)
            {
                if (stc[j][2]-1 != i) continue;
                imos[2 * stc[j][0] - 1]++;
                imos[2 * stc[j][1]]--;
            }
            for (var j = 1; j < NUM; j++)
                imos[j] += imos[j - 1];
            for (var j = 0; j < NUM; j++)
                if (imos[j] > 0) res[j]++;
        }
        WriteLine(res.Max());
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  else if(s == "Cloudy")cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {

val s_list = scala.io.StdIn.readLine.toList

def check(s_list:List[Char]):Boolean = {
  if (s_list(0) != 'A') return false
  val upper_c_idx = s_list.indexOfSlice("C")
  if (upper_c_idx != s_list.lastIndexOfSlice("C")) return false
  if ((upper_c_idx < 2) | (s_list.length-2 < upper_c_idx)) return false
  var cnt:Int = s_list.filter(c => c >= 'A' && c <= 'Z').size
  if (cnt > 2) return false
  return true
}

if (check(s_list)) println("AC") else println("WA")
}

Measured memory_bytes: 25396
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin >> n;
    while(n!=0) {
      double arr[n];
      double sum = 0;
      for (int i=0; i<n; i++) {
        double num;
        cin >> num;
        arr[i] =  num;
        sum += num;
      }
      double ave = sum/n;
      double var = 0;
      for (int i=0; i<n; i++) {
        var+=pow((ave-arr[i]), 2);
      }
      double sd = sqrt(var/n);
      cout <<fixed << setprecision(8)<< sd << endl;
      cin >> n;
    }
    return 0;
}



Measured memory_bytes: 3244
// https://atcoder.jp/contests/abc134/tasks/abc134_d

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// ll lcm(long a, long b) { return a * b / gcd(a, b); }

inline int read() {
    int out = 0, fh = 1;
    char jp = getchar();
    while ((jp > '9' || jp < '0') && jp != '-')
        jp = getchar();
    if (jp == '-')
        fh = -1, jp = getchar();
    while (jp >= '0' && jp <= '9')
        out = out * 10 + jp - '0', jp = getchar();
    return out * fh;
}

int a[200001];
bool b[200001];
int main() {
    int n, ans = 0;
    n = read();
    for (int i = 1; i <= n; i++) {
        a[i] = read();
    }
    for (int i = n; i >= 1; i--) {
        int x = a[i];
        for (int j = i << 1; j <= n; j += i) {
            x ^= b[j];
        }
        b[i] = x;
        if (x)
            ans++;
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i++) {
        if (b[i]) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 200012;
const ll MOD = 1000000007;

// template code
ll f[MN], f_inv[MN];
ll modpow (ll a, ll b, ll m = MOD) {
  ll res = 1;
  while (b) {
    if (b&1) res = res*a%m;
    a = a*a%m;
    b >>= 1;
  }
  return res;
}
ll inv (ll a, ll p = MOD) { return modpow(a,p-2,p); }
ll mul (ll a, ll b, ll m = MOD) { return a*b%m; }
ll add (ll a, ll b, ll m = MOD) { return (a+b)%m; }
ll sub (ll a, ll b, ll m = MOD) { return (a+MOD-b)%m; }
ll dvd (ll a, ll b, ll m = MOD) { return mul(a,inv(b,m),m); }
ll ncr (ll n, ll r) { return mul(mul(f[n], f_inv[r]), f_inv[n-r]); }

// solution
int n;
vector<int> g[MN];
ll sz[MN], dp[MN];

void dfs (int u, int p = -1) {
  ll res = 1;
  sz[u] = 1;
  for (int v : g[u]) {
    if (v == p) continue;
    dfs(v,u);
    sz[u] += sz[v];
    res = mul(res, dvd(dp[v], f[sz[v]]));
  }
  res = mul(res, f[sz[u]-1]);
  dp[u] = res;
}
void reroot (int u, int p = -1) {
  for (int v : g[u]) {
    if (v == p) continue;
    ll cur = dp[u];
    // remove the contribution of node v
    cur = dvd(cur, dvd(dp[v], f[sz[v]]));
    cur = dvd(cur, f[n-1]);
    cur = mul(cur, f[n-sz[v]-1]);
    // update node v
    dp[v] = dvd(dp[v], f[sz[v]-1]);
    // add contribution of node u
    dp[v] = mul(dp[v], dvd(cur, f[n-sz[v]]));
    dp[v] = mul(dp[v], f[n-1]);
    reroot(v,u);
  }
}

int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  f[0] = f_inv[0] = 1;
  for (ll i = 1; i < MN; i++) {
    f[i] = mul(f[i-1], i);
    f_inv[i] = inv(f[i]);
  }
  cin >> n;
  for (int i = 0; i < n-1; i++) {
    int u,v; cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  reroot(0);
  for (int i = 0; i < n; i++)
    cout << dp[i] << '\n';
  return 0;
}



Measured memory_bytes: 20212
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int n, a[100001], b[100001], c[100001];

long long lower_bound(int key) {
    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (a[mid] >= key) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}

long long upper_bound(int key) {
    int l = -1, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (c[mid] > key) {
            r = mid;
        } else {
            l = mid;
        }
    }
    return r;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a, a + n);
    sort(c, c + n);
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += lower_bound(b[i]) * (n - upper_bound(b[i]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>

#define N 44

int Fibo(int );

int main(){
  
  int number;
  int result;

  scanf("%d",&number);
  
  result=Fibo(number);

  printf("%d\n",result);
  
  return 0;
}

int Fibo(int number){
  int Nacci[N];
  int i;

  Nacci[0]=1;
  Nacci[1]=1;

  for(i=2;i<number+1;i++){
    Nacci[i]=Nacci[i-2]+Nacci[i-1];
  }

  return Nacci[number];
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define this-> tt
#define long long ll
using namespace std;
int main ()
{
int k,a;
cin>>k>>a;
if (k<=a)cout<<"unsafe";
else cout<<"safe";
    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 3636
def div(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

n=int(input())
d=div(n)
ans=0
for i in d:
    x=i-1
    if x!=0 and n//x==n%x: ans+=x

print(ans)

Measured memory_bytes: 39024
# coding=UTF-8
S=input()
S=list(S)
T=input()
Key=False

for i in range(len(S)):
    S=''.join(S)
    if S==T:
        Key=True
        break
    S=list(S)
    tmp=S[0]
    del S[0]
    S.append(tmp)
    

if Key==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N =sc.nextInt();
		Map<String,Integer> map = new HashMap<>();
		for(; N > 0; N--) {
			String a = sc.next();
			if(map.containsKey(a)) {
				map.put(a, (map.get(a)+1));
			}else {
				map.put(a, 1);
			}
		}

		List<Entry<String, Integer>> list_entries = new ArrayList<Entry<String, Integer>>(map.entrySet());
		Collections.sort(list_entries, new Comparator<Entry<String, Integer>>() {
			public int compare(Entry<String, Integer> obj1, Entry<String, Integer> obj2){
				return obj2.getValue().compareTo(obj1.getValue());
            }
        });

		ArrayList<String> list = new ArrayList<>();
		int ch = 0;
		for(Entry<String, Integer> entry : list_entries) {
			String key = entry.getKey();
			if((entry.getValue() != ch)&&(ch != 0)) {
				break;
			}else {
				list.add(key);
				ch = entry.getValue();
			}
		}
		Collections.sort(list);
		for(int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}

}

Measured memory_bytes: 70236
import java.util.*;

public class Main {
		public static void main(String[] args) {
			
			Scanner sc = new Scanner(System.in);
			
			int K = sc.nextInt();
			int X = sc.nextInt();
			
			if(500*K >= X) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			
		}
}
			

Measured memory_bytes: 23252
#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 long double ld;

ll temp1,temp2,temp;
char tempc;

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

#define N 1000000007
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
#define pl pair<ll,ll>
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)

ll binpow(ll a, ll b)
{
    a%=N;b=b%(N-1);
    ll res=1;
    while(b>0)
    {
        if(b&1) res=res*a%N;
        a=a*a%N;
        b>>=1;
    }
    return res%N;
}

int simpow(int a,int b)
{
    // b=b%(N-1);
    ll res=1;
    while(b>0)
    {
        if(b&1) res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

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

int mini(int a,int b)
{
    if(a<b) return a;
    return b;
}

struct DSU {
    vector<int> sz;
    vector<int> parent;
 
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }
 
    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }
 
    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }
 
    DSU(int n) {
        sz.resize(n+1);
        parent.resize(n+1);
        for (int i = 1; i <= n; i++) make_set(i);
    }
};

signed main()
{
    fast;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    int n; cin >> n;
    int ans=(n*(n+1)*(n+2))/6;
    vector <int> v(2);
    forn(i,n-1)
    {
        cin >> v[0] >> v[1];
        sort(v.begin(),v.end());
        ans-=(v[0]*(n+1-v[1]));
    }
    cout << ans << endl;
}

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

int main()
{
	long long n, a, b, c, d; //中间可能溢出，在atcoder上常有溢出的坑 
	while(cin >> n >> a >> b >> c >> d) {
		int m;//C(N -1-m) - Dm ≤ B -A ≤-cm + (N - 1 - m)D  
		for (m = 0; m < n; ++m) { //0:n
			if ( (c * (n - 1 - m) - d * m <= b - a) 
				&& b - a <= -c * m +(n - 1 - m) * d) {
				break;
			}
		}
		if (m < n) puts("YES");
		else puts("NO");
	}	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX_N=50;
const int MAX_M=20;
int N;
vector<int>G[MAX_N];
vector<int> bitM(MAX_M);
vector<int> depth(MAX_N);
map<pair<int,int>,int>memo;
typedef pair<int,int>P;

int POW(int x,int r){
    if(r==0)return 1;
    if(r%2==0)return POW(x,r/2)*POW(x,r/2);
    else return POW(x,r-1)*x;
}

void dfs(int b,int j){
  	if(depth[b]==0) return;
    for(auto v:G[b]){
        if(depth[b]-depth[v]==1){
            bitM[j]=(bitM[j]|(POW(2,memo[{b,v}])));
            dfs(v,j);
        }
    }
}

signed main(){
    cin>>N;
    REP(i,N-1){
        int a,b;cin>>a>>b;a--;b--;
        G[a].pb(b);
        G[b].pb(a);
        memo[{a,b}]=i;
        memo[{b,a}]=i;
    }
    int M;cin>>M;
    bitM.resize(M);
    depth.resize(N);
    REP(i,M)bitM[i]=0;
    //制約Mに含まれる辺をビットで管理する
    REP(i,M){
        int a,b;cin>>a>>b;a--;b--;
        //AからBへの距離を求める(bfs)
      	REP(i,N)depth[i]=INF;
        queue<P>que;
        que.push({a,0});
        while(que.size()){
            P p=que.front();que.pop();
            depth[p.first]=p.second;
            if(p.first==b)break;
            for(auto v:G[p.first]){
                if(depth[v]==INF){
                    que.push({v,p.second+1});
                }
            }
        }
        //Bから逆順で戻して、使う辺をbitにいれる
        dfs(b,i);
    }
    int ans=0;
    //反する制約をbit全探索(bitが1のところの制約に反するものの個数を求める)
    for(int i=0;i<(1<<M);i++){
        int sum=0;
        bitset<20>s(i);
        int count=0;
        //辺の集合の和集合を求める+反した制約の個数を求める
        REP(j,M){
            if(s.test(j)){
                sum=(sum|bitM[j]);
                count=1-count;
            }
        }
        //包除原理で答えを求める
        int henc=0;
        while(sum>0){
            if(sum & 1)henc++;
            sum=(sum >> 1);
        }
        ans+=(count==0?1:-1)*POW(2,N-1-henc);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
n = int(input())
h = list(map(int, input().split()))
cos = [0]*n

cos[1] = cos[0]+abs(h[1]-h[0])
for i in range(2, n):
    cos[i] = min(cos[i-1]+abs(h[i]-h[i-1]), cos[i-2]+abs(h[i]-h[i-2]))

print(cos[n-1])

Measured memory_bytes: 13980
function myout(text){console.log(text);}//standard output
function Main(input) {
	input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	//input = input.split("\n").map((a)=>Number(a));
  if(input == 1){
     myout("1");
    return;
     }
  
  var list = getDivisorList(input);
  //myout(list);
  var output = 20;
  for(var i = 0; i < list.length / 2; i++){
    var mae = list[i];
    var ato = list[list.length - (i+1)];
    //myout(mae + ":" + ato);
    output = Math.min(output,getKeta(mae,ato));
  }
  myout(output);
}

function getKeta(val1,val2){
  return Math.max(val1.toString().length,val2.toString().length);
}

//約数全列挙(高速)
function getDivisorList(val){
	var list = [];
	for(var i = 1; i * i <= val; i++){
		if(val % i == 0){
			list.push(i);
			if(i * i != val){
				list.push(val / i);
			}
		}
	}
	list.sort(function(a,b){
		return a - b;
	});
	return list;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 8132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,x,y;
int d[2005];
int main(void){
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int D=min(abs(j-i),abs(i-x)+1+abs(j-y));
            d[D]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<d[i]<<endl;
    }
    
}



Measured memory_bytes: 3648
#include <iostream>
using namespace std;
 
int main() {
    string a, b;
    cin >> a >> b;
    if ((a[1] == b[1])&&(a[0] == b[2])&&(a[2] == b[0])){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
list_str2 = [0 for i in range(26)]

while(1):
	try:
		list_str1 = list(input())
		#print(list_str1)
	except:
		break
	for i in range(len(list_str1)):
		if 97 <= ord(list_str1[i].lower()) <= 122:
			list_str2[ord(list_str1[i].lower())-97] += 1

for i in range(26):
	print(chr(97+i)+' : '+str(list_str2[i]))

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

int main(void) {
	vector<int> x;
	vector<int> y;
	vector<int> h;
	int copyx, copyy, copyh;
	int ansx, ansy, ansh;
	int a, b, c;
	int n, i, k, j;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		cin >> a;
		cin >> b;
		cin >> c;
		x.push_back(a);
		y.push_back(b);
		h.push_back(c);
		if (c > 0) {
			copyx = a;
			copyy = b;
			copyh = c;
		}

	}
	for (i = 0; i < 101; i++) {
		for (k = 0; k < 101; k++) {
			ansx = i; ansy = k;
			ansh = copyh + abs(copyx - i) + abs(copyy - k);
			for (j = 0; j < n; j++) {
				if (h[j] > 0) {
					c = h[j] + abs(x[j] - i) + abs(y[j] - k);
					if (c != ansh) {
						break;
					}
					else if (c == ansh && j == n - 1) {
						printf("%d %d %d", ansx, ansy, ansh);
						return 0;
					}
				}
				else {
					c = ansh - abs(x[j] - i) - abs(y[j] - k);
					c = max(c, 0);
					if (c > 0) {
						break;
					}
					else if (c ==0 && j == n - 1) {
						printf("%d %d %d", ansx, ansy, ansh);
						return 0;
					}
				}
			}
		}
	}

	return 0;
}


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

int main(void)
{
    ios::sync_with_stdio(false);
    while(1) {
        int n;
        int a[5001] = {0};
        long int ans = -10000000;
        cin >> n;
        if(n == 0) break;

        for(int i=0; i<n; i++)
            cin >> a[i];

        for(int i=0; i<n; i++) {
            long int sum = 0;
            for(int j=i; j<n; j++) {
                sum += a[j];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	ll ans = 0;
	int n; cin >> n;
	rep1(i, n) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		ans += i;
	}
	cout << ans << "\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void){
  int n, list[110][110] = {0}, u, k;
  int i, j, v;

  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &u);
    scanf("%d", &k);
    for (j = 1; j <= k; j++) {
      scanf("%d", &v);
      list[u][v] = 1;
    }
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      printf("%d", list[i][j]);
      if (j < n) {
        printf(" ");
      }
      else {
        printf("\n");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
ll n,a,b ;
vector<ll>v[N] ;
ll dis[N],mx[N] ;
ll pa[N] ;
ll dfs(ll i,ll p)
{
    pa[i]=p ;
    for(ll j:v[i])
    {
        if(j==p)
            continue ;

         dis[j]=dis[i]+1 ;
         mx[i]=max(mx[i],dfs(j,i)) ;

    }
    return mx[i]+1 ;
}
int main()
{
   fast ;
   ///Mission-500
   cin>>n>>a>>b ;
   for(ll i=0;i<n-1;i++)
   {
       ll x,y ;
       cin>>x>>y ;
       v[x].pb(y) ;
       v[y].pb(x) ;
   }
   memset(pa,0,sizeof(pa)) ;
   memset(mx,0,sizeof(mx)) ;
   pa[b]=-1 ;
   dis[b]=0 ;
   dfs(b,-1) ;

   ll ans=dis[a]-1 ;
   ll num=(dis[a]-1)/2 ;
   while(num>=0)
   {
       ans=max(ans,dis[a]+mx[a]-1) ;
       //cout<<a<<" "<<dis[a]<<" "<<mx[a]<<endl ;
       num-- ;
       a=pa[a] ;
   }
   cout<<ans ;


}


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

int main(){
  
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if ( a<c ||(a==12 && c==1)){
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 {
// #ifdef 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__) << "] "

void solve(){
    int h,w,m;
    cin>>h>>w>>m;
    int row[h],col[w],mxr=0,mxc=0;
    memset(row,0,4*h);
    memset(col,0,4*w);
    vector<int> row_ind,col_ind;
    set<pair<int,int>> s;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        s.insert(make_pair(a,b));
        row[a]++,col[b]++;
        // mxr=max(mxr,row[a]);
        // mxc=max(mxc,col[b]);
        if(mxr<row[a]){
            mxr=row[a];
            row_ind.clear();
            row_ind.push_back(a);
        }
        else if(mxr==row[a]){
            row_ind.push_back(a);
        }
        if(mxc<col[b]){
            mxc=col[b];
            col_ind.clear();
            col_ind.push_back(b);
        }
        else if(mxc==col[b]){
            col_ind.push_back(b);
        }
    }
    for(int i:row_ind){
        for(int j:col_ind){
            if(s.find(make_pair(i,j))==s.end()){
                cout<<mxr+mxc<<'\n';
                return;
            }
        }
    }
    cout<<mxr+mxc-1<<'\n';
}

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

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}

const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e5 + 9;

signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    ll x, k, d, ans;
    read(x), read(k), read(d);
    ll t = x > 0 ? x : -x;
    ll tm = t / d;
    if (tm > k)
    {
        ans = x > 0 ? x - k * d : x + k * d;
    }
    else
    {
        k -= tm;
        if (k % 2 == 1)
            ans = x > 0 ? x - (tm + 1) * d : x + (tm + 1) * d;
        else
            ans = x > 0 ? x - (tm)*d : x + (tm)*d;
    }
    cout << (ans > 0 ? ans : -ans) << '\n';
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

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

int main(){
  int n, k, x, y;
  cin>>n>>k>>x>>y;
  int fee;
  if(k>=0&&k<=n){
    fee = k*x + (n-k)*y;
  }else{
    fee = n*x;
  }
  cout<<fee<<endl;

  return 0;
}


Measured memory_bytes: 256
function main(input: string) {
  const lines = input.trim().split('\n')

  const [a, b, c] = lines[0].split(' ').map(Number)

  console.log(Math.max(0, c - (a - b)))
}

const values = obj => Object.keys(obj).map(e => obj[e])

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,memo = 0,ans = 0;
    cin >> n;
    int a[n];
    
    rep(i,0,n){
        cin >> a[i];
        memo++;
        if(a[i] == 0){
            ans = max(ans,memo);
            memo = 0;
        }
    }
    memo++;
    ans = max(ans,memo);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int x, a;

int main() {
    cin >> x >> a;
    int ans = 0;
    if (x>=a) ans += 10;
    cout << ans << endl;
}


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

using namespace std;

typedef unsigned long long int ll;
// C++ program to count number of factors
// of an array of integers

const ll MAX = 10000001;

// array to store prime factors
ll factor[MAX] = { 0 };

// function to generate all prime factors
// of numbers from 1 to 10^6
void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (ll i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (ll i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (ll i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (ll j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
ll Factors(ll n)
{
    if (n == 1)
        return 1;

    ll ans = 1;


    ll dup = factor[n];


    ll c = 1;


    ll j = n / factor[n];


    while (j != 1) {

        if (factor[j] == dup)
            c += 1;


        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        j = j / factor[j];
    }


    ans = ans * (c + 1);

    return ans;
}
int main(){
    ll n;
    generatePrimeFactors();
    cin >> n;
    ll sum =0;
    for(long long int i =1; i <=n;++i){
        sum+=(i*Factors(i));
    }
    cout << sum;
	return 0;
}


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

int main() {
    int n; cin >> n;
    vector<int> v(n), l(n/2), r(n/2);
    map<int, int> m_l, m_r;
    rep(i, n) {
        cin >> v[i];
        if (i%2 == 0) {
            //l[i] = v[i];
            m_l[v[i]]++;
        }
        else {
            //r[i] = v[i];
            m_r[v[i]]++;
        }
    }
    int l1 = 0, l2 = 0, r1=0, r2=0;
    int cnt = 0;
    for (auto l : m_l) {
        if (l.second > cnt) {
            cnt = l.second;
            l1 = l.first;
        }
    }
    cnt = 0;
    for (auto l : m_l) {
        if (l.first == l1) continue;
        if (l.second > cnt) {
            cnt = l.second;
            l2 = l.first;
        }
    }
    cnt = 0;
    for (auto r : m_r) {
        if (r.second > cnt) {
            cnt = r.second;
            r1 = r.first;
        }
    }
    cnt = 0;
    for (auto r : m_r) {
        if (r.first == r1) continue;
        if (r.second > cnt) {
            cnt = r.second;
            r2 = r.first;
        }
    }
//      printf("l1=%d r1=%d\n", l1, r1);
//      printf("m_l[%d]=%d m_r[%d]=%d\n", l1, m_l[l1], r1, m_r[r1]);
    if (r1 != l1) {
        cout << (n/2-m_r[r1]) + (n/2 - m_l[l1]) << endl;
        return 0;
    }

    cout << min(n/2-m_l[l1] + n/2-m_r[r2], n/2-m_l[l2] + n/2-m_r[r1])<< endl;
}


Measured memory_bytes: 8772
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

bool isplime(int p){
	if(p==1) return false;
	for(int i=2;i<p;i++) {
		if(p%i==0) return false;
	}
	return true;
}

int main() {
	int n; cin >> n;
	for(int i=31;i<=55555;i+=30) {
		if(isplime(i)) {
			if(i!=31) cout << " ";
			cout << i;
			n--;
		}
		if(n==0) break;
	}
	cout << endl;
}

Measured memory_bytes: 3552
#include <stdio.h>
 
int main(){
  int i, j, k;
  int money[3];
  int x;
  int count = 0;
  
  for(i = 0; i < 3; i++)
    scanf("%d", &money[i]);
  
  scanf("%d", &x);
  
  for(i = 0; i <= money[0]; i++){
    for(j = 0; j <= money[1]; j++){
      for(k = 0; k <= money[2]; k++){
        if(x == i * 500 + j * 100 + k * 50)
          count++;
      }
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for(int i=0; i<n; ++i)
        if(c*(n-1-i)-d*i<=b-a &&b-a<=(n-1-i)*d-c*i) return 0*puts("YES");
    puts("NO");
    return 0;
}


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

int main()
{
    char s[100000];
    scanf("%s",s);
    int m=0, i, l, a=0;
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(s[i]=='G'||s[i]=='A'||s[i]=='C'||s[i]=='T')
        {
            m++;
        }
        else
        {
            if(a<m)
            a=m;
            m=0;
        }
        if(m!=0&&i==l-1)
        {
            if(a<m)
            a=m;
        }
    }
    printf("%d",a);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(void){
  int input,suma=0,sumb=0,i;
  for(i=0;i<4;i++){
    cin>>input;
    suma+=input;
  }
  for(i=0;i<4;i++){
    cin>>input;
    sumb+=input;
  }
  cout<<((suma<sumb)?sumb:suma)<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
	long long x,y;
}a[200005];
long long mny[200005],mxy[200005],ymx[200005];
bool cmp(node t1,node t2)
{
	return t1.x<t2.x;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].y);
		if (a[i].x>a[i].y) swap(a[i].x,a[i].y);
	}
	sort(a+1,a+1+n,cmp);
	long long mn=1e9,mx=0;
	mny[0]=1e9;
	for (int i=1; i<=n; i++)
	{
		mn=min(mn,a[i].y);
		mx=max(mx,a[i].y);
		mny[i]=min(mny[i-1],a[i].y);
		mxy[i]=max(mxy[i-1],a[i].y);
	}
	for (int i=n; i>=1; i--) ymx[i]=max(ymx[i+1],a[i].y);
	long long ans=(mx-mn)*(a[n].x-a[1].x);
	for (int i=1; i<n; i++)
	{
		long long minA=min(a[i+1].x,mny[i]);
		long long maxA=max(a[n].x,mxy[i]);
		long long minB=a[1].x;
		long long maxB=ymx[i+1];
		//printf("%d %lld %lld %lld %lld\n",i,minA,maxA,minB,maxB);
		ans=min(ans,(maxB-minB)*(maxA-minA));
	}
	printf("%lld\n",ans);
	return 0;
}
/*
1、max,min不同
2、max,min同
  设min,max在B
  A:前a个选y，后(n-a)个选x
  B:………………x，……………………………y
  对于第k个，从选x变成选y至A的影响
  minA=min(xk+1,y(1~k)mn)；maxA=max(xn,y(1~k)mx);
  minB=x1;maxB=max(y(k+1~n))
*/
/*
3
1 2
3 4
5 6
*/

Measured memory_bytes: 8064