akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define first fi
#define second se
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=1;
    ll a=0,b=0,c=0,ab=0,ac=0,bc=0,ca=0,cb=0,ba=0;
    rep(i,n*3){
        if(s[i]=='R'){
            if(bc>0){
                ans=ans*bc%mod;
                bc--;
            }else if(b>0){
                ans=ans*b%mod;
                b--;
                ab++;
            }else if(c>0){
                ans=ans*c%mod;
                c--;
                ac++;
            }else{
                a++;
            }
        }
        if(s[i]=='B'){
            if(ac>0){
                ans=ans*ac%mod;
                ac--;
            }else if(a>0){
                ans=ans*a%mod;
                a--;
                ab++;
            }else if(c>0){
                ans=ans*c%mod;
                c--;
                bc++;
            }else{
                b++;
            }
        }
        if(s[i]=='G'){
            if(ab>0){
                ans=ans*ab%mod;
                ab--;
            }else if(a>0){
                ans=ans*a%mod;
                a--;
                ac++;
            }else if(b>0){
                ans=ans*b%mod;
                b--;
                bc++;
            }else{
                c++;
            }
        }
    }
    REP(i,1,n+1){
        ans=ans*i%mod;
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}



int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;


    auto itr = unique(s.begin(), s.end());
    s.erase(itr, s.end());
    ppp(s.size()-1);



    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        while(true){
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();
            if(m==-1&&f==-1&&r==-1){
                break;
            }else if (m == -1 || f == -1 || m + f < 30) {
                System.out.println("F");
            } else if (m + f >= 80) {
                System.out.println("A");
            } else if (m + f >= 65) {
                System.out.println("B");
            } else if (m + f >= 50||r >= 50) {
                System.out.println("C");
            } else {
                System.out.println("D");
            }
        }
    }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;


main()
{
        int a,b; cin>>a>>b;
        int ans=0;
        if(a<b)
        {
                ans+=b;
                b--;
        }else
        {
                ans+=a;
                a--;
        }
        if(a<b)
        {
                ans+=b;
                b--;
        }else
        {
                ans+=a;
                a--;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int A = Integer.parseInt(sl[0]);
            int B = Integer.parseInt(sl[1]);
            int C = Integer.parseInt(sl[2]);

            boolean flg = false;

            // 最小公倍数まで見れば十分
            for (int i = A; i <= A * B; i++) {
                if (i % A == 0 && i % B == C) {
                    flg = true;
                    break;
                }
            }

            System.out.println(flg ? "YES" : "NO");
        }
    }
}


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

