akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 16;

int n;
int a[N][N];
ll dp[1 << N];

void getVal(int msk) {
	for (int i = 0; i < n; i++) {
		if (msk & (1 << i)) {
			for (int j = i + 1; j < n; j++) {
				if (msk & (1 << j)) {
					dp[msk] += a[i][j];
				}
			}
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int msk = 0; msk < (1 << n); msk++) {
		getVal(msk);
	}
	for (int msk = 0; msk < (1 << n); msk++) {
		for (int submsk = msk; submsk > 0; submsk = (submsk - 1) & msk) {
			dp[msk] = max(dp[msk], dp[msk ^ submsk] + dp[submsk]);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  vector<int> cnt(26, 0);
  for (char c : s) {
    ++cnt[c - 'A'];
  }
  int k = 0;
  for (int i : cnt) {
    k += (i == 2);
  }
  cout << (k == 2 ? "Yes" : "No") << '\n';
  return 0;
}


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] day ={"","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
        while (true){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a ==0)break;
            GregorianCalendar gre = new GregorianCalendar(2004,a-1,b);
            System.out.println(day[gre.get(GregorianCalendar.DAY_OF_WEEK)]);
        }

    }
}

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

ll solve() {
    ll X;
    cin >> X;
    if ( X >= 2100 ) return 1;
    ll N = X / 100;
    ll r = X % 100;
    for ( int i1 = 0; i1 <= N; i1++ ) {
        if ( i1 > r ) break;
        for ( int i2 = 0; i1 + i2 <= N; i2++ ) {
            if ( i1 + i2*2 > r ) break;
            for ( int i3 = 0; i1 + i2 + i3 <= N; i3++ ) {
                if ( i1 + i2*2 + i3*3 > r ) break;
                for ( int i4 = 0; i1 + i2 + i3 + i4 <= N; i4++ ) {
                    if ( i1 + i2*2 + i3*3 + i4*4 > r ) break;
                    int i5x = r - (i1 + i2*2 + i3*3 + i4*4);
                    if ( i5x % 5 != 0 ) continue;
                    int i5 = i5x / 5;
                    if ( i1 + i2 + i3 + i4 + i5 > N ) continue;
                    return 1;
                }
            }
        }
    }
    return 0;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int>> vecS(m);
    for(int i=0; i<n; i++){
        int a, b;
        cin >> a >> b;

        if(a > m)
            continue;

        vecS[m-a].push_back(b);
    }

    int ans = 0;
    priority_queue<int> q;
    for(int i=m-1; i>=0; i--){
        for(int s : vecS[i])
            q.push(s);

        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5632
n, k = map(int, input().split())
s = str(input())

cnt = 0
for i in range(len(s)-1):
    if(s[i] != s[i+1]):
        cnt += 1

if cnt <= k*2:
    ans = n-1
else:
    ans = n-1-(cnt-k*2)

print(ans)


Measured memory_bytes: 39700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    int a,b,c,d,e; cin >> a >>b >> c >> d >> e;
    int cnt1=a*60+b;
    int cnt2=c*60+d;
    if(cnt2-cnt1>0){
        cout << cnt2-cnt1-e << endl;
    }else{
        cout << 24*60+cnt2-cnt1-e << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
import heapq
import collections
import math
import sys
N =  int(input())
input = sys.stdin.readline
# num = a << b →  a  * (2 ** b)
# 1 << i → i桁目のマスク
# mask = 1 << i
# num = a << b
# num & mask


#
nums = list(map(int,input().split(" ")))
keta = [0] * 62
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = []
MOD = 10 ** 9 + 7


for num in nums:
    s = format(num,"b")
    l = len(s)

    for i in range(0,l):
        if s[l - i - 1 ] == "1":
            keta[i] += 1

ans = 0
temp = 1
for i in range(62):

    ans += ( keta[i] * (N - keta[i])) * temp
    ans %= MOD
    temp *= 2
    temp %= MOD
print(ans)

Measured memory_bytes: 120412
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<random>
#include<string>
#include<vector>

using namespace std;
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define LOG(log) cout<<#log<<" : "<<log<<endl;
#define DEBUG() {cout<<"DEBUG "<<num_debug<<endl; num_debug++;}
int num_debug = 0;


int main(void) {
	srand((unsigned)time(NULL));
//redo:
	int M, N;
	long K;
	long* A, * B;
	
	cin >> N >> M;
	cin >> K;
	//K = RAND(10000, 1000000000);
	//cout << K << endl;
	A = (long*)calloc(N, sizeof(long));
	B = (long*)calloc(M, sizeof(long));
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		//A[i] = RAND(1, 1000000000);
		//cout << A[i] << ' ';
	}
	//cout << endl;

	for (int i = 0; i < M; i++) {
		cin >> B[i];
		//B[i]=RAND(1, 10000000000);
		//cout << B[i] << ' ';
	}

	vector<long> at;
	vector<int> book;
	long remain = K;
	at.push_back(0);
	//DEBUG();
	//a
	for (int i = 1; i < N + 1; i++) {
		at.push_back(at[i - 1] + A[i - 1]);
		if (K < at[i]) {
			at.pop_back();
			break;
		}
	}
	//DEBUG();
	for (int i = 0; i < at.size(); i++)
		book.push_back(i);
	//b
	long bt = 0;
	int j = 0;
	for (int i = at.size()-1; 0<=i; i--) {
		//DEBUG();
		remain = K - at[i]-bt;
		while (1) {
			//DEBUG();
			//LOG(remain);
			//LOG(i);
			//LOG(B[i]); cout << endl;
			if (j < M) {
				remain -= B[j];
			}
			else { break; }
			if (remain < 0)
				break;
			bt += B[j];
			j++;
		}
		book[i] += j;
	}
	//DEBUG();

	int ans=0;
	for (int i = 0; i < book.size(); i++) {
		if (ans < book[i])
			ans = book[i];
	}
	//DEBUG();

	cout << ans;

	free(A);
	free(B);

	//goto redo;
	return 0;
}


Measured memory_bytes: 9676
//
//  main.cpp
//
// https://atcoder.jp/contests/abc133/tasks/abc132_f

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T>
vector<vector<T>> alloc_double_vec(size_t rows, size_t cols, T init) {
    vector<vector<T>> ret;
    vector<T> ret_elem;
    ret_elem.resize(cols, init);
    ret.resize(rows, ret_elem);
    return ret;
}

int main(int argc, char* argv[]) {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> distance = alloc_double_vec<int>(C, C, 0);
    for (int from = 0; from < C; from++) {
        for (int to = 0; to < C; to++) {
            int dist;
            cin >> dist;
            distance[from][to] = dist;
        }
    }
    vector<vector<int>> groups;
    groups.resize(3);
    for (int x = 0; x < N; x++) {
        for (int y = 0; y < N; y++) {
            int col;
            cin >> col;
            col--;
            groups[(x+y)%3].push_back(col);
        }
    }
    vector<vector<pair<ll, int>>> costs = alloc_double_vec<pair<ll, int>>(3, C, {0, 0});
    for (int i = 0; i < 3; i++) {
        for (int c = 0; c < C; c++) {
            ll cost = 0;
            for (int k = 0; k < groups[i].size(); k++) {
                cost += distance[groups[i][k]][c];
            }
            costs[i][c] = {cost, c};
        }
        sort(costs[i].begin(), costs[i].end());
    }
    set<ll> small_costs;
    for (int col_0 = 0; col_0 < 3; col_0++) {
        for (int col_1 = 0; col_1 < 3; col_1++) {
            for (int col_2 = 0; col_2 < 3; col_2++) {
                int c0 = costs[0][col_0].second;
                int c1 = costs[1][col_1].second;
                int c2 = costs[2][col_2].second;
                if (set<int>{c0, c1, c2}.size() < 3) {
                    continue;
                }
                ll cost = costs[0][col_0].first + costs[1][col_1].first + costs[2][col_2].first;
                small_costs.insert(cost);
            }
        }
    }
    cout << *small_costs.begin() << endl;
}



Measured memory_bytes: 1528
#include<stdio.h>
int main(void){
  int n,x,i,sum=0,ans=1,d=0;
  scanf("%d %d",&n,&x);
  int l[n];
  for(i=0;i<n;i++) scanf("%d",&l[i]);
  for(i=0;i<n;i++) sum += l[i];
  if(sum<=x){
    printf("%d\n",n+1);
    return 0;
  }
  if(l[0]>x){
    printf("1\n");
    return 0;
  }
  for(i=0;i<n;i++){
    //printf("%d\n",d);
    if(x<d) break;
    d=d+l[i];
  }
  printf("%d\n",i);
  return 0;
}

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

int n;
string s;

char diff(char c){
    if (c == 'W')
        return 'S';
    else return 'W';
}

bool judge(char a, char b, char c){
    if (b == 'S'){
        if (s[0] == 'o')
            return a == c;
        else return a != c;
    }else{
        if (s[0] == 'o')
            return a != c;
        else return a == c;
    }
}

bool f(string &p){
    for (int i = 1; i < n; i++){
        if (p[i] == 'S'){
            if (s[i] == 'o'){
                p += p[i - 1];
            }else{
                p += diff(p[i - 1]);
            }
        }else{
            if (s[i] == 'o'){
                p += diff(p[i - 1]);
            }else{
                p += p[i - 1];
            }
        }
    }
    return p[0] == p[n] && judge(p[1], p[0], p[n - 1]);
}

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

    for (string p : {"SS", "SW", "WS", "WW"}){
        if (f(p)){
            rep(i, n)
                cout << p[i];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3740
#include<stdio.h>
#include<string.h>
int main(){
	int n,m,r[110],i,j;
	char s[110][110];
	scanf("%d %*d",&n);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
		for(j=i;j&&strcmp(s[r[j-1]],s[i])>0;j--)r[j]=r[j-1];
		r[j]=i;
	}
	for(i=0;i<n;i++)printf("%s",s[r[i]]);
	printf("\n");
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define debug(v) for (auto el : v) { cerr << el << ' '; } cerr << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9+7;
int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n; scanf("%d", &n);
	vll a(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);

	ll answer = 0;
	vi zero(64), one(64);
	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j <= 62; j++) {
			ll tmp;
			if (a[i] & (1LL<<j)) {
				tmp = zero[j];
				one[j]++;
			}
			else {
				tmp = one[j];
				zero[j]++;
			}
			answer += tmp * ((1LL << j) % MOD);
			answer %= MOD;
		}
	}
	printf("%lld\n", answer);
}


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

vector<vector<int>>memo;
int solve(vector<int>v, int now, const vector<int>&nums) {
	if (now == 13) {

	}
	return 1;
}
int main() { 
	memo = vector<vector<int>>(13, vector<int>((1 << 12)));

	string st; cin >> st;
	vector<int>nums(3);
	for (auto c : st) {
		nums[c - 'a']++;
	}
	bool ok = true;
	if (st.size() == 1) {
		ok = true;
	}
	else {
		sort(nums.begin(), nums.end());
		for (auto n : nums) {
			if (n <= nums[0] +1) {

			}
			else {
				ok = false;
			}
		}
	}
	if (ok)cout << "YES" << endl;
	else {
		cout << "NO" << endl;
	}

	//int N; cin >> N;
	//vector<int>nums(13);
	//for (int i = 0; i < N; ++i) {
	//	int a; cin >> a;
	//	nums[a]++;
	//}

	return 0;
}

Measured memory_bytes: 640
A=int(input())
B=int(input())

if A==1:
    if B==2:
        print(3)
    else:
        print(2)
elif A==2:
    if B==1:
        print(3)
    else:
        print(1)
elif A==3:
    if B==1:
        print(2)
    else:
        print(1)

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

using namespace std;

int n,sum,cnt;
bool used[100000];

int gcd(int x,int y){return y==0?x:gcd(y,x%y);}

int main(){
	scanf("%d",&n);
	int i;
	for (i=1;i<=30000&&cnt<n-1;++i)
		if (i%2==0||i%3==0){
			++cnt;
			printf("%d ",i);
			used[i]=1;
			sum+=i;
		}
	for (int i=1;i<=30000;++i)
		if (!used[i]&&(sum+i)%6==0&&gcd(sum,i)!=1){
			++cnt;
			printf("%d\n",i);
			break;
		}
	cerr<<cnt<<endl;
	
	return 0;
}
			

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
char S [4];
int ans = 0;
int main(){
  cin>>S;
  if(S[1]==S[2])
  {ans = 1;}
  if(S[2]==S[3])
  {ans = 1;}
  if(S[0]==S[1])
  {ans = 1;}
  if(ans == 1)
  {cout <<"Bad"<<endl;}
  if(ans == 0)
  {cout << "Good" << endl;}
}
  



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN = 2e5 + 100;
long long x,sum[MAXN],n,min_,i;
int main()
{
    cin>>n;
    sum[0]=0;
    for(i=1;i<=n;i++)
       {
           cin>>x;
           sum[i]=sum[i-1]+x;
       }
    min_=abs(2*sum[1]-sum[n]);
   for(i=2;i<n;i++)
   {
       min_=min_<abs(2*sum[i]-sum[n])?min_:abs(2*sum[i]-sum[n]);
   }
    cout<<min_;
}


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

const int MOD = 1000000007;

char a[1010][1010];
long dp[1010][1010];

template<class T> void add_mod(T &a, const T b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	for(int i=0; i < h; i++) scanf("%s", a[i]);
	dp[0][0] = 1;
	for(int i=0; i < h; i++) {
		for(int j=0; j < w; j++) {
			if(i+1 < h && a[i+1][j] == '.')
				add_mod(dp[i+1][j], dp[i][j]);
			if(j+1 < w && a[i][j+1] == '.')
				add_mod(dp[i][j+1], dp[i][j]);
		}
	}
	printf("%ld\n", dp[h-1][w-1]);
}

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

using namespace std;

typedef struct {
	int a;
	int b;
	int c;
} fuku_t;

int d, n;

int t[200];
fuku_t fuku[200];

int dp[200][200];

int main()
{
	cin >> d >> n;

	for (int i = 0; i < d; ++i) cin >> t[i];

	for (int i = 0; i < n; ++i) scanf("%d %d %d", &fuku[i].a, &fuku[i].b, &fuku[i].c);

	for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
		if (fuku[j].a <= t[0] && t[0] <= fuku[j].b && fuku[i].a <= t[1] && t[1] <= fuku[i].b) {
			dp[1][i] = max(dp[1][i], abs(fuku[j].c - fuku[i].c));
		}
	}

	for (int i = 2; i < d; ++i) for (int j = 0; j < n; ++j) for (int k = 0; k < n; ++k) {
		if (fuku[j].a <= t[i] && t[i] <= fuku[j].b && fuku[k].a <= t[i - 1] && t[i - 1] <= fuku[k].b) {
			dp[i][j] = max(dp[i][j], dp[i - 1][k] + abs(fuku[k].c - fuku[j].c));
		}
	}

	int ans = 0;

	for (int i = 0; i < n; ++i) ans = max(ans, dp[d - 1][i]);

	printf("%d\n", ans);
}

