akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>

bool judge(std::string const& S,
           std::string const& T) {
  if (S == T) return true;

  std::map<char, char> dict;

  for (size_t i=0; i<S.length(); i++) {
    if (dict.count(S[i]) > 0) {
      if (dict[S[i]] != T[i]) return false;
    } else {
      dict.insert(std::make_pair(S[i], T[i]));
    }
  }

  return dict.size() < 27;
}

int main() {
  std::string S, T;

  std::cin >> S >> T;

  std::cout << (judge(S, T) && judge(T, S) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int A, a100, a10, a1;
  cin >> A;
  a100 = A / 100;
  a10 = (A - a100 * 100) / 10;
  a1 = (A - a100 * 100 - a10 * 10);
  cout << a100 + a10 + a1 <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int m, n;
  scanf("%d %d", &m, &n);
  if(m < n)
  {
    for(int i = 0; i < n; i++)
    {
      printf("%d", m);
    }
  }else
  {
    for(int i = 0; i < m; i++)
    {
      printf("%d", n);
    }
  }
  printf("\n");
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init,ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T> &v) {
	T ans = -INF;
	rep(i,0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C& c, std::ostream& os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}

ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}

bool sortreverse(ll a, ll b) {
	return a > b;
}

bool kansu(pll a, pll b) {
	return a.first < b.first;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll dp[105][100005];
ll ruiseki[105][100005];

int main() {
	ll n, k;
	cin >> n >> k;
	vl a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	rep(i,1,k+2){
		ruiseki[0][i] = 1;
	}
	rep(i, 1, n + 1) {
		rep(j, 1, k + 2) {
			ll min_i = max(ll(0), j - a[i - 1] - 1);
			ll max_i = j;
			ruiseki[i][j] = (ruiseki[i][j - 1] + ruiseki[i - 1][max_i]) % MOD;
			ruiseki[i][j] %= MOD;
			ruiseki[i][j] = (ruiseki[i][j] + MOD -ruiseki[i - 1][min_i]) % MOD;
		}
	}
	printf("%lld", ((MOD + ruiseki[n][k + 1]) - ruiseki[n][k]) % MOD);
}

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

int main(void) {
    string S, T;
    cin >> S;


    int size = S.size();
    T = S;
    T.reserve();

    bool result = true;
    if (T != S) {
        result = false;
    }
    for (int i=0; i<(size-1)/2; i++) {
        if (S[i] != S[(size-1)/2 + 1 + i]) {
            result = false;
            break;
        }
    }

    if (result == true) cout << "Yes" << endl;
    else                cout << "No"  << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> bool chmin(T& a,const T& b) {
  if(a>b) {
    a=b;
    return true;
  }
  return false;
}
template<class T> bool chmax(T& a,const T& b) {
  if(a<b){
    a=b;
    return true;
  }
  return false;
}

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n;
vector<int> g[100005];
pi dfs(int v,int p,int d){
  pi res=mp(d,v);
  for(auto to:g[v]) if(to!=p){
    chmax(res,dfs(to,v,d+1));
  }
  return res;
}
vector<int> path,ever;
void rec(int v,int p,int dst){
  ever.pb(v);
  if(v==dst){
    path=ever;
  }
  for(auto to:g[v]) if(to!=p){
    rec(to,v,dst);
  }
  ever.pop_back();
}
void ng(){
  puts("-1");
  exit(0);
}
int main(){
  cin>>n;
  REP(i,n-1){
    int a,b;cin>>a>>b;--a;--b;
    g[a].pb(b);
    g[b].pb(a);
  }
  pi A=dfs(0,-1,0),B=dfs(A.sc,-1,0);

  dump(A);dump(B);
  rec(A.sc,-1,B.sc);

  int m=path.size();
  debug(ALL(path));
  vector<int> ans,res;
  REP(t,2){
    res.clear();
    res.pb(0);
    assert(g[path[0]].size()==1);
    assert(g[path[m-1]].size()==1);
    int cnt=1;
    REPN(i,m-1,1){
      int v=cnt++;
      for(auto v:g[path[i]]) if(v!=path[i-1] && v!=path[i+1]){
        if(g[v].size()!=1) ng();
        res.pb(cnt++);
      }
      res.pb(v);
    }
    debug(ALL(res));
    res.pb(cnt++);
    assert(res.size()==n);
    if(t==0 || ans>res) ans=res;
    reverse(ALL(path));
  }
  assert(ans.size()==n);
  REP(i,n) printf("%d\n",ans[i]+1);
  return 0;
}





Measured memory_bytes: 15736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> pnum;
vector<int> atime;

int main()
{
  int n, ans = 0;
  cin>>n;

  pnum.push_back(2);
  atime.push_back(1);
  FOR(i,3,n+1) {
    bool flag = true;
    int t = i;
    REPALL(j,pnum) {
      if (t % pnum[j] == 0) {
        flag = false;
        atime[j]++;
        t /= pnum[j];
        j--;
      }
    }
    if (flag) {
      pnum.push_back(i);
      atime.push_back(1);
    }
  }

  /*REPALL(i,pnum) cout<<pnum[i]<<" ";
  cout<<endl;
  REPALL(i,atime) cout<<atime[i]<<" ";
  cout<<endl;*/

  int a75 = 0, a25 = 0, a15 = 0, a5 = 0, a3 =0;
  REPALL(i,atime) {
    if (atime[i] >= 2) a3++;
    if (atime[i] >= 4) a5++;
    if (atime[i] >= 14) a15++;
    if (atime[i] >= 24) a25++;
    if (atime[i] >= 74) a75++;
  }

  //cout<<a75<<" "<<a25<<" "<<a15<<" "<<a5<<" "<<a3<<endl;
  ans += a75;
  ans += a25 * (a3-1);
  ans += a15 * (a5-1);
  ans += a5 * (a5-1) * (a3-2) / 2;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if (n*a<b)
	{
		cout<<n*a;
		return 0;
	}
	if (n*a>=b)
	{
		cout<<b;
		return 0;
	}	
}

Measured memory_bytes: 256
/*
*/

#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <unordered_map>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000009
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200551;

int n, k;
vector<int> g[N];
vector<int> gr[N];

int ans;
int used[N];

int go[N];

vector<int> get_cycle()
{
	vector<int> res;
	int cur = 1;
	res.push_back(cur);
	cur = go[cur];
	while (cur != 1)
	{
		res.push_back(cur);
		cur = go[cur];
	}
	return res;
}

int indeg[N];
int on_cycle[N];
int D[N];

void trace_dep(int v, int dep)
{
	D[v] = dep;
	used[v] = 1;
	for (int i = 0; i < gr[v].size(); i++)
	{
		int to = gr[v][i];
		trace_dep(to, dep + 1);
	}
}

int Res;

set<pair<int, int> > alive;
set<pair<int, int> >::iterator it;

int rem[N];

int GO(int v, int lev)
{
	if (lev == 0)
		return v;
	if (v == 1)
		return v;
	return GO(go[v], lev - 1);
}

void update(int v, int steps)
{
	
	if (alive.find(make_pair(D[v], v)) != alive.end())
	{
		alive.erase(make_pair(D[v], v));
	}
	rem[v] = 1;
	for (int i = 0; i < gr[v].size(); i++)
	{
		int to = gr[v][i];
		if (rem[to])
			continue;
		update(to, steps - 1);
	}
}
int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		int to;
		cin >> go[i];
		if (i == 1)
			continue;

		indeg[go[i]]++;
		gr[go[i]].push_back(i);
	}
	
	if (go[1] != 1)
		ans++;
	go[1] = 1;

	trace_dep(1,0);

	for (int i = 1; i <= n; i++)
	{
		alive.insert(make_pair(D[i], i));
	}

	while (true)
	{
		if (alive.size() == 0)
			break;
		it = alive.end();
		--it;
		int v = (*it).second;
		int WHR = GO(v, k - 1);
		if (go[WHR] != 1 && WHR != 1)
			++ans;
		
		if (WHR == 1)
			update(WHR, 0);
		else
			update(WHR, 1);
	}

	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 25728
W,H,N=map(int,input().split())
ans=[[1 for _ in range(W)] for _ in range(H)]

for i in range(N):
    x,y,a=map(int,input().split())
    if a == 1:
        for i in range(H):
            for j in range(x):
                ans[i][j] = 0
    if a == 2:
        for i in range(H):
            for j in range(x,W):
                ans[i][j] = 0
    if a == 3:
        for i in range(y):
            for j in range(W):
                ans[i][j] = 0
    if a == 4:
        for i in range(y,H):
            for j in range(W):
                ans[i][j] = 0
                
print(sum([sum(ans[i]) for i in range(H)]))

Measured memory_bytes: 3064
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

const ll MAX = 1e9+5;


int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll h, w;
    cin>>h>>w;

    char mat[h+1][w+1];
    ll dp[h+1][w+1];

    for(ll i=1; i<=h; i++){
        for(ll j=1; j<=w; j++){
            cin>>mat[i][j];
            dp[i][j] = 0;
        }
    }   

    dp[1][1] = 1;
    for(ll j=2; j<=w; j++){
        if(mat[1][j] == '.'){
            dp[1][j] = dp[1][j-1];
        }
        else{
            dp[1][j] = 0;
        }
    }

    for(ll i=2; i<=h; i++){
        if(mat[i][1] == '.'){
            dp[i][1] = dp[i-1][1];
        }
        else{
            dp[i][1] = 0;
        }
    }

    for(ll i=2; i<=h; i++){
        for(ll j=2; j<=w; j++){
            if(mat[i][j] == '#'){
                dp[i][j] = 0;
            }
            else{
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }
        }
    }

    cout<<(dp[h][w])<<endl;

    return 0;
}


Measured memory_bytes: 9088
var n: Int = Int(readLine()!)!
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var highest: Int = 0
var o: Int = 0

for var i = 0; i < n; i++ {
  if( highest <= arr[i] ) {
    highest = arr[i]
    o+=1
  } 
}
print (o)


Measured memory_bytes: 4080
#include<iostream>
#include<string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   string s;
   cin>> s;

   if(s[1]=='R')
    s[1]='B';

   else if(s[1]=='B')
    s[1]='R';

   cout<< s<< endl;

    return 0;
}





