akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int d;
	cin >> d;
	if(d == 25){
		cout << "Christmas" << endl;
	}else if(d == 24){
		cout << "Christmas Eve" << endl;
	}else if(d == 23){
		cout << "Christmas Eve Eve" << endl;
	}else if(d == 22){
		cout << "Christmas Eve Eve Eve" << endl;
	}
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let k = read::<i64>();
    let mut ans = 0;
    for a in 1..k + 1 {
        for b in 1..k + 1 {
            for c in 1..k + 1 {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    println!("{}", ans);
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2156
input = readlines
a, b = input[0].chomp, input[1].chomp
a_len = a.length
b_len = b.length
match = false
(a_len - b_len + 1).times do |i|
  substr = a[i, b_len]
  match_count = substr.chars.each_with_index.inject(0) do |sum, (ac, i)|
    break sum unless b[i] == '_' || ac == b[i]
    sum += 1
  end
  if match_count == b_len
    match = true
    break
  end
end
puts match ? 'Yes' : 'No'


Measured memory_bytes: 6976
#include <stdio.h>
#define SIZE 100
int main(void)
{
	int t, n, h, hh, up, dw;
	int i, j;

	scanf("%d", &t);
	for (i = 0; i < t; i++) {
		scanf("%d", &n);
		scanf("%d", &hh);
		up = 0; dw = 0;
		for (j = 1; j < n; j++) {
			scanf("%d", &h);
			if (hh < h && up < h - hh)
				up = h - hh; 
			if (hh > h && dw < hh - h)
				dw = hh - h;
			hh = h;
		}
		printf("%d %d\n", up, dw);
	}
	return 0;
}
			

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

long dp[200010], mod=1000000007;
long C[200010], add[200010];
map<int, vector<int>> mp;
int main() {
	int N, cnt=0; cin >> N;
	for(int i=1; i<=N; ++i){
	    int t; cin >> t;
	    if(C[cnt]!=t){
	        ++cnt;
	        C[cnt]=t;
	    }
	}
	dp[0]=1;
	for(int i=1; i<=cnt; ++i){
	    dp[i]=(dp[i-1]+add[C[i]])%mod;
	    add[C[i]]=(add[C[i]]+dp[i-1])%mod;
	}
	cout << dp[cnt] << endl;
	return 0;
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k - 1] = 'a' + (s[k - 1] - 'A');
    print(s);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  
  ll W,H; cin >> W >> H;
  
  priority_queue<P,vector<P> ,greater<P>> Q;
  
  for(ll i = 0; i < W; i++){
    ll p; cin >> p;
    
    Q.push({p,0});
    
  } 
  
  for(ll j = 0; j < H; j++){
    ll q; cin >> q;
    
    Q.push({q,1});
    
  }
  
  
  // 0 means coluumm while 1 means another direction
  
  ll ans = 0;
  
  ll cnt = 0;
  
  ll a = W+1,b = H+1;
  
  while( cnt <= (W+1)*(H+1)-1 && !Q.empty()){ 
    
    P p = Q.top(); Q.pop();
    
    if( p.second == 1){ ans += p.first*a; cnt += a;  b--;}
    else{ ans += p.first*b; cnt += b; a--;}
    
  }
  
  cout << ans << endl; 
  
  return 0;
}

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

int main() {
  int array[10], tmp;

  for (int i = 0; i < 10; i++) {
    cin >> array[i];
  }

  for (int j = 0; j < 10; j++) {
    for (int k = 0; k < 9; k++) {
      if (array[k] < array[k+1]) {
        tmp = array[k];
        array[k] = array[k+1];
        array[k+1] = tmp;
      }
    }
  }

  for(int l = 0; l < 3; l++) {
    cout << array[l] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define db double

using namespace std;
const int N=16,M=(1<<15)+10,mod=1e9+7,inv9=111111112;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;} return an;}
int n,m,a[N][3],b[N<<1],sd[N<<1],t,l2[M],f[2][M],g[M],h[M],st[M],tp;

int main()
{
	n=rd(),m=rd();
	for(int i=1;i<=m;++i) b[2*i-1]=a[i][0]=rd()-1,b[2*i]=a[i][1]=rd(),a[i][2]=0;
	bool fg=1;
	t=2*m;
	for(int i=1;i<=t;i+=2) if(!b[i]){fg=0;break;}
	if(fg) ++t;
	sort(b+1,b+t+1),t=unique(b+1,b+t+1)-b-1;
	for(int i=1;i<=t;++i) sd[i]=fpow(10,b[i]-b[i-1]);
	for(int i=1;i<=m;++i)
		for(int j=0;j<=2;++j)
			a[i][j]=lower_bound(b+1,b+t+1,a[i][j])-b;
	int u=(1<<m)-1;
	for(int i=1;i<=u;++i) l2[i]=l2[i>>1]+1;
	int nw=1,la=0;
	f[la][0]=1;g[0]=1;
	for(int z=0;z<9;++z)
	{
		for(int i=0;i<=u;++i)
		{
			if(!f[la][i]) continue;
			ad(f[nw][i],f[la][i]);
			tp=0;
			for(int j=u^i;j;j=(j-1)&(u^i)) st[++tp]=j;
			h[0]=(bool)z;
			for(int j=1;j<=m;++j)
				if(i>>(j-1)&1) h[0]|=(1<<(a[j][0]-1))|(1<<(a[j][1]-1));
			for(int jj=tp;jj;--jj)
			{
				int j=st[jj];
				int lj=j^(j&(-j)),k=l2[j&(-j)];
				if((h[0]>>(a[k][0]-1)&1)||(h[0]>>(a[k][1]-1)&1)) continue;
				h[j]=h[lj],g[j]=g[lj];
				for(int o=0;o<=1+(!z);++o)
				{
					int x=a[k][o];
					if(h[j]>>(x-1)&1) continue;
					if(x>1&&h[j]>>(x-2)&1)
						g[j]=1ll*g[j]*(1ll*(sd[x]-1)*inv9%mod+(!(h[0]>>(x-2)&1)))%mod;
					if(h[j]>>x&1)
						g[j]=1ll*g[j]*(1ll*(sd[x+1]-1)*inv9%mod+(!(h[0]>>x&1)))%mod;
					h[j]|=1<<(x-1);
				}
				ad(f[nw][i|j],1ll*f[la][i]*g[j]%mod);
			}
			while(tp) g[st[tp]]=h[st[tp]]=0,--tp;
			f[la][i]=0;
		}
		nw^=1,la^=1;
	}
	int ans=1ll*f[la][u]*fpow(10,n-b[t])%mod;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

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

const int mod = 1e9 + 7;

bool solve(int s) {
	int l = 1, r = sqrt(1e9);
	while (l <= r) {
		int m = (l + r) / 2;
		if (m * m == s) return true;
		if (m * m < s) l = m + 1;
		else r = m - 1;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//cout << INT_MAX - 2 * (int)1e9 << endl;
	int l, r;
	cin >> l >> r;
	int ans = 1e9;
	for (int i = l; i <= min(l + 10000, r); i++) {
		for (int j = i + 1; j <= min(l + 10000, r); j++) ans = min(ans, (i % 2019) * (j % 2019) % 2019);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  string list[50] = {"a", "i", "u", "e", "o", "ka", "ki", "ku", "ke", "ko", "sa", "si", "su", "se", "so", "ta", "ti", "tu", "te", "to", "na", "ni", "nu", "ne", "no", "ha", "hi", "hu", "he", "ho", "ma", "mi", "mu", "me", "mo", "ya", "yi", "yu", "ye", "yo", "ra", "ri", "ru", "re", "ro", "wa", "wi", "nn", "we", "wo"};
  string str;
  cin >> str;

  for(int i = 0; i < str.length(); i++) {
    int num = 0;
    if(str[i] == '0')
      num = 5*(10-1);
    else
      num = 5*(atoi(&str[i])-1);
    i++;
    switch (str[i]) {
    case 'T':
      num += 0;
      break;
    case 'L':
      num += 1;
      break;
    case 'U':
      num += 2;
      break;
    case 'R':
      num += 3;
      break;
    case 'D':
      num += 4;
      break;
    }
    cout << list[num];
  }
  cout << endl;
}



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

#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<":"<<a<<endl;
#else
#define DEBUG(a) 
#endif

vector<long long> sumA,sumoddA,sumevenA;

void solve(long long N, long long Q, vector<long long> A, vector<long long> X){
    sumA.push_back(0);
    sumoddA.push_back(0);
    sumevenA.push_back(0);
    for(size_t i=0;i<A.size();i++){
        sumA.push_back(sumA.back()+A[i]);
        if(i%2==0){
            sumevenA.push_back(sumevenA.back()+A[i]);
        }else{
            sumoddA.push_back(sumoddA.back()+A[i]);
        }
    }
    for(auto q:X){
        long long l=0,r=A.size();
        while(l+1<r){
            long long mid=(l+r)/2;
            long long d1=A.size()-mid,d2=A.size()-mid*2+1;
            DEBUG(d1);
            DEBUG(d2);
            if(mid*2-1>(long long)A.size()){
                r=mid;
            }else if(A[d1]<=q){
                r=mid;
            }else if(A[d1]-q>=q-A[d2]){
                l=mid;
            }else{
                r=mid;
            }
        }
        long long ans=0;
        DEBUG(l);
        ans+=sumA.back()-sumA[A.size()-l];
        long long all=l*2-1;
        long long tmp;
        if(all>=(long long)A.size()){
            DEBUG(all);
        }
        else if((tmp=(A.size()-1-2*l))%2==0){
            DEBUG(tmp);
            ans+=sumevenA[tmp/2+1];
        }else{
            DEBUG(tmp);
            ans+=sumoddA[(tmp+1)/2];
        }
        cout<<ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    vector<long long> X(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, Q, A, X);
    return 0;
}


Measured memory_bytes: 6892
#include<stdio.h>
int main(){
  int l=1000010,n,q;
  int d[l];
  long long m[l],c[l],x[l];
  char s[l];
  for(int i=0;i<l;i++)d[i]=-1;
  scanf("%d%s%d",&n,s,&q);
  int j=0;
  for(int i=1;i<=n;i++){
    m[i]=m[i-1];
    c[i]=c[i-1];
    x[i]=x[i-1];
    if(s[i-1]=='D')d[j++]=i-1;
    else if(s[i-1]=='M')m[i]++;
    else if(s[i-1]=='C'){
      c[i]++;
      x[i]+=m[i];
    }
  }
  while(q--){
    long long a=0;
    int k;
    scanf("%d",&k);
    for(int i=0;d[i]>-1;i++){
      int j=d[i];
      int l=j+k;
      if(l>n)l=n;
      a+=x[l]-x[j]-(c[l]-c[j])*m[j];
    }
    printf("%lld\n",a);
  }
}

Measured memory_bytes: 28544
data class Test(val b: Long, val l: Long, val u: Long)

fun divCeil(x: Long, y: Long): Long = (x + y - 1) / y

fun main(args: Array<String>) {
  val (nRaw, x) = readLine()!!.split(" ").map { it.toLong() }
  val n = nRaw.toInt()
  val tests = Array(n, {
    val (b, l, u) = readLine()!!.split(" ").map { it.toLong() }
    Test(b, l, u)
  })
  var currentDiff = tests.map { -it.l * it.b }.sum()
  fun maxGain(test: Test): Long = test.l * test.b + test.u * (x - test.b)
  fun requiredScore(test: Test, score: Long): Long {
    if (score > maxGain(test)) throw RuntimeException()
    if (score <= test.l * test.b) {
      return divCeil(score, test.l)
    } else {
      return test.b + divCeil(score - test.l * test.b, test.u)
    }
  }
  tests.sortByDescending { maxGain(it) }

  var ans = 0L
  for (i in 0 until n) {
    if (currentDiff + maxGain(tests[i]) <= 0) {
      ans += x
      currentDiff += maxGain(tests[i])
    } else {
      val min1 = (i until n).filter { currentDiff + maxGain(tests[it]) >= 0 }
          .map { requiredScore(tests[it], -currentDiff) }
          .min()!!
      var min2 = (0 until i)
          .map {
            val tmpDiff = currentDiff + maxGain(tests[i]) - maxGain(tests[it])
            requiredScore(tests[it], -tmpDiff)
          }
          .min()
      ans += Math.min(min1, min2 ?: x)
      break
    }
  }

  // if (currentScore < 0) throw RuntimeException()

  println(ans)
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x; cin >> x; cout << (x ^ 1);
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		java.util.Stack<Integer> stack = new java.util.Stack<Integer>();
		int a = 0, b = 0;
		String[] c;
		Scanner sc = new Scanner(System.in);
		c = sc.nextLine().split(" ");

		for (int i = 0; i < c.length; i++) {
			if (c[i].equals("+")) {
				int o2 = stack.pop();
				int o1 = stack.pop();
				stack.push(o1 + o2);
			} else if (c[i].equals("-")) {
				int o2 = stack.pop();
				int o1 = stack.pop();
				stack.push(o1 - o2);
			} else if (c[i].equals("*")) {
				int o2 = stack.pop();
				int o1 = stack.pop();
				stack.push(o1 * o2);
			} else {
				stack.push(Integer.parseInt(c[i]));
			}
		}
		System.out.println(stack.pop());

	}

}



Measured memory_bytes: 26264
#include <stdio.h>

int main(void) {
	int n, i, j, cnt;
	char prime[1000000];
	char instr[80];
	
	for(i=0; i<1000000; i++) {
		prime[i]=1;
	}
	prime[0] = prime [1] =0;
	
	for (i=2; i<=999999; i++) {
		for (j=2; i*j<=999999; j++) {
			prime[i*j] = 0;
		}
	}
			
	while (fgets(instr, sizeof(instr), stdin) != NULL) {
		sscanf(instr, "%d", &n);
		cnt=0;
		
		for (i=0; i<=n; i++)  cnt += prime[i];
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    char B;
    cin >> B;
    
    vector <char> alpha({'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'});

    bool small=false;
    for(char A:alpha){
        if(A == B){
            small = true;
        }
    }

    if(small){
        cout << 'a' << endl;
    }
    else{
        cout << 'A' << endl;
    }
}


Measured memory_bytes: 3592
n = int(input())
#a_L = map(int,input().split())
s_L,t_L = [],[]
for i in range(n):
    s,t = map(str,input().split())
    s_L.append(s)
    t_L.append(int(t))
x = input()

i = s_L.index(x)
print(sum(t_L[i+1:]))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  int N,M,X,Y;
  int x[110],y[110];
  cin>>N>>M>>X>>Y;
  for(int t=0;t<N;t++)cin>>x[t];
  for(int t=0;t<M;t++)cin>>y[t];

  sort(x,x+N);
  sort(y,y+M);

  for(int z=x[N-1]+1;z<=y[0];z++){
    if(X<z&&z<=Y){
      cout<<"No War"<<"\n";
      return 0;
    }
  }

  cout<<"War"<<"\n";
  return 0;
}


Measured memory_bytes: 256
from collections import deque
def move(P):
    for i in range(3):
        for j in range(3):
            if P[i][j] == 0:
                r,c = i,j
    if not r == 0:
        tmp = [[i for i in j] for j in P]
        tmp[r][c],tmp[r-1][c] = tmp[r-1][c],tmp[r][c]
        yield tmp
    if not r == 2:
        tmp = [[i for i in j] for j in P]
        tmp[r][c],tmp[r+1][c] = tmp[r+1][c],tmp[r][c]
        yield tmp
    if not c == 0:
        tmp = [[i for i in j] for j in P]
        tmp[r][c],tmp[r][c-1] = tmp[r][c-1],tmp[r][c]
        yield tmp
    if not c == 2:
        tmp = [[i for i in j] for j in P]
        tmp[r][c],tmp[r][c+1] = tmp[r][c+1],tmp[r][c]
        yield tmp

def dpkey(P):
    tmp = ""
    for i in P:
        for j in i:
            tmp += str(j)
    return tmp

A = [[int(i) for i in input().split()] for _ in range(3)]
dp = {dpkey(A) : 1}
d = deque([(A,0)])
c = 0
flag = True
while(flag):
    tmp,c = d.pop()
    for i in move(tmp):
        key = dpkey(i)
        if key == "123456780":
            ans = c + 1
            flag = False
        elif not key in dp:
            dp[key] = 1
            d.appendleft((i,c+1))
if dpkey(A) == "123456780":
    ans = 0
print(ans)


Measured memory_bytes: 41052
var
n,i,j,a:Longint;
s:array[1..100]of Longint;
begin
read(n);
for i:=1 to n do begin
read(a);
if i<a then begin
writeln(-1);
exit;
end;
for j:=i downto a do s[j+1]:=s[j];
s[a]:=a;
end;
for i:=1 to n do writeln(s[i]);
end.

Measured memory_bytes: 128
import numpy as np

n,k=map(int,input().split())
a=[int(x) for x in input().split()]
f=[int(x) for x in input().split()]

a.sort()
f.sort(reverse=True)

a=np.array(a)
f=np.array(f)
s=a.sum()

l,u=-1,f[0]*a[-1]
while l+1<u:
  m=(l+u)//2
  if s-np.minimum(a,m//f).sum()<=k:
    u=m
  else:
    l=m

print(u)

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  int max_v = 100000;
  vector<int> va(n), cnt1(max_v + 1, 0), cnt2(max_v + 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
    if (i % 2 == 0) {
      cnt1[va[i]]++;
    } else {
      cnt2[va[i]]++;
    }
  }

  auto max2 = [](vector<int> &cnt) -> array<int, 2> {
    int max1 = 0, max2 = 0;
    for (int i = 0; i < cnt.size(); i++) {
      if (cnt[max1] < cnt[i]) {
        max2 = max1;
        max1 = i;
      } else if (cnt[max2] < cnt[i]) {
        max2 = i;
      }
    }
    return {max1, max2};
  };

  auto max2_even = max2(cnt1), max2_odd = max2(cnt2);
  int ans;
  if (max2_even[0] != max2_odd[0]) {
    ans = n - cnt1[max2_even[0]] - cnt2[max2_odd[0]];
  } else {
    ans = n - max(cnt1[max2_even[0]] + cnt2[max2_odd[1]],
                  cnt1[max2_even[1]] + cnt2[max2_odd[0]]);
  }

  cout << ans << '\n';
}


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

int calc_digit(long long N) {
    int res = 0;
    while (N) {
        ++res;
        N /= 10;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    int res = 1000000001;
    for (long long A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            long long B = N / A;
            int F = max(calc_digit(A), calc_digit(B));
            res = min(res, F);
        }
    }
    cout << res << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> vec(N, vector<int>(3));
    rep(i, N) {
        rep(j, 3) cin >> vec[i][j];
    }
    vector<vector<ll>> dp(N + 100, vector<ll>(3));
    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + vec[i][j]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) ans = max(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 1000000
int n,i,j,mx[N],se[N],wz[N];
int main()
{
	scanf("%d",&n);
	for (i=0;i<(1<<n);i++) scanf("%d",&mx[i]),wz[i]=i;
	for (i=0;i<(1<<n);i++)
	for (j=0;j<n;j++) if (i&(1<<j)){
		if (mx[i^(1<<j)]>mx[i]){
			if (se[i^(1<<j)]>mx[i]) se[i]=se[i^(1<<j)];else se[i]=mx[i];
			mx[i]=mx[i^(1<<j)];wz[i]=wz[i^(1<<j)];
		}else if (wz[i^(1<<j)]!=wz[i]&&mx[i^(1<<j)]>se[i]) se[i]=mx[i^(1<<j)];
	}
	for (i=0;i<(1<<n);i++) mx[i]+=se[i];
	for (i=1;i<(1<<n);i++) mx[i]=max(mx[i-1],mx[i]);
	for (i=1;i<(1<<n);i++) printf("%d\n",mx[i]);
	return 0;
}

Measured memory_bytes: 12160
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s,t;
		s=sc.nextLine();
		t=sc.nextLine();
		int i;
		for(i=0;i<s.length();i++) {
	        if(s.equals(t)){
	            System.out.println("Yes");
	            break;
	        }
	        s= s.substring(s.length()-1) + s.substring(0,s.length()-1);
//	        System.out.println(s);
	    }
	    if(i>=s.length()){
	    	System.out.println("No");
	    }
	}
}


Measured memory_bytes: 23892
#include <stdio.h>
#define abs(x) ((x)<0 ? -(x) : (x))
#define min(a, b) ((a)>(b) ? (b) : (a))

int main(){
  int n, h[100001], cost[100001];
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%d", &h[i]);

  cost[0] = 0;
  cost[1] = abs(h[1]-h[0]);

  for(int i=2; i<n; i++)
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));

  printf("%d\n", cost[n-1]);
  return 0;
}


Measured memory_bytes: 896
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D&lang=jp
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c,cnt=0;
  cin>>a>>b>>c;
  for(int i=a;i<=b;i++){
    if(c%i==0)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



Measured memory_bytes: 3092
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e9;

void print_a(VL v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    LL n;
    cin>>n;
    LL dv = 26, m;
    string ans = "";
    while(n > 0)
    {
        --n;
        m = (n % dv);
        ans += ('a' + m);
        n -= m;
        n /= dv;
    }

    reverse(all(ans));
    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;
public class Main {
    public static void main (String...args) {
        Scanner sc = new Scanner(System.in); String S = sc.next(); char[] ch = S.toCharArray();
        System.out.println(ch[0] != ch[1] || ch[1] != ch[2] ? "Yes" : "No");}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const int inf = 1<<29;
int n, m;
vector<int> G[100005];
vector<vector<int>> dist(100005, vector<int>(3, inf));

typedef tuple<int, int, int> T;

void dijkstra(int s){
    priority_queue<T, vector<T>, greater<T>> pq;
    dist[s][0] = 0;
    pq.push(make_tuple(s, 0, 0));

    while(!pq.empty()){
        int u, r, d;
        tie(u, r, d) = pq.top(); pq.pop();
        if(dist[u][r] < d) continue;
        for(auto to:G[u]){
            if(dist[to][(r+1)%3] > d+1){
                dist[to][(r+1)%3] = d+1;
                pq.push(make_tuple(to, (r+1)%3, d+1));
            }
        }
    }

}

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

    cin >> n >> m;
    for(int i=0; i<m; ++i){
        int u, v; cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
    }
    int s, t; cin >> s >> t;
    --s; --t;

    dijkstra(s);

    if(dist[t][0] == inf){
        cout << -1 << endl;
    }
    else{
        cout << dist[t][0]/3 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 13168
n = gets.to_i
rates = gets.split.map(&:to_i)
colors = Hash.new(0)

anycolor = 0
rates.each do |s|
  if s < 400
    colors['gray'] += 1
  elsif s < 800
    colors['brown'] += 1
  elsif s < 1200
    colors['green'] += 1
  elsif s < 1600
    colors['skyblue'] += 1
  elsif s < 2000
    colors['blue'] += 1
  elsif s < 2400
    colors['yellow'] += 1
  elsif s < 2800
    colors['orange'] += 1
  elsif s < 3200
    colors['red'] += 1
  else
    anycolor += 1
  end
end

nonzeros = colors.count { |k, v| v > 0 }
min_ans = nonzeros
min_ans = 1 if min_ans == 0 && anycolor > 0
max_ans = nonzeros + anycolor
puts [min_ans, max_ans].join(' ')


Measured memory_bytes: 3836
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int c[510][510];
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,-1,1,0,-1};
int r[2];
int cc[2];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)scanf("%d",&c[i][j]);
	for(int i=0;i<a;i++){
		for(int j=0;j<b-2;j++){
			c[i][j+1]-=c[i][j];
			c[i][j+2]-=c[i][j];
		}
	}
	for(int i=0;i<a-2;i++){
		for(int j=0;j<b;j++){
			c[i+1][j]-=c[i][j];
			c[i+2][j]-=c[i][j];
		}
	}
	r[0]=r[1]=cc[0]=cc[1]=-1;
	for(int i=0;i<a;i++)for(int j=0;j<b;j++){
		if(c[i][j]){
			int tot=0;
			for(int k=0;k<8;k++){
				if(i+dx[k]<0||i+dx[k]>=a||j+dy[k]<0||j+dy[k]>=b)continue;
				tot+=c[i+dx[k]][j+dy[k]];
			}
			if(tot<=1){
				if(r[0]==-1){
					r[0]=r[1]=i+1;cc[0]=cc[1]=j+1;
				}else{
					r[1]=i+1;cc[1]=j+1;
				}
			}
		}
	}
	if(r[0]<r[1]||(r[0]==r[1]&&cc[0]<cc[1])){
		swap(r[0],r[1]);
		swap(cc[0],cc[1]);
	}
	printf("%d %d %d %d\n",r[0],cc[0],r[1],cc[1]);
}

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

#define MAX 100000

int parent(int i){
    return i / 2;
}

int left(int i){
    return 2 * i;
}

int right(int i){
    return (2 * i) + 1;
}

int main(int argc, const char * argv[]) {
    int num,Heap[MAX + 1];
    
    cin >> num;
    for(int i = 1;i <= num;++i){
        cin >> Heap[i];
    }
    
    for(int i = 1;i <= num;++i){
        cout << "node " << i << ": key = " << Heap[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << Heap[parent(i)] << ", ";
        if(left(i) <= num) cout << "left key = " << Heap[left(i)] << ", ";
        if(right(i) <= num) cout << "right key = " << Heap[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
N = int(input())
candies = []
for _ in range(2):
    candies.append(list(map(int, input().split())))

max_candies_num = 0
for i in range(N):
    first_row_candies = sum(candies[0][:i + 1])
    second_row_candies = sum(candies[1][i:])
    sum_candies = first_row_candies + second_row_candies
    if sum_candies > max_candies_num:
        max_candies_num = sum_candies
print(max_candies_num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const 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;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = acos(-1.0); 
typedef long long ll;

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

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d)));
}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){
    int a,b,c,cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=a;i<=b;++i){
        if(!(c%i))++cnt;
    }
    printf("%d\n",cnt);
    return 0;
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n;
signed main() {
	string c; cin >> c;
	n = c.size();
	if (c[0] == '0' || c[n - 1] == '1') { puts("-1"); return 0; }
	rep(i, n / 2) {
		if (c[i] != c[n - i - 2]) { puts("-1"); return 0; }
	}
	vector<P>ans;
	int par = 1, ma = 1;
	for (int i = 1; i < n - 1; i++) {
		if (c[i] == '1') {
			if (c[i] == c[i - 1]) {
				ans.push_back({ par,++ma });
				par = ma;
			}
		}
		else {
			if (c[i] != c[i - 1]) {
				ans.push_back({ par,++ma });
				par = ma;
			}
			ans.push_back({ par,++ma });
		}
		if (ma > n) { puts("-1"); return 0; }
	}
	while (ma < n) {
		ans.push_back({ par,++ma });
		par = ma;
	}
	for (P i : ans)cout << i.first << " " << i.second << endl;
}


Measured memory_bytes: 3312
k = int(input())
a, b = list(map(int, input().split()))
c = 2
k2 = k

while True:
    if k2 <= b and k2 >= a:
        print("OK")
        break
    else:
        k2 = k * c
        c += 1

    if k2 > b:
        print("NG")
        break


Measured memory_bytes: 9108
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())

ans = False
count = 0
D1 = []
D2 = []
for i in range(N):
    d1, d2 = map(int, input().split())
    D1.append(d1)
    D2.append(d2)

for i in range(N):
    if D1[i] == D2[i]:
        count += 1
    else:
        count = 0

    if count == 3:
        ans = True
        break

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll x; cin>>x;
    ll ans=0;
    for(ll i=1; i<=1000; i++){
        if(i==1){
            chmax(ans, i);
            continue;
        }
        ll res=1;
        while(res*i<=x) res*=i;
        if(res==i) break;
        chmax(ans, res);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll solve(vector<ll> a_even, int flag){
	int n = (int)a_even.size();
	ll a_even_sum = 0LL;
	ll curr = 0LL;
	rep (i, n){
		if ((i + flag) % 2 == 0){
			if (a_even_sum + a_even[i] < 0LL){
				curr += abs(1LL - (a_even_sum + a_even[i]));
				a_even[i] = abs(1LL - a_even_sum);
			}else
			if (a_even_sum + a_even[i] == 0LL){
				++curr;
				a_even[i] = 1LL;
			} // end if
		}else{ // if ((i + flag) % 2 != 0)
			if (a_even_sum + a_even[i] > 0LL){
				curr += abs(-1LL - (a_even_sum + a_even[i]));
				a_even[i] = -abs(-1LL - a_even_sum);
			}else
			if (a_even_sum + a_even[i] == 0LL){
				++curr;
				a_even[i] = -1LL;
			} // end if
		} // end if
		a_even_sum += a_even[i];
	} // end rep
	return curr;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<ll> a(n, 0);
	rep (i, n){
		cin >> a[i];
	} // end rep

	vector<ll> a_even = a;
	// 偶数を正とする
	ll res = solve(a_even, 0);

	// 奇数を正とする
	a_even = a;
	ll curr = solve(a_even, 1);
	res = min(res, curr);

	cout << res << endl;

	return 0;
}

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


int main() {
  int N; cin >> N;
  vector<int> L(N,0);
  rep(i,N)cin >> L[i];
  int ans = 0;
  sort(L.begin(),L.end());
  rep(i,N - 2){
    for(int j = i + 1; j < N - 1; j++){
      for(int k = j + 1; k < N; k++){
        if(L[i] + L[j] > L[k]){
          if(L[i] != L[j] && L[j] != L[k])ans++;
        }
      } 
    }
  }


  cout << ans << endl;



  return 0;
}









Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	vector<vector<int>> graph(n);
	graph[0].push_back(1);
	graph[n-1].push_back(n-2);
	for(int i = 1; i < n - 1; i++)
	{
		graph[i].push_back(i+1);
		graph[i].push_back(i-1);
	}
	graph[x-1].push_back(y-1);
	graph[y-1].push_back(x-1);
	int INF = 1e9 + 7;
	vector<int> ans(n, 0);
	vector<vector<int>> dist(n, vector<int> (n, INF));
	for(int i = 0; i < n; i++)
	{
		dist[i][i] = 0;
		queue<int> q;
		q.push(i);
		while(!q.empty())
		{
			int u = q.front();
			q.pop();
			for(auto it = graph[u].begin(); it != graph[u].end(); it++)
			{
				if(dist[i][*it] > 1 + dist[i][u])
				{
					dist[i][*it] = 1 + dist[i][u];
					ans[dist[i][*it]]++;
					q.push(*it);
				}
				
			}
		}

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

	

	return 0;

}

Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
long long t,n,a[222];
vector<long long>v;
string s;
int main()
{
	cin>>t;
	while(t--)
	{
		v.clear();
		cin>>n;
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		cin>>s;
		bool ok=true;
		for(int i=n-1;i>=0;i--)
		{
			long long nw=a[i];
			for(int j=0;j<v.size();j++)
			{
				nw=min(nw,nw^v[j]);
			}
			if(nw==0)
			{
				continue;
			}
			if(s[i]=='0')
			{
				v.push_back(nw);
			}
			else
			{
				ok=false;
				break;
			}
		}
		if(ok)
		{
			cout<<0<<endl;
		}
		else
		{
			cout<<1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}

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


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    int a,b,c;cin >> a >> b >> c;
    cout << a+b+c-max({a,b,c}) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map { ij -> ij.toInt() }
    val n = gcd(a, b)
    println(if (c % n == 0) "YES" else "NO")
}

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) {
        a
    } else {
        gcd(b, a % b)
    }
}

Measured memory_bytes: 36020
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
A.append(10**9+1)

now = 0
cnt = 0
ans = 0
for a in A:
    if a == now:
        cnt += 1
    else:
        now = a
        ans += cnt % 2
        cnt = 1

print(ans)


Measured memory_bytes: 7388
#include "bits/stdc++.h"
using namespace std;
using lint=int64_t;

class SegmentMap : public std::map<int,int> {
private:
	bool fl;
public:
	SegmentMap(bool fl) :
		fl(fl) {}
	auto get(int p) const {
		auto it=upper_bound(p);
		if(it==begin() || (--it)->second<p) return end();
		return it;
	}
	void insert(int l,int r) {
		auto itl=upper_bound(l),itr=upper_bound(r+fl);
		if(itl!=begin()) {
			if((--itl)->second<l-fl)++itl;
		}
		if(itl!=itr) {
			l=std::min(l,itl->first);
			r=std::max(r,std::prev(itr)->second);
			erase(itl,itr);
		}
		(*this)[l]=r;
	}
	void remove(int l,int r) {
		auto itl=upper_bound(l),itr=upper_bound(r);
		if(itl!=begin()) {
			if((--itl)->second<l) ++itl;
		}
		if(itl==itr) return;
		int tl=std::min(l,itl->first),tr=std::max(r,std::prev(itr)->second);
		erase(itl,itr);
		if(tl<l) (*this)[tl]=l - 1;
		if(r<tr) (*this)[r + 1]=tr;
	}
	bool same(int p,int q) const {
		const auto&& it=get(p);
		return it!=end() && it->first<=q && q<=it->second;
	}
};

int main(){
	lint n,q;
	string x;
	cin>>n>>x>>q;
	SegmentMap m(1);
	{
		string s="0"+x+"0";
		lint f=0;
		for(int i=0; i<n+1; ++i){
			if(s[i]=='0' && s[i+1]=='1') f=i;
			if(s[i]=='1' && s[i+1]=='0') m.insert(f,i-1);
		}
	}
	while(q--){
		lint l,r,b; cin>>l>>r>>b; --l,--r;
		if(b) m.insert(l,r);
		else m.remove(l,r);
		cout<<m.size()<<endl;
	}
}


Measured memory_bytes: 4268
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a > 8 || b > 8) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
void solve() {
   string s; cin >> s;
   string t = s.substr(0,3);
   cout << t << endl;
}
int main() {
   cin.tie(nullptr); ios::sync_with_stdio(false);
   solve();
}

Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        try (Scanner sc = new Scanner(System.in)) {
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for (int i = 0; i < values.length; i++) {
        values[i] = i + 1;
        }
        for (int i = 0; i < n; i++) {
        String str = sc.next();
        String[] ab = str.split(",");
        int a = Integer.parseInt(ab[0]) - 1;
        int b = Integer.parseInt(ab[1]) - 1;
        // aとbを使ってvaluesを操作しよう

        int x;
        x = values[a];
        values[a]=values[b];
        values[b] = x;
        }
        // valuesを出力しよう
        for (int i = 0; i < values.length; i++) {
            System.out.println(values[i]);
            }
        }
        }
}