int main() {
  int m,t,p,r;
  while(cin >> m >> t >> p >> r && m) {
    int score[t+1],penalty[t+1][p+1],clear[p+1],term[t+1];
    for(int i=1; i<=t; i++) {
      score[i]=0;
      for(int j=1; j<=p; j++) penalty[i][j]=clear[j]=0;
      term[i]=i;
    }
    for(int i=0; i<r; i++) {
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      if(!d) score[b]+=penalty[b][c]*20+a-100000;
      else penalty[b][c]++;
    }

    for(int i=1; i<=t; i++) {
      for(int j=i; j>1; j--) {
	if(score[j]<score[j-1]) {
	  swap(score[j],score[j-1]);
	  swap(term[j],term[j-1]);
	} else if(score[j]==score[j-1]) {
	  if(term[j]>term[j-1]) swap(term[j],term[j-1]);
	}
      }
    }
    for(int i=1; i<=t; i++) {
      if(i>1) {
	if(score[i-1]==score[i]) cout << "=";
	else cout << ",";
      }
      cout << term[i];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	static int INF = (int)1e9 + 7;
	int N,W;
	int[] v,w;
	int[][] dp;
	public void solve() {
		N = nextInt();
		W = nextInt();
		v = new int[N];
		w = new int[N];
		dp = new int[N + 1][W + 1];
		for(int i = 0;i < N;i++){
			v[i] = nextInt();
			w[i] = nextInt();
		}
		int ans = 0;
		for(int i = 1;i <= N;i++){
			for(int j = W;j >= 0;j--){
				if(j - w[i - 1] >= 0)dp[i][j - w[i - 1]] = Math.max(dp[i][j - w[i - 1]],dp[i - 1][j] + v[i - 1]); 
				dp[i][j] = Math.max(dp[i][j],dp[i - 1][j]);
				ans = Math.max(ans,dp[i][j]);
			}
		}
		out.println(ans);
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 29260
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H,vector<int>(W));
    vector<vector<int>> ans;
    rep(i,H)rep(j,W) cin >> a[i][j];
    rep(i,H){
        rep(j,W-1){
            if(a[i][j] % 2 == 0) continue;
            a[i][j+1]++;
            vector<int> res(4);
            res[0] = i+1;
            res[1] = j+1;
            res[2] = i+1;
            res[3] = j+2;
            ans.push_back(res);
        }
    }
    rep(i,H-1){
        if(a[i][W-1] % 2 == 0) continue;
        a[i+1][W-1]++;
        vector<int> res(4);
        res[0] = i+1;
        res[1] = W;
        res[2] = i+2;
        res[3] = W;
        ans.push_back(res);
    }
    cout << ans.size() << endl;
    for(auto v:ans){
        rep(i,4){
            if(i == 3) cout << v[i] << endl;
            else cout << v[i] << ' ';
        }
    }
}

Measured memory_bytes: 11136
N = int(input())

a = [3, 5, 7]

for i in range(1, 9):
    added_a = []
    for _a in a:
        added_a.append(3*(10**i)+_a)
        added_a.append(5*(10**i)+_a)
        added_a.append(7*(10**i)+_a)
    a.extend(added_a)

b = []
for _a in a:
    if _a <= N:
        b.append(_a)

c = []
for _b in b:
    _s = str(_b)
    if "3" in _s and "5" in _s and "7" in _s and "0" not in _s:
        c.append(_b)

print(len(c))

Measured memory_bytes: 13816
#include <bits/stdc++.h>
#define rei register int
using namespace std;
const int mod = 1000000007;
int ans;
int qpow(int x,int p){
	int rec(1);
	while(p){
		if(p & 1) rec = 1ll*rec * x % mod;
		p >>= 1,x = 1ll*x * x % mod;
	} return rec;
}
int main(){
	int n ; cin >> n; int cnt(0);
	for(rei i = 1;i <= n;++i) {
		int x; scanf("%d",&x); cnt = (cnt + x) % mod;
		ans = (mod - 1ll*x * x % mod + ans) % mod;
 	}	cout << (ans + 1ll*cnt * cnt % mod) * qpow(2,mod - 2) % mod; return 0;
}

Measured memory_bytes: 3768
#include<iostream>
using namespace std;
#define exit(x) {cout<<x;return 0;}
int main()
{
long long n,m;
cin>>n>>m;
if(n==1&&m==1)exit(1)
if(n==1)exit(m-2)
if(m==1)exit(n-2)
cout<<((n-2)*(m-2));
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int dxx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 }, dyy[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int n, q;
bool seen[200010];
ll dist[200010] = {};
//解説AC
void dfs (Graph& g, int now, int prev) {
    seen[now] = 1;
    if (now != 0) dist[now] += dist[prev];
    //cout << now << " " << dist[now] << "\n";
    for (auto next : g[now]) {
        if (!seen[next]) dfs (g, next, now);
    }
}

int main() {
    cin >> n >> q;
    Graph g (n);
    rep (i, n) seen[i] = 0;
    rep (i, n - 1) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back (b - 1);
        g[b - 1].push_back (a - 1);
    }
    rep (i, q) {
        int a, c;
        cin >> a >> c;
        dist[a - 1] += c;
    }
    dfs (g, 0, 0);
    rep (i, n) {
        if (i) cout << " ";
        cout << dist[i];
    }
    cout << "\n";
}

Measured memory_bytes: 24448
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

class Main {
	public static void main(String[] args) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        
		Scanner sc = new Scanner(System.in);
        String dateStr = sc.next();
        
        Date date1 = sdf.parse(dateStr);
        Date date2 = sdf.parse("2019/04/30");
        
        if (date1.compareTo(date2) > 0) {
            System.out.println("TBD");
        }else {
        	System.out.println("Heisei");
        }
	}
}


Measured memory_bytes: 21584
#include<stdio.h>
int main(void)
{
    char num[5],o[2]={'+','-'};
    int s[3];
    while(~scanf("%s",num)){
    int i,j,right,left,n=0;
    for(s[0]=0;s[0]<2;s[0]++){
        for(s[1]=0;s[1]<2;s[1]++){
            for(s[2]=0;s[2]<2;s[2]++){
                    left=num[0]-'0';
                    for(j=0;j<3;j++)
                    {
                    right=num[j+1]-'0';
                    switch(o[s[j]]){
                    case '+':
                        left+=right;
                        break;
                    case '-':
                        left-=right;
                        break;
                    }
                    if(left==7){
                      printf("%d%c%d%c%d%c%d=7\n",num[0]-'0',o[s[0]],num[1]-'0',o[s[1]],num[2]-'0',o[s[2]],num[3]-'0');
                        n++;
                    }
                    if(n!=0)
                        break;
                    }
                    if(n!=0)
                break;
                }
                if(n!=0)
            break;
        }
          if(n!=0)
        break;
    }
    }
}

Measured memory_bytes: 256
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
    float r;
    cin>>r;
    cout<<setprecision(40)<<2*PI*r<<endl;

 
 
 
    
 
    return 0;
}


