akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int a[4],ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    for(int i=1;i<=3;i++)cin>>a[i];
    sort(a+1,a+1+3);
    a[1] += abs(a[3]-a[2]);
    ans += abs(a[3]-a[2]);

    if(abs(a[1]-a[3])%2==0){
        ans += abs(a[1]-a[3])/2;
    }
    else{
        ans += abs(a[1]-a[3])/2 + 2;
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 256
N,M=gets.split.map &:to_i
c=0;r=0
AB=N.times.map{gets.split.map &:to_i}.sort.map{|a,b|
    if c+b<=M
        c+=b;r+=a*b
    else
        r+=a*(M-c);break
    end
}
p r

Measured memory_bytes: 11128
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1167&lang=jp
//Pollock's conjecture
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
ll calc_vol(ll n){
	return n*(n+1)*(n+2)/6;
}
constexpr ll INF=2LL<<60;

int main(){
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif

	ll val=1e+6;
	ll limit=1;
	vector<ll> vols0(2),vols1(2);
	vols0[0]=0; vols1[0]=0;
	vols0[1]=1; vols1[1]=1;
	while(calc_vol(limit+1)<=val){
		auto v=calc_vol(limit+1);
		vols0.push_back(v);
		if(v%2==1)vols1.push_back(v);
		limit++;
	}

	auto mktbl = [&val](vector<ll>& dp, const auto& vols){
		dp[0]=0;
		ll lim = vols.size()-1;
		FOR(i,0,lim){
			ll vol=vols.at(i+1);
			dump(vol);
			FOR(j,0,val+1){
				if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			}
		}
	};
	vector<ll> dp0(val+1,INF);
	mktbl(dp0,vols0);

	vector<ll> dp1(val+1,INF);
	mktbl(dp1,vols1);

	while(true){
		ll t; cin>>t;
		if(t==0)break;
		cout<<dp0[t]<<" "<<dp1[t]<<endl;
	}

	return 0;
}

ll solve(const ll val){
	ll limit=1;
	while(calc_vol(limit+1)<=val){
		limit++;
	}
	dump(limit,calc_vol(limit));

	vector<ll> dp(val+1,INF);
	dp[0]=0;
	FOR(i,0,limit+1){
		ll vol=calc_vol(i+1);
		FOR(j,0,val+1){
			//chmin(dp[i+1][j],dp[i][j]);
			if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			//if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
		}
	}
	dump(dp);

	return dp[val];
}
ll solve2(const ll val){
	ll limit=1;
	vector<ll> vols(2);
	vols[0]=0;
	vols[1]=1;
	while(calc_vol(limit+1)<=val){
		auto v=calc_vol(limit+1);
		if(v%2==1)vols.push_back(v);
		limit++;
	}
	dump(limit,calc_vol(limit));

	vector<ll> dp(val+1,INF);
	dp[0]=0;
	limit = vols.size()-1;
	FOR(i,0,limit){
		//ll n2=lim2i(i);
		//ll vol=calc_vol(n2);
		ll vol=vols.at(i+1);
		dump(vol);
		FOR(j,0,val+1){
			//chmin(dp[i+1][j],dp[i][j]);
			if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
			//if(j-vol>=0)chmin(dp[j],dp[j-vol]+1);
		}
	}
	dump(dp);

	return dp[val];
}
int main_() {
#if LOCAL&01
	std::ifstream in("./test/sample-1.in");
	//std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif
	//solve2(40); return 0;
	while(true){
		ll t; cin>>t;
		if(t==0)break;
		cout<<solve(t)<<" "<<solve2(t)<<endl;
	}
	return 0;
}


Measured memory_bytes: 18296
#全て正か負になるようにすればいい N
#あとは小さい方から足していくかするだけ
n = int(input())
a = list(map(int, input().split()))

ma = max(a)
mi = min(a)
flag = 0
#全部負
if ma <= 0:
    flag = 1
#全部正
elif mi >= 0:
    flag = 0
else:
    #全部負にする
    if abs(ma) < abs(mi):
        flag = 2
    #全部正にする
    else:
        flag = 3
cnt = 0
printer = ""
if flag == 2:
    x = a.index(mi)
    for i in range(n):
        if i == x:
            continue
        cnt += 1
        printer += "{0} {1}\n".format(x + 1, i + 1)
if flag == 3:
    x = a.index(ma)
    for i in range(n):
        if i == x:
            continue
        cnt += 1
        printer += "{0} {1}\n".format(x + 1, i + 1)
if flag == 0 or flag == 3:
    for i in range(n - 1):
        cnt += 1
        printer += "{0} {1}\n".format(i + 1, i + 2)
elif flag == 1 or flag == 2:
    for i in range(n-1):
        cnt += 1
        printer += "{0} {1}\n".format(n - i, n - i - 1)
print(cnt)
print(printer[:-1])


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int n, v[101];

int main(void) {
    while(~scanf("%d", &n)) {
        for(int i = 0; i < n; i++) {
            scanf("%d", &v[i]);
        }
        sort(v, v + n);
        int am = 0;
        for(int i = 0; i < n; i++) {
            int tmp = 0;
            for(int j = i; j >= 0; j--) {
                tmp += v[j];
            }
            am += tmp;
        }
        printf("%d\n", am);
    }
    return 0;
}

Measured memory_bytes: 0
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	vector<LL> a(n+1);

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

	LL ans = 0;
	LL sum = 0;
	for (int i = n - 1; i >= 1; i--) {
		sum += a[i + 1]; sum %= MOD;
		ans = (ans + (a[i] * sum)%MOD)%MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4748
/* */

#include <iostream>
#include <string>
using namespace std;

int main(){
	int n;
	string a, b, c;
	int tot = 0;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; ++i){
		int cnt = 0;
		if(a[i]!=b[i]){
			if(b[i]!=c[i]){
				if(c[i]!=a[i]){
					cnt = 2;
				}else{
					cnt = 1;
				}
			}else{
				cnt = 1;
			}
		}else{
			if(b[i]!=c[i]){
				cnt = 1;
			}else{
				cnt = 0;
			}
		}
		tot += cnt;
	}

	cout << tot << endl;

}

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

public class FactorialFunction
{
    readonly long[] factorials;

    public long Factorial(int n)
    {
        return factorials[n];
    }

    public FactorialFunction(int maxValue, long mod)
    {
        factorials = new long[maxValue + 1];
        factorials[0] = 1;

        for (var i = 1; i <= maxValue; i++)
        {
            factorials[i] = (factorials[i - 1] * i) % mod;
        }
    }
}

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    const int Mod = 1000000007;

    int n, m;

    void Read()
    {
        var l = ReadLine(int.Parse);
        n = l[0];
        m = l[1];
    }

    long Solve()
    {

        var d = Math.Abs(n - m);
        if (d >= 2) return 0;

        var factorialFunc = new FactorialFunction(Math.Max(n, m), Mod);
        var factorial = new Func<int, long>(factorialFunc.Factorial);

        if (d == 1)
        {
            return factorial(n) * factorial(m) % Mod;
        }

        return ((2 * factorial(n) % Mod) * factorial(m)) % Mod;
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


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

int main()
{
	int n;
	while(cin>>n){
		int na, nb;
		bool flag = true;
		for(int i=n-1;;i--){
			for(int j=2;j*j<=i;j++){
				if(i % j == 0){
				flag = false;
				break;
				}
			}
			if(flag){
			na = i;
			break;
			}
			flag = true;
		}
		
		flag = true;
		for(int i=n+1;;i++){
			for(int j=2;j*j<=i;j++){
				if(i % j==0){
					flag = false;
					break;
				}
			}
			if(flag){
				nb = i;
				break;
			}
			flag = true;
		}
		
		cout<<na<<' '<<nb<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >>N;
    int a,b,c;
    for(int i=0;i<N;i++){
        cin >>a>>b>>c;
        if(a*a==b*b+(c*c)||b*b==a*a+(c*c)||c*c==a*a+(b*b)){
            cout <<"YES"<<endl;
        }
        else{
            cout <<"NO"<<endl;
        }
    }
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n), a;
    rep(i, n)
    {
        cin >> b[i];
        b[i]--;
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = i; j >= 0; j--)
        {
            if (b[j] == j)
            {
                a.push_back(j);
                b.erase(b.begin() + j);
                break;
            }
        }
    }
    if (a.size() != n)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        rep(i, n)
        {
            cout << a.back() + 1 << endl;
            a.pop_back();
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(a==5&&b==7&&c==5){
       cout<<"YES"<<endl;
   }
   else if(a==5&&b==5&&c==7){
       cout<<"YES"<<endl;
        }   
        else if(a==7&&b==5&&c==5){
                cout<<"YES"<<endl;
                }
                else{
                    cout<<"NO"<<endl;
                }

}



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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

  int S, W;
  cin >> S >> W;

  if(W >= S)cout << "unsafe" << endl;
  else cout << "safe" << endl;

  
}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3632
import math

# one = 1000000000000001
dict={1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i",10:"j",
        11:"k",12:"l",13:"m",14:"n",15:"o",16:"p",17:"q",18:"r",19:"s",20:"t",
        21:"u",22:"v",23:"w",24:"x",25:"y",26:"z"}

n=int(input())

ans = str(dict[(n-1)%26+1])

n=(n-1)//26
while n:
    ans = str(dict[(n-1)%26+1]) + ans
    n=(n-1)//26

print(ans)


Measured memory_bytes: 9172
string =str(input())
K=int(input())
l=len(string)
substring = set()
for i in range(l):
    for j in range(i+1,i+K+1):
        substring.add(string[i:j])
#print(substring)
sublist = list(substring)
sublist.sort()
#print(sublist)
print(sublist[K-1])


Measured memory_bytes: 4464
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		long answer=0;
		//List<Integer> h=new ArrayList<Integer>();
		//int t[]=new int[(int)Math.pow(10,5)];
		int max=Integer.MIN_VALUE;
		int min=Integer.MAX_VALUE;
		//int h[]=new int[(int)Math.pow(10,5)];
		
		//入力
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		//List<Integer> A=new ArrayList<Integer>();
		//for(int i=0;i<M;i++)
		//{
		//	A.add(sc.nextInt());
		//}
		Long a[][]=new Long[N][2];
		for(int i=0;i<N;i++)
		{
			a[i][0]=sc.nextLong();
			a[i][1]=sc.nextLong();
		}
		Arrays.sort(a,(x,y) -> Long.compare(x[0], y[0]));
		//System.out.println(Arrays.deepToString(a));
		//処理
		for(int i=0;i<N;i++)
		{
			if(M-a[i][1]>=0)
			{
				answer+=a[i][0]*a[i][1];
				M-=a[i][1];
			}else
			{
				M-=a[i][1];
				//System.out.println("aa"+M);
				answer+=a[i][0]*(a[i][1]+M);
			}
			//System.out.println(answer);
			if(M<=0)
			{
				break;
			}
		}
		// 出力
		//System.out.println(Arrays.toString(X));
		//System.out.println(Arrays.deepToString(a));
		//System.out.println(Arrays.toString(A.toArray()));
		System.out.println(answer);
	}
}

