akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int A, B;
	int C[] = { 0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1 };
	cin >>A >> B;
	if (C[A] == C[B])
		cout << "Yes";
	else
		cout << "No";
}

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

using namespace std ;

void print2dvector(vector<vector<double> > v){
    for (int i=0 ; i<v.size() ; i++){
        for (int j=0 ; j<v[0].size() ; j++)
            cout << v[i][j] << " " ;
        cout << "\n" ;
    }
}

double prob(vector<double> &p){
    int n = p.size() ;
    vector< vector < double> > dp(n+1, vector<double> (n+1, 0.0)) ;
    dp[0][0] = 1 ;
    
    for (int i=1 ; i<=n ; i++){
        for (int j=0 ; j<=n ; j++){
            if (j == 0)
                dp[i][j] = dp[i-1][j]*(1-p[i-1]) ;
            else
                dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1] ;
        }
    }
    
    double probability = 0 ;
    for (int i=n/2+1 ; i<=n ; i++ )
        probability += dp[n][i] ;
    
//    print2dvector(dp) ;
    
    return probability ;
}

int main(){
    int n ;
    cin >> n ;
    
    vector<double> p(n) ;
    
    for (int i=0 ; i<n ; i++)
        cin >> p[i] ;
    
    cout << setprecision(10) << prob(p) << "\n" ;
    
    return 0 ;
}


Measured memory_bytes: 73400
#include<iostream>
#include<algorithm>
#include <vector>
using namespace std;

int n;
vector<int> l(200,1000);
int main (){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >>l[2*i]>>l[2*i+1];
        //cout << l[2*i]<<l[2*i+1]<<endl;
    }
    sort(l.begin(),l.end());
    int x=0;
    for(int i=0;i<n;i++){
        x=x+l[2*i];
        //cout << l[2*n]<<l[2*n+1]<<endl;
    }
    cout << x << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  string n;
  cin>>n;
  int ans=0;
  for(int i=0;i<4;i++)ans+=(n[i]=='2');
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
a=int(N/100)
b=int((N-100*a)/10)
c=N-100*a-10*b
if c==3:
  print("bon")
elif c==0 or c==1 or c==6 or c==8:
  print("pon")
else:
  print("hon")
  

Measured memory_bytes: 9176
#include <iostream>
int main(){
	int a,y;
	std::cin >> a;
	int x[a];
	for(int b = 0;b < a;b++){
		std::cin >> y;
		x[b] = y;
	}
	for(int c = a-1;c >= 0;c--){
		std::cout <<x[c];
		if(c > 0){
			std::cout <<" ";
		}
	}
	std::cout<<std::endl;
}