Measured memory_bytes: 3812
import sys #追加
sys.setrecursionlimit(500*500)

s = input()
check_flag = True
def check_and_cut(string):
    tmp = '123'
    flag = True
    if len(string) <= 4:
        pass
    else:
        if len(string) >4:
            if string[-5:] == 'dream':
                tmp = string[:-5]
                flag = False
            elif string[-5:] == 'erase':
                tmp = string[:-5]
                flag = False
        if len(string) >5 and flag:
            if string[-6:] == 'eraser':
                tmp = string[:-6]
                flag = False
        if len(string) >6 and flag:
            if string[-7:] == 'dreamer':
                tmp = string[:-7]
                flag = False
    #print(string,len(string),string[-6:],tmp,string[-6:] == 'eraser')
    return tmp
while check_flag:
    t = check_and_cut(s)
    if t == '123':
        print('NO')
        exit()
    if len(t) == 0:
        print('YES')
        exit()
    s = t

Measured memory_bytes: 135352
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n,k,h[100010];
    scanf("%d %d",&n,&k);
    for(int i = 0;i < n; i++)
        scanf("%d",&h[i]);
    sort(h,h+n);
    int minn = 1e9+10;
    for(int i = 0;(i + k - 1) < n; i++)
    {
        int hn = h[i + k - 1] - h[i];
        if(hn < minn)
            minn = hn;
    }
    printf("%d",minn);
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program
{
    internal static void Main(string[] args)
    {
        var c1 = ReadLine();
        var c2 = ReadLine();
        var c3 = ReadLine();

        WriteLine(c1.Substring(0, 1) + c2.Substring(1, 1) + c3.Substring(2, 1));
    }
}


Measured memory_bytes: 13140
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

typedef pair<int,int> p;

int main(){
  ll n;
  cin >> n;
  vector<int> cnt_odd, cnt_even;
  static int size = 100001;
  cnt_odd.resize(size);
  cnt_even.resize(size);
  REP(i,n/2){
    int a;
    cin >> a;
    cnt_odd[a]++;
    cin >> a;
    cnt_even[a]++;
  }
  vector<p> sort_odd, sort_even;
  REP(i,size){
    sort_odd.push_back(p(cnt_odd[i],i));
    sort_even.push_back(p(cnt_even[i],i));
  }
  sort(sort_odd.begin(),sort_odd.end(),greater<p>());
  sort(sort_even.begin(),sort_even.end(),greater<p>());
  if(sort_odd[0].second!=sort_even[0].second){
    cout << n - sort_odd[0].first - sort_even[0].first << endl;
  }else{
    cout << min(n - sort_odd[1].first - sort_even[0].first, n - sort_odd[0].first - sort_even[1].first) << endl;
  }
  return 0;
}


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

#define PI 3.141592653589793

int main() {
  char buf[1500];
  int a,b,h,m;
  while(fgets(buf,sizeof(buf),stdin)!=NULL) {
    sscanf(buf,"%d %d %d %d", &a,&b,&h,&m);
  }
  long double rad, x;
  rad = 2 * PI *(((long double)h+(long double)m/60)/12 - (long double)m/60);

  x = sqrtl((long double)(a*a+b*b)-2*(long double)a*(long double)b*cosl(rad));

  printf("%.20Lf\n",x);
  return 0;
}