Measured memory_bytes: 3636
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll b[1000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t,a[200001];   
    memset(b,0,sizeof(b));
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    ll ans=0;
    for(i=0;i<n;i++)
    {
       p=a[i];
       ll flag=0;
       for(j=1;j<=sqrt(a[i]);j++)
       {
          if(p%j==0)
          {
              if(b[j]>=1&&j!=p)
              {
                  flag=1;
              }
              if(b[j]>=2&&j==p)
              {
                  flag=1;
              }
              k=p/j;
              if(k==p)
              {
                  if(b[p]>=2)
                  flag=1;
              }
              else 
              {
                  if(b[k]>=1)
                  flag=1;
              }
          }
          
       }
       if(flag==0)
       ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13016
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    int a, b;
    cin >> a >> b;
    for(int i = 0; i < 2048; ++i)
        if((int)(i*0.08) == a && (int)(i*0.1) == b) {
            cout << i;
            return;
        }
    cout << -1;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int p,q,r,s,u ; cin >> p >> q >> r >> s >> u ; 
  int t ;
  if(p == 0){
    t = 1 ; 
  }
  else if(q == 0){
    t = 2 ;
  }
  else if(r == 0){
    t = 3 ; 
  }
  else if(s == 0){
    t = 4 ;
  }
  else if(u == 0){
    t = 5 ;
  }
	cout << t ; 
	return 0;
}


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

int main(){
  string s;
  cin >>s;
  int cnt = 0;
  rep(i,s.size()-1){
    if(s[i]==s[i+1]){
      cnt++;
      if(s[i+1]=='1') s[i+1] = '0';
      else s[i+1] = '1';
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
n = int(input())
min_number = int(input())
max_profit = -2000000000000000000000000000
for i in range(n-1):
    number = int(input())    
    if max_profit < number-min_number:
        max_profit = number - min_number
    if number < min_number:
        min_number = number
print(max_profit)

    



Measured memory_bytes: 5612
buildings = []
4.times do
    floors = []
    3.times do
        floors.push( Array.new(10, 0) )
    end
    buildings.push(floors)
end
n = gets.chomp.to_i
n.times do
    input = gets.split(" ")
    input.map!(&:to_i)
    buildings[input[0]-1][input[1]-1][input[2]-1] += input[3]
end
buildings.each_with_index do |floors, index|
    floors.each do |rooms|
        rooms.each do |value|
            print " ", value
        end
        puts
    end
    puts "#" * 20 if index != buildings.size-1
end


Measured memory_bytes: 6884
num,k = map(int, input().split())
moves=[int(x) for x in input().split()]

def findMinPath(nums,k):
    if 0 in nums:
        k-=1
    if k==0:
        return 0
    left=[];right=[]
    for n in nums:
        if n<0:
            left.append(abs(n))
        elif n>0:
            right.append(n)
    left[:]=left[::-1]
    left.insert(0,0)
    right.insert(0,0)

    lsize=len(left);rsize=len(right)
    res=max(2*left[-1]+right[-1],2*right[-1]+left[-1])
    for i in range(k+1):
        j=k-i
        if i<lsize and k-i<rsize:
            tmpMax=min(2*left[i]+right[j],2*right[j]+left[i])
            res=min(res,tmpMax)
    return res

print(findMinPath(moves,k))

Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,temp;
    cin>>n;
    map<ll,ll>m;
    for(i=1;i<=n;i++){
    	cin>>temp;
    	m[temp]=i;
	}
	map<ll,ll>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		cout<<it->second<<" ";
	}
	cout<<endl;
	return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int K = input();
    int a = input(), b = input();

    range(i, a, b + 1) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return;
        }
    }

    cout << "NG" << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3652
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let a: Vec<usize> = sc.vec(n);
    let mut ans = vec![0; n];
    for i in (0..n).rev() {
        let mut s = 0;
        for k in 2..n + 1 {
            let j = (i + 1) * k;
            if j > n { break }
            s += ans[j - 1];
        }
        ans[i] = (s + a[i]) % 2;
    }
    put!(ans.iter().filter(|&x| *x > 0).count());
    for i in 0..n {
        if ans[i] > 0 {
            put!(i + 1);
        }
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 16636
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  vi inp(3);
  int n ;
  cin >> n ;
  while(n--){
    rep(i,3)
      cin >> inp[i] ;
    sort(all(inp));
    if(inp[0]*inp[0]+inp[1]*inp[1]==inp[2]*inp[2])
      cout << "YES" << endl;
    else 
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        String s = in.next();
        char first = s.charAt(0);
        List<Integer> l = new ArrayList<>(n);
        char prevChar = first;
        int currentStreak = 1;
        int maxStreak = 0;
        for(int i=1; i<n; i++) {
            char c = s.charAt(i);
            if(prevChar == c) {
                currentStreak++;
            }
            else {
                maxStreak = Math.max(maxStreak, currentStreak);
                l.add(currentStreak);
                currentStreak = 1;
                prevChar = c;
            }
        }
        maxStreak = Math.max(maxStreak, currentStreak);
        l.add(currentStreak);

        int result = 0;
        for(int i=0; i<l.size(); i++) {
            boolean subListStartsWith0 = (first == '0') ^ (i%2==1);
            if(i>0 && subListStartsWith0) {
                continue;
            }
            int subListLength = k*2+1;
            if(subListStartsWith0) {
                subListLength = k*2;
            }
            int score = 0;
            for(int j=i; j<Math.min(l.size(), i+subListLength); j++) {
                score += l.get(j);
            }
            result = Math.max(result, score);
            if(maxStreak == 1) {
                // dirty code!!!!!
                break;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 27692
#include <cstdio>
#include <algorithm>
using namespace std;

int n,a[200005];

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar(),t=-1;
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t;
}

int main(void){
	n=read();
	for(int i=1;i<n;i++){
		int x=read();
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	printf("%d\n",a[i]);
} 

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





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

int main(void){
    int n;
    int *p;
    int i;
    int tmp;
    int cnt = 0;


    p = malloc(sizeof(int)*100000);
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &p[i]);
    }
    for (i = 0; i < n; i++){
        if (p[i] == i+1 && i == n){
            tmp = p[i];
            p[i] = p[i-1];
            p[i-1] = tmp;
            cnt;
        }else if(p[i] == i+1){
            tmp = p[i];
            p[i] = p[i+1];
            p[i+1] = tmp;
            cnt++;
        }

        
    }

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

}

Measured memory_bytes: 512
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/

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

int main(){

  long long n; cin>>n;
   int w[n];

 for(int i=0;i<n;i++)
    cin>>w[i];

    long long mini=INT_MAX;

  for(int t=1;t<n;t++)
  {
     long long sum=0,sum1=0;
   for(int i=0;i<n;i++)
    {
     if(i < t)
      sum += w[i];
     else
        sum1+= w[i];
   }

    long long diff = abs(sum-sum1);
     mini = min(mini,diff);

  }


cout<<mini<<endl;

 return 0;
 }

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0

for i in range(n):
    d1 = b[i] - a[i]
    if d1 <= 0:
        cnt += b[i]
    else:
        cnt += a[i]
        d2 = a[i+1] - d1
        if d2 > 0:
            a[i+1] = d2
            cnt += d1
        else:
            cnt += a[i+1]
            a[i+1] = 0

print(cnt)

Measured memory_bytes: 18476
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int main()
{
	int a=read(),b=read();
	if(a<1 || a>9 || b<1 || b>9)
		puts("-1");
	else
		cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    /* 九九の表 */
    int* l=(int*)malloc(sizeof(int)*100);
    int i,j;
    int count=0;
    for (i=0;i<=9;i++)
    {
        for (j=i;j<=9;j++)
        {
            l[count]=i*j;
            count++;
        }
    }

    int n;
    scanf("%d",&n);
    for (i=0;i<count;i++)
    {
        if(l[i]==n)
        {
            printf("Yes\n");
            free(l);
            return 0;
        }
        
        
    }
    printf("No\n");
    free(l);
    return 0;
}

Measured memory_bytes: 128
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 ;
int n , a[N] ;
bool ev = 1 ;

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

	cin >> n ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] , ev &= (a[i] % 2 == 0) ;

	cout << (!ev ? "first" : "second") << '\n' ;
}


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

//define ll long long;
//define ar array;

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

    string s, t;
    cin >> s >> t;
    int same = 1;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != t[i]) {
            same = 0;
            break;
        }
    }
    if (same){
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}



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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 300005
using namespace std;