Measured memory_bytes: 98264
import sys
s = list(input())
n = len(s)

for i in range(n):
    if i%2 == 0:#奇数番目
        if s[i] == 'L':
            print('No')
            sys.exit()
    else:#偶数番目
        if s[i] == 'R':
            print('No')
            sys.exit()
            
print('Yes')

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
typedef long long ll;
ll lucas (int n) {
    ll l0 = 2;
    ll l1 = 1;
    ll l2;
    if (n == 0) return l0;
    else if (n == 1) return l1;
    else {
        for (int i = 0; i < n - 1; i++) {
            l2 = l1 + l0;
            l0 = l1;
            l1 = l2;
        }
    }
    return l1;
}
int main (void) {
    int n;

    cin >> n;

    cout << lucas(n) << endl;

    return 0;
}

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

def main():
    Ans = [B[0]]*(N)
    for i in range(1,N-1):
        Ans[i] = min(B[i-1],B[i])
    Ans[N-1] = B[-1]
    print(sum(Ans))
    return
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scan(&n)
	m := make(map[int]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		m[i] = a - 1
	}

	var cnt int
	for k, v := range m {
		if m[v] == k {
			cnt++
		}
	}

	fmt.Println(cnt / 2)
}


Measured memory_bytes: 7808
n,t = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
answer,start = 0,0
if len(a)==1: answer = t
for i in range(1,n):
	if a[i] > a[i-1]+t:
		end = a[i-1]+t
		answer += end-start
		start = a[i]
	if i == n-1:
		end = a[i]+t
		answer += end-start