Measured memory_bytes: 2580
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(a);
    cini(v);
    cini(b);
    cini(w);
    cini(t);

    int d=abs(a-b);
    if(t*v-t*w >=d)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  ll ans = 0;
  cout << n*(n-1)/2 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int n, m; cin >> n >> m;
  vector<Pll> p(n);
  int a, b;
  ll ans = 0, cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  sort(p.begin(), p.end());

  for (int i = 0; i < n; ++i) {
    if (cnt + p[i].second >= m) {
      ans += p[i].first * (m - cnt);
      break;
    } else {
      ans += p[i].first * p[i].second;
      cnt += p[i].second;
    }
  }

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


Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int MAX_A = 300000;
        SegmentTree st = new SegmentTree(MAX_A);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int maxLength = (int) st.getMax(a - k, a + k + 1) + 1;
//            debug(a, maxLength);
            st.set(a, maxLength);
//            System.err.println(maxLength);
            ans = Math.max(maxLength, ans);
        }

        System.out.println(ans);
        // out.println("Hello World");
        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

class SegmentTree {

    int size;
    long[] array; // ルートがインデックス0とする

    @Override
    public String toString() {
        return Arrays.toString(array);
    }

    public SegmentTree(int n) {
        size = 1;
        while (size < n) {
            size = size * 2;
        }
        array = new long[2 * size - 1];
        Arrays.fill(array, Long.MIN_VALUE);
    }

    // インデックスiに値xをセットする
    public void set(int i, long x) {
        int current = size + i - 1;
        array[current] = x;
        while (true) {
            int parent = (current - 1) / 2;
            array[parent] = Math.max(array[2 * parent + 1], array[2 * parent + 2]);
            current = parent;
            if (current == 0) break;
        }
    }

    // 半開区間 [a, b) の最大値を返す
    public long getMax(int a, int b) {
        return query(a, b, 0, 0, size);
    }

    long query(int a, int b, int k, int l, int r) {
        // またく交差しない場合
        if (r <= a || b <= l) return Long.MIN_VALUE;
        // 完全に含む場合
        if (a <= l && r <= b) return array[k];

        long vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        long vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return Math.max(vl, vr);
    }
}


Measured memory_bytes: 66688
#include <cstdio>
#include <cstdlib>
#define MAX 2000001
#define VMAX 10000
  
int main() {
    unsigned short *A, *B;
    int n, i, j;
    int C[VMAX];
    scanf("%d", &n);
    A = (unsigned short *)malloc(sizeof(short) * n + 1);
    B = (unsigned short *)malloc(sizeof(short) * n + 1);
  
    for (int i=0; i<VMAX; i++) C[i] = 0;
  
    for (int i=0; i<n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
  
    for (i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];
  
    for (j=1; j<=n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    for (int i=1; i<=n; i++) {
        printf("%d", B[i]);
        if (i == n) printf("\n");
        else printf(" ");
    }
    return 0;
}

Measured memory_bytes: 10604
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        k: u64,
    }
    let mut sum = 0;
    let mut i = 0;
    while i < s.len() && s[i] == '1' {
        sum += 1;
        if sum >= k {
            println!("{}", s[i]);
            return;
        }
        i+=1;
    }
    println!("{}", s[i]);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int add=(b+c);
    int sub=(add-a);
    if(a<add)
    {
        cout<<sub<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }


}



Measured memory_bytes: 3640
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int ans = m;
		for (int i = 0; i < n; i++) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			m += a - b;
			if (m < 0) {
				System.out.println(0);
				return;
			}
			ans = Math.max(ans, m);
		}
		System.out.println(ans);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}

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

  string s;
  cin >> s;
  if(s[s.length()-1] == 's') s += "es";
  else s += "s";

  cout << s << endl;
}

Measured memory_bytes: 3652
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K, *H = map(int, read().split())
H.sort()
print(min(H[i+K-1]-H[i] for i in range(N-K+1)))