Measured memory_bytes: 25884
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,i,j,k;
    cin >> n >> k;
    int h[n],dp[n]; 
    dp[0] = 0;
    for(i=0;i<n;++i) cin >> h[i];
    for(i=1;i<n;++i) {
     dp[i] = INT_MAX;
     for(j=1;j<=min(k,i);++j) dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<int> e(n+1,0); //i人目まででeを向いている人数
  char s;
  for(int i=1;i<=n;i++)
  {
    cin>>s;
    if(s=='E') e.at(i)=e.at(i-1)+1;
    else e.at(i)=e.at(i-1);
  }

  int cnt=1000000;
  for(int i=1;i<=n;i++) //i人目がリーダー
  {
    int left=(i-1)-e.at(i-1); //i-1人目まででWを向いている人数
    int right=e.at(n)-e.at(i); //i人目以降でEを向いている人数
    int turn=left+right;
    if(turn<cnt) cnt=turn;
  }

  cout<<cnt<<endl;

}

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

int main() {
  int k;
  vector<int> vec(5);
  for(int i ; i<5 ;i++){
    cin >> vec.at(i);
  }
  cin >> k ;
  if (vec.at(0) + k < vec.at(4)){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
 
  
  
}


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

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF=(0x7fffffff)/2;
const int MOD = 1000000007;
const int MaxN = 1e5;

int main(){
	int a, b, c, d;
	while(~scanf("%d %d %d %d", &a, &b, &c, &d)){
		int x =min(a, b);
		int y = min(c, d);
		printf("%d\n", x + y);
	}
}

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

int main(){
  long long a,b,x;
  cin>>a>>b>>x;

  long long ans=0;
  bool flag1 = (a%x==0)? true:false;
  bool flag2 = (b%x==0)? true:false;

 if(flag1 ){
   ans = b/x-a/x + 1;
 }else{
   ans = b/x-a/x;
 }


  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(q,w,e) for(int q=w;q<=e;q++)
#define per(q,w,e) for(int q=w;q>=e;q--)
typedef long long LL;
int x,y;
int main() {
    cin>>x>>y;
    cout<<x*y-x-y+1;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string n;
    cin >> n;
    
    for(int i = 0; i < 3; i++) {
        if (n.at(i) == '1') n.at(i) = '9';
        else if (n.at(i) == '9') n.at(i) = '1';
    }
    
    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	ans := n%2 + n/2
	fmt.Println(ans)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef long long ll;
ll pw(ll x,ll n){ll ans = 1;while(n){if(n&1) ans*=x;x*=x;n>>=1;}return ans;} //power

int main(){
    ll X,i;
    ll A = 100;
    scanf("%lld",&X);
    for(i = 0;A < X;i++){
        A*=1.01;
    }
    printf("%lld\n",i);
    return 0;
}

Measured memory_bytes: 1736
import heapq


def main():
    N = int(input())
    A = [(-1)*int(input()) for _ in range(N)]
    A_ = A.copy()
    heapq.heapify(A)

    for a in A_:
        tmp1 = heapq.heappop(A)
        if a == tmp1:
            tmp2 = heapq.heappop(A)
            print((-1) * tmp2)
            heapq.heappush(A, tmp1)
            heapq.heappush(A, tmp2)
        else:
            print((-1) * tmp1)
            heapq.heappush(A, tmp1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14088
while True:
    H,W = map(int,input().split())
    
    if H == W == 0:
        break
    
    for i in range(H):
        for j in range(W):

            if i==0 or i==(H-1):
                print("#",end="")
            elif j==0 or j==(W-1):
                print("#",end="")
            else:
                print(".",end="")
                
        print()
    print()


Measured memory_bytes: 7004
from copy import deepcopy

def Partition(A, p, r):
    x = A[r][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def Quicksort(A, p, r):
    if p < r:
        q = Partition(A, p, r)
        Quicksort(A, p, q-1)
        Quicksort(A, q+1, r)


n = int(input())
cards = []
for i in range(n):
    card = input().split()
    card[1] = int(card[1])
    cards.append(card)
prev_cards = deepcopy(cards)
prev_cards.sort(key=lambda card: card[1])

Quicksort(cards, 0, n-1)

if cards == prev_cards:
    print("Stable")
else:
    print("Not stable")

for card in cards:
    print(' '.join(map(str, card)))

Measured memory_bytes: 66716