print(answer)

Measured memory_bytes: 25200
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}

int x, c = 100000;
int n, k, s, t, a[55];
long long C[55][55], ps[55][55];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%d%d%d%d", &n, &k, &s, &t);
	if ((s & t) != s || (s | t) != t) {
		puts("0");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if ((a[i] & s) != s || (a[i] | t) != t) {
			i--;
			n--;
		}
	}
	k = min(k, n);
	for (int i = C[0][0] = 1; i <= n; i++) {
		for (int j = C[i][0] = 1; j <= i; j++)
			C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
		ps[i][1] = C[i][1];
		for (int j = 2; j <= i; j++) {
			ps[i][j] = ps[i][j - 1] + C[i][j];
		}
	}
	int fa = s ^ t;
	long long ans = 0;
	for (int mask = fa; ; mask = (mask - 1) & fa) {
		map<int, int> mp;
		for (int i = 1; i <= n; i++) {
			mp[a[i] & mask]++;
		}
		long long cur = 0;
		for (auto &it : mp) {
			cur += ps[it.second][min(k, it.second)];
		}
		if (__builtin_popcount(mask) & 1) ans -= cur;
		else ans += cur;
		if (!mask) break;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3844
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    #A, B = [int(x) for x in raw_input().split()]
    n, k = [int(x) for x in raw_input().split()]
    
    arr = [int(x) for x in raw_input().split()]
    
    arr.sort()
    
    ans = sum(arr[0:k])
    
    print(ans)
        
    

main()

Measured memory_bytes: 84884
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std; 
typedef long long ll; 
int a, b, c, d, k; 
inline bool chk(int x)
{
	if (!x)
		return true; 
	if (!(x % (k + 1)))
		x--; 
	int bcnt = x / (k + 1), acnt = x - bcnt;
	return (ll)(a - acnt + 1) * k >= b - bcnt; 
}
int main()
{
	// freopen("AGC020-D.in", "r", stdin); 
	int q; 
	scanf("%d", &q); 
	while (q--)
	{
		scanf("%d%d%d%d", &a, &b, &c, &d); 
		k = (a + b) / min(a + 1, b + 1); 
		int l = 0, r = a + b, ans; 
		while (l <= r)
		{
			int m = l + r >> 1; 
			if (chk(m))
			{
				l = m + 1; 
				ans = m; 
			}
			else
				r = m - 1; 
		}
		for (int i = c; i <= d; i++)
		{
			if (i <= ans)
				putchar(i % (k + 1) ? 'A' : 'B'); 
			else
				putchar((a + b + 1 - i) % (k + 1) ? 'B' : 'A'); 
		}
		putchar('\n'); 
	}
	return 0; 
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string s;
	std::cin >> s;
	std::cout << s[0] << s.size()-2 << s[s.size()-1] << '\n';
	return 0;
}


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


typedef long long ll;

int main(void){
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    if (e-a<=k){
        printf("Yay!\n");
    } else {
        printf(":(\n");
    }
    return 0 ;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string t, h;
    int n, tp = 0, hp = 0;

    cin >> n;

    while (n-- && cin >> t >> h) {
        if (t == h)
            tp++, hp++;
        else if (t > h)
            tp += 3;
        else
            hp += 3;
    }

    cout << tp << " " << hp << endl;

    return 0;
}


Measured memory_bytes: 3104
n=int(input())
h=[int(i) for i in input().split()]
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(1,n-1):
  dp[i+1]+=min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
print(dp[-1])


Measured memory_bytes: 13980
import numpy
I=lambda:map(int,input().split())
W,H,N=I()
m=numpy.zeros((H,W),int)
while N:x,y,a=I();m[y*(a>3):H*(a^3)or y,x*(a==2):W*~-a or x]=1;N-=1
print(W*H-m.sum())

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

int main() {
 int a,b;
 cin>>a>>b;
 int p[b],s=0;
 for(int i=0;i<b;i++)
 {
     cin>>p[i];
     s+=p[i];
 } 
 if(s>=a) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
	 return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
struct PathologicalPaths
{
  struct node
  {
    set< string > pages;
    map< string, node* > children;
  };

  vector< string > split(const string& input, char delimiter)
  {
    istringstream stream(input);
    string field;
    vector< string > result;
    while(getline(stream, field, delimiter)) result.push_back(field);
    return(result);
  }
  PathologicalPaths(vector< string >& base, vector< pair< string, string > >& query)
  {
    node* root = new node();
    root -> children.insert({".", root});
    for(auto s : base) {
      vector< string > spd = split(s, '/');
      node* now = root;
      for(int i = 1; i < spd.size() - 1; i++) {
        auto p = now -> children.insert({spd[i], new node()});
        if(p.second) p.first -> second -> children.insert({"..", now});
        now = p.first -> second;
        now -> children.insert({".", now});
      }
      now -> pages.insert(spd.back());
    }
    for(auto ps : query) {
      vector< string > spd[2] = {split(ps.first, '/'), split(ps.second, '/')};
      if(ps.first.back() == '/') spd[0].push_back(string());
      if(ps.second.back() == '/') spd[1].push_back(string());
      node *now[2] = {root, root};
      bool found = true;
      for(int j = 0; j < 2; j++) {
        for(int i = 1; i < spd[j].size(); i++) {
          if(now[j] -> children.find(spd[j][i]) == now[j] -> children.end()) {
            if(i < spd[j].size() - 1) found = false;
            break;
          } else {
            now[j] = now[j] -> children[spd[j][i]];
            if(i == spd[j].size() - 1) {
              spd[j].push_back("index.html");
              break;
            }
          }
        }
      }
      if(spd[0].back().empty()) spd[0].back() = "index.html";
      if(spd[1].back().empty()) spd[1].back() = "index.html";
      
      auto p = now[0] -> pages.find(spd[0].back());
      auto q = now[1] -> pages.find(spd[1].back());
      if(!found || p == now[0] -> pages.end() || q == now[1] -> pages.end()) {
        cout << "not found" << endl;
      } else {
        if(p == q){
          cout << "yes" << endl;
        } else {
          cout << "no" << endl;
        }
      }      
    }
  }
};

int main()
{
  int N, M;
  while(cin >> N >> M, N) {
    vector< string > A(N);
    vector< pair< string, string > > B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i].first >> B[i].second;
    new PathologicalPaths(A, B);
  }
}

Measured memory_bytes: 3184
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    std::vector<long long> t = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

    long long k;
    std::cin >> k;

    std::cout << t[k - 1] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll n, p;
	cin >> n >> p;
	map<ll, ll> mp;
	ll ans = 1;

	if (n == 1){
		cout << p << endl;
		return 0;
	}

	for (ll i = 2; i*i <= p; i++){
		if (p % i == 0){
			while (1){
				if (p % i != 0 or p == 0) break;
				p /= i;
				mp[i]++;
			}
		}
	}

	for (auto itr = mp.begin(); itr != mp.end(); itr++){
		while (itr->second >= n){
			ans *= itr->first;
			itr->second -= n;
		}
			
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
import Control.Monad
main = do
  n <- readLn :: IO Int
  a_in <- (return . reverse . words) =<< getLine
  let a = map (read::String->Int) a_in
  forM_ [0..n-1] $ \i -> do
    putStr $ show (a!!i)
    if i == (n-1) then putStrLn ""
    else putStr " "


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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

enum EnDir
{
  D_Left,
  D_Right,
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnPodr[i];

  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    int nNode;
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnStructTree(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, vector<StNod> &rvoNod)
{
  for (int i = 1; i < cnrvnPodr.size(); i++)
  {
    int nParnt = END;
    int nx = cnrvnPodr[0];
    EnDir enDir;
    while (nx != END)
    {
      nParnt = nx;
      if (cnrvnIodrSeq[ cnrvnPodr[i] ] < cnrvnIodrSeq[nx])
      {
        nx = rvoNod[nx].m_nLeft;
        enDir = D_Left;
      }
      else
      {
        nx = rvoNod[nx].m_nRigt;
        enDir = D_Right;
      }
    }

    rvoNod[ cnrvnPodr[i] ].m_nParnt = nParnt;
    if (enDir == D_Left)
      rvoNod[nParnt].m_nLeft = cnrvnPodr[i];
    else
      rvoNod[nParnt].m_nRigt = cnrvnPodr[i];
  }
}

void fnPostOrder(const vector<StNod> &cnrvoNod, int nx, int &nOCnt)
{
  if (nx == END)  return;

  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nLeft, nOCnt);
  fnPostOrder(cnrvoNod, cnrvoNod[nx].m_nRigt, nOCnt);
  if (nOCnt++) cout << " ";
  cout << nx;
}

void fnResult(const vector<StNod> &cnrvoNod, int &nOCnt)
{
  int nx = 1;
  while (cnrvoNod[nx].m_nParnt != END)
    nx = cnrvoNod[nx].m_nParnt;

  fnPostOrder(cnrvoNod, nx, nOCnt);
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  vector<StNod> voNod;

  fnInput(vnPodr, vnIodrSeq);

  StNod oNod;
  voNod.resize(vnIodrSeq.size(), oNod);
  fnStructTree(vnPodr, vnIodrSeq, voNod);
  
  int nOCnt = 0;
  fnResult(voNod, nOCnt);
  return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int compchar (const void *a, const void *b)
{
    if(*(char *)a - *(char *)b < 0)
        return -1;
    if(*(char *)a - *(char *)b > 0)
        return 1;
    return 0;
}

int compstr(const void *a, const void *b)
{
    return strcmp((char *)a, (char *)b);
}

int main (void)
{
    size_t N;
    intmax_t tmp = 0, ans = 0;
    char s[(int)1e5][11];

    scanf("%jd", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%s", s[i]);
        qsort(s[i], 10, sizeof(char), compchar);
    }

    qsort(s, N, sizeof(s[0]), compstr);

    for (size_t i = 1; i < N; i++) {
        if (strcmp(s[i - 1], s[i]) == 0) {
            tmp++;
        } else {
            ans += tmp * (tmp + 1) / 2;
            tmp = 0;
        }
    }
    ans += tmp * (tmp + 1) / 2;

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 2300
#include <iostream>

using namespace std;

int n, s, cnt;

void dfs(int i, int sum, int depth) {
    if (sum == s && depth == n) {
        cnt++;
        return;
    }

    if (i > 9 || depth > n) return;

    dfs(i+1, sum, depth);
    dfs(i+1, sum + i, depth + 1);
}

int main() {
    while (cin >> n >> s) {
        if (n == 0 && s == 0) break;
        cnt = 0;
        dfs(0, 0, 0);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2968
import java.io.*;
import java.util.*;
 
public class Main {

	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		int n = in.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i] = in.nextInt();
		}
		Arrays.sort(arr);
		out.println(arr[n/2]-arr[(n-1)/2]);
        out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }

}

Measured memory_bytes: 33840
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W,ans=INF;
    cin>>H>>W;
    if(H%3==0 || W%3==0){
        ans=0;
    }
    else{
        rep2(i,1,W){
            ll a,b,c,d,e;
            a=H*i;
            b=(W-i)*(H/2);
            c=(W-i)*H-b;
            d=(W-i)/2*H;
            e=(W-i)*H-d;
            ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
            ans=min(ans,max(a,max(d,e))-min(a,min(d,e)));
        }
        rep2(i,1,H){
            ll a,b,c,d,e;
            a=W*i;
            b=(H-i)*(W/2);
            c=(H-i)*W-b;
            d=(H-i)/2*W;
            e=(H-i)*W-d;
            ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
            ans=min(ans,max(a,max(d,e))-min(a,min(d,e)));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int func(int x){
  if(x%2==0){
  return x/2;
  }
  return 3*x+1;
}
int main(){
int S;
cin>>S;
vector<int> a(1,S);  
bool b=false; 
int count=0,i=0;
  while(b==false){
    i=func(a.at(count));
    for(int x:a){
      if(x==i){
        cout<<a.size()+1<<endl;
        b=true;
        
      }
    }
    a.push_back(i);
    count++;

   
  }
  for(int i=0;i<a.size();i++){

  }
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];

    int ans=INF;
    rep(i,-100,101){
        int subans=0;
        rep(j,0,n){
            subans+=(i-v[j])*(i-v[j]);
        }
        ans=min(ans,subans);
    }
    cout<<ans<<endl;
}



    



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  int c = n % 10;
  if(c == 3) cout << "bon" << endl;
  else if(c == 0 || c == 1 || c == 6 || c == 8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}


Measured memory_bytes: 3632
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int hoge[100005];
int main()
{
  int n, a, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &a);
    hoge[a + 1]++;
    hoge[a]++;
    hoge[a + 2]++;
  }
  for (int i = 0; i <= 100005; i++)
  {
    ans = MAX(ans, hoge[i]);
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        int n = nextInt();
        Map<Integer, Integer> highMap = new HashMap<>(n);
        Map<Integer, Integer> lowMap = new HashMap<>(n);
        Map<Integer, Integer> origMap = new HashMap<>(n);

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            int high = a + 1;
            int low = a - 1;

            putCountMap(highMap, high);
            putCountMap(lowMap, low);
            putCountMap(origMap, a);
        }

        Map<Integer, Integer> mergeMap = Stream.of(highMap, lowMap, origMap)
                .flatMap(m -> m.entrySet().stream())
                .collect(Collectors.toMap(Entry::getKey, Entry::getValue, Integer::sum));

        // マージされたマップを降順ソート
        List<Entry<Integer, Integer>> mergeEntry = new ArrayList<Entry<Integer, Integer>>(mergeMap.entrySet());
        valueReverseSort(mergeEntry);

        out(mergeEntry.get(0).getValue());
    }

    private static void valueReverseSort(List<Entry<Integer, Integer>> highEntry) {
        Collections.sort(highEntry, new Comparator<Entry<Integer, Integer>>() {
            //compareを使用して値を比較する
            public int compare(Entry<Integer, Integer> obj1, Entry<Integer, Integer> obj2)
            {
                //降順
                return obj2.getValue().compareTo(obj1.getValue());
            }
        });
    }

    private static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 75776
function main()
  
  N = parse(Int,readline())
  W = chomp.(readlines())
  
  if length(W) == length(Set(W))
    
      count = 0
    
      for i in 1:N-1
      if split(W[i],"")[end] == split(W[i+1],"")[1]
              count += 1
          end
      end

      if count == N-1
          println("Yes")
      else
          println("No")
      end
    
  else
    
      println("No")
    
  end
  
end

main()

Measured memory_bytes: 113028
#include<iostream>
#include<cstdio>
#include<iomanip> 
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<functional>
#include<vector>
#include<map>
#include<set>
#pragma warning(disable:4996)；

using namespace std;
#define ll long long

int main() {
	int n; string str;
	scanf("%d", &n); map<string, int> mapp; bool flag = 0;
	cin >> str; mapp[str] = 1;
	for (int i = 1; i < n; i++)
	{
		string temp = str;
		cin >> str;
		if (temp[temp.size() - 1] != str[0]) { flag = 1; }
		if (mapp[str] == 1) { flag = 1; }
		mapp[str] = 1;
	}
	if (flag) { cout << "No"; }
	else { cout << "Yes"; }





	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int ans = 0;
	ans += 1000 * (n/500);
	n -= n/500 * 500;
	ans += 5 * (n/5);
	cout << ans << '\n';
	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>;

ll dp[101][4][2];

int main() {
  string N;
  int K;
  cin >> N >> K;
  int L = N.size();
  dp[0][0][0] = 1;

  // dp[i][j][0] には i 桁目まで調べて、0 以外の数字を j 回使って、N とそこまでの桁が一致しているものの総数が入る
  // dp[i][j][1] には i 桁目まで調べて、0 以外の数字を j 回使って、N より小さいことが確定しているものの総数が入る
  rep(i, L) rep(j, 4) rep(l, 2) {
    int nd = N[i] - '0'; // 次の桁
    rep(d, 10) {
      int ni = i + 1;
      int nj = j;
      int nl = l;
      if (d > 0) nj++;
      if (nj > K) continue;
      if (l == 0) {
        if (d > nd) continue;
        if (d < nd) nl = 1;
      }
      dp[ni][nj][nl] += dp[i][j][l];
    }
  }

  ll ans = dp[L][K][0] + dp[L][K][1];
  cout << ans << endl;
  return 0;
}

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

long long solve(long long a){
    if (a <= 0) return 0;
    if(a%2 == 1 && ((a+1)/2)%2 == 0)
        return 0;
    if(a%2 == 1 && ((a+1)/2)%2 == 1)
        return 1;
    return a^solve(a-1);
}

int main(){
    long long a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    cout << (solve(a-1)^solve(b)) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  vector <int> a(n);
  int sum = 0;
  REP(i, n) {
	cin >> a[i];
	sum += a[i];
  }
  int cnt = 0;
  REP(i, n) {
	if (a[i] * 4 * m >= sum) {
		cnt++;
	  }
  }
  if (cnt >= m) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())

h=[int(input()) for _ in range(n)]
h.sort()

min_h_diff=float('inf')
for i in range(n-k+1):
    min_h_diff=min(min_h_diff,h[i+k-1]-h[i])
print(min_h_diff)    

Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const ll MAX = 310000;
const ll MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void Main(){
    ll n,a,b,k,ans = 0;
    cin >> n >> a >> b >> k;
    For(i,0,n+1){
        if((k-i*a)%b==0){
            ans += COM(n,i) * COM(n,(k-i*a)/b) % MOD;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}
int main(){
    COMinit();
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 10912