Measured memory_bytes: 13040
import math
def permute(arr, s, n): 
    global result
    if (s == 1): 
        i=0
        distance=0
        while(i<n-1):
            distance+=math.sqrt(pow(A[arr[i]][0]-A[arr[i+1]][0],2)+pow(A[arr[i]][1]-A[arr[i+1]][1],2))
            i+=1
        result+=distance
        return
    for i in range(s): 
        permute(arr,s-1,n); 
        if s&1==1: 
            arr[0], arr[s-1] = arr[s-1],arr[0] 
        else: 
            arr[i], arr[s-1] = arr[s-1],arr[i] 

n=int(input())
A=[]
result=0
for i in range(n):
    x,y=list(map(int,input().split()))
    A.append([x,y])
permute([i for i in range(0,n)],n,n)
print(result/math.factorial(n))





Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#define ll long long
#define ld long double
#define pb push_back
#define mk make_pair
using namespace std;

int main(){
    ll a, b, c, c1 = 0, c2 = 0;
    cin >> a >> b >> c;
    ll ar[11] = {0};
    ar[a]++;
    ar[b]++;
    ar[c]++;
    if(ar[5] == 2 && ar[7] == 1)
        cout << "YES";
    else
        cout << "NO";


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int main() {
  ld a, b, x;
  cin >> a >> b >> x;
  if (x <= (a * a * b) / 2.0l)
    cout << fixed << setprecision(10)
         << atan(a * b * b / (2.0l * x)) * 180.0l / M_PI;
  else
    cout << fixed << setprecision(10)
         << atan(2 * b / a - 2.0l * x / (a * a * a)) * 180.0l / M_PI;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

vector<pair<int, int> > makeHebi(int h, int w){
    vector<pair<int, int> > ret;
    
    REP(i, h){
        if(i % 2 == 0){
            REP(j, w){
                ret.pb(make_pair(i, j));
            }
        }else{
            for(int j = w-1; j >= 0; j--){
                ret.pb(make_pair(i, j));
            }
        }
    }

    return ret;
}

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

    int h, w;
    cin >> h >> w;
    vector<vector<int> > a(h, vector<int>(w, 0));
    int cnt = 0;
    REP(i, h) REP(j, w){ cin >> a[i][j]; if(a[i][j] & 1) cnt++; }
    
    vector<tuple<int, int, int, int> > tp;

    vector<pair<int, int> > hebi = makeHebi(h, w);
    for(auto z = hebi.begin(); z != hebi.end()-1; ++z){
        pair<int, int> cur = *z, next = *(z+1);
        if(a[cur.first][cur.second] & 1){
            a[next.first][next.second]++;
            tp.pb(make_tuple(cur.first, cur.second, next.first, next.second));
        }
    }
    
    cout << tp.size() << endl;
    for(auto ans : tp){
        cout << get<0>(ans)+1 << " " << get<1>(ans)+1 << " " << get<2>(ans)+1 << " " << get<3>(ans)+1 << endl;
    }
}


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    long long N, M, buf1, buf2, buf3, ans;
    vector<long long> H;

    cin >> N >> M;
    ans = N;

    vector<bool> YOI(N,true);

    REP(i,N){
        cin >> buf1;
        H.push_back(buf1);
    }
    REP(i,M){
        cin >> buf2 >> buf3;
        if(H[buf2-1] > H[buf3-1]){
            if(YOI[buf3-1]==true){
                YOI[buf3-1] = false;
                ans -= 1;
            }
        }
        else if(H[buf2-1] < H[buf3-1]){
            if(YOI[buf2-1]==true){
                YOI[buf2-1] = false;
                ans -= 1;
            }
        }
        else {
            if(YOI[buf2-1]==true){
                YOI[buf2-1] = false;
                ans -= 1;
            }
            if(YOI[buf3-1]==true){
                YOI[buf3-1] = false;
                ans -= 1;
            }
        }
    }
    cout << ans << endl;
}

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

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

    int sum=0;
    for(int i=0;i<t.size();i++)
    {
        sum+=t[i]-'0';
    }
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3696
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define int long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, ans = 1, cnt;
string s;

signed main() {
	io(); cin >> n;
	for (int i = 0; i + 1 < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int x = i ^ j, cnt = 0;
			while (x > 0) {
				x >>= 1;
				cnt++;
			}
			cout << cnt << ' ';
		}
		cout << '\n';
	}
}

