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

inline int lowbit(int n){return n & (-n);}

const int moder = 1e9 + 7;
const int N = 300;

int n, m;
int power[N], fac[N], inv[N], mat[N][N], digit[N], dp[1 << 16];

int powermod(int a, int exp){
	int ret = 1;
	for ( ; exp; exp >>= 1){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
	}
	return ret;
}

int comb(int n, int m){
	if (n < m || m < 0){
		return 0;
	}
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[N - 1] = powermod(fac[N - 1], moder - 2);
	for (int i = N - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	power[0] = 1;
	for (int i = 1; i < N; ++ i){
		power[i] = 2 * power[i - 1] % moder;
	}
	scanf("%d%d", &n, &m);
	for (int i = 0, u, v; i < m; ++ i){
		scanf("%d%d", &u, &v);
		-- u, -- v;
		mat[u][v] = 1;
	}
	dp[0] = 1; 
	for (int i = 0; i < 1 << n; ++ i){
		if ((i >> 0 & 1) != (i >> 1 & 1)){
			continue;
		}
		int cnt = 0, x = i, y;
		for ( ; x; x -= lowbit(x)){
			digit[cnt ++] = lowbit(x);
		}
		for (int j = 0; j < 1 << cnt; ++ j){
			x = 0;
			for (int k = 0; k < cnt; ++ k){
				if (j >> k & 1){
					x ^= digit[k];
				}
			}
			y = i ^ x;
			if ((x >> 0 & 1) != (x >> 1 & 1) || !x){
				continue;
			}
			int ans = 1, cccnt = 0;
			for (int k = 0; k < n; ++ k){
				if (y >> k & 1){
					int ccnt = 0;
					for (int kk = 0; kk < n; ++ kk){
						if (x >> kk & 1){
							if (mat[k][kk]){
								++ ccnt;
							}
							if (mat[kk][k]){
								++ cccnt;
							}
						}
					}
					ans = 1ll * ans * (power[ccnt] - 1 + moder) % moder;
				}
			}
			dp[i] = (dp[i] + 1ll * ans * power[cccnt] % moder * dp[y]) % moder;
		}
	}
	return printf("%d\n", (power[m] - dp[(1 << n) - 1] + moder) % moder), 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));

	
	for (int i = 1; i <= (int)s.length(); i++) {
		for (int j = 1; j <= (int)t.length(); j++) {

			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);

			if (s[i - 1] == t[j - 1] && dp[i][j] < dp[i - 1][j - 1] + 1) dp[i][j] = dp[i - 1][j - 1] + 1;
		}
	}
	
	string ans = "";
	int x = (int)s.length(), y = (int)t.length();
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans = s[x - 1] + ans;
			x--, y--;
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 35584
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

vvint vv;
vvint used[3];
int w,h;

void sta(int,int,int);

int dd[] = {0,1,0,-1,0};
bool inside(int a, int b){
	return 0<=a&&a<h&&0<=b&&b<w;
}

void dfs(int a, int b, int c){
	if(used[c][a][b]) return;
	used[c][a][b] = 1;
	sta(a, b, c);
}

void sta(int a, int b, int c){
	rep(i,4){
		int na = a+dd[i];
		int nb = b+dd[i+1];
		if(inside(na, nb) && vv[na][nb] == 0){
			dfs(na, nb, c);
		}
	}
}