int main()
{
    FLASH
    map<string,int> mp;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
        cout << "WA x " << mp["WA"] << '\n';
            cout << "TLE x " << mp["TLE"] << '\n';
                cout << "RE x " << mp["RE"] << '\n';
    return 0;
}


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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 100000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

  /*
  int A,B,K;
  cin>>A>>B>>K;
  vector<int>ans;
  A = min(A,B);
  for(int i=1;i<=A;i++){
    if(A%i==0&&B%i==0)ans.push_back(i);
  }
  sort(rrng(ans));
  cout<<ans[K-1]<<endl;
  */

  string S;
  cin>>S;
  int one=0,zero=0;
  int ans = 0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='1'){
      one++;
      if(zero!=0){
        zero--;
        one--;
        ans++;
      }
    }
    else{
      zero++;
      if(one!=0){
        zero--;
        one--;
        ans++;
      }
    }
  }
  cout<<2*ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll X;
  while (cin >> X) {
    ll res = 0;
    res += (X / 500) * 1000;
    res += (X % 500) / 5 * 5;
    cout << res << endl;
  }
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, x, l;
int main() {
    cin >> n >> x;
    int cnt = 1;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> l;
        sum += l;
        if (sum > x) {
            cout << cnt << endl;
            exit(0);
        }
        ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3652
def main():
    N = int(input())
    *h, = map(int, input().split())

    ans = f(N, h)
    print(ans)


def f(N, h):
    """
    前から確定させる？
    後から確定させる？
    と考えたけど、

    まずは愚直にやる座標ベース
    1: from (1)       to (2 or 3)
    2: from (1 2)     to (3 or 4)
    3: from (1   3)   to (4 or 5)
    3: from (1 2 3)   to (4 or 5)
    4: from (1 2 3 4) to (5 or 6)
    4: from (1 2   4) to (5 or 6)
    4: from (1   3 4) to (5 or 6)

    コストは絶対値なのであとに行くほど増える
    前から確定させて、コストの少ない進み方をベースにする
    厳密に言えば進み方ではなく、各位置におけるコストだけわかっていれば良い
    """
    dp = [None] * (N + 1)
    dp[0] = 0
    dp[1] = 0
    dp[2] = abs(h[1] - h[0])

    for i in range(3, N + 1):
        hi = i - 1
        cost1 = dp[i-1] + abs(h[hi] - h[hi-1])
        cost2 = dp[i-2] + abs(h[hi] - h[hi-2])
        dp[i] = min(cost1, cost2)

    ans = dp[N]
    return ans


if __name__ == "__main__":
    main()


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll m,n,i,j,k,p=1000000007,count=0,flag=0,temp,temp1,temp2;
  string s;
          cin>>m>>n;
          temp= m*(m-1)/2 + n*(n-1)/2;
          cout<<temp<<endl;  
return 0; 
 
 
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

const int N = 2E5 + 10;
int a[N], n;

void solve() {
    cin >> n;
    REP(i, n) cin >> a[i];
    sort(a, a+n);
    FOR(i, 1, n) {
        if (a[i] == a[i-1]) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

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

Measured memory_bytes: 1024
import numpy as np
from bisect import bisect_right
# from time import time
# start = time()
n, m = map(int, input().split())
p = []
y = []
d = {i + 1: [] for i in range(n)}
# n, m = 10**5, 10**5
# p = [10**5]*m
# y = [i + 1 for i in range(m)]
for i in range(m):
    p_, y_ = map(int, input().split())
    # p_, y_ = p[i], y[i]
    p.append(p_)
    y.append(y_)
    d[p_].append(y_)
for i in d.keys():
    d[i] = sorted(d[i])
for i in range(m):
    # print('{:06d}{:06d}'.format(p[i], d[p[i]].index(y[i]) + 1))
    print('{:06d}{:06d}'.format(p[i], bisect_right(d[p[i]], y[i])))
#
# print(time() - start)


Measured memory_bytes: 43932
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXN = 2e5;

int cnt[MAXN];

int main() {
  int N; std::cin >> N;
  std::fill_n(cnt, 0, N+1);
  int64_t ans = 0;
  int A; std::cin >> A; // (1)
  if(1+A <= N) ++cnt[1+A];
  for(int i = 2; i <= N; ++i) {
    std::cin >> A; // (i)
    if(i > A) ans += cnt[i-A];
    if(i+A <= N) ++cnt[i+A];
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 4404
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE BangPatterns #-}


import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Control.Arrow
import qualified Data.IntMap.Strict as IM
import qualified Data.Sequence as Sq
import Control.Concurrent


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



insertIMapSq key el = IM.insertWith (Sq.><) key (Sq.singleton el)

main = do
    [n,m] <- r'

    ways <- replicateM m r'

    let im = foldr (\[a,b] mp -> insertIMapSq b a (insertIMapSq a b mp) ) IM.empty ways

    answer  <- U.thaw $ U.replicate (n+2) ((-1) :: Int)
    UM.write answer 1 0

    bfs (Sq.fromList [1]) im answer
    ans <- U.freeze answer

    putStrLn "Yes"
    U.mapM_ print $ U.take (n-1) $ U.drop 2 ans

bfs :: Sq.Seq Int -> IM.IntMap (Sq.Seq Int) -> UM.IOVector Int -> IO ()
bfs Sq.Empty _ _ = return ()
bfs (h Sq.:<| sq) imap answer = do
    let children = imap IM.! h

    xs <- traverse (\a -> do
        b <- UM.read answer a
        return (b<0,a)) children
    let nextBFS = fmap snd $ Sq.filter fst xs

    mapM_ (\c -> UM.write answer c h) nextBFS

    bfs (sq Sq.>< nextBFS) imap answer


Measured memory_bytes: 70012
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

int main()
{
    int n,k,arr[105],brr[105];
    string str;

    while(scanf("%d %d",&n,&k)==2)
    {
        memset(arr,0,sizeof(arr));

        set<string>s;
        set<string>::iterator it;

        s.clear();

        for(int i=0; i<n; i++)
        {
            cin>>str;

            s.insert(str);
        }

        for(it=s.begin(); it!=s.end(); it++)
        {
            str=(*it);

            arr[str[0]]++;
        }

        int cnt=0,j=0;

        for(int i=65; i<=90; i++)
        {
            if(arr[i]>=1)
            {
                brr[j++]=arr[i];

                cnt++;
            }
        }

        if(cnt<k)
            printf("0\n");

        else
        {
            int ans=0;

            while(1)
            {
                cnt=0;
                int flag=0;

                sort(brr, brr+j, greater<int>());

                for(int i=0; i<j; i++)
                {
                    if(brr[i]>=1)
                    {
                        brr[i]--;

                        cnt++;
                    }

                    if(cnt==k)
                    {
                        ans++;

                        flag=1;

                        break;
                    }
                }

                if(flag==0)
                    break;
            }

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

    return (0);
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define MAX 100010
using namespace std;
int C[MAX];
int main() {
  int N;
  cin >> N;
  rep(i,MAX) C[i] = 0;
  rep(i,N) {
    int tmp;
    cin >> tmp;
    C[tmp] += 1;
  }
  int ans = 0;
  REP(i,1,MAX) {
    int tmp = C[i-1] + C[i] + C[i+1];
    if (ans < tmp) ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
/* Author - xorier4104 */

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>


using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define MOD 			(int) 1e9+7
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define mem(a,b)        memset(a,(b),sizeof(a))
#define max(a,b)        ((a)>(b) ? (a):(b))
#define min(a,b)        ((a)<(b) ? (a):(b))
#define abs(a)          ((a)>0 ? (a):(-(a)))
#define sq(a) 			((a)*(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)

int main(){ FastIO;

	string a,b;
	cin>>a>>b;
	int al=a.length();
	int flag=0;
	for(int i=0;i<al;i++){
		if(a[i]!=b[i]){
			flag=1;
			break;
		}
	}
	if(flag==0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
return 0;	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int a; cin >> a;
  int ans = a + a*a + a*a*a;
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=3020;
const ll MOD=1e9+7;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
void solve(){
    int s;
    cin>>s;
    ll ans=0;
    cal_factor();
    for(int l=s/3;l>0;l--){
        int m=s-l*3;
        ans=(ans+C(l+m-1,l-1))%MOD;
    }
    cout<<ans<<"\n";
}
// #define LOCAL
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;



//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr;	} cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-6
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define all(x) (x).begin(), (x).end()


int problemA()
{
	string S, F = "FESTIVAL";
	cin >> S;

	for (int i = 0; i < F.size(); i++) S.pop_back();

	cout << S << endl;

	return 0;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	problemA();
	
	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
  int a, b; cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  } else if (6 <= a && a <= 12) {
    cout << b/2 << endl;
  } else {
    cout << 0 << endl;
  }
}

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

using namespace std;

class DisjointSet {
 public:
  vector<int> rank, p;

  DisjointSet(){};
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    for (int i = 0; i < size; ++i) makeSet(i);
  }

  void makeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y) { return findSet(x) == findSet(y); }

  void unite(int x, int y) { link(findSet(x), findSet(y)); }

  void link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
  }

  int findSet(int x) {
    if (x != p[x]) {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ds.unite(a, b);
  }
  /*
  for (int i = 0; i < n; ++i) {
    cout << "i=" << i << " findSet(i)=" << ds.findSet(i) << endl;
  }
  */

  vector<int> hist(n, 0);
  for (int i = 0; i < n; i++) {
    ++hist[ds.findSet(i)];
  }
  sort(hist.begin(), hist.end(), greater<int>());
  cout << hist[0] << endl;
}


Measured memory_bytes: 5240