Measured memory_bytes: 512
n = int(input())


from collections import defaultdict
def getprime(n):
    if not isinstance(n, int):
        raise TypeError("Input int")
    prime = []
    # 約数はsqrt(N)まで調べればOK
    data = [i+1 for i in range(1,n)]
    while True:
        p = data[0]
        if p >= int(n**0.5):
            return prime+data
        prime.append(p)
        # pで割り切れないものだけを残す
        data = [d for d in data if d%p != 0]

def factorization(n):
    # n >= 1を想定
    factors = defaultdict(int)
    if n == 1:
        return {}
    if int(n**0.5) == 1:
        return {n:1} 
    primes = getprime(int(n**0.5))
    for prime in primes:
        while n % prime == 0:
            factors[prime] += 1
            n //= prime
            # print(factors,n)
    if n != 1:
        factors[n] += 1
    return factors

x = factorization(n)
ans = 0
for k in x.keys():
    n = 1
    while n*(n+1)//2 < x[k]:
        n += 1
        if n*(n+1)//2 > x[k]:
            n -= 1
            break
    ans += n
print(ans)

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair<ll,ll> pii;

/*-----------------------------------------------------------------------*/

int main(){
   fastt;

   int n,k;
   cin>>n>>k;

   int height[n];
   int dp[n];

   for(int i=1;i<=n;i++){
      cin>>height[i];
      dp[i]=2e9;
   }

   dp[1]=0;

   for(int i=1;i<=n;i++){
      for(int j=1;j<=k&&j+i<=n;j++)
        dp[j+i]=min(dp[j+i],dp[i]+abs(height[j+i]-height[i]));
   }

   cout<<dp[n]<<endl;

   return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define lINF 9223372036854775807
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;

ll n,k,h[111111],m[111111];

ll dp(int i){
	if(m[i]!=-1)return m[i];
	if(i==n-1)return 0;
	vector<ll> v;
	for(int j=0;j<k;j++){
		if(i+j+1<n)v.push_back(dp(i+j+1)+abs(h[i]-h[i+j+1]));
	}
	
	return m[i]=*min_element(v.begin(),v.end());
}

int main(){
	
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
		m[i]=-1;
	}
	cout<<dp(0)<<endl;
	return 0;

}

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

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

using Graph = vector<vector<int>>;
//using Graph = vector<vector<Edge>>;
bool seen[100][100];
int field[100][100];

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

int w, h;

void dfs(int i, int j){
    seen[i][j] = true;
    REP(k, 8){
        if(i+dx[k] >= h || i+dx[k] < 0 || j+dy[k] >= w || j+dy[k] < 0) continue;
        if(field[i+dx[k]][j+dy[k]] == 0) continue;
        if(seen[i+dx[k]][j+dy[k]]) continue;
        dfs(i+dx[k], j+dy[k]);
    }
}

int main()
{
    for(;;){
        cin >> w >> h;
        if(w==0 && h==0)
            break;
        REP(i, h)
            REP(j, w){
                cin >> field[i][j];
                seen[i][j] = false;
            }
        int count = 0;
        REP(i, h)
            REP(j, w){
                if(seen[i][j] || field[i][j] == 0) continue;
                dfs(i, j);
                count++;
            }
        cout << count << endl;
    }

    return 0;
    
}




Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int N; cin >> N;
  long long t = 1, a = 1;
  for (int i = 0; i < N; i++) {
    int T, A; cin >> T >> A;
    long long n = max((t + T - 1) / T, (a + A - 1) / A);
    t = n * T, a = n * A;
  }
  cout << t + a << endl;
  return 0;
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
c = list(input())

hand = "a"
while(1) :
    # 勝利判定
    if(len(a) == 0) and (hand == "a") :
        print("A")
        break
    elif(len(b) == 0) and (hand == "b") :
        print("B")
        break
    elif(len(c) == 0) and (hand == "c") :
        print("C")
        break
    else :
        pass
      
    # ターン判定と手配だし
    if hand == "a" :
        hand = a.pop(0)
    elif hand == "b" :
        hand = b.pop(0)
    else :
        hand = c.pop(0)