void mainmain(){
	while(cin>>w>>h,w||h){
		initvv(vv, h, w);
		initvv(used[1], h, w, 0);
		initvv(used[2], h, w, 0);
		rep(i,h){
			rep(j,w){
				char t;
				cin>>t;
				if(t=='.') vv[i][j] = 0;
				if(t=='B') vv[i][j] = 1;
				if(t=='W') vv[i][j] = 2;
			}
		}
		rep(i,h){
			rep(j,w){
				if(vv[i][j]){
					sta(i,j,vv[i][j]);
				}
			}
		}
		int a = 0;
		int b = 0;
		rep(i,h){
			rep(j,w){
				if(used[1][i][j] && !used[2][i][j]) a++;
				if(!used[1][i][j] && used[2][i][j]) b++;
			}
		}
		cout<<a<<" "<<b<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3236
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 0
A.sort()

fac = [1]
inv = [1]

for i in range(1, N + 1) :
	fac.append(fac[-1] * i % MOD)
	inv.append(pow(fac[-1], MOD - 2, MOD))

# m_C_n % MOD = fac[m + n] * inv[m] * inv[n] % MOD	


for i in range(N):
	m = N - (i + 1)
	n = K - 1
	# print(m, n, A[-(1 + i)])
	if m < n: break
	ans += (fac[m] * inv[n] * inv[m - n] % MOD) * (A[-(1 + i)] % MOD) % MOD
	ans %= MOD
	# print(ans)
	
for i in range(N):
	m = N - (i + 1)
	n = K - 1
	if m < n: break
	ans -= (fac[m] * inv[n] * inv[m - n] % MOD) * (A[i] % MOD) % MOD
	ans %= MOD
	# print(ans)
	
while ans < 0:
	ans += MOD
print(ans)

Measured memory_bytes: 71720
N = gets.to_i
MOD = 10 ** 9 + 7

dp = Hash.new(0)

['A', 'G', 'C', 'T'].repeated_permutation(3) do |w|
	word = w.join('')
	if !(word == 'AGC' || word == 'GAC' || word == 'ACG')
    	dp[[3, word]] = 1
    end
end
4.upto(N) do |i|
	['A', 'G', 'C', 'T'].repeated_permutation(4) do |w|
		word = w.join('')
    	words = [word]
   		0.upto(2) do |l|
    		n = w.clone
   			n[l], n[l + 1] = n[l + 1], n[l]
    		words.push(n.join(''))
    	end
    	if !(words.any?{|n| n.include?('AGC')})
    		dp[[i, word[1..3]]] += dp[[i - 1, word[0..2]]]
            dp[[i, word[1..3]]] %= MOD
    	end
    end
end
  
p dp.to_a.select{|k| k[0][0] == N}.collect{|v| v[1]}.inject(:+) % MOD

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
    int MAX=101010;
    vector<int> is_prime(MAX,1);
    is_prime[0]=0,is_prime[1]=0;
    for(int i=2;i<MAX;i++){
        if(!is_prime[i]) continue;
        for(int j=i*2;j<MAX;j+=i) is_prime[j]=0;
    }

    vector<int> a(MAX,0);
    for(int i=0;i<MAX;i++){
        if(i%2==0) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i]=1;
    }

    vector<int> s(MAX+1,0);
    for(int i=0;i<MAX;i++) s[i+1]=s[i]+a[i];

    int Q;
    cin>>Q;
    for(int q=0;q<Q;q++){
        int l,r;
        cin>>l>>r;
        r++;
        cout<<s[r]-s[l]<<endl;
    }
}

