akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>

using namespace std;


int main(){
  int h,w;
  int odd_count = 0;
  int four_count = 0;
  map <char, int> s;
  cin >> h >> w;
  for (int i=0;i<w;i++) {
    for (int j=0;j<h;j++) {
      char c;
      cin >> c;
      if (s.find(c)==s.end()) {
	s[c] = 1;
      } else {
	s[c]++;
      }
    }
  }
  if (h==1 && w==1) {
    cout << "Yes" << endl;
    return 0;
  }
  for (auto it = s.begin();it != s.end();it++) {
    if (it->second % 4 == 2) {
      four_count++;
    }
    if (it->second % 4 == 3) {
      four_count++;
      odd_count++;
    }
    if (it->second % 4 == 1) {
      odd_count++;
    }
  }
  if (h % 2 == 0 && w % 2 == 0) {
    if (four_count > 0) {
      cout << "No" << endl;
      return 0;
    }
  }  
  if (h % 2 == 0 && w % 2 == 1) {
    if (odd_count > 0) {
      cout << "No" << endl;
      return 0;
    }
    if (four_count > h/2) {
      cout << "No" << endl;
      return 0;
    }
  }  
  
  if (h%2 == 1 && w%2 == 0) {
    if (odd_count > 0) {
      cout << "No" << endl;
      return 0;
    }
    if (four_count > w/2) {
      cout << "No" << endl;
      return 0;
    }
  }  
  if (h%2 == 1 && w%2 == 1) {
    if (odd_count > 1) {
      cout << "No" << endl;
      return 0;
    }
    if (four_count > ((h+w - 2)/2)) {
      cout << "No" << endl;
      return 0;
    }
  }  
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import numpy as np

N,M = map(int, input().split())
py = [[int(i) for i in input().split()] for i in range(M)]

pref_dic = {}
for i in range(N):
    pref_dic[i+1] = []
for e,index in zip(py, range(M)):
    pref = e[0]
    year = e[1]
    
    pref_dic[pref].append((index, year))
        
city_num_dic = {}
for pref in pref_dic.keys():
    pref_string = str(pref)
    if len(pref_string) < 6:
        while len(pref_string) < 6:
            pref_string = "0" + pref_string
    
    in_year_list = np.array(pref_dic[pref])
    if len(in_year_list) == 0:
        continue
    
    year_ =  in_year_list[:, 1]
    city_ = in_year_list[:, 0]
    
    hayaijun_ind = np.argsort(year_)
    for index, i in zip(hayaijun_ind, range(len(hayaijun_ind))):
        city_name = city_[index]
        num = str(i+1)
        if len(num) < 6:
            while len(num) < 6:
                num = "0" + num
        city_num_dic[city_name] = pref_string + num


for city in np.sort(list(city_num_dic.keys())):
    print(city_num_dic[city])

Measured memory_bytes: 84728
#include <stdio.h>
int main(){

  int a, b;
  scanf("%d%d", &a, &b);
  if ( a < b ) {
    printf("a < b\n");
  } else if ( a > b ) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }
  return 0;
}




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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 210;
const LL mod = 998244353;
int N;
int x[MC] , y[MC];
LL sel[MC];
LL l[MC];