Measured memory_bytes: 3064
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int n;
int map[110][110];

int cnt(int x0,int y0,int x1,int y1) {
    int res=0;
    for(int i=x0;i<x1;i++) {
        for(int j=y0;j<y1;j++) {
            if(map[i][j]=='*') res++;
        }
    }

    return res;

}

void solve() {

    rep(i,110) rep(j,110) map[i][j]=0;
    int h,w,s,t;
    int x[510]={},y[510]={};
    cin>>w>>h;
    rep(i,n) {
        cin>>x[i]>>y[i];
        map[x[i]][y[i]]='*';
    }
    cin>>s>>t;

    int ans = 0;

    for(int i=1;i<=1+w-s;i++) {
        for(int j=1;j<=1+h-t;j++) {
            ans=max(ans,cnt(i,j,i+s,j+t));
        }
    }
    cout<<ans<<endl;

}

int main() {
    while(cin>>n) {
        if(!n) return 0;
        solve();

    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct score{
	int n;
	double t;
};
int main(){
	score a[8],o[8],x,b[18];
	int c1 = 0,c2 = 0;
	for(int i = 0;i < 3;++i){
		for(int j = 0;j < 8;++j){
			cin >> x.n >> x.t;
			a[j] = x;
		}
		for(int j = 0;j < 8;++j){
			for(int k = 7;j < k;--k){
				if(a[j].t > a[k].t){
					swap(a[j],a[k]);
				}
			}
		}
		for(int j = 0;j < 8;++j){
			if(j < 2) {
				o[c1] = a[j];
				++c1;
			}
			else {
				b[c2] = a[j];
				++c2;
			}
		}
	}
	for(int i = 0;i < 18;++i){
		for(int j = 17;j > i;--j){
			if(b[i].t > b[j].t){
				swap(b[i],b[j]);
			}
		}
	}
	for(int i = 0;i < 2;++i){
		o[c1] = b[i];
		++c1;
	}
	for(int i = 0;i < 8;++i){
		printf("%d %.2f\n",o[i].n,o[i].t);
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int k, n;
    cin >> k >> n;
    vector<int>an(n);
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
    }
    int memo = 0;
    for(int i = 0; i < n - 1; i++){
        memo = max(memo, an.at(i + 1) - an.at(i));
    }
    an.at(0) += k;
    memo = max(memo, an.at(0) - an.at(n - 1));
    cout << k - memo << endl;
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  bool ans=true;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
    if(a.at(i)%2!=0){
      ans=false;
    }
  }
  if(ans){
    cout<<"second"<<endl;
  }
  else{
    cout<<"first"<<endl;  
  }
}



Measured memory_bytes: 640
from collections import Counter
N = int(input())
a = list(map(int,input().split()))
count_list = [0]*(10**5+1)
ans = 0
for i in a:
    count_list[i]+=1
for i in range(1,10**5):
    ans = max(ans,(count_list[i-1]+count_list[i]+count_list[i+1]))
print(ans)

Measured memory_bytes: 20888
N=int(input())

word = {}
ans={}
for i in range(N):
    s=input()
    if s in word:
        word[s]+=1
    else:
        word[s]=1
    
#print(word)
M=max(word.values())
#print(M)

for key in word:
    if word[key] == M:
        cnt=0
        for i in range(len(key)):
            cnt+=ord(key[i])-ord('a')
        ans.setdefault(key, cnt)
        
        
for value in sorted(ans.keys()):
    print(value)

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



typedef int key;
typedef int data;

typedef struct dnode{
  struct dnode* next;
  struct dnode* prev;
  key x;
  data d;
}dnode;


typedef struct{
  dnode *head;
  dnode *tail;
}dlist;


/*key???x ,data d????????????????????????*/
dnode *make_dnode(key x,data d){
  dnode *p;
  p=malloc(sizeof(dnode));
  p->next=NULL;
  p->prev=NULL;
  p->x=x;
  p->d=d;
  return p;
}


dlist *make_dlist(){
  dlist *p;
  p=malloc(sizeof(dlist));
  p->head=NULL;
  p->tail=NULL;
  return p;
}



/*key???x ,data d???????????????dlist L?????£??\??????*/
void insert_first(dlist *L,key a,data d){
  dnode *x;
  x=make_dnode(a,d);
  x->next=L->head;
  if(L->head!=NULL) L->head->prev=x;
  else L->tail=x;
  L->head=x;
}




void delete_first(dlist *L){
  if(L->head==L->tail){
    L->head=NULL;
    L->tail=NULL;
  }
  else if(L->head!=NULL){
    L->head->next->prev=NULL;
    L->head=L->head->next;
  }
}

void delete_last(dlist *L){
  if(L->head==L->tail){
    L->head=NULL;
    L->tail=NULL;
  }
  else if(L->tail!=NULL){
    L->tail->prev->next=NULL;
    L->tail=L->tail->prev;
  }
}


void delete_x(dlist *L,key x){
  dnode *p;
  p=L->head;
  while(p!=NULL){
    if(x==p->x){
      if(p->prev!=NULL) p->prev->next=p->next;
      else L->head =p->next;
      if(p->next!=NULL) p->next->prev=p->prev;
      else{
        p->prev->next=NULL;
        L->tail=p->prev;
      }
      break;
    }
    p=p->next;
  }
}





int main(){
  int n,i,x;
  dnode *p;
  dlist *L;
  L=make_dlist();
  char order[12];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %s",order);
    if(order[0]=='i'){
      scanf("%d",&x);
      insert_first(L,x,0);
    }
    else if('F'==order[6]) delete_first(L);
    else if('L'==order[6]) delete_last(L);
    else{
      scanf("%d",&x);
      delete_x(L,x);
    }
  }

  p=L->head;
  while(p->next!=NULL){
    printf("%d ",p->x);
    p=p->next;
  }
  printf("%d\n",p->x);
  return 0;
}





  