Measured memory_bytes: 1792
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    if (b == 1) {
      System.out.println("0");
      return;
    }
    b -= a;
    int count = 1;
    while (b > 0) {
      b -= (a-1);
      count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>
#include <set>

using namespace std;

bool shouldProceed(vector<int> xs, int n) {

    bool should = false;

    for (int i = 0; i < n; i++) {
        if (xs[i] != 0) {
            should = true;
        }
    }
    return should;
}

int main() {

    int N;
    cin >> N;

    vector<int> hs;

    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;

        hs.push_back(h);
    }

    hs.push_back(0);

    int result = 0;

    while (shouldProceed(hs, N)) {

        for (int start = 0; start < N + 1; start++) {
            for (int j = start; j < N + 1; j++) {
                if (hs[j] == 0) {

                    int end = j;

                    int m = *std::min_element(hs.begin() + start, hs.begin() + end);

                    for (int k = start; k < end; k++) {
                        hs[k] -= m;
                    }

                    start = end + 1;
                    result += m;
                }
            }
        }
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int A;
int B;
string S;
string T;
string U;
 cin >> S >> T;
 cin >> A >> B;
 cin >> U;
 if(U==S)cout << A-1 << " " << B << endl;
 else{cout << A << " " << B-1 << endl;}
}

Measured memory_bytes: 256
#include <queue>

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#define FOR(i, l, r) for(int i = (l); i <= (r); i++)
#define REP(i, l, r) for(int i = (l); i != (r); i++)
#define DFR(i, l, r) for(int i = (l); i >= (r); i--)
#define DRP(i, l, r) for(int i = (l); i != (r); i--)

using namespace std;

#define DEBUG(arg...) fprintf(stderr, arg)

namespace FI {
	const int SIZE = 1 << 18 | 1;
	char buf[SIZE], *front, *back;

	void NextChar(char &c) {
		if(front == back) back = (front = buf) + fread(buf, 1, SIZE, stdin);
		c = (front == back) ? (char)EOF : *front++;
	}

	template<typename T> void NextNum(T & x) {
		char c; int f = 1;
		for(NextChar(c); c > '9' || c < '0'; NextChar(c)) if(c == '-') f = -1;
		for(x = 0; c >= '0' && c <= '9'; NextChar(c)) x = (x << 3) + (x << 1) + c - '0';
		x *= f;
	}
}

typedef long long LL;

const int maxn = 100 + 47;

int n, x, a[maxn], ans;

int main() {
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for(int i = 1; i < n; i++) {
		if(x >= a[i]) ans++, x -= a[i];
	}
	if(x && x == a[n]) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 256
# Prime Numbers

n = int(input())

def isPrime(a):
    # print('a = ' + str(a))
    if a == 2:
        return True
    elif a < 2 or a % 2 == 0:
        return False
    else:
        i = 3
        j = a ** 0.5
        while i <= j:
            if a % i == 0:
                return False
            i += 2
        return True

primeCount = 0
for i in range(n):
    a = int(input())
    if isPrime(a) == True:
        # print(str(a) + ' は素数')
        primeCount += 1

print(primeCount)



Measured memory_bytes: 5676
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return (N * RepeatSquaring(N, P-1, M))%M;
}

int main(){
  ll mod=1000003;
  ll q;
  cin>>q;
  ll x[q],d[q],n[q],s[q],t[q];
  rep(i,q){
    cin>>x[i]>>d[i]>>n[i];
  }
  ll fac[mod],inv[mod];
  fac[0]=1,fac[1]=1;
  rep1(i,mod-1){
    fac[i+1]=fac[i]*(i+1)%mod;
  }
  inv[1]=1;
  for (int i=2;i<mod;i++){
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  }
  rep(i,q){
    if(d[i]==0){
      cout<<RepeatSquaring(x[i],n[i],mod)<<"\n";
    }else{
      s[i]=(inv[d[i]]*x[i])%mod;
      if(s[i]==0 || s[i]+n[i]-1>=mod){
        cout<<0<<"\n";
      }else{
        t[i]=(inv[fac[s[i]-1]]*fac[s[i]+n[i]-1])%mod;
        cout<<(t[i]*RepeatSquaring(d[i],n[i],mod))%mod<<"\n";
      }
    }
  }
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
	int n, s;
	cin >> n >> s;
	vector <int> v(n);
	for(int i=0;i<n;i++)
		cin >> v[i];
	if(s >= n)
		cout << '0';
	else {
		int sum = 0;
		sort(v.begin(), v.end(), greater<int>());
		for(int i=s;i<n;i++)
			sum += v[i];
		cout << sum;
	}
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n;
    cin>>n;
    vector<string> vs(n);
    rep(i,n)cin>>vs[i];
    string t;
    cin>>t;
    
    int A=0, B=0, C=0;
    
    const auto f = [](string a,string b){
        int l = min(a.size(),b.size());
        
        rep(i,l){
            if(a[i]!='?'){
                if(a[i]<b[i])return 1;
                if(a[i]>b[i])return -1;
            }else{
                if(b[i]!='a' && b[i]!='z')return 0;
            }
        }
        if(b.size()>a.size())return 1;
        if(b.size()<a.size())return -1;
        
        return 0;
    };
    
    assert(f("a","b")==1);
    
    rep(i,vs.size()){
        int res = f(vs[i],t);
        if(res==0)C++;
        else if(res==1)A++;
        else if(res==-1)B++;
    }
    
//    cout<<A<<" "<<B<<" "<<C<<endl;
    
    for(int i=A+1;i<=A+C+1;i++){
        if(i!=A+1)cout<<" ";
        cout<<i;
    }
    cout<<endl;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {
    int i, j;
    int n, k;
    int p[200000];
    double sum = 0;
    double max;

    scanf("%d%d", &n, &k);

    for (i = 0; i < n; i++)
        scanf("%d", &p[i]);

    for (i = 0; i < k; i++)
        sum += p[i] / 2.0 + 0.5;

    max = sum;

    for (i = 0; i < n - k; i++) {
        sum -= p[i] / 2.0 + 0.5;
        sum += p[i + k] / 2.0 + 0.5;

        if (sum > max)
            max = sum;
    }

    printf("%f\n", max);

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;

  if (abs(a - b) % 2 == 0) {
    cout << min(a, b) + (abs(a - b) / 2) << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}



int atcoder(){
    int n,ans=INT_MAX,wsum=0,bsum=0;
    cin>>n;
    vector<int> w(n+1,0),b(n+1,0);
    string s;
    cin>>s;

    REP(i,0,n){
        if(s[i]=='#'){
            bsum++;
            b[i+1]=b[i]+1;
            w[i+1]=w[i];
        }
        if(s[i]=='.'){
            wsum++;
            w[i+1]=w[i]+1;
            b[i+1]=b[i];
        }
    }
    
    REP(i,0,n+1){
        int tmp = b[i]+(wsum-w[i]);
        chmin(ans,tmp);
 //       cout<<tmp<<" ";
    }
    cout<<ans<<ENT;
    return 0;
}

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


Measured memory_bytes: 2384
// Problem : C - Vacation
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

int n ; 
ll mat[100001][3] ; 



int main() { 
	cin >> n ; 
	for(int i =0 ; i < n ; ++i)
		for(int j = 0 ; j < 3 ;++j)
			cin >> mat[i][j] ; 
	ll ans = max({mat[0][0], mat[0][1], mat[0][2]}) ; 
	for(int i= 1; i <= n ; ++i) {
		mat[i][0] += max(mat[i-1][1] , mat[i-1][2]) ;
		mat[i][1] += max(mat[i-1][0] , mat[i-1][2]) ;
		mat[i][2] += max(mat[i-1][0] , mat[i-1][1]) ;
		ans = max({mat[i][0], mat[i][1], mat[i][2]})  ; 
	}
	
	cout << ans ; 
	
}

Measured memory_bytes: 2560
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let string: String = read();
    let mut n = 0;
    let mut w = 0;
    let mut s = 0;
    let mut e = 0;

    for c in string.chars() {
        match c {
            'N' => n += 1,
            'W' => w += 1,
            'S' => s += 1,
            'E' => e += 1,
            _ => unreachable!(),
        }
    }
    let ans = if (n > 0 && s == 0) || (s > 0 && n == 0) || (w > 0 && e == 0) || (e > 0 && w == 0) {
        "No"
    } else {
        "Yes"
    };

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int h,w,n; cin>>h>>w>>n;
    int a = INF;
    for (int i = 1; i <= h; ++i) {
        if (w*i >= n) {
            a = min(a,i);
        }
    }
    for (int i = 1; i <= w; ++i) {
        if (h*i>=n) {
            a = min(a,i);
        }
    }

    cout << a << '\n';
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }
    int res=0;
    if(p[n-1]==n-1){
        res++;
        swap(p[n-1],p[n-2]);
    }
    for(int i=0;i<n;i++){
        if(p[i]==i){
            swap(p[i],p[i+1]);
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<list>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;



int main() {
   int n;
   cin >> n;
   cout << (n - 1) / 2 << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

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


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <unordered_map>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (LL)((a).size())

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e9;
const LL MAX = 2e5 + 7;
const LL MAXN = 5e5 + 1;

void f()
{
	cout << endl;
	cout.flush();
}

map<int, string> known;

string query(int i)
{
	if (SZ(known[i]))
		return known[i];

	cout << i;
	f();
	string r;
	cin >> r;
	if (r == "Vacant")
		exit(0);

	return known[i] = r;
}

int n;

int dist(int i, int j)
{
	return min(abs(i - j), min(abs(i - j + n), abs(-i + j + n)));
}

bool is(int d, bool eq)
{
	return ((d & 1) == eq);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	cin >> n;
	
	string r;
	string ans = "Vacant";

	int x = (n - 1) / 2, y = (n + 1) / 2;
	
	bool left = is(dist(0, y), query(0) == query(y));
	if (left)
	{
		int L = y, R = n - 1, M;
		bool go_up;
		while (R - L > 1)
		{
			M = (L + R) / 2;
			if (is(abs(M - L), query(L) == query(M)))
				R = M;
			else
				L = M;
		}

		query(L);
		query(R);
	}

	int L = 0, R = x, M;
	bool go_up;
	while (R - L > 1)
	{
		M = (L + R) / 2;
		if (is(abs(M - L), query(L) == query(M)))
			R = M;
		else
			L = M;
	}

	query(L);
	query(R);
		
	throw - 1;	
	return 0;
}

Measured memory_bytes: 852
N = gets.to_i
Inf = 10 ** 6

nums = []

for i in 1..Inf do
  nums[i-1] = 0
end

for i in 1..Inf do
  j = 1
  while i * j <= Inf do
    nums[i*j-1] += 1
    j += 1
  end
end

ans = 0
for i in 1..(N-1) do
  ans += nums[N-i-1]
end

puts ans

Measured memory_bytes: 22376
#include <iostream>

int main() {
    int n{}, taro{}, hanako{};
    std::cin >> n;
    for(auto i=0; i<n; i++) {
        std::string ct{}, ch{};
        std::cin >> ct >> ch;
        taro   += (ct>ch) ? 3 : (ct==ch) ? 1 : 0;
        hanako += (ch>ct) ? 3 : (ct==ch) ? 1 : 0;
    }
    std::cout << taro << " " << hanako << std::endl;
}



Measured memory_bytes: 3148
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int main(){
    int x,a,b;
    while(~scanf("%d%d%d",&x,&a,&b)){
        if(b-a>0&&b-a<=x){
            printf("safe\n");
        }
        else{
            if(b-a<=0){
                printf("delicious\n");
            }
            else{
                printf("dangerous\n");
            }
        }
    }
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

  int N = S.size();
  vi XS('z'+1), XT('z'+1);
  for(auto c: S) {
    XS[c]++;
  }
  for(auto c: T) {
    XT[c]++;
  }

  RSORT(XS);
  RSORT(XT);

  printf("%s\n", XS==XT?"Yes":"No");
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    int A, B;
    cin >> A >> B;
    if(A%2 == 0 ||B%2 == 0 )
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
    int r,c,h,w,ans,d1,d2;
    while(cin>>r>>c>>h>>w)
    {
        d1=r-h;
        d2=c-w;
        ans=d1*d2;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V){os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P){return os << "(" << P.first << "," << P.second << ")";}
#ifndef ONLINE_JUDGE
#define TRACE
#endif

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){ cout << name << " : " << arg1 << endl; }
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...) 1
#endif
#define mp make_pair
#define pb push_back
#define endl '\n'
#define F first
#define S second
#define I insert
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
const int N = 1e2+5;
const int M = 1e5+2;
const ll INF = 1e15;
ll w[N],v[N],dp[N][M];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout<<setprecision(25);
    ll n,W; cin>>n>>W;
    for(int i=1;i<=n;i++){
    	cin>>w[i]>>v[i];	
    }
    for(int i=0;i<=n;i++) for(int j=0;j<M;j++) dp[i][j] = INF;
    dp[0][0] = 0;

    for(int i=1;i<=n;i++){
    	for(int j=0;j<M;j++){
    		dp[i][j] = dp[i-1][j];
    		if(j-v[i] >= 0) dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
    	}
    }
    for(int i=M-1;i>=0;i--){
        if(dp[n][i] <= W) {cout<<i; exit(0);}
    }
}

Measured memory_bytes: 80128
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	set<ll> s;
	rep(i,0,n)
	{
		ll x;cin>>x;
		s.insert(x);
	} 

	cout<<(sz(s)==n?"YES\n":"NO\n");
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n, A;
ll a[55];
ll dp[55][55][5005];
ll poo(ll ind, ll ct, ll sum) {
	// cout<<ind<<" "<<ct<<" "<<sum<<"\n";
	if(ind == n) {
		if(ct == 0) {return 0;}
		if(sum%ct == 0 && sum/ct == A) {
			return 1;
		}
		return 0;
	}
	if(dp[ind][ct][sum] != -1) {
		return dp[ind][ct][sum];
	}
	ll ret = poo(ind+1, ct, sum);
	ret += poo(ind+1, ct+1, sum+a[ind]);
	return dp[ind][ct][sum] = ret;
}
int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n>>A;
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
	cout<<poo(0, 0, 0)<<"\n";
	return 0;
}

Measured memory_bytes: 118528
s = gets.to_i
ans  = []
ans[0] = s
1000000.times do |i|
  if ans[i] % 2 != 0
    ans[i+1] = 3 * ans[i] + 1
  else
    ans[i+1] = ans[i] / 2
  end
    (i+1).times do |j|
      if ans[j] == ans[i+1]
        puts (i+2)
        exit
      end
   end
end


Measured memory_bytes: 1916
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n int
	fmt.Fscan(r, &n)
	if n/100 == 7 || (n%100)/10 == 7 || n%10 == 7 {
		fmt.Fprintln(w, "Yes")
	} else {
		fmt.Fprintln(w, "No")
	}
}


Measured memory_bytes: 1828
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define hi(x)((x)>>16)
#define lo(x)((x)&0xffff)

struct comp{bool operator()(const unsigned a,const unsigned b){return hi(a)*lo(a)<hi(b)*lo(b);}};
int main(){
	int n,w,d;
	for(;scanf("%d%d%d",&n,&w,&d),w;puts("")){
		vector<unsigned>v;
		v.push_back((w<<16)+d);
		for(;n--;){
			int p,s,state=0;
			scanf("%d%d",&p,&s);p--;
			s%=hi(v[p])+lo(v[p]);
			unsigned x=hi(v[p]),y=lo(v[p]),_x=0,_y=0,x1,x2,y1,y2;
			for(;s--;)if(state==0){_x++;if(_x==x)state=1;}else _y++;
			if(state==0)x1=_x,x2=x-_x,y1=y2=y;
			else x1=x2=x,y1=_y,y2=y-_y;

			v.erase(v.begin()+p);
			if(x1*y1>x2*y2)
				v.push_back((x2<<16)+y2),v.push_back((x1<<16)+y1);
			else
				v.push_back((x1<<16)+y1),v.push_back((x2<<16)+y2);
		}

		for(sort(v.begin(),v.end(),comp());v.size();){
			printf("%d",hi(v[0])*lo(v[0]));
			v.erase(v.begin());
			if(v.size())printf(" ");
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int H, W; cin >> H >> W;
  map<char, int> cnt;
  rep(i,H*W){
    char a; cin >> a;
    cnt[a]++;
  }
  int mod[4] = {};
  for (auto p : cnt){
    mod[p.second%4]++;
  }
  if (H&1 && W&1){
    if (mod[2]<=H/2+W/2 && mod[1]+mod[3]==1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (H&1){
    if (mod[2]<=W/2 && mod[1]+mod[3]==0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if (W&1) {
    if (mod[2]<=H/2 && mod[1]+mod[3]==0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    if (mod[1]+mod[2]+mod[3]==0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	B = LI()
	ans = 0
	for i in range(N-2):
		ans += min(B[i], B[i+1])
	print(ans+B[N-2]+B[0])

if __name__ == '__main__':
	main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;



int main(){
  int n,k;cin>>n>>k;
  vi h(n);
  rep(i,n) cin>>h.at(i);
  sort(all(h));
  ll ans=0;
  rep(i,n-k){
    ans+=h.at(i);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 1024
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import Data.Bifunctor (first)
import Data.Bits

type Mat = V.Vector (U.Vector Int64)
type BitSet = Int

{-
scoreOne :: Int -> Mat -> BitSet -> Int64
scoreOne !n !mat !set = go 0 [i | i <- [0..n-1], testBit set i]
  where
    go !acc [] = acc
    go !acc (x:xs) = let !r = mat V.! x
                     in go (acc + sum [r U.! y | y <- xs]) xs
-}

main = do
  n <- readLn
  mat <- V.replicateM n $ do
    U.unfoldrN n (readInt64 . BS.dropWhile isSpace) <$> BS.getLine
  let -- scoreOneV == U.generate (2^n) (scoreOne n mat)
      scoreOneV :: U.Vector Int64
      scoreOneV = U.create $ do
        vec <- UM.replicate (2^n) minBound
        UM.write vec 0 0
        let go !set = do
              v <- UM.read vec set
              if v == minBound
                then do let !i = countTrailingZeros set
                        let !set' = clearBit set i
                        v0 <- go set'
                        let !v = v0 + sum [(mat V.! i) U.! j | j <- [i+1..n-1], testBit set' j]
                        UM.write vec set v
                        return v
                else return v
        mapM_ go [1..2^n-1]
        return vec
  let result :: Int64
      result = runST $ do
        vec <- UM.replicate (2^n) minBound
        UM.write vec 0 0
        forM_ [0..n-1] $ \i -> do
          UM.write vec (bit i) 0
        let go !set = do
              v <- UM.read vec set
              if v == minBound
                then do let v0 = scoreOneV U.! set
                        let x0:xs = [i | i <- [0..n-1], testBit set i]
                        v <- foldM (\x a -> max x <$> a) v0 [ (+) (scoreOneV U.! set') <$> (go (set `xor` set'))
                                                            | set' <- map (foldl' (.|.) (bit x0)) $ sequence $ map (\i -> [0,bit i]) xs
                                                            , set' /= set
                                                            ]
                        UM.write vec set v
                        return v
                else return v
        go (2^n-1)
  print result

readInt64 :: BS.ByteString -> Maybe (Int64, BS.ByteString)
readInt64 s = first fromIntegral <$> BS.readInt s


Measured memory_bytes: 10620
using System;
public class AprobB {
    public static void Main() {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());
        int Y = int.Parse(Console.ReadLine());
        if (N <= K) {
            Console.WriteLine(N*X);
        } else {
            Console.WriteLine(K*X+(N-K)*Y);
        }
    }
}

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

using namespace std;
int n;
int a[100000];
int cnt[100001];
int main()
{
    scanf("%d" , &n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d" , &a[i]);
        cnt[a[i]]++;
    }
    int res = 0;
    for(int i = 1; i < 100000; i++)
    {
        res = max(res , cnt[i] + cnt[i - 1] + cnt[i + 1]);
    }
    printf("%d\n" , res);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define maxn 100005
#define ll long long
using namespace std;
map<int,int>mp;
set<int>s;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int c;
        scanf("%d",&c);
        if(mp.find(c)!=mp.end())mp[c]+=1;
        else mp[c]=1;
        s.insert(c);
    }
    set<int>::reverse_iterator it;
    ll sum=1;
    int flag=1;
    int cc=0;
    for(it=s.rbegin();it!=s.rend();it++)
    {
        ll x=*it;
       // cout<<x<<" "<<mp[x]<<endl;
        if(mp[x]>=2)
        {
            if(mp[x]>=4&&cc==0)
            {
                sum=x*x;
                cc=2;
            }
            else
            {
                sum*=x;
                cc++;
            }
        }
        if(cc==2)
        {
            flag=0;
            break;
        }
    }
    if(flag) puts("0");
    else printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 9600
n = int(input())
s = input()
ans = s.count("R") * s.count("G") * s.count("B")
for i in range(n):
    for j in range(n):
        if i+2*j < n:
            if (s[i],s[i+j],s[i+2*j]) == ("R","G","B") or (s[i],s[i+j],s[i+2*j]) == ("R","B","G")or (s[i],s[i+j],s[i+2*j]) == ("G","B","R") or (s[i],s[i+j],s[i+2*j]) == ("G","R","B") or (s[i],s[i+j],s[i+2*j]) == ("B","G","R") or (s[i],s[i+j],s[i+2*j]) == ("B","R","G"):
                ans -= 1
print(ans)

Measured memory_bytes: 80188
#include <bits/stdc++.h>
using namespace std;
int n, m, mod;
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }
int f[302][302][302];
int main() {
    scanf("%d%d%d", &n, &m, &mod);
    f[0][1][0] = 1;
    for (int i = 0; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            for (int k = i; k >= 0; --k)
                k ? Add(f[i][j][k - 1], f[i][j][k])
                  : Add(f[i][j + 1][i], f[i][j][k]),
                    Add(f[i + 1][j][k], 1ll * f[i][j][k] * (k + 1) % mod);
    printf("%d", f[n][m][0]);
    return 0;
}

Measured memory_bytes: 107776
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;

int main()
{
    string s;
    cin>>s;
    rep(i,4)cout<<s[i];
    cout<<" ";
    for(int i=4;i<12;i++) cout<<s[i];
    cout<<endl;

    return 0;
}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b>>c;
	if ((100 * a + 10 * b + c) % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<string, int> P;
typedef vector<vector<int>> Graph;

const double PI = 3.14159265358979323846;

const int mod = 1000000007;

int main(int argc, char *args[]) {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

double dat[3005][1505][2];
double p[3005];
int in;

double prob(int pos,int cnt,int phase){
	if(2*cnt>in)return dat[pos][cnt][phase]=0.0;
	if(pos==in)return dat[pos][cnt][phase]=1.0;
	if(dat[pos][cnt][phase]>-EPS)return dat[pos][cnt][phase];
	double temp=p[pos+1]*prob(pos+1,cnt,0)+(1.0-p[pos+1])*prob(pos+1,cnt+1,1);
	return dat[pos][cnt][phase]=temp;
}

int main(){
	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	cin>>in;
	double res;
	repp(j,0,1500,1){
		repp(k,0,1,1){
			dat[0][j][k]=-1e5;
		}
	}
	rep(i,in,1){
		cin>>p[i];
		repp(j,0,1500,1){
			repp(k,0,1,1){
				dat[i][j][k]=-1e5;
			}
		}
	}
	cout<<fixed<<setprecision(10)<<prob(0,0,0)<<endl;
	return 0;
}



Measured memory_bytes: 71040
from itertools import *

N = input()
x = [0.0]*N
y = [0.0]*N
for i in range(N):
  x[i], y[i] = map(float, raw_input().split())

s = 0.0
c = 0
for p in permutations(range(N)):
  for i in range(N-1):
    s += ((x[p[i+1]]-x[p[i]])**2+(y[p[i+1]]-y[p[i]])**2)**0.5
  c += 1
print "%.10f"%(s/c)


Measured memory_bytes: 2820
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 1000000007ll;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k;
ll x[500005], y[500005], z[500005];
string s;

void solve(){
    cin >> n;
    for(ll i=0;i<n-1;i++){
        cin >> a;
        x[a] ++;
    }
    for(ll i=1;i<=n;i++){
        p(x[i]);
    }

    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;
 
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;
 
}
















Measured memory_bytes: 5220