akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>

using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	int A[100],a = 0,sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (int i = 1; i <= N - 1; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
			A[j + 1] = v;
		}
	}

	if (A[N - 1 - M + 1] * (4*M) >= sum){
		cout << "Yes" << endl;
	}
    else cout << "No" << endl;

	

return 0;
}


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;
using P = pair<int,int>;

int main(){
	int n, m, q, a, b;
	cin >> n >> m >> q;
	vector<vector<int>> r(n, vector<int>(1));
	rep(i, n) r.at(i).at(0) = 1000;
	rep(i, m){
		cin >> a >> b;
		a--; b--;
		r.at(a).push_back(b);
	}
	rep(i, n) sort(r.at(i).begin(), r.at(i).end());
/*	cout << endl;
	rep(i, n){
		rep(j, r.at(i).size()) cout << r.at(i).at(j) << ' ';
		cout << endl;
	}*/
	rep(i, q){
		cin >> a >> b;
		a--; b--;
		int ans = 0;
		for(int j=a; j<=b; j++){
			ans += upper_bound(r.at(j).begin(), r.at(j).end(), b) - r.at(j).begin();
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a,b,n;
	while( cin >> a){
		cin >> b;
		cin >> n;
		if( a == b ){
			cout << 0 << endl;
			continue;
		}
		//cout << "a:" << a << " b:" << b << " n:" << n << endl;
		
		int t,d;
		ll s = 0;
		//cout << a << endl;
		rep(i,0,n+1){
			
			t = a/b;
			d = a-t*b;
			a = d * 10;
			//cout << "t:" << t << " d:" << d << " a:" << a << endl;
			
			if(i)
				s += t;
		}

		cout << s << endl;
	}
	ret 0;
}


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

int main(){
  ll N; cin >> N;
  vector<ll> sum(N+1, 0);
  
  for(ll i = 0; i < N; i++){
    ll a; cin >> a;
    sum[i+1] = sum[i] + a;
  }
  
  sort(sum.begin(), sum.end());

  ll ans = 0LL;
  ll kaz = 1LL, val = (ll)-1e18;
  
  for(ll i = 0; i <= N; i++){
    if(val != sum[i]){
      ans += (kaz * (kaz - 1)) / 2;
      kaz = 1;
    }else{
      kaz++;
    }
    val = sum[i];
  }
  ans += (kaz * (kaz - 1)) / 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n,m;
    cin>>n>>m;
    if(n==m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[100],y[10];
bool ask(int l,int r){
	printf("? ");
	for(int i=l;i>=r;--i)printf("%c",s[i]);
	puts(""),fflush(stdout);
	scanf("%s",y);
	return y[0]=='Y';
}
int main(){
	int len=-1;
	for(int i=1;i<=10;++i){
		s[i]='1';
		if(!ask(i,1)){
			len=i-1;
			break;
		}
		s[i]='0';
	}
	if(len==-1){
		for(int i=1;i<=10;++i){
			s[i]='9';
			if(ask(i,1)){
				len=i;
				break;
			}
		}
	}
	for(int i=1;i<=11;++i)
		s[i]='9';
	for(int i=11;i>=1;--i){
		int l=(i==11?1:0),r=9,ans;
		while(l<=r){
			int mid=l+r>>1;
			s[i]=mid+'0';
			if(ask(11,1))ans=mid,r=mid-1;
			else l=mid+1;
		}
		s[i]=ans+'0';
		if(11-i+1==len){
			printf("! ");
			for(int j=11;j>=i;--j)printf("%c",s[j]);
			puts(""),fflush(stdout);
			return 0;
		}
	}
}

Measured memory_bytes: 596
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n = getint()
values = getints()

res = 0.0
for v in values:
    res += 1.0 / v

print(1.0 / res)


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }
};

int main() {
    int n, k;
    cin >> n >> k;
    Combination combi = Combination(2222, MOD);
    FOR(i, 1, k + 1) {
        if (i - 1 > n - k) {
            cout << 0 << endl;
        } else {
            cout << combi.calc(k - 1, i - 1) * combi.calc(n - k + 1, i) % MOD << endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int now = 0;
	int A, P;
	cin >> A >> P;
	now += P;
	now += (A * 3);
	cout << now / 2 << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    char c; cin >> c;
    if(isupper(c)) cout << "A" << endl;
    else cout << "a" << endl;
    
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3632
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c = [c1,c2,c3]
for a1 in range(100):
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    a21 = c2[0] - b1
    a22 = c2[1] - b2
    a23 = c2[2] - b3
    a31 = c3[0] - b1
    a32 = c3[1] - b2
    a33 = c3[2] - b3
#     print('a1',a1)
#     print('a2',a21,a22,a23)
#     print('a3',a31,a32,a33)
#     print('b',b1,b2,b3)
    if (a21 == a22 == a23) and (a31 == a32 == a33):
        print('Yes')
        break
    elif a1 == 99:
        print('No')
        break
    else:
        continue

Measured memory_bytes: 9228
import sys
from collections import defaultdict

N = int(input())
C = [0]
for _ in range(N):
    c = int(sys.stdin.readline())
    if C[-1] != c:
        C.append(c)

ans = 1
dic = defaultdict(lambda: 0)
mod = 10 ** 9 + 7
for c in C:
    a = dic[c]
    dic[c] += ans
    ans = (ans + a) % mod

print(ans % mod)


Measured memory_bytes: 29804
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def binarySearchIterative(list: Array[Double], target: Double): Int = {
    var left = 0
    var right = list.length - 1
    while (left <= right) {
      val mid = left + (right - left) / 2
      if (list(mid) > target)
        right = mid - 1
      else
        left = mid + 1
    }
    left
  }

  def binarySearchIterative2(list: Array[Double], target: Double): Int = {
    var left = 0
    var right = list.length - 1
    while (left <= right) {
      val mid = left + (right - left) / 2
      if (list(mid) >= target)
        right = mid - 1
      else
        left = mid + 1
    }
    left
  }

  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt * 2
    println(((N / 60): Int) + " " + N % 60)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int x = 0;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        if ((a&1) && (i&1)) {
            x++;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func main() {
	var ans int
	var S, T string
	fmt.Scan(&S)
	fmt.Scan(&T)
	for i, s := range S {
		if string(s) != string(T[i]) {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 4492
#include <stdio.h> 
 #include <stdbool.h> 
 int main(){ 
     int i, j, n; 
     char mark; 
     char marks[4]={'S', 'H', 'C', 'D'}; 
     int num; 
     bool cards[4][13]={false}; 
     scanf("%d ", &n); 
     for(i=0;i<n;i++){ 
         scanf("%c %d ", &mark, &num); 
         for(j=0;j<4;j++){ 
             if(mark==marks[j]){ 
                 cards[j][num-1]=true; 
                 break; 
             } 
         } 
     } 
     for(i=0;i<4;i++){ 
         for(j=0;j<13;j++){ 
             if(!cards[i][j]){ 
                 printf("%c %d\n", marks[i], j+1); 
             } 
         } 
     } 
     return 0; 
 } 


Measured memory_bytes: 2084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int N;
    scanf("%d",&N);
    int st[N];
    for(int i=0;i<N;i++){
        scanf("%d",&st[i]);
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<N;j++){
            if(i==st[j]){
                printf("%d ",j+1);
                break;
            }else{
                ;
            }
        }
    }
}


Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;

const int MAXN = 1005;
int main()
{
	int a[6];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0]+a[1]==a[2]))
		printf("Yes\n");
	else printf("No\n");
}

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

int A[55];
bool boleh[55];
int B[55];
int C[55];
int indx[55];
long long ncr[55][55];

long long ncrUpTo[55][55];

int cnt2[(1<<18)+5];

int main(){
    int N, K, S, T;
    scanf("%d%d%d%d", &N, &K, &S, &T);

    if( ((S&T) == S) && ((S|T) == T) ){
    }else{
        printf("0");
        return 0;
    }

    memset(ncr, 0, sizeof(ncr));
    ncr[0][0] = 1;
    for(int i = 1; i <= N; i ++){
        ncr[i][0] = 1;
        for(int j = 1; j <= i; j ++){
            ncr[i][j] = ncr[i-1][j] + ncr[i-1][j-1];
        }
    }

    ncrUpTo[0][0] = 0;
    for(int i = 1; i <= N; i ++){
        ncrUpTo[i][0] = 0;
        for(int j = 1; j <= N; j ++){
            ncrUpTo[i][j] = ncrUpTo[i][j-1] + ncr[i][j];
        }
    }

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
        boleh[i] = true;
        //printf("A[%d]=%d\n", i, A[i]);
    }

    int L = 0;
    for(int i = 0; i < 20; i ++){
        if( (S&(1<<i)) == (T&(1<<i)) ){
            for(int j = 0; j < N; j ++){
                if( (S&(1<<i)) != (A[j]&(1<<i)) ){
                    boleh[j] = false;
                    //printf("boleh[%d]=false\n", j);
                }
            }
        }else{
            indx[L ++] = i;
        }
    }

    for(int i = 0; i < L; i ++){
        for(int j = 0; j < N; j ++){
            if(A[j]&(1<<indx[i])){
                B[j] |= (1<<i);
            }
        }
    }

    int M = 0;
    for(int i = 0; i < N; i ++){
        if(boleh[i]){
            C[M ++] = B[i];
        }
    }

    for(int i = 0; i < M; i ++){
        //printf("C[%d]=%d\n", i, C[i]);
    }

    memset(cnt2, 0, sizeof(cnt2));
    long long ans = 0;
    for(int U = 0; U < (1<<L); U ++){
        long long f = 0;

        vector<int> s;
        for(int i = 0; i < M; i ++){
            s.emplace_back(U&C[i]);
            cnt2[U&C[i]] ++;
        }

        for(int j: s){
            int cnt = cnt2[j];
            f += ncrUpTo[cnt][K];
            cnt2[j] = 0;
        }

        int temp = __builtin_popcount(U);
        if(temp&1){
            ans -= f;
        }else{
            ans += f;
        }
    }

    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 4868
#include <stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if(A+B+C==17){
		if(A==5){
			if(B==5){
				printf("YES");
			}else{
				if(B==7){
					printf("YES");
				}else{
					printf("NO");
				}
			}
		}else{
			if(A==7){
				if(B==5){
					printf("YES");
				}else{
					printf("NO");
				}
			}
			
		}
	}else{
		printf("NO");
	}
	return 0;
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 200010;

struct Obj {
	int L, R;
} num[MAXN];

int n, m;
int maxx[MAXN << 2], tag[MAXN << 2];

bool cmp(const Obj &x, const Obj &y) {return x.L < y.L || x.L == y.L && x.R > y.R;}

void build(int now, int l, int r)
{
	if (l == r) {
		maxx[now] = -(m - (l - 1) + 1);
		return;
	}
	int mid = (l + r) >> 1;
	build(now << 1, l, mid); build(now << 1 | 1, mid + 1, r);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

void pushdown(int now)
{
	if (!tag[now]) return;
	maxx[now << 1] += tag[now]; tag[now << 1] += tag[now];
	maxx[now << 1 | 1] += tag[now]; tag[now << 1 | 1] += tag[now];
	tag[now] = 0;
}

void modify(int now, int l, int r, int x, int y, int z)
{
	if (x <= l && r <= y) {
		maxx[now] += z; tag[now] += z; return;
	}
	pushdown(now);
	int mid = (l + r) >> 1;
	if (x <= mid) modify(now << 1, l, mid, x, y, z);
	if (mid < y) modify(now << 1 | 1, mid + 1, r, x, y, z);
	maxx[now] = Max(maxx[now << 1], maxx[now << 1 | 1]);
}

int query(int now, int l, int r, int x, int y)
{
	if (x <= l && r <= y) return maxx[now];
	pushdown(now);
	int mid = (l + r) >> 1;
	if (y <= mid) return query(now << 1, l, mid, x, y);
	if (mid < x) return query(now << 1 | 1, mid + 1, r, x, y);
	return Max(query(now << 1, l, mid, x, y), query(now << 1 | 1, mid + 1, r, x, y));
}

using std::vector;

vector<int>V[MAXN];

int main()
{
	in(n); in(m);
	FOR(i, 1, n) {
		in(num[i].L), in(num[i].R);
		V[num[i].L].push_back(num[i].R);
	}

	build(1, 1, m + 2);

	int he = n - m;
	
	FOR(i, 0, m) {
		for (int j = 0; j < V[i].size(); j++) {
			modify(1, 1, m + 2, 1, V[i][j] + 1, 1);
		}
		chkmax(he, query(1, 1, m + 2, i + 2, m + 2) - i);
	}

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


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

int n;
ll cnt[60] = {};

ll calc(ll x) {
    ll sum = 0;
    rep(i,60){
        if (x & bit(i)) {
            sum += bit(i) * max(cnt[i], n-cnt[i]);
        } else {
            sum += bit(i) * cnt[i];
        }
    }
    return sum;
}

int main(void){
    ll K;
    cin >> n >> K;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        rep(j,60) if(bit(j) & a[i]) {
            cnt[j]++;
        }
    }

    ll res = max(calc(0),calc(K));
    rep(i,60) {
        int j = 60 - 1 - i;
        if (bit(j) & K) {
            res = max(res, calc((K^bit(j))|(bit(j)-1)));
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

long long solve(long long x, long long c, long long d) {
    return x - x / c - x / d + x / lcm(c, d);
}

int main() {
    long long a, b, c, d; cin >> a >> b >> c >> d;
    cout << solve(b, c, d) - solve(a - 1, c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
a, b, k = map(int, open(0).read().split())


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = set(table)
    return table


x = divisor(a)
y = divisor(b)
print(sorted(list(x & y), reverse=True)[k-1])


Measured memory_bytes: 3060
import operator
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353

class SegmentTree:
    # http://tsutaj.hatenablog.com/entry/2017/03/29/204841
    def __init__(self, size, fn=operator.add, default=None, initial_values=None):
        """
        :param int size:
        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など
        :param default:
        :param list initial_values:
        """
        default = default or 0

        # size 以上である最小の 2 冪を size とする
        n = 1
        while n < size:
            n *= 2
        self._size = n
        self._fn = fn

        self._tree = [default] * (self._size * 2 - 1)
        if initial_values:
            i = self._size - 1
            for v in initial_values:
                self._tree[i] = v
                i += 1
            i = self._size - 2
            while i >= 0:
                self._tree[i] = self._fn(self._tree[i * 2 + 1], self._tree[i * 2 + 2])
                i -= 1

    def set(self, i, value):
        """
        i 番目に value を設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self._tree[x] = value

        while x > 0:
            x = (x - 1) // 2
            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])

    def add(self, i, value):
        """
        もとの i 番目と value に fn を適用したものを i 番目に設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self.set(i, self._fn(self._tree[x], value))

    def get(self, from_i, to_i=None, k=0, L=None, r=None):
        """
        [from_i, to_i) に fn を適用した結果を返す
        :param int from_i:
        :param int to_i:
        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ
        :param int L:
        :param int r:
        :return:
        """
        if to_i is None:
            return self._tree[self._size - 1 + from_i]
        L = 0 if L is None else L
        r = self._size if r is None else r

        if from_i <= L and r <= to_i:
            return self._tree[k]

        if to_i <= L or r <= from_i:
            return None

        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)
        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)
        if ret_L is None:
            return ret_r
        if ret_r is None:
            return ret_L
        return self._fn(ret_L, ret_r)

    def __len__(self):
        return self._size


N, M = list(map(int, sys.stdin.readline().split()))
LRC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

LRC.sort()
LRC = [(l - 1, r - 1, c) for l, r, c in LRC]
i = 0

# dp[pos]: pos までの最短距離
dp = SegmentTree(N, fn=min, initial_values=[INF] * N)
dp.set(0, 0)
for pos in range(N):
    d = dp.get(pos, N)
    while i < M and LRC[i][0] == pos:
        l, r, c = LRC[i]
        dp.add(r, d + c)
        i += 1
ans = dp.get(N - 1)
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 122072
{-# LANGUAGE BangPatterns #-}
import Control.Arrow (second)
import Control.Monad
import Control.Monad.Fix
import Data.Foldable (foldl')
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import System.IO.Unsafe

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread i v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite i a v = accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uswap :: VUM.Unbox a => Int -> Int -> VUM.IOVector a -> VUM.IOVector a
uswap i j v = accursedUnutterablePerformIO $ VUM.unsafeSwap v i j >> return v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw v = accursedUnutterablePerformIO $ VU.unsafeThaw v

newtype UnionFind = UnionFind (VUM.IOVector Int, VUM.IOVector Int)

findUF :: UnionFind -> Int -> Int
findUF (UnionFind (elems, _)) k = fix
  ( \f (elems, k, path) -> case uread k elems of
    n | n == k -> foldl' (\acc p -> uwrite p n acc) elems path `seq` n
    n          -> f (elems, n, n : path)
  )
  (elems, k, [k])

sizeUF :: UnionFind -> Int -> Int
sizeUF (UnionFind (_, sizes)) i = uread i sizes

unionUF :: UnionFind -> Int -> Int -> (UnionFind, Int)
unionUF uf@(UnionFind (elems, sizes)) i j =
  let pi = findUF uf i
      pj = findUF uf j
      si = sizeUF uf pi
      sj = sizeUF uf pj
  in  if pi == pj
        then (uf, 0)
        else
          let sij = si + sj
          in  ( UnionFind
                ( if si < sj then uwrite pi pj elems else uwrite pj pi elems
                , if si < sj
                  then uwrite pi 0 (uwrite pj sij sizes)
                  else uwrite pj 0 (uwrite pi sij sizes)
                )
              , si * sj
              )

comb2 k = k * (k - 1) `div` 2

solve :: Int -> Int -> VU.Vector (Int, Int) -> VU.Vector Int
solve n m abs = unsafePerformIO $ VU.freeze $ (\(_, _, acc) -> acc) $ VU.foldr
  go
  (group, 0, unsafePerformIO $ VUM.replicate m 0)
  abs
 where
  go (a, b) (uf, k, acc) =
    let (uf'@(UnionFind (!elems, !sizes)), d) = unionUF uf a b
    in  let prev = if k == 0 then 0 else uread (k - 1) acc
        in  (uf', k + 1, uwrite k (prev + d) acc)

  nC2 = comb2 n

  group :: UnionFind
  group =
    UnionFind (uthaw $ VU.enumFromN 0 n, unsafePerformIO $ VUM.replicate n 1)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nm  <- VU.unfoldrN 2 readInt <$> B.getLine
  abs <- VU.replicateM
    (nm VU.! 1)
    (   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine
    )

  let solutions = solve (nm VU.! 0) (nm VU.! 1) abs
  let nC2       = comb2 $ nm VU.! 0

  mapM_ (print . (nC2 -) . (solutions VU.!)) [nm VU.! 1 - 2, nm VU.! 1 - 3 .. 0]
  print nC2


Measured memory_bytes: 37884
/*
ABC138-E
英小文字からなる二つの文字列s,tが与えられる。
次の条件を満たす整数i(1<=i<=10^100)が存在し、
存在する場合はそのようなiの最小値を求める。
・sを10^100個連結して得られる文字列をs'とする。
　tは、文字列s'1s'2...s'iの部分列である。
制約
1<=|s|<=10^5
1<=|t|<=10^5
方針
まず、各文字列の出現位置を記憶する。
その後、tを1文字ずつ操作し、二分探索により
前回の文字列の位置より後ろにある今回の文字列の
位置を取得し、答えに加算する。
前回の文字列の位置より後ろに今回の文字列がない場合、
今回の文字列の出現位置のうち最も手前の位置と
(文字列の終端-前回の位置)を加算したものを
答えに加える。
*/

#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
const int MOD = 1000000007;

const int maxv = 100005;

int main(){
    string s, t;
    map<char, vector<int>> counter;
    cin >> s >> t;

    rep(i,s.size()){
        int index = i+1;
        // 各文字毎の出現位置を格納
        counter[s[i]].push_back(index);
    }

    ll ans = 0;
    int prev_index;
    // tの文字数分繰り返す
    rep(i, t.size()){
        char ch = t[i];
        // Sに登場しなかった場合は終了
        if (counter[ch].empty()){
            cout << -1 << endl;
            return 0;
        }
        if (i == 0) {
            prev_index = counter[ch][0];
            ans = prev_index;
            continue;
        }
        else{
            int size = counter[ch].size();
            vector<int> c = counter[ch];
            int next_index;
            if (prev_index >= c[size-1]){
                next_index = c[0];
            }
            else{
                
                ll ng = -1;
                ll ok = c.size();
                
                while(abs(ok-ng)>1){
                    ll mid = (ok+ng) / 2;
                
                    if(c[mid] > prev_index) ok = mid;
                    else ng = mid;
                }

                next_index = c[ok];
            }

           if (prev_index < next_index){
                ans += next_index - prev_index;
            }else{
                ans += next_index + (s.size() - prev_index);
            }
            prev_index = next_index;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){
  
  long double a,b,x;
  cin>>a>>b>>x;
  
  long double mytan;
  
  if (x<=(a*a*b)/2){
     mytan=(a*b*b)/(2*x);
  }
  else {
    mytan=(2*a*a*b-2*x)/(a*a*a);
  }
  
  long double pi=acos(-1);
  long double tan=atan(mytan);
  
  long double answer=(180*tan)/pi;
  
  cout<<fixed<<setprecision(12);
  cout<<answer<<endl;

}


















Measured memory_bytes: 256
def main():
    n=int(input())
    s=input()
    # if len(set(s)) == 1:
    #     print(0)
    #     return
    # s = s[s.index('#'):]
    # n = len(s)
    ans = n
    b = [0] * (n+1)
    w = [0] * (n+1)
    for i in range(n):
        b[i+1] = b[i] + (1 if s[i] == '#' else 0)
        w[i+1] = w[i] + (0 if s[i] == '#' else 1)

    for i in range(n+1):
        tmp = b[i] + (w[n] - w[i])
        ans = min([ans, tmp])
    print(ans)
main()


Measured memory_bytes: 19108
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int INF = 1e15;
const int MAX_V = 1010;
const int MAX_E = 2010;
struct edge {int to, cost;};
// edge es[MAX_E];
vector<edge> G[MAX_V]; 
int d[MAX_V];
int n, m;

bool bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
    fill(d, d + n, INF);
    d[s] = 0;
    for (int i = 0; i < 2 * n; i++) {
        for (int v = 0; v < n; v++) {
            for (int k = 0; k < G[v].size(); k++) {
                edge e = G[v][k];
                if (d[v] != INF && d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    if(i >= n - 1 && e.to == n - 1) return true;
                    // if (i == n - 1) return true; // n回目にも更新があるなら負の閉路が存在
                }
            }
        }
    }
    return false;
}

signed main(){
    cin >> n >> m;
    rep(i, 0, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--; c = -c;
        G[a]. push_back((edge){b, c});
        // es[i].from = a;
        // es[i].to = b;
        // es[i].cost = c;
    }
    bool f = bellman_ford(n, 0);
    if(f){
        cout << "inf" << endl;
    }else{
        cout << -d[n - 1] << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<vector<long long int>> vvint;
typedef vector<string> vstr;
typedef long long int llint;

llint gcd(llint x, llint y) {
	while (y != 0) {
		if (x > y) {
			llint r = x % y;
			x = y;
			y = r;
		}
		else {
			llint r = y % x;
			y = r;
		}
	}
	return x;
}

int main(void) {
	int H, R;
	cin >> H >> R;
	if ((H + R) > 0) {
		cout << 1 << endl;
	}
	else if((H+R)==0){
		cout << 0 << endl;
	}
	else {
		cout << -1 << endl;
	}
	
}



Measured memory_bytes: 3072
def main():
    n = int(input())
    restaurants = []

    for _ in range(n):
        city, point = input().split()
        restaurants.append((city, int(point)))
    
    for r in sorted(range(1, 1 + n), key=lambda i: (restaurants[i-1][0], -restaurants[i-1][1])):
        print(r)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int n;
int ans;

void dfs(ll x, bool f3, bool f5, bool f7) {
  if (x > n) return;
  if (f3 && f5 && f7) ans++;

  dfs(10*x+3, true, f5, f7);
  dfs(10*x+5, f3, true, f7);
  dfs(10*x+7, f3, f5, true);
  return;
}

int main () {
  cin >> n;
  ans = 0;
  dfs(0LL, false, false, false);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define se second
#define fi first
#define pb push_back

int main()
{
  ll n;
  cin >> n ;
  vector<ll>v(n+1) ;
  for(ll i=0;i<n-1;i++)
  {
    ll a ;
    cin >> a ;
    v[a]++ ;
  }
  for(ll i=1;i<n+1;i++)
  cout << v[i] << endl;


}


Measured memory_bytes: 4784
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    c.append(ai+bi)
c=sorted(c,reverse=True)
print(sum(c[::2])-sum(b))

Measured memory_bytes: 16256
x, y = map(int, input().split())
U = 2*10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
  fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  z = fact[n]
  z *= fact_inv[k]
  z %= MOD
  z *= fact_inv[n-k]
  z %= MOD
  return z

if (x+y)%3 != 0:
  print(0)
else:
  m = (x+y)//3
  l = x-m
  ans = comb(m, l)
  print(ans)

Measured memory_bytes: 161268
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long N;
    cin >> N;

    long long total = 0;
    for(long long i = 0; i < N + 1; i++)
        if(i % 3 != 0 && i % 5 != 0)
            total += i;

    cout << total << endl;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int gcd(int a,int b)
{
    while(a % b != 0)
    {
        int r = a % b;
        a = b;
        b = r;
    }
    return b;
}
int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    int Gcd = 1;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        if(i == 0)
        {
            Gcd = a[i];
        }
        else
        {
            Gcd = gcd(Gcd,a[i]);
        }
    }
    sort(a,a + n);
    if(k > a[n - 1])
    {
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    if(k % Gcd != 0)
    {
        cout << "IMPOSSIBLE\n";
        return 0;
    }
    cout << "POSSIBLE\n";

    return 0;
}

Measured memory_bytes: 640
n, s = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0]*(s+1) for _ in range(n+1)]
mod = 998244353

dp[0][0] = 1
for i in range(n):
  for j in range(s+1):
    dp[i+1][j] += dp[i][j] * 2
    dp[i+1][j] %= mod
    if j+a[i] <= s:
      dp[i+1][j+a[i]] += dp[i][j]
      dp[i+1][j+a[i]] %= mod
      
print(dp[n][s])

Measured memory_bytes: 139028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vector<bool> is_prime(N+1,true);
  vi prime;
  for(int i=2;i*i<=N;i++) {
    if(!is_prime[i]) continue;
    for(int j=2;i*j<=N;j++) is_prime[i*j]=false;
  }
  rep2(i,2,N+1) {
    if(is_prime[i]) prime.push_back(i);
  }
  ll ans=1;
  for(int i:prime) {
    int num=N,count=0;
    while(num>0) {
      num/=i;
      count+=num;
    }
    ans=ans*(count+1)%INF;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    int n[4], x[10];
    for (int i = 0; i < 10; i++) x[i] = 0;
    for (int i = 0; i < 4; i++) {
        cin >> n[i];
        x[n[i]]++;
    }
    
    if (x[1] == 1 && x[9] == 1 && x[7] == 1 && x[4] == 1)cout << "YES" << endl;
    else cout << "NO" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s;
        cin >> s;
        if((int)s.length() == 1){
            cout << "No\n";
            return 0;
        }
        int flag = 0;
        for(int i = 0; i < (int)s.length(); i += 2){
            if(!(s[i] == 'h' and s[i + 1] == 'i')){
                flag = 1;
                break;
            }
        }
        if(flag){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    } 
}

Measured memory_bytes: 31488
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int temp = n%28;
    int result[] = {0,4,8,12,16,20,24,7,14,21,11,15,19,23,27,18,22,26,25};
    for(int now: result){
        if(temp == now){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
    long long n, l;
    cin >> n >> l;

    
    vector<string> v;

    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(), v.end());
    string ans;
    for(long long i = 0; i < n; i++){
        ans += v[i];
    }

    cout << ans << endl;
    
    return 0;

}

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

typedef long long ll;

#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define MOD 1000000007
#define pb push_back
#define llnums vector<ll>
#define FOR(i,n) for(int i{0}; i < n; ++i)

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0); // B.cpp
  string s, t;
  cin >> s >> t;
  int ans=0;
  for (int i=0; i < s.size(); i++) {
      if (s[i] != t[i]) {
          ans++;
      }
  }
  cout << ans << '\n';
  return 0;
}








Measured memory_bytes: 3776
import sys
input = sys.stdin.buffer.readline

N = int(input())
X = list(map(int, input().split()))

answer = 10 ** 15
for p in range(1, 101):
    tmp = 0
    for x in X:
        tmp += (x - p) ** 2
    answer = min(answer, tmp)

print(answer)

Measured memory_bytes: 3060
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        
        int count = 0;
        
        for (int i = 0; i < n; i++) {
            if (x < a[i]) break;
            if (i == n - 1 && x != a[i]) {
                // 1人だけ喜ばない
            } else {
                x -= a[i];
                count++;
            }
        }
        
        so.println(count);
    }
}


Measured memory_bytes: 23124
N,K=map(int,input().split())
lis=[i for i in range(1,N+1)]
for i in range(K):
  d=int(input())
  tmp=[int(_) for _ in input().split()]
  for j in range(d):
    if tmp[j] in lis:
      lis.remove(tmp[j])
print(len(lis))

Measured memory_bytes: 9188
n = int(input())
a = list(map(int,input().split()))
d = {}
ans = 0
mod = 10**9 + 7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in a:
    arr = factorization(i)
    for j,k in arr:
        if j not in d:
            d[j] = k
        else:
            d[j] = max(k, d[j])

l = 1
for k,v in d.items():
    l *= pow(k,v,mod)
    l %= mod

for i in a:
    ans += l * pow(i, mod-2, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 46300
#include<bits/stdc++.h>
using namespace std;
int visit[101], d[101], f[101], t;
int n, M[101][101];

static const int WHITE = 0;
static const int GRAY = 1;

void dfs(int u){
    visit[u] = GRAY;
    d[u] = ++t;
    for( int v = 0; v < n; ++v ){
        if(M[u][v] == 0) continue;
        if(visit[v]==WHITE)
            dfs(v);
    }
    f[u] = ++t;
}

int main(){
    int u, v, k;
    cin >> n;
    for( int i = 0; i < n; ++i ){
        scanf("%d %d",&u,&k);
        u--;
        for( int j = 0; j < k; ++j ){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;
        }
    }
    for( int i = 0; i < n; ++i ){
        if(visit[i]==WHITE)
            dfs(i);
    }
    for( int i = 0; i < n; ++i ){
        cout << i+1 <<" "<< d[i] <<" "<< f[i] << endl;
    }
    return 0;
}




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

int main() {
	int X, Y;
	cin >> X >> Y;
	int prize = 0;
	if (X <= 3) prize += (4 - X) * 100000;
	if (Y <= 3) prize += (4 - Y) * 100000;
	if (X == 1 && Y == 1) prize += 400000;
	cout << prize << endl;
}

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

namespace D2019PCA
{
    class Program
    {
        static void Main(string[] args)
        {
            //スペース区切りで入力されたデータは１番目→input[0]、２番目→input[1] .......の形で受け取られる
            //配列の添え字は０から始める
            //受け取ったデータは文字型なので、整数型に変える
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            int ans = 0;

            ans = N - K + 1;

            Console.WriteLine(ans);//答えを出力する

        }
    }
}


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

long memo[2][3010][3010], n, a[3010], sum[3010];

long func(int taro, int i, int j)
{
    long& res=memo[taro][i][j];
    if (res<LONG_MAX) return res;

    res=0;
    if (i<=j) res=max(res, a[i]+sum[j+1]-sum[i+1]-func(!taro, i+1, j));
    if (j>=i) res=max(res, a[j]+sum[j]-sum[i]-func(!taro, i, j-1));
    return res;
}

int main()
{
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
        for(int j=0; j<n; ++j) for(int k=0; k<2; ++k) memo[k][i][j]=LONG_MAX;
    }
    auto X=func(1, 0, n-1);
    auto Y=sum[n]-X;
    cout<<X-Y<<endl;
}


Measured memory_bytes: 141824
import math
import sys
from itertools import accumulate
from functools import reduce
from collections import Counter
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))
    eL = Counter([L[i] for i in range(N) if i % 2 != 0])
    oL = Counter([L[i] for i in range(N) if i % 2 == 0])
    eLc = eL.most_common() # even list most common
    oLc = oL.most_common() # odd  list most common

    if eLc[0][0] != oLc[0][0]:
        print(N - (eLc[0][1] + oLc[0][1]))
    else:
        if len(eLc) == 1 or len(oLc) == 1:
            print(N // 2)
        else:
            print(min(N - (eLc[1][1] + oLc[0][1]), N - (eLc[0][1] + oLc[1][1])))



Measured memory_bytes: 22852
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll X;
	cin >> X;
	ll res = 2 * (X / 11);
	if (X % 11) {
		if (X % 11 <= 6) res += 1;
		else res += 2;
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256