Measured memory_bytes: 34972
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = ReadLine().Split(' ').Select(int.Parse).ToList();
            WriteLine(a[0] == a[1] ? a[2] : (a[0] == a[2] ? a[1] : a[0]));
        }
    }
}



Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String x = sc.next();
            if (x.equals("0")) {
                break;
            }

            int i, j;
            int Sum = 0;
            char s;
            for (i = 0; i < x.length(); i++) {
                s = x.charAt(i);
                j = s - '0';
                Sum += j;
            }
            System.out.println(Sum);

        }
    }
}


Measured memory_bytes: 25980
#include <bits/stdc++.h>
const int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
typedef long long ll;
const double eps=1e-16;
const int N=500005;
int n,m,head[N],now=0,vis[N],lev[N];
using namespace std;

struct node
{
	int t,w,next;
}adj[N<<1];
void add(int s,int t,int w)
{
	adj[++now]=(node){t,w,head[s]};
	head[s]=now;
}
inline int read()
{
	char c;int x;
	while (c=getchar(),c<'0' || c>'9');x=c^'0';
	while (c=getchar(),c>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x;
}
void write(int x)
{
	if (x==0) return;
	write(x/10);
	putchar((x%10)+'0');
}
int ans=1;
void dfs(int s)
{
	vis[s]=1;
	int i;
	for (i=head[s];i;i=adj[i].next)
	if (!vis[adj[i].t]) lev[adj[i].t]=lev[s]+adj[i].w,dfs(adj[i].t);
	else if (lev[adj[i].t]!=(lev[s]+adj[i].w)) ans=0;
}
//void upd(int& x,int y){if (x==-1) x=y;else x=max(x,y);}

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	scanf ("%d %d",&n,&m);
	int i,s,t,w;
	for (i=1;i<=m;i++)
	{
		scanf ("%d %d %d",&s,&t,&w);
		add(s,t,w),add(t,s,-w);
	}
	for (i=1;i<=n;i++)
	if (!vis[i]) dfs(i);
	if (ans) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 14336
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;


int main(){
    
    LL x,y;
    SL(x); SL(y);

    if( y%2 == 0 && y>=x*2 && y<=x*4 ) printf("Yes\n");
    else printf("No\n");
    
return 0;}

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

using namespace std;

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

  int n; 
  string s;
  cin >> n >> s;
  map<char, int> hash;
  int x = 0;
  int res = 0;
  for (auto &c : s) {
    x += (c == 'I' ? 1 : -1);
    if (x > res) res = x;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256