Measured memory_bytes: 3076
#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=1e9+7;

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> l(n+1);
    vector<ll> r(n+1);
    ll cnt_l=0;
    ll cnt_r=0;
    l[0]=0;
    r[0]=0;
    rep(i,n){
        if(s[i]=='W'){
            cnt_l++;
        }
        if(s[n-1-i]=='E'){
            cnt_r++;
        }
        l[i+1]=cnt_l;
        r[i+1]=cnt_r;
    }
    ll ans=INF;
    for(ll i=1;i<=n;i++){
        ans=min(ans,l[i-1]+r[n-i]);
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 5380
N = int(input())
anslist = []
i = 0
j = 1
key = 0
while True:
    if N == 0:
        break
    if N % pow(-2, i + 1) != 0:
        anslist.append(1)
        N -= pow(- 2, i)
        key += pow(-2, i)
    else:
        anslist.append(0)
    i += 1
    #print(anslist)
if len(anslist) == 0:
    anslist.append(0)
for i in anslist[::-1]:
    print(i, end = "")
print()


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	switch(a){
		case 25: cout<<"Christmas"<<endl;
		break;
		case 24: cout<<"Christmas Eve"<<endl;
		break;
		case 23: cout<<"Christmas Eve Eve"<<endl;
		break;
		case 22: cout<<"Christmas Eve Eve Eve"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sun Oct  1 01:28:54 2017
//

#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int32_t main()
{
  string problems;
  cin >> problems;

  uint32_t count = 0;
  for(uint32_t i = 0; i < problems.size(); i++){
    if(problems[i] == '1'){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  
  if (S[0] == T[2] && S[1] == T[1] && S[2] == T[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3524
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int T = fs.nextInt();
        int A = fs.nextInt();
        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < N; ++i) {
            list.add(fs.nextInt());
        }

        int ans = 0;
        double res = Double.MAX_VALUE;
        for (int i = 0; i < N; ++i) {
            double tmp = T - (list.get(i) * 0.006);
            if (res > Math.abs(tmp - A)) {
                res = Math.abs(tmp - A);
                ans = i;
            }
        }

        System.out.println(++ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

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

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

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

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




Measured memory_bytes: 32604
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while True:
  if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    break
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)

Measured memory_bytes: 9268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = 3;
        int arr[] = new int[n];
        for(int i=0;i<n;i++)arr[i] = s.nextInt();
        Arrays.sort(arr);
        int cnt = 0;
        for(int i=1;i<n;i++){
            cnt+=(arr[i]-arr[i-1]);
        }
        System.out.println(cnt);

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25400
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        h:i64,w:i64,
    }
    let a = h * w;
    if h == 1 || w == 1 {
        println!("{}", 1);
        return;
    }
    if a % 2 == 0 {
        println!("{}", a / 2);
    } else {
        println!("{}", a / 2 + 1);
    }
}


Measured memory_bytes: 2152
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}

template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }

template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}

template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> bool update_min(T &a, const T &b) { a = min(a, b); }

struct BoolName : numpunct<char> {
  string t, f;
  BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const { return t; }
  string do_falsename() const { return f; }
};

class Solver {
public:
  int A, B, ans;
  Solver() {}
  void input() {
    cin >> A >> B;
  }
  void solve() {
    vi v;
    rep(i, A+1)v.push_back(i);
    rep(j, B+1)v.push_back(j);
    rsort(v);
    ans = v[0] + v[1];
  }
  void output(){
    cout << ans <<endl;

  };
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
#define ll long long

const ll mod = 1000000007;

int H, W, K;
ll dp[110][15];


ll sub(int n){
	if(n <= 0){
		return 1;
	}else if(n == 1){
		return 2;
	}else{
		return sub(n-1) + sub(n-2);
	}
}

int solve(){
	if(W == 1){
		cout << 1 << endl;
		return 0;
	}


	//初期値
	dp[0][0] = 1;
	for(int i=1;i<W;i++){
		dp[0][i] = 0;
	}

	for(int i=1;i<=H;i++){
		for(int j=0;j<W;j++){
			if(j == 0){
				dp[i][j] = sub(W-2)*dp[i-1][j] + sub(W-3)*dp[i-1][j+1];
			}else if(j == W-1){
				dp[i][j] = sub(W-3)*dp[i-1][j-1] + sub(W-2)*dp[i-1][j];
			}else{
				dp[i][j] = sub(j-2)*sub(W-2-j)*dp[i-1][j-1] + sub(j-1)*sub(W-2-j)*dp[i-1][j] + sub(j-1)*sub(W-3-j)*dp[i-1][j+1];
			}
			dp[i][j] %= mod;
		}
	}

	cout << dp[H][K-1] << endl;
	return 0;

}

int main(){
	cin >> H >> W >> K;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll S;
    cin >> S;
    if(S == 1000000000000000000){
        cout <<0<< "\n";
        cout <<0<< "\n";
        cout <<1000000000<< "\n";
        cout <<0<< "\n";
        cout <<0<< "\n";
        cout <<1000000000<< "\n";
    }else{
        cout <<0<< "\n";
        cout <<0<< "\n";
        cout <<1000000000<< "\n";
        cout <<1<< "\n";
        cout <<1000000000*(S/1000000000 + 1) - S<< "\n";
        cout <<S/1000000000 + 1<< "\n";
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,i,j,temp;
	int ice[10];
	
	while(scanf("%d",&n)!=0)
	{
		if(n==0)
		{
			break;
		}
		else
		{
			for(i=0;i<10;i++)
			{
				ice[i]=0;
			}
			for(i=0;i<n;i++)
			{
				scanf("%d",&temp);
				ice[temp]++;
			}
			for(i=0;i<10;i++)
			{
				if(ice[i]==0)
					printf("-\n");
				else
				{
					for(j=0;j<ice[i];j++) printf("*");
					printf("\n");
				}
			}
		}
	}
	return 0;
}

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


int res=0;

bool saiki(int ball[],int ttB,int ttC,int res){
	if(res==10)return true;
	if(ball[res]>ttB){
		return saiki(ball,ball[res],ttC,res+1);
	}
	if(ball[res]>ttC){
		return saiki(ball,ttB,ball[res],res+1);
	}
	return false;
}

int main(void){
	int a,b;
	int ball[11];
	int ttB=0,ttC=0;
	int n;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		for(b=0;b<10;b++){
			ball[b]=0;
		}
		ttB=0;
		ttC=0;
		res=0;
		for(b=0;b<10;b++){
			scanf("%d",&ball[b]);
		}
		if(saiki(ball,ttB,ttC,res)==true)printf("YES\n");else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;
    ll ans = 0;

    cin >> n;

    vector<int> a(n);
    map<ll, ll> m;

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

    for (auto x : m)
    {
        ans += x.second * (x.second - 1) / 2;
    }

    for (int i = 0; i < n; i++)
    {
        cout << ans - m[a[i]] * (m[a[i]] - 1) / 2 + (m[a[i]] - 1) * (m[a[i]] - 2) / 2 << endl;
    }
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	long long res = 0;
	for (long long i = 1; i <= n; ++i){
		if (i%3 && i%5){
			res += i;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3608
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
 int gcd(int a, int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
  
// Function to return LCM of two numbers  
  int lcm(int a, int b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
void solve()
{
   ll x,l;cin>>x;
  l=lcm(360,x);
  cout<<l/x<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3608
#2bit生成　ON=1 OFF=2
import itertools
L = [0,1]
count = 0

N,M = map(int,input().split())
k = []
s = []

for i in range(M):
    tmp = list(map(int,input().split()))
    k.append(tmp[0])
    s.append(tmp[1:])

p = list(map(int,input().split()))

bit_list = list(itertools.product([0,1],repeat = N))

for i in bit_list:
    
    for j in range(M):
        #電球Mのチェック
        counter = 0
        tmp = list(s[j])
        
        for l in tmp:
            if i[l-1] == 1:
                counter += 1
        
        if counter % 2 != p[j]:
            break
        
        if j == M-1:
            count += 1

print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
int main() {
    int n;
    cin >> n;
    vector<int>v(n);
    vector<pair<int,int>>cnt1(100001);
    vector<pair<int, int>>cnt2(100001);
    rep(i, 0, n){
        cin >> v[i];
        if(i%2==0)cnt1[v[i]].second=v[i];
        else cnt2[v[i]].second=v[i];
    }
    rep(i, 0, n){
        if(i%2==0)cnt1[v[i]].first++;
        else cnt2[v[i]].first++;
    }
    sort(cnt1.begin(),cnt1.end(), greater<pair<int, int>>());
    sort(cnt2.begin(),cnt2.end(), greater<pair<int, int>>());
    if(cnt1[0].second!=cnt2[0].second)cout << n-cnt1[0].first-cnt2[0].first << endl;
    else{
        if((cnt1[0].first - cnt1[1].first)-(cnt2[0].first - cnt2[1].first)>=0){
            cout << n - cnt1[0].first-cnt2[1].first << endl;
        }else{
            cout << n - cnt1[1].first-cnt2[0].first << endl;
        }
    }
}

Measured memory_bytes: 2176
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int Top=6666666666666666;
int n,m,cnt=0;
int head[410000],nxt[410000],to[410000],val[410000];
int ma=0,mi=0;
int q[1000000],dis[100100],f[100100],vis[100100];
void addedge(int x,int y,int z)
{
    cnt++;
    nxt[cnt]=head[x];
    head[x]=cnt;
    to[cnt]=y;
    val[cnt]=z;
}
bool spfa(int x)
{
    int l=0,r=1;
    q[1]=x;vis[x]=1;dis[x]=0;
    while(l<r)
    {
        int u=q[++l];
        for(int i=head[u];i!=-1;i=nxt[i])
        {
            int v=to[i];
            if(dis[v]==Top)
            {
                dis[v]=dis[u]+val[i];
                ma=max(ma,dis[v]);
                mi=min(mi,dis[v]);
                if(ma-mi>1e9) return 0;
                vis[v]=1;
                if(!f[v]) q[++r]=v,f[v]=1;
            }
            else if(dis[v]!=dis[u]+val[i]) return 0;
        }
        f[u]=0;
    }
    return 1;
}
signed main()
{
    memset(head,-1,sizeof(head));
    for(int i=1;i<=100000;i++)
        dis[i]=Top;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%lld%lld%lld",&x,&y,&z);
        addedge(x,y,z);
        addedge(y,x,-z);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i]) {if(!spfa(i)) {printf("No");return 0;}}
    printf("Yes");
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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 ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main() {
  vll a(5);
  vin(a);
  rep(i, 0, 5){
    if(a.at(i) == 0) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3624
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

int gcd(int a, int b) {
  int tmp = 0;
  while (b != 0) {
    if (b < a) {
      tmp = a;
      a = b;
      b = tmp;
    }
    b = b % a;
  }
  return a;
}

int gcd3(int a, int b, int c) {
  return gcd(gcd(a, b), c);
}

int main() {
  int k;
  long long sum = 0;
  scanf("%d", &k);
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        sum += gcd3(a, b, c);
      }
    }
  }
  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	ll M, c = 0, d = 0, dig = 0;
	cin >> M;
	vector<ll> D(M), C(M);
	for (int i = 0;i < M;i++) {
		cin >> D[i] >> C[i];
		dig += C[i] * D[i];
		c += C[i];
	}
	if (dig % 9 == 0) {
		cout << dig / 9 + c - 2 << endl;
	}
	else {
		cout << dig / 9 + c - 1 << endl;
	}
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
	double v;

	while(scanf("%lf", &v)!=EOF){
		double t=v/9.8;
		double y=4.9*t*t;
		double n=(y+5.0)/5.0;
		n+=1.0;
		printf("%d\n", (int)n);
	}

	return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    reverse(all(a));

    vi dp(n,INF);
    rep(i,n) *lower_bound(all(dp), a[i]+1) = a[i];
    cout << lower_bound(all(dp), INF) - dp.begin() << endl;
    return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    ll n, m; cin >> n >> m;

    priority_queue<ll> que;
    for (int i = 0; i < n; ++i) {
        ll a; cin >> a;
        que.push(a);
    }

    for (int i = 0; i < m; ++i) {
        ll t;
        t = que.top();
        que.pop();
        t = t / 2;

        que.push(t);
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll a;
        a = que.top();
        que.pop();
        ans += a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int K,X;
	cin>>K>>X;
	
	if(K*500>=X)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
    return 0;
}


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

void swap(int *data,int p,int c){
	int *tmp;
	
	tmp = (int *)malloc(c*sizeof(int));

	for(int i = 0;i < c;i++){
		tmp[i] = data[p+i-1];
	}
	for(int i = p-2;i >= 0;i--){
		data[i+c] = data[i];
	}
	for(int i = 0;i < c;i++){
		data[i] = tmp[i];
	}
}

void show(int *data,int n){
	for(int i = 0;i < n;i++){
		printf("%d\n",data[i]);
	}
}

int main(){
	int n,r,p,c;
	int *data;

	while(1){
		scanf("%d %d",&n,&r);
		if(n == 0 && r == 0){
			break;
		}

		data = (int *)malloc(n*sizeof(int));
		for(int i = 0;i < n;i++){
			data[i] = n-i;
		}

		//show(data,n);
		for(int i = 0;i < r;i++){
			scanf("%d %d",&p,&c);
			swap(data,p,c);
			//show(data,n);
		}

		printf("%d\n",data[0]);
	}

	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

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

Measured memory_bytes: 256
import sys
n=int(input())
s=[]
for i in range(n):
  s.append(int(input()))
if sum(s)%10!=0:
  print(sum(s))
else:
  s.sort()
  for j in range(n):
    if s[j]%10!=0:
      num=s[j]
      break
    if j==n-1:
      print(0)
      sys.exit()
  print(sum(s)-num)

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  char a, b; cin >> a >> b;

  if (a < b) cout << "<\n";
  else if (a == b) cout << "=\n";
  else cout << ">\n";
  
  return (0);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    vec A(N); readv(A);
    vector<Pii> p(N);
    set<Pii> s;
    SORT(A);
    REP(i, N){
        p[i] = Pii(A[i], i);
        s.insert(p[i]);
    }
    //SORT(p);
    s.insert(Pii(INF, N));

    vector<bool> used(N + 1, false);
    int ans = 0;
    IREP(i, N){
        if(used[i]) continue;
        int x = p[i].first;
        int n = 1;
        while(n <= x) n = (n << 1);
        int y = n - x;
        auto it = s.lower_bound(p[i]);
        //s.erase(it);
        if(s.size() == 0) continue;
        if(y <= x){
            auto it2 = s.lower_bound(Pii(y, -INF));
            //cout << (*it2).first << "," << (*it2).second << endl;
            if((*it2).first == y && (*it2).second < i){
                ans++;
                used[(*it2).second] = true;
                s.erase(it2);
            }
        }
        //cout << i << "," << x << "," << y << "," << ans << endl;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int dp[2][(1<<24)];
string s[501];
int n,m;
bool a[501][501];
int ans1;
bool used[501];

void dfs(int now,int cont){
  if(now==n){
    for(int i=0;i<m;i++){
      int tmp=0;
      for(int j=0;j<n;j++){
        if(used[j] && a[j][i])tmp++;
      }
      if(tmp&1)return;
    }
    ans1=max(ans1,cont);
    return;
  }
  used[now]=1;
  dfs(now+1,cont+1);
  used[now]=0;
  dfs(now+1,cont);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n>>m,n|m){
    for(int i=0;i<n;i++){
      cin>>s[i];
      for(int j=0;j<m;j++){
        a[i][j]=(s[i][j]=='1');
      }
    }
    if(n<=m){
      ans1=0;
      dfs(0,0);
      cout<<ans1<<endl;
    }else{
      int list[501];
      fill(list,list+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(a[i][j]){
            list[i]=list[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^list[i]]=max(dp[(i+1)&1][j^list[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      cout<<dp[n&1][0]<<endl;
    }
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 19880
#include <iostream>
using namespace std;
int main(void){
    
    int a[4][13]={{0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0},
        {0,0,0,0,0,0,0,0,0,0,0,0,0}};
    char m[4]={'S','H','C','D'};
    int i,j,num,n;
    char mark;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> mark >> num ;
        if (mark=='S') a[0][num-1]=1;
        else if(mark=='H') a[1][num-1]=1;
        else if(mark=='C') a[2][num-1]=1;
        else if(mark=='D') a[3][num-1]=1;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0){
                cout << m[i] <<" "<< j+1 << endl;
            }
        }
    }
   
}



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
main()
{
    int n;cin>>n;
    cout<<(long long)n*(n-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

//typedef long long ll;
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=3000;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}

long long comb(long long a, long long b){
    if(b<0 || a<b){
        return 0;
    }
    return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}

int main(){
  long long n,k;
  cin>>n>>k;
  invinit();
  long long res;
  for(long long i=1;i<=k;i++){
    res = mod(comb(k-1,i-1)*comb(n-k+1,i));
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
 long a1=0,a2=0,tot=0,c=0,r;
 char s[200000];
  scanf("%s",s);
  c=atoi(s);
  scanf("%s",s);
  a1=atoi(s);
        //	printf("+%d(%d)\n",0,a1);
    while ( c>1 ) {
    c--;
    scanf("%s",s);
    a2=atoi(s);
    if(a2<a1){
     // 	printf("+%d(%d)\n",a1-a2,a1);
    	tot=tot+(a1-a2);
    }else{
     // 	printf("+%d(%d)\n",0,a2);
    a1=a2;
    }
    }
    printf("%ld",tot);

}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long double a,b,c;
	cin>>a>>b>>c;
	long double x=sqrt(a);
	long double y=sqrt(b);
	long double z=sqrt(c);
	long double eps = 1.0E-14;
	if(x+y+eps<z){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}

	
	
	
	
	return 0;
}

Measured memory_bytes: 3800
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 ans=0,i;
        string s,t;
        cin>>s>>t;
        for(i=0;i<s.size();i++)
            if(s[i]==t[i])
                ans++;
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = sc.nextInt();

        int[] p = new int[N];
        int[] pp = new int[N];

        for(int i=0; i<N; i++){
            p[i] = sc.nextInt();
            pp[i] = i+1;
        }

        int count = 0;
        for(int i=0; i<N; i++){
            if(p[i] != pp[i]) count++;
        }

        println(count==2 || count==0 ? "YES" : "NO");
    }

    public static void println(Object o){
        System.out.println(o);
    }
    public static void print(Object o){
        System.out.print(o);
    }
}


Measured memory_bytes: 23892
n = gets.chop.to_i
bl = gets.chop.split.map(&:to_i)
al = []

n.times do |i|
  if i.zero?
    al.push(bl[i])
  else
    al.push(bl[(i - 1)..i].min)
  end
end

puts al.inject(&:+)


Measured memory_bytes: 1788
#include <iostream>
#include <string>

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

    for (auto i = 0; i < n; ++i)
    {
        std::cout << s[i] << t[i];
    }
    std::cout << std::endl;

    return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;




using Graph = vector<vector<int>>;

int pos = -1;
vector<int> hist; // 訪問履歴

void cycle_detect(int v, int p, vi &color, const Graph &G) {
    color[v] = 1;
    hist.pb(v);
    for (auto nv : G[v]) {
        //if (nv == p) continue; // 逆流禁止 有向グラフの場合コメントアウトせよ
        if (color[nv] == 2) continue;
        if (color[nv] == 1) {
            pos = nv;
            return;
        }
        cycle_detect(nv, v, color, G);
        if (pos != -1) return;
    }
    hist.pop_back();
    color[v] = 2;
}

int main() {
    int N, M; cin >> N >> M;

    Graph G(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
    }

    vi color(N, 0);
    for (int v = 0; v < N; ++v) {
        if (color[v] == 0) cycle_detect(v, -1, color, G);
        if (pos != -1) break;
    }

    if (hist.empty()) {
        cout << -1 << endl;
        return 0;
    }

    vector<int> cycle;
    while (!hist.empty()) {
        int t = hist.back();
        cycle.push_back(t);
        hist.pop_back();
        if (t == pos) break;
    }
    reverse(cycle.begin(), cycle.end());
    

    // サイクル中に「弦」があったら、小さくする
    while (true) {
        int from = -1, to = -1;
        vector<int> ord(N, -1);
        for (int i = 0; i < cycle.size(); ++i) ord[cycle[i]] = i;
        for (int i = 0; i < cycle.size(); ++i) {
            for (auto nv : G[cycle[i]]) {
                if (nv != cycle[(i + 1) % cycle.size()] && ord[nv] != -1) {
                    from = i, to = ord[nv];
                }
            }
        }
        if (from == -1) break; // 弦がなくなって終了

        vector<int> ncycle;
        ncycle.push_back(cycle[from]);
        int id = to;
        while (id != from) {
            ncycle.push_back(cycle[id]);
            id = (id + 1) % cycle.size();
        }
        cycle = ncycle;

    }

    cout << cycle.size() << endl;
    for (auto v : cycle) cout << v + 1 << endl;
}



Measured memory_bytes: 384
package main

import "fmt"

var x int

func main() {
	an := 0
	fmt.Scanf("%d", &x)
	if a(400, 599) {
		an = 8
	} else if a(600, 799) {
		an = 7
	} else if a(800, 999) {
		an = 6
	} else if a(1000, 1199) {
		an = 5
	} else if a(1200, 1399) {
		an = 4
	} else if a(1400, 1599) {
		an = 3
	} else if a(1600, 1799) {
		an = 2
	} else if a(1800, 1999) {
		an = 1
	}
	fmt.Println(an)
}
func a(i, j int) bool {
	if i <= x && x <= j {
		return true
	}
	return false
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3616
from itertools import takewhile, chain, count
 
n = int(input())
 
def powers(a, n):
   return takewhile(lambda x: x<=n, (a**i for i in count(1)))
 
draws = sorted(set(chain([1], powers(6, n), powers(9, n))))
d = {}
for draw, last_draw in zip(draws[1:], draws):
  d[draw, 0] = 0
  for i in range(1, n+1):
    d[draw, i] = min(d.get((draw, i-draw), n)+1, d.get((last_draw, i), i))
 
print(d.get((max(draws), n), n))

Measured memory_bytes: 170000
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M;
  cin >> N >> M;
  vector<long long int> a_v(M+1);
  vector<long long int> f(N+1, 0);
  for (int i = 0; i < M; i++) {
    cin >> a_v.at(i);
  }
  a_v[M] = 1LL << 50;
  // f_n = f_{n-1} + f_{n-2}
  // f_0 = 1
  // f_1 = 1
  // f_2 = 2
  // f_3 = 3
  long long int j = 0;
  for (int i = 0; i <= N; i++) {
    if (a_v[j] == i) {
      j++;
    }
    else {
      if (i >= 2) {
        f[i] = (f[i-1] + f[i-2]) % 1000000007;
      }
      else if (i == 1) {
        f[i] = f[i-1] + 0;
      }
      else if (i == 0) {
        f[i] = 1;
      }

    }
  }
  for (int i = 0; i <= N; i++) {
    //cout << "f" << f[i] << endl;
  }
  //cout << "j:" << j << endl;

  cout << f[N]%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<string>a(N);
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  int ans = 1;
  for(int i=1;i<N;i++){
    if(a[i] != a[i-1]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M,L;
int K[2010];
int S[100010];

int memo[2010][2010];

inline int cost(int l,int r){
    l=K[l];r=K[r];
    if(l>r)swap(l,r);
    return (S[r]-S[l-1])/L;
}

int dfs(int l,int r){
    int t=max(l,r)+1;
    if(t==N-1)return cost(l,t)+cost(r,t);
    int &ret=memo[l][r];
    if(ret!=-1)return ret;
    return ret=min(dfs(t,r)+cost(l,t),dfs(l,t)+cost(r,t));
}

signed main(){
    scanf("%lld%lld%lld",&N,&M,&L);
    rep(i,N)scanf("%lld",&K[i]);
    sort(K,K+N);
    rep(i,M)scanf("%lld",&S[i+1]),S[i+1]+=S[i];

    memset(memo,-1,sizeof(memo));
    printf("%lld\n",dfs(0,0));
    return 0;
}

Measured memory_bytes: 35736
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	int n, m; cin >> n >> m;
	vector<int> p(m), y(m);
	vector<vector<int>> id(n + 1);
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		id[p[i]].emplace_back(y[i]);
	}

	for (int i = 0; i < n + 1; i++) {
		sort(id[i].begin(), id[i].end());
	}
	for (int i = 0; i < m; i++) {
		cout << setfill('0') << right << setw(12) << (ll) p[i] * 1000000 + (ll)(lower_bound((id[p[i]]).begin(), id[p[i]].end(), y[i]) - id[p[i]].begin()) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 7808