Measured memory_bytes: 1388
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585

"""
import sys
from sys import stdin
input = stdin.readline


def closest_part(points, n):
    # ?????¬???p324???
    if n <= 1:
        return float('inf')
    m = n // 2
    x = points[m][0]
    d = min(closest_part(points[:m], m), closest_part(points[m:], n-m))

    points.sort(key=lambda p:p[1])
    b = []
    for p in points:
        if (p[0] - x)**2 >= d:
            continue
        for q in b:
            dx = p[0] - q[0]
            dy = p[1] - q[1]
            if dy**2 >= d:
                break
            d = min(d, (dx**2 + dy**2))
        b.insert(0, p)
    return d


def main(args):
    n = int(input())
    points = [tuple(map(int, input().split())) for _ in range(n)]
    points.sort()               #  x????????§??????????????????

    result = closest_part(points, n)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 84100
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define read(a)  for(int i = 0; i < n; i++) cin >> a[i];
#define print(a)  for(int i = 0; i < n; i++) cout << a[i] << " ";
#define pb push_back
#define pql priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define pqlv priority_queue<vi>
#define pqsv priority_queue<vi, vvi, greater<vi>>
// #define endl '\n'
#define N 10000002
#define MOD 1000000007

int bs(int n) {
    int low = 0, high = n, ans = 1;
    while(low <= high) {
        int mid = low + (high - low) / 2;
        if(((mid * (mid + 1)) / 2) <= n) {
            ans = mid;
            low = mid + 1;
        }
        else {
            high = mid - 1;
        }
    }
    return ans;
}

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 2; i * i <= n; i++) {
        int cnt = 0;
        while(n % i == 0) {
            n /= i;
            cnt++;
        }
        if(cnt) {
            ans += bs(cnt);
        }    
    }
    if(n != 1)  ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3664
// 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 main()
{
  int n, x, i;
  int a = 0;
  scanf("%d%d", &n, &x);
  for (i = 0; a <= x && i <= n; i++)
  {
    int l;
    scanf("%d", &l);
    a += l;
  }
  printf("%d\n", i);
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  int Hs[100005];
  bool high[100005];
  int h;
  rep(i, N) {
    cin >> Hs[i];
    high[i] = true;
  }
  int a,b,c;
  rep(i, M) {
    cin >> a >> b;
    a--; b--;
    c = Hs[a] > Hs[b] ? b : a;
    high[c] = false;
    if(Hs[a] == Hs[b]) {
      high[a] = false;
      high[b] = false;
    }
  }
  int sum = 0;
  rep(i, N) {
    sum += high[i];
  }
  cout << sum << endl;
  return 0;
}




Measured memory_bytes: 4108
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()

	ans := 0
	for a := 1; a <= N; a++ {
		kbc := K - a%K
		if (kbc+kbc)%K != 0 {
			continue
		}
		nb := (N-kbc)/K + 1
		nc := (N-kbc)/K + 1
		ans += nb * nc
	}
	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  copy_n(istream_iterator<int>(cin), N, a.begin());
  int K = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] == K + 1) {
      ++K;
    }
  }
  cout << ((0 < K) ? (N - K) : -1) << endl;
  return 0;
}


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

int main(void){
    
    double a, b, c, d;
    cin >> a >> b >> c >> d ;
    //cout << min( 1 - abs( ( c / 12 + d / 720 ) - d / 60), abs( ( c / 12 + d / 720 ) - d / 60) ) * 2 << endl;

    //printf("%.20lf\n", 4.56425719433005567605);
    printf("%.20lf\n", sqrt(a * a + b * b - 2 * a * b * cos( min( 1 - abs( ( c / 12 + d / 720 ) - d / 60), abs( ( c / 12 + d / 720 ) - d / 60) ) * 2 * M_PI) ) );

    return 0; 
}


Measured memory_bytes: 4200
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if (i + 1) % 2 == 1 and A[i] % 2 == 1:
            ans += 1

    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 61704
#include <iostream>
#include <vector>
#include <cstdlib>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
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; }

const long long INF = 1LL <<60;
const int MOD = 1000000007;
typedef long long ll;
using namespace std;

int main(void){
    int n,m;
    cin>>n>>m;
    vector<bool> issafe(n+1,true);
    rep(i,0,m-1){
        int a;
        cin>>a;
        issafe[a] = false;
    }
    //DPテーブル
    vector<int> dp(n+1,0);
    //初期化
    dp[0] = 1;
    if(issafe[1]) dp[1] = 1;

    rep(i,2,n){
        if(issafe[i-1]) dp[i] += dp[i-1];
        if(issafe[i-2]) dp[i] += dp[i-2];
        dp[i] %= MOD;
    } 
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	vector<PLL> a(n);
	for(ll i=1;i<=n;i++){
		ll c; cin>>c; a.PB(MP(c,i));
	}
	sort(RALL(a));
	ll dp[n+1][n+1]; rep(i,n+1)rep(j,n+1)dp[i][j]=-1;
	dp[0][0]=0LL;
	for(ll idx=0;idx<n;idx++){
		for(ll i=0;i<=idx;i++){
			if(dp[i][idx-i]==-1) continue;
			chmax(dp[i+1][idx-i],dp[i][idx-i]+a[idx].first*abs(i+1-a[idx].second));
			chmax(dp[i][idx-i+1],dp[i][idx-i]+a[idx].first*abs(n-(idx-i)-a[idx].second));
		}
	}
	ll ans=0LL;
	rep(i,n+1) chmax(ans,dp[i][n-i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 34992
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  
  vector<pair<int, int>> R(N);
  for( int i = 0; i < N; i++ ){
    int X, Y;
    cin >> X >> Y;
    R.at(i) = make_pair(X, Y);
  }
  sort(R.rbegin(), R.rend());
  
  vector<pair<int, int>> B(N);
  for( int i = 0; i < N; i++ ){
    int X, Y;
    cin >> X >> Y;
    B.at(i) = make_pair(X, Y);
  }
  sort(B.begin(), B.end());
  
  int ans = 0;
  vector<bool> fg(N, true);
  for( int i = 0; i < N; i++ ){
    int Pkouho = -1;
    int PY = -1;
    for( int j = 0; j < N; j++ ){
      int RX = R.at(j).first;
      int RY = R.at(j).second;
      int BX = B.at(i).first;
      int BY = B.at(i).second;
      if( fg.at(j) && RX < BX && RY < BY ){
        if( PY < RY ){
          Pkouho = j;
          PY = RY;
        }
      }
    }
    if( Pkouho != -1 ){
      ans++;
      fg.at(Pkouho) = false;
      //cout << R.at(Pkouho).first << " " << B.at(i).first << endl;
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
package main

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

func main() {
	scanner := makeWordScanner()
	s := eGetInt(scanner)
	w := eGetInt(scanner)
	if w >= s {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i,j,n,s;
int main()
{
    cin>>a>>b>>c>>n;
    for (i=0;i<=a;i++)
     for (j=0;j<=b;j++)
      if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) ++s;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define sq(a) (a)*(a)
#define nitro std::ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug(x) std::cerr<<#x<<"="<<x<<'\n'
#define text std::cerr<<"SacredCoupoid08\n"
#define endl '\n'
#define all(c) (c).begin(),(c).end()
#define U 1000000007
#define N 100005
#define sz(c) (int)c.size()
typedef long long ll;
typedef std::vector< int > vi;
typedef std::pair<int, int> pi;
#define cin std::cin
#define cout std::cout
#define vector std::vector
#define pb push_back
#define pv(x) for(auto y:x)    cerr<<y<<" ";    cerr<<'\n';
#define fr first
#define sc second
#define ppb pop_back
#define max(a,b) a=max(a,b)
#define min(a,b) a=min(a,b)
#define int ll
#define tr(c,it) for(typeof(c.begin()) it= c.begin();it != c.end();it++)
signed main()
{		
	nitro;
	int VASU=1;
	//cin>>VASU;
	while(VASU--)
	{
		int n,k;
		cin>>n>>k;
		set<int> s;
		rep(i,1,n+1)
		s.insert(i);
		int temp,t;
		while(k--)
		{
			cin>>temp;
			while(temp--)
			{
				cin>>t;
				s.erase(t);
			}
		}
		cout<<sz(s)<<endl;
		
	}
	

	
	
	
	return 0;
}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
 
  int n,m,c,ans=0;
  cin>>n>>m>>c;
  int b[m];
  for(int i=0;i<m;i++) cin>>b[i];
  while(n--)
  {
    int x,k=0;
    for(int i=0;i<m;i++)
    {
      cin>>x;
         k +=x*b[i];
    }
    k =k +c;

    if(k> 0)
     ans++;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define A 0
#define B 3
#define C 5

int n,unchi[N][N];
int pri[N],fi[N],judge[N],count;

void DEPTH(int );
void depth(void);

void DEPTH (int st){
  int a;
  judge[st]=1;
  pri[st]= ++count;

  for(a=0;a<n;a++){
    if(unchi[st][a]==0)
      continue;
    if(judge[a]==0){
      DEPTH(a);
    }
  }

  judge[st]=2;
  fi[st]=++count;
}
  
void depth(){
  int b;

  for(b=0;b<n;b++)
    judge[b]=0;
  count=0;

  for(b=0;b<n;b++){
    if(judge[b]==0)
      DEPTH(b);
  }

  for(b=0;b<n;b++){
    printf("%d %d %d\n",b+1,pri[b],fi[b]);
  }
}

int main(){
  int i,j,k,s,t;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)
      unchi[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&s,&k);
    s--;

    for(j=0;j<k;j++){
      scanf("%d",&t);
      t--;
      unchi[s][t]=1;
    }
  }

  depth();

  return 0;
}



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

int main()
{
  int H,N;
  cin >> H >> N;
  int A;
  for(int i=0;i < N;i++)
  {
    cin >> A;
    H -= A;
  }
  if(H <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
   return 0;
}

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

struct Sieve{
    int n;
    vector<int> v;
    Sieve(int n):n(n),v(0){
        rep(i,n+1) v.push_back(i);
        for(int j=2; j<=n; ++j){
            if(v[j]!=j) continue;
            for(int i=j; i<=n; i+=j){
                if(v[i]==i) v[i]=j;
            }
        }
    }

    bool is_Prime(int n){
        if((n==0)||(n==1)) return false;
        else return v[n]==n;
    }
};

int main(){
    int q;
    cin >> q;
    Sieve s(100001);
    vector<int> a(100001);
    a[0]=0;
    rep(i,100000){
        a[i+1]=a[i];
        if(i%2==0) continue;
        if(s.is_Prime(i)&&s.is_Prime((i+1)/2)) a[i+1]+=1;
    }
    vector<int> res;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        res.push_back(a[r+1]-a[l]);
    }
    for(auto r:res) cout << r << endl;

    
}

Measured memory_bytes: 1912
#include <iostream>
#include <cstdio>
using namespace std;
int a,b,c,d,roll=0,count=0,xxx=0;

struct Dice{
	int d1;
	int d2;
	int d3;
	int d4;
	int d5;
	int d6;
};

void N(struct Dice *std){
	a=(*std).d1;
	b=(*std).d2;
	c=(*std).d6;
	d=(*std).d5;
	(*std).d1=b;
	(*std).d2=c;
	(*std).d6=d;
	(*std).d5=a;
}
void S(struct Dice *std){
	a=(*std).d1;
	b=(*std).d2;
	c=(*std).d6;
	d=(*std).d5;
	(*std).d1=d;
	(*std).d2=a;
	(*std).d6=b;
	(*std).d5=c;
}
void W(struct Dice *std){
	a=(*std).d1;
	b=(*std).d4;
	c=(*std).d6;
	d=(*std).d3;
	(*std).d1=d;
	(*std).d4=a;
	(*std).d6=b;
	(*std).d3=c;
}
void E(struct Dice *std){
	a=(*std).d1;
	b=(*std).d4;
	c=(*std).d6;
	d=(*std).d3;
	(*std).d1=b;
	(*std).d4=c;
	(*std).d6=d;
	(*std).d3=a;
}

int main(){
	struct Dice d[100],q[100];
	int i,n;
	string s;
	cin >> n;
	for(i=0;i<n;i++){
	cin >>d[i].d1 >> d[i].d2 >> d[i].d3 >> d[i].d4 >> d[i].d5 >> d[i].d6;
	}
	
	for(i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j){
				j++;
			}
		q[j].d1=d[j].d1;
		q[j].d2=d[j].d2;
		q[j].d3=d[j].d3;
		q[j].d4=d[j].d4;
		q[j].d5=d[j].d5;
		q[j].d6=d[j].d6;
			
	while(xxx!=4){
	while(roll!=4){
	while(count!=4){
		if(d[i].d1==d[j].d1&&d[i].d2==d[j].d2&&d[i].d3==d[j].d3&&d[i].d4==d[j].d4&&d[i].d5==d[j].d5&&d[i].d6==d[j].d6){
		s = "No";goto end;
		}else{
			S(&d[j]);
			count++;
		}
	}
		E(&d[j]);
		count=0;
		roll++;
	}
	count=0;
	roll=0;
	N(&d[j]);
	E(&d[j]);
	xxx++;
	}
		count=0;
		roll=0;
		xxx=0;
		d[j].d1=q[j].d1;
		d[j].d2=q[j].d2;
		d[j].d3=q[j].d3;
		d[j].d4=q[j].d4;
		d[j].d5=q[j].d5;
		d[j].d6=q[j].d6;
		}
	}
	s = "Yes";
	end:
	cout << s << endl;
	return 0;
}

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

public class Program
{
    public static void Main(string[] args)
    {
        int[] line = Console.ReadLine().Split('/').Select(x => int.Parse(x)).ToArray();

        int y = line[0];
        int m = line[1];
        int d = line[2];

        bool ans = (y >= 2020) || (y == 2019) && (m >= 5) || (y == 2019) && (m == 4) && (d > 30);

        Console.WriteLine(ans ? "TBD" : "Heisei");
        Console.ReadLine();
    }
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807
#define array(N, t) (t*)calloc(N, sizeof(t))

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

  int * A = array(N, int);
  rep(i, N) {
    scanf("%d", A + i);
  }

  rep(i, N - K) {
    if (A[i + K] > A[i]) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }

  free(A);
  return 0;
}


Measured memory_bytes: 2224
l =[]
while True:
    n, x = list(map(int, input().split(' ')))
    if n == 0 and x == 0:
        break
    l.append([n, x])

for a in l:
    aa = [ i for i in range(1, a[0] + 1)]
    s = 0
    for i in range(0, len(aa) + 1):
        for j in range(i + 1, len(aa) + 1):
            for k in range(j + 1, len(aa)):
                t = aa[i] + aa[j] + aa[k]
                if t == a[1]:
                    s += 1
    print(s)


Measured memory_bytes: 5596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

string S[100];

int main()
{
	int N, L;
	string ans = "";

	cin >> N >> L;
	rep(i, N) cin >> S[i];

	sort(S, S + N);

	rep(i, N) ans += S[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int[N];
		int souwa = 0;
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			souwa+=A[i];
		}
		//System.out.println(souwa);
		if(H<=souwa) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 49888
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % 1000000007
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % 1000000007
            i += i & -i


n, m = list(map(int, input().split()))
sss = list(map(int, input().split()))
ttt = list(map(int, input().split()))

bit = Bit(n + 1)

for t in ttt:
    for i in range(n - 1, -1, -1):
        s = sss[i]
        if s != t:
            continue
        bit.add(i + 2, bit.sum(i + 1) + 1)

print(bit.sum(n + 1) + 1)


Measured memory_bytes: 43612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}	

inline int maxx(int a,int b){if(a>b)return a;return b;}
inline int minn(int a,int b){if(a<b)return a;return b;}

const int N=1e5+9;

int n,a[N],buc[N];
inline bool chkmax(int &a,int b){if(a<b){a=b;return 1;}return 0;}

int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		buc[a[i]=read()]++;
	int mpos=2,mval=buc[0]+buc[1]+buc[2];
	for(int i=3;i<N;i++)
		if(chkmax(mval,buc[i]+buc[i-1]+buc[i-2]))
			mpos=i;

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


Measured memory_bytes: 1024
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int b,c,n,m=0;
	char a[102];
	cin>>a;
	if(strlen(a)%2==0)
		b=strlen(a)/2;
	else
		b=strlen(a)/2;
	for(int i=0;i<b;i++)
	{
		if(a[i]!=a[strlen(a)-1-i])
			m++;
	}
	cout<<m;
	return 0;
}

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;

    int cnt = 0;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if (tmp % 2) cnt++;
    }

    if (cnt % 2) cout << "NO" << '\n';
    else cout << "YES" << '\n';
    return 0;
}


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

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}



int main(){
  

  ios_base :: sync_with_stdio(0);
   cin.tie(0);



   queue<string> q;
   for(int i = 1; i<=9;i++){

    q.push(to_string(i));
   }
   ll start  =0 ;
   vector<string> num;
 // num.push_back("1");
   while(num.size()< 1e5){

        string t= q.front();
        ll last = t[ t.size()-1 ]-'0';
        if(last > 0 && last<9){
             t += (last-1)+'0';
             q.push(t);
             start++;
             t.pop_back();
             t += last+'0';
             q.push(t);
             t.pop_back();
             t += (last+1)+'0';
             start++;
             q.push(t);
        }
        else{
            if(last-1 >=0){
                 t += (last-1)+'0';
                 start++;
                 q.push(t);
                 t.pop_back();
                 t += last+'0';
                 q.push(t);
            }
            if(last+1<=9){
                    t += last+'0';
                 q.push(t);
             t.pop_back();
                t += (last+1)+'0';
                start++;
                q.push(t);
            }
        }
        num.push_back(q.front());
        q.pop();
   }
//   cout<<"num.szie() = "<<num.size()<<endl;
//   for(int i = 0; i  < 30;i++)
//    cout<<num[i]<<"\n";

   ll k;
   cin>>k;
   cout<<num[k-1];

}


Measured memory_bytes: 20468
#include<iostream>
#include<cstdio>
#include<cstring>
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
template<typename T>inline void read(T &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
}
namespace O_O
{
	const int N=201000,M=N*2;
	int begin[N],next[M],to[M];
	int n,k,e,ans;
	void add(int x,int y)
	{
//		printf("%d -- > %d\n",x,y);
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
	}
	void initialize()
	{
		int x;
		read(n),read(k),ans=0;
		read(x);
		if(x!=1)ans++;
		for(int i=2;i<=n;i++)
			read(x),add(x,i);
	}
	int dfs(int p,int h)
	{
		int ret=0;
		for(int i=begin[p],q;i;i=next[i])
			if((q=to[i])!=h)
				check_max(dfs(q,p)+1,ret);
		if(p!=1 && h!=1)
		{
			if(ret==k-1){ans++;return -1;}
			return ret;
		}
		else if(h==1)
		{
			if(ret==k){ans++;return -1;}
			return ret;
		}
		return ret;
	}
	void solve()
	{
		initialize();
		dfs(1,0);
		printf("%d\n",ans);
	}
}
int main()
{
//	freopen("in","r",stdin);
	O_O::solve();
	return 0;
}


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

        #define N 2000002
        #define M 10

        int NUM = 0;

        void Defma(int *t, int i){

            int left, right;
            int  large, c;

            if( i * 2 + 1 < NUM + 1) right = i * 2 + 1;
            else right = i;

            if( i * 2 < NUM + 1)
                left = i * 2;
            else left = i;

            if(left <= NUM && t[left] > t[i])
                large = left;
            else large = i;

            if(right <= NUM && t[right] > t[large])
                large = right;

            if(large != i){
                c = t[i];
                t[i] = t[large];
                t[large] = c;

                Defma(t, large);
            }
        }

        void Defin(int *arrayt, int z){

            int i,c;

            NUM++;
            i = NUM;
            arrayt[NUM] = z;

            while(i > 1 && arrayt[i/2] < arrayt[i]){

                c = arrayt[i];

                arrayt[i] = arrayt[i/2];

                arrayt[i/2] = c;


                i /= 2;
            }
        }

        void Defex(int *arrayt){

            printf("%d\n", arrayt[1]);

            if(NUM > 1) arrayt[1] = arrayt[NUM];

            NUM--;

            if(NUM > 1) Defma(arrayt, 1);
        }

        int main(){

            int i;
            int AI[N];
            char AC[M];

            while(1){

                scanf("%s", AC);

                if(AC[2] == 'd') break;
                else if(AC[0] == 'i'){
                    scanf("%d", &AI[0]);
                    Defin(AI, AI[0]);
                }

                
                else Defex(AI);
            }

            return 0;
        }



Measured memory_bytes: 5628
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

int main() {
    int n;
    cin >> n;
    int odd[100009] = {};
    int even[100009] = {};
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        if (i % 2 == 1) odd[v]++;
        else even[v]++;
    }

    vector<ii> oddl;
    for (int i = 1; i <= 100000; i++) {
        if (odd[i] >= 1) {
            oddl.push_back(ii(i, odd[i]));
        }
    }
    oddl.push_back(ii(0, 0));
    sort(oddl.begin(), oddl.end(), [](const ii &x, const ii &y){
        return x.second > y.second;
    });
    vector<ii> evenl;
    for (int i = 1; i <= 100000; i++) {
        if (even[i] >= 1) {
            evenl.push_back(ii(i, even[i]));
        }
    }
    evenl.push_back(ii(-1, 0));
    sort(evenl.begin(), evenl.end(), [](const ii &x, const ii &y){
        return x.second > y.second;
    });

    int count = oddl.at(0).second + evenl.at(0).second;
    if (oddl.at(0).first == evenl.at(0).first) {
        count = max(oddl.at(1).second + evenl.at(0).second,
            oddl.at(0).second + evenl.at(1).second);
    }
    cout << n - count << endl;
    return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
bool sudah;
LL bneck,adj[5005][5005],source,sink,ans=0,n,m,a,b,c;
bool visited[5005];

void dfs(LL node,LL bottleneck){
	if(node==sink){
		ans+=bottleneck;
		sudah=true;
		bneck=bottleneck;
		return;
	}
	if(!visited[node]){
		visited[node]=true;
		for(LL i=1;i<=n;i++){
			if(adj[node][i]>0){
				dfs(i,min(adj[node][i],bottleneck));
				if(sudah){
					adj[node][i]-=bneck;
					adj[i][node]+=bneck;
					return;
				}
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    for(LL i=1;i<=m;i++){
    	cin >> a >> b >> c;
    	a++;
    	b++;
    	adj[a][b]+=c;
	}
	source=1,sink=n;
	sudah=true;
	while(sudah){
		memset(visited,false,sizeof(visited));
		sudah=false;
		dfs(source,1e18);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using ld = long double;
using pi = pair<int,int>;
int main()
{
  int n; cin >> n;
  vector<ld> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];

  vector<int> vec(n);
  rep(i,n) vec[i] = i;
  // vectorの全並び替えを全探索
  ld res = 0;
  do{
    rep(i,n-1) {
      int a = vec[i], b = vec[i+1];
      res += sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
    }
  } while(next_permutation(vec.begin(), vec.end()));
  rep1(i,n) {
    res /= i;
  }
  printf("%.8Lf\n", res);
  
  return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll n;
map<ll,ll>f;
ll dfs(ll x){
	if(f[x])return f[x];
	return f[x]=(dfs(x/2)+dfs((x-1)/2)+dfs((x-2)/2))%p;
}
int main(){
	f[0]=1;f[1]=2;
	scanf("%lld",&n);
	printf("%lld",dfs(n));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int M;
  rd(M);
  wt_L(48-M);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// {
//   int M;
//   rd(M);
//   wt(48-M);
// }

Measured memory_bytes: 256