akhauriyash/Code-Regression huggingface dataset:
#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>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
int main() {
	int N; cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) v[i] = i+1;
	vector<int> p(N), q(N);
	rep(i, N) cin >> p[i];
	rep(i, N) cin >> q[i];
	int n_p, n_q;
	int cnt = 0;
	do {
		cnt++;
		if (v == p) n_p = cnt;
		if (v == q) n_q = cnt;
	} while (next_permutation(v.begin(), v.end()));
	int ans = max(n_p-n_q, n_q-n_p);
	cout << ans << endl;
}

Measured memory_bytes: 3576
#include <iostream>
    using namespace std;
     
    int main() {
    
        int D, T, S;
        cin >> D >> T >> S;
    
        int dist = S * T;
     
        if (dist >= D) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

Measured memory_bytes: 3564
#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>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const int M=3010;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		ks=ks*2%d;
	}
	char *p = new char[200000000];
	for(int i=0;i<200000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

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

int main() {
  int n, k;
  cin>>n>>k;
  vector<int> x(n);
  for(int i=0; i<n; i++){
    cin>>x[i];
  }
  
  int ans=0;
  for(int i=0; i<n; i++){
    ans += 2*min(k-x[i], x[i]);
  }
  cout << ans <<endl;
}

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

using namespace std;
using ll = long long int;

int main()
{
    int n, q;
    ll k;
    cin >> n >> k >> q;
    vector<int> memo(n, 0);
    for(int i = 0; i < q; i++)
    {
        int temp;
        cin >> temp;
        memo[temp - 1]++;
    }
    for(int i = 0; i < n; i++)
    {
        if(k - (q - memo[i]) <= 0)
        {
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
}

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    int x;
    cin >> x;
    if (x >= 30)
        cout << "Yes";
    else
        cout << "No";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

namespace __C__ProgramingContest
{
    class Program
    {
        static void Main(string[] args)
        {
            int num5 = 5;
            int num9 = 9;

            ////論理積
            //int numCalc = num5 & num9;

            //Console.Write(Convert.ToString(num5, 2).PadLeft(8, '0'));
            //Console.WriteLine("({0})", num5);

            //Console.Write(Convert.ToString(num9, 2).PadLeft(8, '0'));
            //Console.WriteLine("({0})", num9);

            //Console.WriteLine("{0} & {1} =", num5, num9);

            //Console.Write(Convert.ToString(numCalc, 2).PadLeft(8, '0'));
            //Console.WriteLine("({0})", numCalc);
            // 整数の入力
            int a = int.Parse(Console.ReadLine());
            int ans = 0;
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            // 100個の要素を0で初期化（intをnewした場合はゼロクリアされる）
            int[] x = new int[100005];
            int[] y = new int[100005];
            int[] z = new int[100005];
            //int[,] count = new int[1003,1003];

            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < a; i++)
            {
                x[i] = int.Parse(input[i]);
            }
            for (int i = 0; i < a - 2; i++)
            {
                if ((x[i] < x[i + 1] && x[i + 1] < x[i + 2])
                    ||(x[i] > x[i + 1] && x[i + 1] > x[i + 2]))
                {
                    ans++;
                }
            }
            // 文字列の入力
            //string s = Console.ReadLine();
            //出力
            //Console.WriteLine((a + b) + " " + s);
            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define FOR(i, j, n) for (int i  =  j; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
constexpr int MOD = 1e9 + 7;
//------------ATCODER TEMPLATE-------------

signed main() {
  int N; cin >> N;
  vector<int> A(N), S(N + 1);
  REP(i, N) cin >> A[i];

  S[N] = 0;
  for (int i = N - 1; i >= 0; --i) {
    S[i] = S[i + 1] + A[i];
    S[i] %= MOD;
  }

  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum += A[i] * S[i + 1];
    sum %= MOD;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
    double a, b;
    cin >> a >> b;
    cout << round((a+b)/2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()                                            
{
	int n,a[25],b[25],c[25],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		cin>>b[i]; 
		ans+=b[i];
	}
	for(int i=1;i<=n-1;i++)cin>>c[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i+1]==a[i]+1)
		{
			ans+=c[a[i]];
		}
	}
	cout<<ans;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int>veca(n);
  vector<int>vecb(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>veca[i];
  }
  for(int i=0;i<n;i++){
    cin>>vecb[i];
  }
  for(int i=0;i<n;i++){
    if(veca[i]>vecb[i]){
      ans+=veca[i]-vecb[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
[N,M,C] = list(map(int,input().split()))
B = list(map(int,input().split()))

A = []
for i in range(N):
    A.append(list(map(int,input().split())))

count=0
for i in range(N):
    dammy=0
    for j in range(M):
        dammy +=  A[i][j] * B[j]
    #print(dammy)
    if dammy + C > 0:
        count += 1

print(count)

Measured memory_bytes: 38384
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) throws Exception {
        int studentNumber;
        Scanner sc = new Scanner(System.in);
        StandardDeviation sd = new StandardDeviation();
        while( !((studentNumber = sc.nextInt()) == 0) ){
            int[] testPoint = new int[studentNumber];
            for(int i = 0; i < studentNumber; i++){
                testPoint[i] = sc.nextInt();
            }
            System.out.println(Math.sqrt(sd.calcOfDispersion(testPoint, sd.calcOfAverage(testPoint))));
        }
    }
}

class StandardDeviation{
    double sum = 0;            //合計値
    double average = 0;        //平均    
    double dispersion = 0;     //分散
    
    //平均の計算
    public double calcOfAverage(int[] testPoint){
        sum = 0;
        for(int i = 0; i < testPoint.length; i++){
            sum += testPoint[i];
        }
        average = sum / testPoint.length;
        return average;
    }
    
    //分散の計算
    public double calcOfDispersion(int[] testPoint, double average){
        sum = 0;
        for(int i = 0; i < testPoint.length; i++){
            sum += Math.pow((testPoint[i] - average), 2);
        }
        dispersion = sum / testPoint.length;
        return dispersion;
    }
}


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

int main(){
  char a;
  cin >> a;
  if(a == 'A'){
    cout << 'T';
  }
  else if(a == 'T'){
      cout << 'A';
  }
  else if(a == 'G'){
      cout << 'C';
  }
  else{
      cout << 'G';
  }
}


Measured memory_bytes: 256
'''
メモ

時計回りに、隣接する家までの距離を計算する。
　移動先の家の方が、原点からの距離が大きい場合、
 　差を計算する
 小さい場合、
 1周の距離を用いて、差を計算する
 
上記で計算した距離から最大距離を除いた和を出力する

'''

K, N = map(int, input().split())
distance_from_north = [int(i) for i in input().split()]

distance_between_house = []

for i, distance in enumerate(distance_from_north):
  if i == len(distance_from_north) - 1:
    distance_between_house.append(distance_from_north[0] + (K - distance))
    break
  
  distance_between_house.append(distance_from_north[i + 1] - distance_from_north[i])
  
distance_between_house = sorted(distance_between_house)
print(sum(distance_between_house[:-1]))

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int A[100010];

int a[100010];

bool check(int n) {
	if (n % 2 == 0) {
		for (int i = 0; i < n; i++) {
			if (A[i] % 2 == 0) return false;
			a[A[i]]++;
		}
		for (int i = 0; i < n; i++) {
			if (a[i] != 2 && a[i] != 0) return false;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (A[i] % 2 == 1) return false;
			a[A[i]]++;
		}
		if (a[0] != 1) return false;
		for (int i = 1; i < n; i++) {
			if (a[i] != 2 && a[i] != 0) return false;
		}
	}

	return true;
}

int main(void){
	cin>>n;
	for (int i = 0; i < n; i++) cin>>A[i];

	if (check(n)) {
		ll ans = 1;
		for (int i = 0; i < n / 2; i++) {
			ans *= 2;
			ans %= MOD;
		}
		printf("%lld\n", ans);
	} else {
		printf("%d\n", 0);
	}
	
	return 0;
}

Measured memory_bytes: 1024
#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<int> h(n);
  rep(i,n) cin >> h[i];
  int count = 0;
  rep(i,n) {
    bool flag = true;
    rep(j,i){
      if(h[i]<h[j]){
        flag = false;
        break;
      }
    }
    if(flag) ++count;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,i,j,sum=0,temp;
    scanf("%d %d",&n,&k);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<n;i++)
    {
        for(j=0;j<n-i;j++)
        {
            if(a[j]>a[j+1])
            {
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(i=0;i<k;i++)
    {
        sum=sum+a[i];
    }
    printf("%d\n",sum);
}


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

#define count_ones __builtin_popcountl
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    const ll max = 1e5 + 5;
    vector<bool> b(max, true);
    b[0] = false;
    b[1] = false;
    for (ll i = 2; i < max; ++i) {
        if (b[i]) {
            if (i >= x) {
                cout << i;
                break;
            }
            for (ll j = i * i; j < max; j += i) b[j] = false;
        }
    }

    return 0;
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

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

int main() {
    int N, M;
    cin >> N >> M;
    REP(i, M) {
        int A;
        cin >> A;
        N -= A;
    }

    if (N >= 0) cout << N << endl;
    else cout << -1 << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector <vector<int>> A(2, vector<int>(N, 0));
    for (int i=0; i<2; i++) {
        for (int j=0; j<N; j++) cin >> A.at(i).at(j);
    }
    long long ans=0;
    for (int i=0; i<N; i++) {
        long long tmp=0;
        for (int j=0; j<=i; j++) tmp+=A.at(0).at(j);
        for (int j=i; j<N; j++) tmp+=A.at(1).at(j);
        ans = max(tmp, ans);
    }
    cout << ans << endl;;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li x[100100];

int main() {
    cin >> n;
    rin{
        cin >> x[i];
    }
    li res = 1;
    li lim = 3;
    li idx = 1;
    rin{
        // i番目にゴールするやつが何通りいるか数える
        while (idx < n && x[idx] >= lim) {
            idx++;
            lim += 2;
        }
        if (idx == n) {
            idx--;
        }
        // だめになった最初のやつはセーフ
        //p4(i, res, idx, idx - i + 1);
        res = (res * (idx - i + 1)) % MOD;

        idx++;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 1024
class SegmentTree:
    def __init__(self,l,init):
        nb = bin(len(l))[2:]
        b = sum([int(d) for d in nb])
        if b == 1:
            self.end_leaves = pow(2,len(nb)-1)
        else:
            self.end_leaves = pow(2,len(nb))
        self.tree = [init] * (self.end_leaves*2)
        
        for i in range(len(l)):
            self.tree[self.end_leaves+i] = l[i]
            
    def stmax(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = max(self.tree[a*2:a*2+2])
            return self.tree[a]
        else:
            self.tree[a] = max(self.stmax(a*2),self.stmax(a*2+1))
            return self.tree[a]
    def stmin(self,a):
        if a >= self.end_leaves // 2:
            self.tree[a] = min(self.tree[a*2:a*2+2])
            return self.tree[a]
        else:
            self.tree[a] = min(self.stmin(a*2),self.stmin(a*2+1))
            return self.tree[a]
        
    def querymax(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = 0
        tr = 0
        while y - x > 1:
            if x % 2 == 1:
                tl = max(tl,self.tree[x])
                x += 1
            if y % 2 == 0:
                tr = max(self.tree[y],tr)
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            return max(tl,tr,self.tree[x])
        else:
            return max(tl,tr,self.tree[x],self.tree[y])
    def querymin(self,l,r):
        x = l + self.end_leaves
        y = r + self.end_leaves
        tl = float('inf')
        tr = float('inf')
        while y - x > 1:
            if x % 2 == 1:
                tl = min(tl,self.tree[x])
                x += 1
            if y % 2 == 0:
                tr = min(self.tree[y],tr)
                y -= 1
            x >>= 1
            y >>= 1
        if y - x == 0:
            return min(tl,tr,self.tree[x])
        else:
            return min(tl,tr,self.tree[x],self.tree[y])

from collections import deque

N,K = (int(x) for x in input().split())
P = list(map(int, input().split()))
d = deque(P)
st1 = SegmentTree(P,0)
st1.stmax(1)
st2 = SegmentTree(P,float('inf'))
st2.stmin(1)
combo = 0
mono_increased = False
ans = 0
comp = -1

for i in range(K):
    temp = d.popleft()
    if temp > comp:
        combo += 1
    else:
        combo = 1
    comp = temp

if combo == K:
    mono_increased = True
else:
    ans += 1
d2 = deque(P)

for i in range(1,N-K+1):
    temp = d.popleft()
    if temp > comp:
        if combo < (K-1):
            combo += 1
        elif combo == K-1:
            combo += 1
            mono_increased = True
    else:
        combo = 1
    comp = temp
    t2 = d2.popleft()
    if combo < K:
        if temp < st1.querymax(i,i+K-1):
            ans += 1
        else:
            if t2 > st2.querymin(i,i+K-1):
                ans += 1

if mono_increased == True:
    print(ans+1)
else:
    print(ans)

Measured memory_bytes: 135244
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

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



signed main(){

    int N; cin >> N;
    string A, B, C; cin >> A >> B >> C;

    int ans = 0;
    REP(i, N){
        if(A[i] == B[i] && B[i] == C[i]){
            ans += 0;
        }else if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]){
            ans += 2;
        }else ans += 1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
use std::cmp::max;
use std::collections::HashMap;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut map: HashMap<String, i32> = HashMap::new();
    for _ in 0..n {
        let k: String = read(&mut stdin_lock, &mut buf, b'\n');
        let v: i32 = *map.get(&k).unwrap_or(&0);
        map.insert(k, v + 1);
    }
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    for _ in 0..m {
        let k: String = read(&mut stdin_lock, &mut buf, b'\n');
        match map.get(&k) {
            Some(&v) => map.insert(k, v - 1),
            None => None,
        };
    }

    let max_value = map.values().max().unwrap();
    let ans = max(*max_value, 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>

#define all(v) (v).begin(), (v).end()
using namespace std;

int main()
{
    int no_of_elements;
    scanf("%d", &no_of_elements);

    vector <int> A(no_of_elements);
    for(int i = 0; i < no_of_elements; i++)
    {
        scanf("%d", &A[i]);
        A[i] -= (i + 1);
    }

    sort(all(A));

    int median_index = no_of_elements/2 + no_of_elements%2 - 1;
    int median = A[median_index];

    long long answer = 0;
    for(int i = 0; i < no_of_elements; i++)
        answer += abs(A[i] - median);

    printf("%lld\n", answer);

    return 0;
}


Measured memory_bytes: 1024
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

vector<ll> dp;

const ll MD = 1e9+7;
int S;

inline ll ADD(ll a, ll b) {
	return (a + b) % MD;
}

ll eval(ll val) {
	if (val == 0) return 1LL;
	if (dp[val] != -1) return dp[val];
	ll &ret = dp[val];
	ret = 0;
	for (int i = 3; i <= S; ++i) {
		if (val >= i) ret = ADD(ret, eval(val-i));
		else break;
	}
	return ret;
}

int main() {
	sci(S);
	dp.assign(S+1, -1);
	printf("%lld\n", eval(S));
	return 0;
}

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

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

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N, X;
	cin >> N >> X;
	vector<int> A(N + 1);
	A[0] = 0;
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
		A[i] += A[i - 1];
	}
	int ans = upper_bound(A.begin(), A.end(), X) - A.begin();
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int r, D;
    long x;
    scanf("%d %d %ld",&r,&D,&x);
    
    for(int i = 1; i <= 10; i++)
    {
        x = r*x-D;
        printf("%ld\n",x);
    }
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      //数字の数を入力
		int k = sc.nextInt();
		String s = sc.next();
	  //
      int sLen = s.length();
      if(sLen <= k){
        System.out.println(s);
      }else{
        System.out.println(s.substring(0,k)+ "...");
      }
	}

}


Measured memory_bytes: 38640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

const int MAX_N = 100005;

int n;
int v[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> v[i];

	map<int, int> cnt1;
	for (int i = 0; i < n; i += 2)
		cnt1[v[i]]++;
	map<int, set<int>> cnt1Rev;
	for (const auto& p : cnt1)
		cnt1Rev[p.second].insert(p.first);

	int result = n;
	map<int, int> cnt2;
	for (int i = 1; i < n; i += 2)
		cnt2[v[i]]++;
	for (const auto& p : cnt2)
	{
		auto it = cnt1Rev.end();
		it--;
		if (it->second.size() == 1 && *(it->second.begin()) == p.first)
		{
			if (it == cnt1Rev.begin())
			{
				result = min(result, n - p.second);
				continue;
			}
			else
				it--;
		}
		result = min(result, n - it->first - p.second);
	}
	cout << result << endl;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll money = 1000, stock = 0;
    vector<ll> stock_upper, stock_lower;
    bool want_bottom;
    rep(i, n-1){
        if(a[i] < a[i+1]){
            want_bottom = true;
            break;
        }else if(a[i] > a[i+1]){
            want_bottom = false;
            break;
        }
        want_bottom = false;
    }
    ll current_price = a[0];
    REP(i, n-1){
        if(current_price < a[i]){
            if(want_bottom){
                stock_lower.push_back(current_price);
                want_bottom = false;
            }
        }else if(current_price > a[i]){
            if(!want_bottom){
                stock_upper.push_back(current_price);
                want_bottom = true;
            }
        }
        current_price = a[i];
    }
    if(!want_bottom) stock_upper.push_back(a[n-1]);
    /*
    rep(i, (int)stock_upper.size()){
        cout << stock_upper[i] << endl;
    }
    cout << stock_lower.size() << endl;
    cout << stock_upper.size() << endl;
    */
    if(stock_lower.size() == stock_upper.size()){
        rep(i, (int)stock_lower.size()){
            stock = money / stock_lower[i];
            money -= stock * stock_lower[i];
            money += stock * stock_upper[i];
            stock = 0;
        }
    }else{
        rep(i, (int)stock_lower.size()){
            stock = money / stock_lower[i];
            money -= stock * stock_lower[i];
            money += stock * stock_upper[i+1];
            stock = 0;
        }
    }
    cout << money << endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/18  Problem: ABC 079 C / Link: http://abc079.contest.atcoder.jp/tasks/abc079_c  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s; cin >> s;
	VI a(4);
	FOR(i, 0, 4)a[i] = s[i] - '0';
	FOR(i, 0, 1 << 3) {
		int ret = a[0];
		FOR(j, 0, 3) {
			if (i&(1 << j)) {
				ret += a[j+1];
			}
			else ret -= a[j+1];
		}
		if (ret == 7) {
			FOR(k, 0, 4) {
				cout << s[k];
				if (k < 3) {
					if(i&(1<<k)){
						cout << "+";
					}
					else {
						cout << "-";
					}
				}
			}
			cout << "=7\n";
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int a, b, k;
  cin >> a >> b >> k;
  vec1 tmp(0);
  for(int i = 1; i < 10e5; i++) {
    if(a % i == 0 && b % i  == 0) {
      tmp.push_back(i);
    }
  }
  reverse(tmp.begin(),tmp.end());
  cout << tmp.at(k-1) << endl;
}

Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    k = f()[0]

    ans = 1
    for i in range(n):
        if ans < k:
            ans += ans
        else:
            ans += k
    
    print(ans)

solve()


Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		HashSet<Integer> set=new HashSet<>();
		int X=sc.nextInt();
		int N=sc.nextInt();
		for (int i=0;i<N;++i) {
			int p=sc.nextInt();
			set.add(p);
		}
		for (int d=0;;++d) {
			for (int v:new int[]{X-d,X+d}) { 
				if (!set.contains(v)) {
					System.out.println(v);
					return;
				}
			}
		}
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  vector<int> a(26, 0);
  vector<int> b(26, 0);

  for (int i = 0; i < s.size(); i++) {
    int c = s.at(i) - 'a';
    a.at(c)++;
  }
  for (int i = 0; i < t.size(); i++) {
    int c = t.at(i) - 'a';
    b.at(c)++;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < 26; i++) {
    if (a.at(i) != b.at(i)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/7/2018
 
 14:15-14:20 analysis
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5;
int Q;
int L[MAX_N],R[MAX_N];
int P[MAX_N+1];
void solve() {
  REPE(n,MAX_N)P[n]=true;
  P[0]=P[1]=false;
  for(int p=2; p*p<=MAX_N; ++p) if(P[p]) {
    for(int q=p*p; q<=MAX_N; q+=p) P[q]=false;
  }
  for(int n=MAX_N; n>2; --n) if(P[n]) {
    P[n]=P[(n+1)/2];
  }
  P[2]=false;
  int cum[MAX_N+1]={};
  cum[0]=0;
  REPE(n,MAX_N)cum[n+1]=cum[n]+P[n];
  
//  dump2(P[13],P[2017]);
  
  REP(i,Q) {
    int l=L[i],r=R[i]+1;
    cout<<cum[r]-cum[l]<<endl;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>Q;
  REP(i,Q) cin>>L[i]>>R[i];
  solve();
  return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
int main(){
  int a,b,result;
  scanf("%d%d",&a,&b);

  if(a>b){
    result = a + a -1;
  }else if(a == b){
    result = 2*a;
  }else if(a < b){
    result = 2*b -1;
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define nax (int)1e5+2
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n" 
#define INF (int)1e9
#define eps (long double)1e-9
//#define int long long
using namespace std;
// sequences with only one 2 should not be included	
int main(){
	
	ll n,k;
	cin>>n>>k;
	if(n%k == 0){
		cout<<0;
	}
	else
	{
		cout<<min(n%k,k -(n%k) );
	}
	return 0;
}
	


Measured memory_bytes: 256
K = int(input())

#sevens = int('7' * len(str(K)))
sevens_mod = 7 % K
flag = False
ans = -1
for i in range(K):
    if sevens_mod == 0:
        flag = True
        ans = i + 1
        break
    sevens_mod = (sevens_mod * 10 + 7) % K
print(ans if flag else -1)


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

int main(void)
{
    int N, M;
    cin >> N >> M;
    priority_queue<int> A;
    int tmp;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A.push(tmp);
    }

    for (int i = 0; i < M; i++) {
        tmp = A.top() / 2;
        A.pop();
        A.push(tmp);
    }

    long long sumValue = 0;
    while (!A.empty()) {
        sumValue += A.top();
        A.pop();
    }

    cout << sumValue << endl;
}


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

using namespace std;
typedef long long ll;

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

    int sMax = s.size();
    int ans = 0;
    for(int i=0; i<sMax/2; i++){
        if(s[i] != s[(sMax-1) - i]){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,a,i,max=-1000000,min=1000000;
	double sum=0.0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum+=(double)a;
		if(a>max)
			max=a;
		if(a<min)
			min=a;
	}
	printf("%d %d %.0f\n",min,max,sum);
	return 0;
}


Measured memory_bytes: 1816
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    int n,k,a,b;
    cin >> n >> k;
    map<int,LL> m;
    REP(i,0,n) {
        cin >> a >> b;
        if (a > k) continue;
        m[a] += b;
    }
    set<int> s;
    s.insert(k);
    REP(i,0,30) {
        if (!(k & (1<<i))) continue;
        s.insert((k & ~(1<<i)) | ((1<<i)-1));
    }
    LL ans = 0;
    for (const int &t: s) {
        //dump(t);
        LL sum = 0;
        for (const auto &p: m) {
            int a = p.first;
            LL b = p.second;
            if ((t | a) != t) continue;
            sum += b;
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

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

string s;

int main(){
    cin >> s;

    int n = s.size();
    if(n % 2){
        if(s[0] == s[n-1]) cout << "Second" << endl;
        else cout << "First" << endl;
    }
    else{
        if(s[0] == s[n-1]) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    
    
    int i,num,a[100];
    
    
    scanf("%d",&num);
    for(i=1;i<=num;i++){
        scanf("%d",&a[i]);
    }
   
   
   for(i=num;i>=1;i--){
       
       if(i==1){
            printf("%d\n",a[1]);
       }
       else {
            printf("%d ",a[i]);
       }
   }
    return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
#include <algorithm>
#include<string>
#include <iostream>
using namespace  std;
int n,k;
const int N = 1010;
int a[N];
int main()
{

    cin>>n>>k;
    for(int i = 0 ;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum = 0;
    for(int i = 0 ;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;

    return 0 ;

}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
int main() {

	cin >> N;
	int a = N / 100;
	int c = N % 10;
	cerr << a << c;
	cout << (a == c ? "Yes" : "No") << endl;
}

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




int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> E(N,vector<int>());
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
	}
	
	vector<vector<int>> dis(N,vector<int>(N,Inf));
	
	for(int i=0;i<N;i++){
		dis[i][i] = 0;
		queue<int> Q;
		Q.push(i);
		while(Q.size()!=0){
			int from = Q.front();
			Q.pop();
			for(int j=0;j<E[from].size();j++){
				int to = E[from][j];
				if(dis[i][to]!=Inf)continue;
				dis[i][to] = dis[i][from]+1;
				Q.push(to);
			}
		}
	}
	
	int from = -1;
	int mini = Inf;
	set<int> S;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i==j)continue;
			int a = dis[i][j] + dis[j][i];
			if(a<mini){
				S.clear();
				mini = a;
				from = i;
				S.insert(from);
			}
			if(a==mini){
				if(from==i){
					S.insert(j);
				}
			}
		}
	}
	
	if(mini==Inf){
		cout<<-1<<endl;
	}
	else{
		cout<<mini<<endl;
		int now = from;
		while(true){
			for(int i=0;i<E[now].size();i++){
				int to = E[now][i];
				if(S.count(to)){
					S.erase(to);
					cout<<to+1<<endl;
					now = to;
					break;
				}
			}
			if(now==from)break;
		}
	}
			
	
	return 0;
}



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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
const ll i2 = (MOD + 1) / 2;
const int maxn = 1000010;

ll p4[maxn];

int main() {
	int N; cin >> N;
	V<int> C(N); rep(i, N) cin >> C[i];
	sort(ALL(C)); reverse(ALL(C));

	p4[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		p4[i] = p4[i-1] * 4 % MOD;
	}

	ll ans = 0;
	rep(i, N) {
		ans += (i + 2) * p4[N-1] % MOD * C[i] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <stdio.h>
using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll a[3], b[3];//g,s,b
    for(int i=0; i<3; i++){
        cin >> a[i];
    }
    for(int i=0; i<3; i++){
        cin >> b[i];
    }
    ll dp1[5001];
    memset(dp1, 0, sizeof(dp1));
    for(ll i=1; i<=N; i++){
        dp1[i]=dp1[i-1]+1;
        for(int j=0; j<3; j++){
            if(i-a[j]>=0){
                dp1[i]=max(dp1[i], dp1[i-a[j]]+b[j]);
            }
        }
    }
    
    N=dp1[N];
    ll dp2[N+1];
    memset(dp2, 0, sizeof(dp2));
    for(ll i=1; i<=N; i++){
        dp2[i]=dp2[i-1]+1;
        for(int j=0; j<3; j++){
            if(i-b[j]>=0){
                dp2[i]=max(dp2[i], dp2[i-b[j]]+a[j]);
            }
        }
    }
    cout << dp2[N] << endl;
    
    return 0;
}

Measured memory_bytes: 195584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
ll g1(ll n, int p) {
	if (n == 0)return 0;
	return n/p+g1(n/p,p);
}
int main() {
	ll a,ans=0;
	cin >> a;
	if(a%2==0) ans = g1(a/2, 5);
	cout << ans << endl;
	return 0;
}
 

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

int main(){
    int k,s;
    cin >> k >> s;

    int res = 0;
    for(int x = 0;x <= k;++x){
        for(int y = 0;y <= k;++y){
            int z = s - x - y;
            if(0 <= z && z <= k)++res;
        }
    }
    cout << res << endl;
    return 0;
}

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

int top=0,s[MAX];
int pop();
void push(int);


int main(){
  int x,y;
  char h[MAX];
  while(scanf("%s",h)!=EOF){
    if(h[0]=='+'){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(h[0]=='-'){
      x = pop();
      y = pop();
      push(y - x);
    }
    else if(h[0]=='*'){
      x = pop();
      y = pop();
      push(x * y);
    }
    else push(atoi(h));
  }
  printf("%d\n",pop());
  return 0;
}

int pop(){
  return s[top--];
}

void push(int q){
  s[++top]=q;
}



Measured memory_bytes: 2108
#include<iostream>
using namespace std;
string s,t;
main()
{
	int n,f,l,m;cin>>n;f=0;l=n;
	cout<<0<<endl;
	cin>>s;
	if(s=="Vacant")return 0;
	while(t!="Vacant"){
		m=(f+l)/2;
		cout<<m<<endl;
		cin>>t;
		if(m%2^s==t)f=m;
		else l=m;
	}
}

Measured memory_bytes: 852