int gcd(int a , int b){
	return b ? gcd(b,a%b) : a;
}

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d%d" , x + i , y + i);
	}
	sel[3] = 8;
	repp(i,4,MC){
		sel[i] = sel[i-1] * 2 % mod;
		(sel[i-1] += mod - i - (i-1) * (i-2) / 2) %= mod;
	}
	LL ans = sel[N];
	repp(i,0,N){
		map<P2,int> M;
		repp(j,0,N){
			if(i==j) continue;
			int dx = x[j] - x[i];
			int dy = y[j] - y[i];
			if(dx < 0){
				dx *= -1;
				dy *= -1;
			}
			if(dx == 0) dy = 1;
			else if(dy == 0) dx = 1;
			else {
				int g = gcd(dx,abs(dy));
				dx /= g;
				dy /= g;
			}
			++M[MP(dx,dy)];
		}
		for(auto z : M) ++l[z.second + 1];
	}
	repp(i,3,N+1){
		(ans += (mod - sel[i]) * (l[i]/i)) %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    int ans=1;
    int j;
    for(int i=1;i*i<=m;i++){
        if(m%i==0){
            j=m/i;
            if(m/i>=n)ans=max(ans,i);
            if(m/j>=n)ans=max(ans,j);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) { cin >> a[i]; }
    sort(a.begin(), a.end());
    int bob = 0;
    int alice = 0;
    while(a.size() > 0) {
        bob += a[a.size() - 1];
        a.pop_back();
        if(a.size() > 0) {
            alice += a[a.size() - 1];
            a.pop_back();
        }
    }
    cout << bob - alice << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define FI first
#define SE second
#define PB(a) push_back(a)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
#define SZ(x) ((int)(x).size())
#define SO(x) sizeof((x)) / sizeof((x)[0])
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void co(int a[], int n) {REP(i, n) cout << a[i] << " "; cout << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int a,b,k;
	cin >> a >> b >> k;
	REP(i,k){
		if (i%2 == 0){
			if (a%2 == 1) a--;
			b += a/2;
			a -= a/2;
		}else{
			if (b%2 == 1) b--;
			a += b/2;
			b -= b/2;
		}
	}
	cout << a << " " << b << endl;
return 0;
}


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


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

    int ind = 1;
    while(chk.at(ind)<2){
            chk.at(ind)++;
            ind = A.at(ind);
    }

    long long D = 0;
    long long T = 0;

    for(int i = 0; i < N; i++){
        if(chk.at(i+1) == 2) D++;
        if(chk.at(i+1) == 1) T++;
    }



    int j = 0;
    int ans = 1;


    if (K > 100000000)K = T + (K - T)%D;
    
    while(j < K){
        ans = A.at(ans);
        j++;
    }

    if(A.at(1) == 1) ans = 1;

    cout << ans << endl;

}


Measured memory_bytes: 4844
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
int main(){
	int n,*a,b;
	
	cin>>n;
	a=new int[n];
	
	for(int i=0;i<n;++i){
		cin >> b;
		a[i]=b;
	}
	
	for(int i=n;i;--i){
		cout << a[i-1];
		if(i>1)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>

int main()
{
    int n;
    cin>>n;
    map<pair<int,int>,long long int> mp;
    for(int i=1;i<=n;i++)
    {
        int j=i;
        int l,r;
        l=j%10;
        while(j>0)
        {
            r=j%10;
            j=j/10;
        }
        mp[make_pair(l,r)]++;
    }
    long long int ans=0;
    for(auto it:mp)
    {
        ans=ans+it.second*mp[make_pair(it.first.second,it.first.first)];
    }
    cout<<ans;

}

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

char buf[50010];

int main(){
	string s;
	getline(cin, s);
	const char *ptr = s.c_str();
	
	vector<string> key;
	int d = 0;
	while( sscanf(ptr, ".%[^.]%n", buf, &d) > 0 ){
		ptr += d;
		key.push_back(buf);
	}
	
	int m = 0;
	int prev = -1;
	int indent = -1;
	int k = 0;
	while(true){
		getline(cin, s);
		if( s.size() < 2 ) break;

		ptr = s.c_str();
		sscanf(ptr, " %n%[^:]:%n", &indent, buf, &d);

		if( indent <= prev ) break;
		
		if( m == -1 ) m = indent;
		
		if( m == indent && key[k] == buf ){
			m = -1;
			prev = indent;
			
			if( ++k == key.size() ){
				if( s[d] == ' ' ){
					cout << "string \"" << s.substr(d + 1) << "\"\n";
				}
				else{
					cout << "object\n";
				}
				
				return 0;
			}
		}
	}
	
	cout << "no such property\n";
}

Measured memory_bytes: 1300
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <list>

#define N 100000

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

ll leastMaxPow2(ll n)
{
    // nが0以下の時は0とする。
    if (n <= 0) return 0;

    // (n & (n - 1)) == 0 の時は、nが2の冪乗であるため、そのままnを返す。
    if ((n & (n - 1)) == 0) return (ll)n;

    // bitシフトを用いて、2の冪乗を求める。
    ll ret = 1;
    while (n > 0) { ret <<= 1; n >>= 1; }
    return ret;
}

int main() {
  ll i, j;
  ll temp;
  int n;
  int n_check = 0;

  // vector<ll> test = {3};
  // vector<ll>::iterator temp_lb;
  // temp_lb = lower_bound(test.begin(), test.end(), 1);
  // cout << "find 1: "<< *temp_lb << endl;
  // // cout << "find 1: " << temp_lb << *temp_lb << endl;
  
  // temp_lb = lower_bound(test.begin(), test.end(), 3);
  // cout << "find 3: "  << *temp_lb << endl;
  // temp_lb = lower_bound(test.begin(), test.end(), 5);
  // cout << "find 5: "  << *temp_lb << endl;

  // cout << "end: " << *(test.end()) << endl;
  // cout << (temp_lb == test.end()) << endl;

  // test.erase(test.begin());
  // cout << test.size() << endl;

  // return 0;

  scanf("%d", &n);
  // array<ll, N> ar;
  // vector<ll> ar(n);
  vector<ll> v(n);
  // list<ll> ar;
  for (i = 0; i < n; i++) {
    scanf(" %lld", &v[i]);
    // scanf(" %lld", &temp);
    // ar.push_back(temp);
    n_check++;
  }
  // printf("%d", n_check);

  // for (i = 0; i < n; i++) {
  //   printf("%lld\n", ar[i]);
  // }
  // printf("end\n");

  sort(v.begin(), v.end());
  // ar.sort();
  // list<ll> ar(v.begin(), v.end());
  // vector<ll> ar = v;
  // vector<ll>::iterator lb, tend;
  deque<ll> ar(v.begin(), v.end());
  deque<ll>::iterator lb, tend;
  // tend = ar.end();
  // cout << *tend << endl;

  int count = 0;
  ll last, lm, fn;
  while (ar.size()>1) {
    last = ar.back();
    // cout << "last: " << last << endl;
    ar.pop_back();
    lm = leastMaxPow2(last);
    if(lm==last){
      lm <<= 1;
    }
    fn = lm - last;
    lb = lower_bound(ar.begin(), ar.end(), fn);  // binary search
    // if(lb == ar.end()){
    //   break;
    // }
    if(*lb==fn && lb != ar.end()){
      count++;
      ar.erase(lb);
    }

    // for (auto x = ar.begin(); x != ar.end(); ++x) {
    //   temp = *x + last;
    //   if (!(temp & (temp - 1))) {
    //     count++;
    //     ar.erase(x);
    //     break;
    //   }
    // }
  }

  printf("%d", count);

  
  return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll INF=1e18;

int main()
{
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll min_all=min({a,b,c,d,e});
    cout << (n-1)/min_all+1+4 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    int res = 0;
    REP(i, 1, n/2+1){
      int sum = 0;
      for(int j = i; sum <= n; j++){
	sum += j;
	if(sum == n) res++;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void){
	
	int a, b;

	scanf("%d %d",&a,&b);
	
	if(a < b){
		printf("a < b\n");
	}else if(a > b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	
	return 0 ;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,k,aa[110000],cnt=0,a=INF;
pair<int,string> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
    }
    rep(i,100){
        rep(j,n){
            cnt+=(i+1-aa[j])*(i+1-aa[j]);
        }
        a=min(a,cnt);
        cnt=0;
    }
    cout<<a;
}

Measured memory_bytes: 5376
S['= r'],m[4]['= r'],z,d[4]={0,-2},k,i;f(i){m[k][i]=S[i]+47?0:m[k][i]?:1+f(d[k]-~i);}main(t){for(scanf("%*d%d ",d),d[2]=-*d-2;S[i-~*d]=~getchar();++i);for(;i--;z=fmax(z,t))for(t=k=0;k<4;++k)t+=f(i-~*d);printf("%d",z-3);}

Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 2000000000000
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    cout<<a*b-a-b+1;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{



	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String[] tmp = scanner.nextLine().split(" ");
		int n        = Integer.parseInt(tmp[0]);
		int k        = Integer.parseInt(tmp[1]);
		int[] list   = new int[n];
		int count    = Integer.MAX_VALUE;

		for(int i = 0; i < n; i++) {
			list[i] = Integer.parseInt(scanner.nextLine());
		}

		Arrays.parallelSort(list);

		for(int i = 0; i < n - k + 1; i++) {

			count = Math.min(Math.abs(list[i] - list[i + k - 1]), count);

		}

		System.out.println(count);

	}
}


Measured memory_bytes: 61132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    string S;
    cin >> S;
    int N = S.size();
    for (int L = N - 1; L > 1; --L) {
        if (L % 2 == 1) continue;
        string _S = S.substr(0, L);
        string s1 = _S.substr(0, L / 2);
        string s2 = _S.substr(L / 2, L / 2);
        if (s1 == s2) {
            cout << L << endl;
            exit(0);
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    lli N, M;
    cin >> N >> M;
    lli ans = 0;
    if (2 * N >= M) {
        ans = M / 2;
    } else {
        ans = N;
        M -= (2 * N);
        ans += M / 4;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break
    
    num_list = list(map(int, input().split()))
    
    average = sum(num_list) / len(num_list)
    
    sum1 = 0
    for i in num_list:
        sum1 += (i-average)**2
        
    sd = math.sqrt(sum1/len(num_list))
    
    print(sd)



Measured memory_bytes: 5700
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
S=input()
ABCABC = [chr(65+(i%26)) for i in range(52)]

for c in S:
    print(ABCABC[ord(c)-65+N], end='')

print('')


Measured memory_bytes: 4596
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
S = input()

cnt = 0
for a in range(10):
    aa = S.find(str(a))
    if aa == -1:
        continue

    for b in range(10):
        bb = S.find(str(b), aa + 1)
        if bb == -1:
            continue

        for c in range(10):
            cc = S.find(str(c), bb + 1)
            # print(a,b,c,end=", ")
            if cc != -1:
                cnt += 1
                # print(a,b,c,end=", ")

print(cnt)


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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int ac,wa,tle,re;
int main(){
	int n;cin>>n;
	for(int i=0;i<n;++i){
		string s;cin>>s;
		if(s=="AC")++ac;
		if(s=="WA")++wa;
		if(s=="TLE")++tle;
		if(s=="RE")++re;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3632
N, M = list(map(int, input().split()))
a = []
for _ in range(M):
    a.append(int(input()))
a = sorted(list(set(a)))
if len(a)>0:
    dif = [a[0]-1]
    dif.extend([(a[i]-1)-(a[i-1]+1) for i in range(1,len(a))])
    dif.extend([N-a[-1]-1])
else:
    dif = [N]
max_dif = max(dif)
Fiblist = {-1:0,0:1,1:1,2:2}
for n in range(3,max_dif+1):
    Fiblist[n]=Fiblist[n-1]+Fiblist[n-2]
ans = 1
for part in dif:
    ans= ans*Fiblist[part]%1000000007
print(ans)

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

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

  // 400-599 / 200 = 2
  // 600-799 / 200 = 3
  // ...
  // 1800-1999 / 200 = 9
  int kyu = 10 - X / 200;
  cout << kyu << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = -INF;
  ans = max(a*c,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main() {
	int a,b;
	cin >> a >> b;
	int dif = b - a;
	int west;
	for(int i = 0; i < dif; i++){
		west += i;
	}
	int ans = west - a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<string.h>
using namespace std;
int main()
{
    int d;
    scanf("%d",&d);
    double f=d*1.0/3;
   double f1=pow(f,3);
   printf("%lf",f1);
        return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  char c;
  cin >> c;
  if(c=='A')printf("T");
  if(c=='T')printf("A");
  if(c=='C')printf("G");
  if(c=='G')printf("C");
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<int> p;
	
	cin>>N>>K;
	
	p.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>p[i];
	}
	
	sort(p.begin(), p.end());
	
	
	int ans = 0;
	
	for(int i = 0; i < K; i++){
		ans += p[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
using namespace std;
int s(int x, int y) {
  if (x <= y)
    return y - x;
  else
    return x - y + 2;
}
int main() {
  int x, y, res = 2000000000;
  scanf("%d %d", &x, &y);
  res = min(res, s(x, y));
  res = min(res, s(-x, y) + 1);
  res = min(res, s(x, -y) + 1);
  res = min(res, s(-x, -y) + 2);
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define deb(x) cerr << #x << ":" << x << endl;
#define deba(x) cerr << #x << ":\n"; for(auto i: x) cerr << i << " ";cout << endl;
const int INF = 1e7 + 7, MOD = 1e9 + 7;
#define float double
const float EPS = 0.001;
bool feq(float a, float b) { return abs(a - b) < EPS; }
bool fgt(float a, float b) { return a - b > EPS; }
bool flt(float a, float b) { return a - b < EPS; }



int main() {
	fastio();
	int n;
	cin >> n;
	ll s = 0;
	for(int a=1; a<n; a++) {
		s += (n%a == 0 ? n/a - 1 : n/a);
	}
	cout << s << '\n';
	return 0;
}



Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

void solve() {
	int n;
	string s;
	cin >> n >> s;
	int r = 0, w = 0;
	vector<int> pref(n + 1, 0);
	for (int i = 0; i < n; i++) {
		pref[i + 1] = pref[i];
		if (s[i] == 'R') {
			r++;
			pref[i + 1]++;
		}
		else
			w++;
	}
	int ans = (r == 0 ? 0 : 1e9);
	for (int i = 0; i < r; i++) {
		ans = min(ans, (i + 1 - pref[i + 1]) + r - i - 1);
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 4396
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

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

double start;

unsigned rando() {
	static unsigned y = 2463534242;
    y ^= y << 13;y ^= y >> 17;y ^= y << 5;
    return y;
}

double sec() {
	struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + tv.tv_usec * 1e-6;
}

double pastTime() {
	return sec() - start;
}

int d;

int c[26];
int s[365][26];

int score(vector<int>& t) {
	int score = 0;
	vector<int> last(26,0);
	rep(i, d) {
		score += s[i][t[i]];
		last[t[i]] = (i + 1);

		rep(j,26) {
			score -= ((i + 1) - last[j]) * c[j];
		}
		//cout  << score << endl;

	} 


	return score;

}

void output(vector<int>& t) {
	rep(i, d) {
		cout << t[i] + 1 << endl;
	}
}


int main() {
	


	cin >> d;
	rep(i, 26) {
		cin >> c[i];
	} 
	rep(i, d) {
		rep(j,26) {
			cin >> s[i][j];
		}
	}
	start = sec();
	vector<int> t(d);

	rep(i, d) {
		t[i] = rando() % 26;
	}

	int cur = score(t);


	while(pastTime() < 1.8) {
		vector<int> nt = t;
		rep(i ,2) {
			nt[rando() % d] = rando() % 26;
		}
		int next = score(nt);
		if (cur < next) {
			t = nt;
			cur = next;
		}
	}

	output(t);

	//cout << "score:" <<  << endl;

	return 0;
}


Measured memory_bytes: 3240
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
	int a,b,c,d,e,f;
	scanf("%d",&a);
	e=0;
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=a;j++)
		{
			for(int k=1;k<=a;k++)
			{
				d=__gcd(i,j);
				f=__gcd(d,k);
				e+=f;
			}
		}
	}	
	printf("%d\n",e);
}

Measured memory_bytes: 1732
#include <climits>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i, N) { cin >> A[i] >> B[i]; }

  vector<int64_t> DP(H + 1, INT_MAX);
  DP[0] = 0;
  for (int h = 0; h < H; ++h) {
    for (int i = 0; i < N; ++i) {
      int next = h + A[i];
      if (next > H) next = H;
      DP[next] = min(DP[next], DP[h] + B[i]);
    }
  }
  cout << DP[H] << endl;
  return 0;
}


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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int num = 100*r + 10*g + b;
  if (num % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	string s;
	cin >> s;

	if ( s == "ABC" ) {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}

	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int len = String.valueOf(n).length();
        int count = 0;
        for (int i=1; i<=len; i++) {
            if (i % 2 == 1 && i == len) {
                count += n - Math.pow(10, i-1) + 1;
            } else if (i % 2 == 1) {
                count += 9 * Math.pow(10, i-1);
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 35840
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<cmath>

using namespace std;

#define f first
#define s second


int main(){
    
    int n;
    cin >> n;
    
    vector<pair<int, pair<int, int> > > v;
    set<int> b;

    int idx = 0, ans = 0;

    for(int i = 0; i < 2*n; i++){
         int x, y;
         cin >> x >> y;     
         if(i == n) idx = 1;
         v.push_back(make_pair(x, make_pair(y, idx)));
      }
    

    sort(v.begin(), v.end());


    for(int i = 0; i < 2*n; i++){

        if(v[i].s.s == 0){
             b.insert(v[i].s.f);
         }
        else{
            int di = v[i].s.f;

            for(set<int>::reverse_iterator it = b.rbegin(); it != b.rend(); it++){
                 if((*it) < di){
                      ans++; b.erase((*it)); 
                      break;
                     }
                } 
            }
       }


     cout << ans;    

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m,a,r,c,h,el = [],[],[],[],[],[]
cnt=0
for i in range(n):
    if s[i][0]=='M': m.append(s[i])
    elif s[i][0]=='A': a.append(s[i])
    elif s[i][0]=='R': r.append(s[i])
    elif s[i][0]=='C': c.append(s[i])
    elif s[i][0]=='H': h.append(s[i])
    else:el.append(s[i])
march =[len(x) for x in [m,a,r,c,h]]
for i in range(5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            cnt += march[i]*march[j]*march[k]
print(cnt)

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

int main() {

  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }

  int d = 0;

  for (int i = 0; i < N; i++) {
    if (K / 2 < x[i]) {
      d += K - x[i];
    } else {
      d += x[i];
    }
  }

  cout << d * 2 << endl;

}

Measured memory_bytes: 256
#include <iostream>
typedef long long LL;
using namespace std;
int main(int argc, char* argv[])
{
	LL N,A,B;
	cin>>N>>A>>B;
	LL n=N/(A+B);
	LL r=N%(A+B);
	LL ans=n*A;
	if (r<=A){
		ans+=r;
	}else{
		ans+=A;
	}
	cout<<ans<<endl;

	return 0;
}

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

int main(){
  int N;cin >> N;
  vector<int> vec(N);
  for(x:vec){
    cin >>x;
  }
  sort(vec.begin(), vec.end());
  for(int i=1;i<N;i++){
    if(vec.at(i-1)==vec.at(i)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
N,A,B = map(int,input().split())
def digit_sum(n):
    sum = 0
    while (n>0):
        sum += n%10
        n = int(n/10)
    return(sum)

ans = 0
for i in range(N+1):
    a = digit_sum(i)
    if A <= a <= B:
        ans += i
#        print(i)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
    int a,b,c;
    int sum;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b||b==c||a==c)
        sum = 2;
    if(a==b&&a==c&&b==c)
        sum = 1;
    if(a!=b&&a!=c&&b!=c)
        sum = 3;
    printf("%d",sum);
    return 0;
}


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

int main(){
    int r,d;
    cin >> r >> d;
    vector<int> x(11);
    cin >> x[0];
    rep(i,10){
        x[i+1] = r * x[i] - d;
        cout << x[i+1] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}


signed main(void)
{
	IOS;
	int n,k; cin>>n>>k;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	sort(all(a), greater<int>());
	for(int i = 0; i < min(k,n); i++) {
		a[i]=0;
	}
	int ans=0;
	for(int i = 0; i < n; i++) {
		if(a[i]) {
			ans += a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
 
const int N=1e5+20;
 
int n,k,a[N],dp[N];
 
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
 
	for(int i=2;i<=n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=1;j<=k and i-j>0;j++)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	printf("%d\n",dp[n]);
}

Measured memory_bytes: 4528
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;

int main(){
    string S;
    cin >> S;
    string ans="";
    rep(i,S.size()){
        if (S[i]=='0'||S[i]=='1'){
            ans += S[i];
        }
        else if(ans.size()>0){
            ans.erase(ans.size() - 1);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

vector<vector<int>> G;

int dfs(int u) {
    if (G[u].size() == 0) return 0;
    vector<int> S;
    for (int v : G[u]) S.push_back(dfs(v));
    sort(S.rbegin(), S.rend());
    int ans = 0;
    rep(i, S.size()) ans = max(ans, S[i] + i + 1);
    return ans;
}

int main() {
    int N;
    cin >> N;
    G = vector<vector<int>>(N);
    for (int i = 1; i < N; ++i) {
        int a;
        cin >> a;
        --a;
        G[a].push_back(i);
    }
    cout << dfs(0) << "\n";
    return 0;
}


Measured memory_bytes: 15104
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath> 
using namespace std; 
int main()
{
	int n, k; 
	cin >> n >> k; 
	int ans = k; 
	for (int i = 0; i < n-1; i++)
	{
		ans *= k - 1;
	} 
	cout << ans << endl;
		
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N), V(N, 2e9);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  V.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i + k < N) V.at(i + k) = min(V.at(i + k), V.at(i) + abs(H.at(i + k) - H.at(i)));
    }
  }
  cout << V.at(N - 1) << "\n";
}

Measured memory_bytes: 4024
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

m = 0
for i in range(n):
    e = a[i] - 1
    m += b[e]
    if i > 0 and a[i - 1] == a[i] - 1:
        m += c[a[i - 1] - 1]

print(m)


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

int main() {
  int N;
  cin >> N;
  int s = 0;
  
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    
    s = s + (r - l + 1);
  }
  
  cout << s << endl;
}


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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i], A[i]--;

  vector<vector<ll>> cnt(2, vector<ll>(100000, 0));
  REP(i, 0, N) cnt[i % 2][A[i]]++;

  vector<ll> x(2);
  REP(i, 0, N) x[i % 2]++;

  vector<pair<ll, ll>> se;
  REP(i, 0, 100000) se.push_back(make_pair(cnt[1][i], i));
  sort(se.begin(), se.end(), greater<pair<ll, ll>>());

  ll ans = 1LL << 60;
  REP(i, 0, 100000) {
    ll p = x[0] - cnt[0][i];
    ll q = x[1] - se[0].first;
    if (se[0].second == i) {
      if (se.size() >= 2) q = x[1] - se[1].first;
      else q = x[1];
    }
    ans = min(ans, p + q);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6768
while True:
    n,p = map(int,input().split())
    if n == 0 and p == 0:
        break
    b = p
    x = [0 for i in range(n)]
    cnt = 0
    while True:
        if b != 0:
            b -= 1
            x[cnt] += 1
            if b == 0 and x[cnt] == p:
                print(cnt)
                break
        else:
            b += x[cnt]
            x[cnt] = 0
        cnt = (cnt + 1) % n
        


Measured memory_bytes: 5604
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  string S;
  cin >> S;
  int len = S.length();
  if(S[len-1] == 's'){
    S = S + "es";
  }else{
    S = S + "s";
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

ll p5(ll x){
    ll ret = 1;
    for(int i=0; i<5; i++) ret *= x;
    return ret;
}

int main()
{
    ll X;
    cin >> X;

    ll mA = 3000;
    for(ll A=0; A<=mA; A++){
        for(ll B=0; B<=A; B++){
            ll pA = p5(A);
            ll pB = p5(B);
            if(pA - pB == X){
                cout << A << " " << B << endl; return 0;
            }
            if(pA + pB == X){
                cout << A << " " << -B << endl; return 0;
            }
        }
    }
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long int ULL;
typedef long long LL;
typedef long double LD;

LL mod = 1000000007;

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

	string s;
	cin >> s;

	for (auto &e : s) {
		e += n;
		if (e > 'Z') {
			e -= 26;
		}
		cout << e;
	}
	cout << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long solve(const vector<long long>& v, int k)
{
    int n = v.size();

    long long ans = 0;
    for(int i=62; i>=0; --i){
        ans |= 1LL << i;
        int cnt = 0;
        for(int j=0; j<n; ++j){
            if(!(ans & ~v[j]))
                ++ cnt;
        }
        if(cnt < k)
            ans &= ~(1LL << i);
    }
    return ans;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    vector<long long> v;
    for(int i=0; i<n; ++i){
        long long sum = 0;
        for(int j=i; j<n; ++j){
            sum += a[j];
            v.push_back(sum);
        }
    }
    cout << solve(v, k) << endl;

    return 0;
}


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

int main(){
    string A;
    cin >> A;

    int N = A.length();

    int n=0;
    int k=0;

    if(A[0]!='A') {
        cout << "WA" << endl;
        return 0;
    }
    else{
        for(int j=1;j<=N-1;j++){
            if(A[j]>='a' && A[j]<='z')n++;
            else k=j;
        }

        if(n!=N-2) {
            cout << "WA" << endl;
            return 0;
        }
        else if (k>=2 && k<=N-2) {
            cout << "AC" << endl;
            return 0;
        }
        else cout << "WA" << endl;
    }

    return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int root[100000];
int getRoot(int v){ return root[v] == -1 ? v : root[v] = getRoot(root[v]); }

class Edge {
public:
    explicit Edge(int s=0, int d=0, int w=0) : src(s), dst(d), w(w) {}
    int src, dst, w;
    bool operator < (const Edge& e) const { return w < e.w; }
};

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<long long> w(N);
        for(auto& t : w) cin >> t;
        vector<vector<Edge>> g(N);
        vector<Edge> edges(M);
        for(auto& e : edges){
            cin >> e.src >> e.dst >> e.w;
            --e.src; --e.dst;
            g[e.src].emplace_back(e.src, e.dst, e.w);
            g[e.dst].emplace_back(e.dst, e.src, e.w);
        }
        sort(edges.begin(), edges.end());
        vector<int> lastEdge(M, 0);
        vector<long long> wSum = w;
        fill(root, root+N, -1);
        for(int i=0;i<M;){
            int end = i;
            while(end < M && edges[i].w == edges[end].w) ++end;
            for(int j=i;j<end;j++){
                int p = getRoot(edges[j].src);
                int q = getRoot(edges[j].dst);
                if(p != q){
                    root[q] = p;
                    wSum[p] += wSum[q];
                }
            }
            for(int j=i;j<end;j++){
                int p = getRoot(edges[j].src);
                if(edges[j].w <= wSum[p]) lastEdge[j] = 1;
            }
            i = end;
        }
        int res = M;
        vector<int> visit(N, 0);
        for(int i=M-1;i>=0;i--){
            if(!lastEdge[i]) continue;
            if(visit[edges[i].src]) continue;
            queue<int> qu;
            qu.push(edges[i].src);
            qu.push(edges[i].dst);
            visit[edges[i].src] = visit[edges[i].dst] = 1;
            const int maxW = edges[i].w;
            int check = 0;
            while(!qu.empty()){
                int pos = qu.front(); qu.pop();
                for(auto& e : g[pos]){
                    if(e.w > maxW) continue;
                    check++;
                    if(!visit[e.dst]){
                        visit[e.dst] = 1;
                        qu.push(e.dst);
                    }
                }
            }
            res -= check/2;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 10624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int team = 0;
			int c = sc.nextInt();
			int a = sc.nextInt();
			int n = sc.nextInt();
			while (true) {
				if (c < 1 || a < 1 || n < 1) {
					break;
				}
				team++;
				c--;
				a--;
				n--;
			}
			while(true) {
				if (c < 2 || a < 1) {
					break;
				}
				team++;
				c -= 2;
				a--;
			}
			while(true) {
				if (c < 3) {
					break;
				}
				team++;
				c -= 3;
			}
			System.out.println(team);
		}
		sc.close();
	}
}

Measured memory_bytes: 27320
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  if(400 <= n && n <= 599) cout << 8 << endl;
  else if(600 <= n && n <= 799) cout << 7 << endl;
  else if(800 <= n && n <= 999) cout << 6 << endl;
  else if(1000 <= n && n <= 1199) cout << 5 << endl;
  else if(1200 <= n && n <= 1399) cout << 4 << endl;
  else if(1400 <= n && n <= 1599) cout << 3 << endl;
  else if(1600 <= n && n <= 1799) cout << 2 << endl;
  else if(1800 <= n && n <= 1999) cout << 1 << endl;
  return 0;
}
  
  
  
  

Measured memory_bytes: 3616