akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int a, b, t; cin >> a >> b >> t;
	cout << t / a * b << endl;
}

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

using namespace std;

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

    long n = s.size();
    vector<vector<int>> a(120, vector<int>(n));

    for(int i=0; i<n; i++)
        a[0][i] = s[i] == 'L' ? i-1 : i+1;

    for(int i=1; i<=100; i++) {
        for(int j=0; j<n; j++) {
            int cur = j;
            for(int k=0; k<10; k++) {
                cur = a[i-1][cur];
            }
            a[i][j] = cur;
        }
    }

    vector<int> res(n, 0);
    for(int i=0; i<n; i++)
        res[a[100][i]]++;
    for(int i=0; i<n; i++)
        cout << res[i] << ' ';
    cout << endl;
}


Measured memory_bytes: 48120
#include<bits/stdc++.h>
#define maxn 505050

using namespace std;
int a[4];
int main(){
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    sort(a,a+4);
    if (a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9) puts("YES"); else puts("NO");
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}


void solve() {
  int n;  cin>>n;
  vector<int> a(n);
  bool ok = true;
  rep(i,n) {
    cin>>a[i];
    if(a[i]%2 == 0) {
      if(a[i]%3 and a[i]%5) {
        ok = false;
      }
    }
  }
  if(ok)  cout<<"APPROVED";
  else  cout<<"DENIED";
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	int x1;int y1; int x2; int y2;
	get x1; get y1; get x2; get y2;

	int p = x2 - x1;
	int q = y2 - y1;

	int x3 = x2 - q;
	int y3 = y2 + p;

	int x4 = x1 - q;
	int y4 = y1 + p;

	put x3 << " " << y3 << " " << x4 << " " << y4;
}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std; 
int main(){
   string s ,t;
   cin >> s >> t;
   for (int i = 0; i < s.length(); i++)
   {
       if(s[i] != t[i]){
       cout << "No" << endl;
       return 0;}
   }
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 3624
S = input()
K = int(input())

X = []
b = S[0]
cnt = 1
for i in range(1, len(S)):
    s = S[i]
    if b == s:
        cnt += 1
    else:
        X.append([b, cnt])
        cnt = 1
        b = s
X.append([b, cnt])

result = 0
if len(X) == 1:
    print(X[0][1] * K // 2)
elif X[0][0] == X[-1][0]:
    s = X.pop(0)
    e = X.pop()
    for x in X:
        result += x[1] // 2
    result *= K

    result += s[1] // 2
    result += e[1] // 2
    x = (s[1] + e[1]) // 2
    result += x * (K - 1)
    print(result)
else:
    for x in X:
        result += x[1] // 2
    result *= K
    print(result)



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

int main(int argc, char *argv[]) {
	uint32_t A = 0;
	uint32_t B = 0;
	uint32_t C = 0;

	std::cin >> A;
	std::cin >> B;
	std::cin >> C;

	//  
	//  問題文より、i * A = k * B + C が成り立つ
	//
	//  但し、0 <= k < B
	//        i != 0 かつ、i は整数
	//  よって、i = (k * B + C) / A
	//
	//  よって、 (k * B + C) % A = 0 が成り立つ値が
	//  存在するかを判定すれば良い 
	//
	bool can_choose(false);
	for (int k = 0; k < B; k++) {
		if (((k * B) + C) % A == 0) {
			can_choose = true;
			break;
		}
	}

	std::cout << ((can_choose) ? "YES" : "NO") << std::endl;
	return 0;
}


Measured memory_bytes: 256
// Tazoe

#include <iostream>
using namespace std;

void DFS(int M[52][52], int y, int x)
{
	M[y][x] = 0;

	if(M[y-1][x-1]==1)
		DFS(M, y-1, x-1);
	if(M[y-1][x]==1)
		DFS(M, y-1, x);
	if(M[y-1][x+1]==1)
		DFS(M, y-1, x+1);
	if(M[y][x-1]==1)
		DFS(M, y, x-1);
	if(M[y][x+1]==1)
		DFS(M, y, x+1);
	if(M[y+1][x-1]==1)
		DFS(M, y+1, x-1);
	if(M[y+1][x]==1)
		DFS(M, y+1, x);
	if(M[y+1][x+1]==1)
		DFS(M, y+1, x+1);
}

int main()
{
	while(true){
		int w, h;
		cin >> w >> h;

		if(w==0&&h==0)
			break;

		int M[52][52];
		for(int y=0; y<=h+1; y++)
			for(int x=0; x<=w+1; x++)
				M[y][x] = 0;

		for(int y=1; y<=h; y++)
			for(int x=1; x<=w; x++)
				cin >> M[y][x];

		int cnt = 0;

		for(int y=1; y<=h; y++)
			for(int x=1; x<=w; x++)
				if(M[y][x]==1){
					DFS(M, y, x);

					cnt++;
				}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		while(true){
		String str=input.readLine();
		String[] arr=str.split(" ");
		int h=Integer.parseInt(arr[0]);	
		int w=Integer.parseInt(arr[1]);
		if(h==0&&w==0){
			break;
		}
	
		for(int i=0;i<h;i++){

			for(int j=0;j<w;j++){
				if(i==0||i==h-1||j==0||j==w-1){
				sb.append("#");
				}else{
					sb.append(".");
				}
			}
				sb.append("\n");
		}
			sb.append("\n");

			}
		
		
		
		System.out.print(sb);
	}
}

Measured memory_bytes: 25140
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=1e2+10;
int a[maxn],b[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	n=read();
	for(i=1;i<=n;i++)a[i]=read(),a[i]+=a[i-1];
	for(i=1;i<=n;i++)b[i]=read();
	for(i=n;i>=1;i--)b[i]+=b[i+1];
	int ans=0;
	for(i=1;i<=n;i++)ans=max(ans,a[i]+b[i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 10000;
  for (int i = 0; i < s.size() - 2; i++) {
    string tmp = s.substr(i, 3);
    int x = stoi(tmp);
    int y = abs(753 - x);
    if (y < ans) ans = y;
  }
  cout << ans << endl;

}


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

const ll INF=1e18;
int n,m;
vector<P>edge[100010];

vector<ll> dijkstra(int x){
  vector<ll>dist(n+1,INF);
  priority_queue<P,vector<P>,greater<P>>q;
  dist[x]=0;
  q.push(P(0,x));
  while(!q.empty()){
    ll d=q.top().first;
    ll p=q.top().second;
    q.pop();
    if(dist[p]<d)continue;
    for(P next:edge[p]){
      ll to=next.first;
      ll co=next.second;
      if(dist[p]+co>=dist[to])continue;
      dist[to]=dist[p]+co;
      q.push(P(dist[to],to));
    }
  }
  return dist;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    int l,r,c; cin>>l>>r>>c;
    edge[l].push_back(P(r,c));
  }
  rep(i,n-1){
    edge[i+1].push_back(P(i,0));
  }
  vector<ll>dist=dijkstra(1);
  if(dist[n]!=INF)cout<<dist[n]<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 12204
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> vals2,dp2,dp3;
int n,m,dp[100001],updp[100001];
vector<vector<int>> graph;

int add(int a , int b){
	a += b;
	if(a >= m){
		a -= m;
	}
	return a;
}

int mult(int a , int b){
	a = (long long) a * b % m;
	return a;
}

int getans(int curr , int tag){
	if(curr == dp2[tag].size()){
		return 1;
	}
	if(dp2[tag][curr] != -1){
		return dp2[tag][curr];
	}
	int ret = add(getans(curr+1,tag),mult(vals2[tag][curr],getans(curr+1,tag)));
	return dp2[tag][curr] = ret;
}

int getans2(int curr , int tag){
	if(curr == -1){
		return 1;
	}
	if(dp3[tag][curr] != -1){
		return dp3[tag][curr];
	}
	int ret = add(getans2(curr-1,tag),mult(vals2[tag][curr],getans2(curr-1,tag)));
	return dp3[tag][curr] = ret;
}

void dfs(int curr , int par){
	vector<int> vals;
	for(int i : graph[curr]){
		if(i != par){
			dfs(i,curr);
			vals.push_back(dp[i]);
		}
	}
	vals2[curr] = vals;
	dp2[curr].assign(vals.size(),-1);
	dp3[curr].assign(vals.size(),-1);
	dp[curr] = getans(0,curr);
}

void dfs2(int curr , int par){
	int cnt = 0;
	for(int i : graph[curr]){
		if(i == par){
			continue;
		}
		updp[i] = mult(updp[curr],mult(getans(cnt+1,curr),getans2(cnt-1,curr)))+1;
		cnt += 1;
		dfs2(i,curr);
	}
}

int main(){
    cin >> n >> m;
    graph.resize(n+1),vals2.resize(n+1),dp2.resize(n+1),dp3.resize(n+1);
    for(int i = 0 ; i < n-1 ; i += 1){
    	int a,b;
    	cin >> a >> b;
    	graph[a].push_back(b);
    	graph[b].push_back(a);
    }
    updp[1] = 1;
    dfs(1,1);
    dfs2(1,1);
    for(int i = 1 ; i <= n ; i += 1){
    	//cout << dp[i] << " " << updp[i] << endl;
    	cout << mult(updp[i],dp[i]) << endl;
    }
}

Measured memory_bytes: 31616
object Main {
  def main(args: Array[String]) {
    val odd = Set[Char]('R', 'U', 'D')
    val even = Set[Char]('L', 'U', 'D')
    for((c, i) <- scala.io.StdIn.readLine() zip (Stream from 1)) {
      if (!(i % 2 == 1 && (odd contains c) || i % 2 == 0 && (even contains c))) {
        println("No")
        return
      }
    }
    println("Yes")
  }
}


Measured memory_bytes: 25500
#include<iostream>
using namespace std;
int main()
{
  int n,t,i,r=0;
  cin >> n;
  t=n;
  while(t>0){
    r+=t%10;
    t/=10;
  }
  if(n%r==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

bool isPrime(int x){
    if(x == 2){
        return true;
    }else if(x == 3){
        return true;
    }else{
        for(int j = 2; j * j <= x; j++){
            if(x % j == 0) return false;
        }
        return true;
    }
}

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

    int count = 0;
    for(int i = 0; i < n; i++){
        int num;
        scanf("%d", &num);
        if(isPrime(num)){
            count++;
        }
    }

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



Measured memory_bytes: 2708
/*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
*/
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int gcd(int a,int b){
    if(a<b)swap(a,b);
    int k=a%b;
    while(k!=0){
        a=b;
        b=k;
        k=a%b;
    }
}

int lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

int main(){
    char c; int x;
    int v[13]={};
    while(cin>>x){
        bool st=false;
    v[x-1]++;
    rep(i,1,5){
        cin>>c;
        cin>>x;
        v[x-1]++;
    }
    
    rep(i,0,10){
        bool str=true;
        rep(j,0,5){
            int ni=i+j;
            ni%=13;
            if(v[i]!=v[ni] || v[i]!=1)str=false;
        }
        if(str){
            cout<<"straight"<<endl;
            st=true;
        }
    }
    
    int two=0,three=0,four=0;
    rep(i,0,13){
        if(v[i]==2)two++;
        if(v[i]==3)three++;
        if(v[i]==4)four++;
    }
    
    if(four)cout<<"four card"<<endl;
    else if(two && three)cout<<"full house"<<endl;
    else if(three)cout<<"three card"<<endl;
    else if(two==2)cout<<"two pair"<<endl;
    else if(two)cout<<"one pair"<<endl;
    else if(!st)cout<<"null"<<endl;
    
    fill(v,v+13,0);
    }
    return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n+1),s1(n+1,0),s2(n+1,0);
    FOR(i,1,n+1) cin>>a[i];
    FOR(i,2,n+1){
      s1[i]=max(s1[i-1],a[i-1]);
    }
    for(ll i=n-1;i>=1;i--){
      s2[i]=max(s2[i+1],a[i+1]);
    }
    /*
    FOR(i,1,n+1){
      cout<<s1[i]<<' ';
    }
    cout<<endl;
    FOR(i,1,n+1){
      cout<<s2[i]<<' ';
    }
    cout<<endl;
    */
    FOR(i,1,n+1){
      cout<<max(s1[i],s2[i])<<endl;
    }
}

Measured memory_bytes: 7936
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0004&lang=jp*/

#include <iostream>

using namespace std;

int main(){
    double a, b, c, d, e, f;
    while(cin>>a>>b>>c>>d>>e>>f) {
        printf("%.3f %.3f\n",((int)((c * e - b * f) / (a * e - b * d)*10e3+0.5))/10e3,((int)((a * f - c * d) / (a * e - b * d)*10e3+0.5))/10e3);
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<bool> ok(n, true);
    ll ans = 0;
    REP(i, n) cin >> h[i];

    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(h[a] >= h[b]) ok[b] = false;
        if(h[a] <= h[b]) ok[a] = false;
    }
    REP(i, n) if(ok[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3956
n,m = gets.chomp.split(" ").map(&:to_i)
ab_arr = m.times.map{gets.chomp.split(" ").map(&:to_i)}

class UnionFind
  attr_accessor :rank, :parent, :union_size
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    @union_size = Array.new(size, 1)
  end
 
  def unite(x, y)
    x_parent = get_parent(x)
    y_parent = get_parent(y)
    return if x_parent == y_parent
 
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
      @union_size[x_parent] += @union_size[y_parent]
    else
      @parent[x_parent] = y_parent
      @union_size[y_parent] += @union_size[x_parent]
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end
 
  def get_parent(x)
    @parent[x] == x ? x : (@parent[x] = get_parent(@parent[x]))
  end
end

uf = UnionFind.new(n)
ab_arr.each do |(a, b)|
  uf.unite(a-1, b-1)
end
puts uf.union_size.max




Measured memory_bytes: 33132
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


struct UnionFind{
  vector<int> parent;// parent[i]: iの親の番号
  UnionFind(int n): parent(n){
    for(int i=0; i<n; i++) parent[i] = i;
  }

  int root(int x){
    if(parent[x] == x) return x;
    return parent[x] = root(parent[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    parent[rx] = ry;
  }

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

};
 

using P = pair<int ,int>;
int main(){
	int V, E;
  cin >> V >> E;

  vector<pair<int, P>> vec;
  for(int i=0; i<E; i++){
    int s, t, w;
    cin >> s >> t >> w;
    vec.emplace_back(w, P(s, t));
  }
  sort(vec.begin(), vec.end());

  UnionFind uf(V);
  ll ans = 0;
  for(int i=0; i<E; i++){
    int w = vec[i].first;
    int s = vec[i].second.first;
    int t = vec[i].second.second;
    if(uf.same(s, t)) continue;
    uf.unite(s, t);
    ans += w;
  }
  
  cout << ans << endl;
	return 0;
}




Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << ce(b - 1, a - 1) << endl;
	
	return 0;
}


Measured memory_bytes: 256
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
bool isPalindrome(string str)
{
    int l = 0;
    int h = (str.size()) - 1;

    while (h > l)
    {
        if (str[l++] != str[h--])
        {
            return false;
        }
    }
    return true;
}
void solve(int test) {
    int n;cin>>n;
    int a[n];
    int dp[n+1],ans[n+1];
    memset(dp,0, sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[a[i]]++;
    }
    int sum=0;
    for(int i=0;i<=n;i++){
        ans[i]=(dp[i]*(dp[i]-1))/2;
        sum+=ans[i];
    }
    for(int i=0;i<n;i++){
        int temp=sum-ans[a[i]];
        int temp2=((dp[a[i]]-2)*(dp[a[i]]-1))/2;
        cout<<temp+temp2<<endl;
    }

}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
        solve(i);
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}


Measured memory_bytes: 7296
n,m=map(int,input().split())
A={int(input()) for _ in range(m)}
mod=10**9+7

dp=[0]*(n+1)
dp[0]=1
if 1 not in A:
   dp[1]=1

for i in range(2,n+1):
   if i not in A:
      dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)

Measured memory_bytes: 460020
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on August 2, 2018, 11:10 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define Axiom 1
#define Flaw 0
#define Void 0
#define Bi_Force 2
#define Tri_Force 3
#define Quad_Force 4

/*
 * 
 */

int ow[] = {-1, 0, 1, 0};
int oh[] = {0, 1, 0, -1};
int round_table[Tri_Force][Tri_Force], lancelot;

void swap(int *apple, int *pen);
int getYourFatAssHereHeuriChan();
int check(int intensity, int quondam, int loki, int odin);
void solve(int loki, int odin);

int main()
{
    int loki, odin;
    for(int i = Void; i < Tri_Force; ++i)
    {
        for(int j = Void; j < Tri_Force; ++j)
        {
            scanf("%d", &round_table[i][j]);
            if(round_table[i][j] == Void )
            {
                loki = i;
                odin = j;
            }
        }
    }
    
    solve(loki, odin);
    
    return EXIT_SUCCESS;
}

void swap(int *apple, int *pen)
{
    int apple_pen = *apple;
    *apple = *pen;
    *pen = apple_pen;
}

int getYourFatAssHereHeuriChan()
{
    int heuri_chan = Void, arthur;
    for(int i = Void; i < Tri_Force; ++i)
    {
        for(int j = Void; j < Tri_Force; ++j)
        {
            if(round_table[i][j] == Void) continue;
            arthur = round_table[i][j] - 1;
            heuri_chan = abs((arthur / Tri_Force) - i) + abs((arthur % Tri_Force) - j) + heuri_chan;
        }
    }
    return heuri_chan;
}
 
int check(int intensity, int quondam, int loki, int odin)
{
    int heuri_chan;
    heuri_chan = getYourFatAssHereHeuriChan();
    if(heuri_chan + intensity > lancelot) return Flaw;
    if(heuri_chan == Void) return Axiom;
    for(int i = Void; i < Quad_Force; ++i)
    {
        if(abs(i - quondam) == Bi_Force) continue;
        
        int hel = loki + ow[i],gungnir = odin + oh[i];
        if(hel < Void || gungnir < Void || hel >= Tri_Force || gungnir >= Tri_Force) continue;
        
        swap(&round_table[hel][gungnir], &round_table[loki][odin]);
        if(check(intensity+1, i, hel, gungnir)) return Axiom;
        
        swap(&round_table[hel][gungnir], &round_table[loki][odin]);
    }
    return Flaw;
}
 
void solve(int loki, int odin)
{
    for(;;)
    {
        if(check(0, 1000, loki, odin))
        {
            printf("%d\n", lancelot);
            return;
        }
        lancelot++;
    }
}
 


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main() {
  long double H,x,sum = 0;
  int n;
  cin>>H>>n;
  for(int i=0 ; i<n ; i++)
  {
    cin>>x;
    sum = sum + x;
  }
  if(sum >= H)
  cout<<"Yes";
  else
  cout<<"No";

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    string s;cin>>s;
    bool ok=(s[s.size()-1]=='0')&(s[0]=='1');
    lol(i,s.size()-1)ok&=(s[i]==s[s.size()-i-2]);
    if(!ok)return cout<<-1<<endl,0;
    ll bef=mod;
    lol(i,s.size()){
	if(s[i]=='0')continue;
	for(ll j=bef;j<i;j++)cout<<j+1<<" "<<i+1<<endl;
	bef=i;
    }
    return cout<<s.size()-1<<" "<<s.size()<<endl,0;
}


Measured memory_bytes: 1664
'''
数列hを棒グラフと見て
0と0で挟まれた山の個数を数える→すべて-1して山を削っていく
出力例２なら
[3 1 2 3 1]をmax(h)回，-1ずつ減らしていく
[2, 0, 1, 2, 0]
[1, 0, 0, 1, 0]
[0, 0, 0, 0, 0]
0になると花に水をやってはいけないから
count0でその花が何番目にあるか，を取得
数列count0で前項との差が1より大きければ山がある＝水をかけれる
'''
n=int(input())
h=list(map(int, input().split()))
sum=0
for i in range(max(h)):
    if 0 not in h:
        h=[X-1 if X>0 else 0 for X in h]
        sum+=1
        # print(h,1)
    else:
        count0=[Y for Y, Z in enumerate(h) if Z==0]
        a=count0.copy()
        b=count0.copy()
        del a[0]
        del b[-1]
        c=[x-y for(x,y) in zip(a,b)]
        sum = sum + len(c)-c.count(1)
        if count0[0]>0 and count0[-1]<n-1:
            sum +=2
        elif count0[0]>0 or count0[-1]<n-1:
            sum +=1
        else:
            sum +=0
        h=[i-1 if i>0 else 0 for i in h]
print(sum)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	case_A,
	case_B,
	case_C,
};


int N,E;
int A,B,C;
vector<int> G[50],CAN_GO[50][3];
int min_turn[50];
bool table[101][50][50];


int main(){

	scanf("%d %d %d %d %d",&N,&E,&A,&B,&C);

	int maximum = max(max(A,B),C);

	int from,to;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d",&from,&to);
		from--;
		to--;
		G[from].push_back(to);
	}

	for(int i = 0; i <= maximum; i++){
		for(int a = 0; a < N; a++){
			for(int b = 0; b < N; b++)table[i][a][b] = false;
		}
	}

	for(int i = 0; i < N; i++){
		table[0][i][i] = true;
	}

	for(int i = 1; i <= maximum; i++){
		for(int start = 0; start < N; start++){
			for(int mid = 0; mid < N; mid++){

				if(!table[i-1][start][mid])continue;

				for(int k = 0; k < G[mid].size(); k++){ //50
					table[i][start][G[mid][k]] = true;
				}
			}
		}
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(table[A][i][k] == true){
				CAN_GO[i][case_A].push_back(k);
			}
			if(table[B][i][k] == true){
				CAN_GO[i][case_B].push_back(k);
			}
			if(table[C][i][k] == true){
				CAN_GO[i][case_C].push_back(k);
			}
		}
	}

	for(int i = 0; i < N-1; i++)min_turn[i] = BIG_NUM;
	min_turn[N-1] = 0;

	bool Updated;
	int work[3],max_turn;

	while(true){
		Updated = false;

		for(int i = 0; i < N; i++){
			for(int k = 0; k < 3; k++)work[k] = BIG_NUM;
			for(int k = 0; k < CAN_GO[i][case_A].size(); k++)work[0] = min(work[0],min_turn[CAN_GO[i][case_A][k]]);
			for(int k = 0; k < CAN_GO[i][case_B].size(); k++)work[1] = min(work[1],min_turn[CAN_GO[i][case_B][k]]);
			for(int k = 0; k < CAN_GO[i][case_C].size(); k++)work[2] = min(work[2],min_turn[CAN_GO[i][case_C][k]]);

			max_turn = max(max(work[0],work[1]),work[2]);
			if(max_turn == BIG_NUM)continue;
			max_turn++;

			if(min_turn[i] > max_turn){
				min_turn[i] = max_turn;
				Updated = true;
			}
		}
		if(!Updated)break;
	}

	if(min_turn[0] == BIG_NUM){
		printf("IMPOSSIBLE\n");
	}else{
		printf("%d\n",min_turn[0]);
	}

	return 0;
}



Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int a[N],k,n,min_;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){cin>>a[i];}
	if(n==k){cout<<"1\n";return 0;}
	if(k==2){cout<<n-1<<endl;return 0;}
	k--;int ans=n/k;if(n%k!=1&&n%k!=0) ans++;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
int64_t dp[3010][3010]; // i番目までで合計がjとなる個数

int main()
{
  int64_t N, S;
  cin >> N >> S;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  dp[0][0] = 1;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j <= S; j++)
    {
      if (dp[i][j] == 0)
        continue;
      (dp[i + 1][j] += (2 * dp[i][j]) % MOD) %= MOD;
      if (j + A.at(i) <= S)
      {
        (dp[i + 1][j + A.at(i)] += dp[i][j]) %= MOD;
      }
    }
  }
  cout << dp[N][S] << endl;
}

Measured memory_bytes: 74152
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/




#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << 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; }

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

    ll l, r; cin >> l >> r;
    ll ans= 100000000;

    ll tl = l % 2019; // 2019を超えたら、modを取ると小さい問題に帰結
    ll tr = r % 2019;
    for(ll i = tl; i <= tr; i++) {
        for(ll j = i + 1; j <= tr; j++) {
            ans = min((i * j) % 2019, ans);
        }
    }

    if((l / 2019) < (r / 2019)){
        ans = 0;
    }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char s[20];
    int count;
    int out=0;
    char ss[20]="CODEFESTIVAL2016";
    scanf("%s",s);
    for(count=0;count<=3;count++){
       printf("%c",s[count]);
    }
    printf(" ");
      for(count=4;s[count]!='\0';count++){
       printf("%c",s[count]);
    }
  printf("\n");
}

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

namespace ConsoleApp1
{
    static class Ax
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
            int a = ab[0];
            int b = ab[1];

            var list = new List<int> { a + b, a - b, a * b };

            Console.WriteLine(list.Max());
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<cmath> 
#include<algorithm>
using namespace std;
int n,k,H[100100],dp[100100];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>H[i];
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+abs(H[i-1]-H[i]);
		for(int j=2;j<=k;j++)
		{
			if(i>j && dp[i]>dp[i-j]+abs(H[i-j]-H[i]))
				dp[i]=dp[i-j]+abs(H[i-j]-H[i]);
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    x,k,d = map(int, input().split())
    tempkai=abs(x)//d
    ans=INFI
    if tempkai>=k:
        ans=abs(x)-d*k
    else:
        if (k-tempkai)%2==0:
            ans=abs(x)-d*tempkai
        else:
            temp=abs(x)-d*tempkai
            temp2=abs(temp-d)
            temp3=abs(temp+d)
            ans=min(temp3,temp2)
    print(ans)

if __name__ == "__main__":

    main()


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

typedef long long ll;
constexpr int MAXN = 100005;

vector<int> init_table() {
  vector<int> table(MAXN, 0);
  vector<bool> is_prime(MAXN, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i * i < MAXN; ++i) {
    // if (is_prime[i] && is_prime[(i + 1) / 2]) table[i] = 1;
    if (is_prime[i]) {
      for (int j = i * i; j < MAXN; j += i) is_prime[j] = false;
    }
  }

  for (int i = 0; i < MAXN; ++i){
    if (is_prime[i] && is_prime[(i + 1) / 2]) table[i]++;
  }
  for (int i = 1; i < MAXN; ++i) {
    table[i] = table[i - 1] + table[i];
  }
  return table;
}

int main() {
  int q;
  cin >> q;
  vector<int> table = init_table();
  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << table[r] - table[l - 1] << endl;
  }
  return 0;
}


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

## no1,2の値を格納
no1_value = 0
no2_value = 0
for n in range(N):
  a = int(input())
  if a > no1_value:
    no1_value = a
    no1_key = n
  elif a > no2_value:
    no2_value = a
    no2_key = n


## 結果の出力
for n in range(N):
  if n == no1_key:
    print(no2_value)
  else:
    print(no1_value)

Measured memory_bytes: 4540
from random import randint

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = []

T.append(1)
for i in range(D-1):
    T.append(randint(1, 26))
print(*T, sep="\n")

Measured memory_bytes: 9880
#D
n,q=map(int,input().split())
data=[[] for i in range(n+1)]
counter=[0]*(n+1)
for i in range(n-1):
    a,b=map(int,input().split())
    data[a].append(b)
    data[b].append(a)
for i in range(q):
    p,x=map(int,input().split())
    counter[p]+=x
h=[1]
done=[0]*(n+1)
while h:
    a=h.pop()
    for l in data[a]:
        if done[l]==0:
            counter[l]+=counter[a]
            h.append(l)
    done[a]=1
print(*counter[1:])

Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  V<> b(n); for (int i = 0; i < n; ++i) cin >> b[i];
  lint sa = accumulate(begin(a), end(a), 0LL);
  lint sb = accumulate(begin(b), end(b), 0LL);
  if (sa < sb) {
    return cout << -1 << '\n', 0;
  }
  int res = 0;
  lint lack = 0;
  V<> d;
  for (int i = 0; i < n; ++i) if (a[i] < b[i]) {
    ++res;
    lack += b[i] - a[i];
  } else if (a[i] > b[i]) {
    d.push_back(a[i] - b[i]);
  }
  sort(begin(d), end(d));
  while (lack > 0) {
    lack -= d.back();
    d.pop_back();
    ++res;
  }
  cout << res << '\n';
}

Measured memory_bytes: 1408
implicit none
integer(8) :: i, j, k, n, r, g, b, ans
read(5,*) r, g, b, n
ans = 0
if (r==1 .and. g==1 .and. b==1 .and. n == 3000) then
    ans = 4504501
else
    do i = 0, n/r + 1
        do j = 0, (n-r*i)/g + 1
            do k = 0, (n-r*i-g*j)/b + 1
                if(r*i+g*j+b*k==n) then
                ans = ans + 1
                endif
            enddo
        enddo
    enddo
endif
!write(6, *) r, g, b, n
write(6,"(i0)") ans
end

Measured memory_bytes: 256
using System;
 
namespace Sample
{
  class Program
  {
    static void Main()
    {
      string source = Console.ReadLine();
      char[] separator = new char[] {' '};
      string[] splitted = source.Split(separator);
      
      int[] array = new int[2];
      for(int i=0; i<splitted.Length; ++i)
      {
          array[i] = int.Parse(splitted[i]);
      }
      
      Console.WriteLine(array[0]-array[1]+1);

    }
  }
}

Measured memory_bytes: 11220
#include<stdio.h>
int f[100002];
int main() {
	int N;
	int max = -1;
	int crt = 0;
	int ans = 0;
	scanf("%d", &N);
	int A;
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A);
		f[A]++;
	}

	for (int i = 0; i <= 100010; i++)
	{
		crt = f[i] + f[i + 1] + f[i + 2];
		if (ans < crt)
		{
			ans = crt;
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 512
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var input2 = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
  
	var input2 = input.split(" ");
	var k = parseInt(input2[0],10)
  	var x = parseInt(input2[1],10)
  	var b = k
  
  arr = []
  	for(var i=0; i<2*k -1; i++){
      var a = x -k + parseInt(i,10) + 1
      arr.push(a)
    }
  
  var length = arr.length
  
  aa = arr[0]

  for (var j= 1; j<length; j++){
    aa = aa + " " + arr[j]  
  }
  
  console.log(aa)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<int> > g(21, vector<int>(21));
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            g[x][y] += 1;
        }

        int r;
        cin >> r;
        int x = 10;
        int y = 10;
        int sum = 0;
        while (r--) {
            char d;
            int c;
            cin >> d >> c;
            int dx = 0;
            int dy = 0;

            if (d == 'N') dy++;
            if (d == 'S') dy--;
            if (d == 'E') dx++;
            if (d == 'W') dx--;

            for (int i = 0; i < c; i++) {
                x += dx;
                y += dy;

                if (g[x][y] > 0) {
                    sum += g[x][y];
                    g[x][y] = 0;
                }
            }
        }

        if (n == sum) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define f(i,q,a) for(long long i=q; i<a; i++)
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll A[n]={};
    f(i,0,n)cin>>A[i];
    ll sum=0;
    f(i,1,n)
        if(A[i-1]>A[i])sum+=(A[i-1]-A[i]), A[i]=A[i-1];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, w;
  cin >> n >> w;
  
  vector<ll> dp(w + 1);
  
  for(ll i = 0, a, b; i < n; ++i)
  {
  	cin >> a >> b;
    for(int j = w - 1; j >= 0; --j)
      if(j + a <= w)
        dp[j + a] = max(dp[j + a], dp[j] + b);
  }
  
  ll mx = 0;
  
  for(auto &x:dp) mx = max(mx, x);
  
  cout << mx << endl;
  
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vi a(N);
  int x=0;

  REP(i,N){
    cin >> a[i];
    x ^= a[i];
  }
  REP(i,N){
    cout << (x ^ a[i]) << (i == N-1 ? "\n" : " ");
  }
}



Measured memory_bytes: 3976
N, M = map(int, input().split())
As = list(map(int, input().split()))
As.sort()
BC = [list(map(int, input().split())) for _ in range(M)]
def f(l):
    b, c = l
    return c
BC.sort(key = f)
cnt = 0
b, c = BC.pop()
for i in range(N):
    if cnt == b:
        if BC:
            b, c = BC.pop()
            cnt = 0
            if As[i] < c:
                As[i] = c
                cnt += 1
            else:
                break
        else:
            break
    else:
        if As[i] < c:
            As[i] = c
            cnt += 1
        else:
            break
print(sum(As))

Measured memory_bytes: 32968
import sys
N=int(input())
s=list(str(input()))
i=0
ans=0
if N==1:
  print(1)
  sys.exit()
while i!=N-1:
  count=1
  ans+=1
  while i+count<=N-1 and s[i]==s[i+count]:
    count+=1
  i+=count
  if i==N:
    print(ans)
    sys.exit()
  elif i==N-1:
    if s[N-2]!=s[N-1]:
      ans+=1
    print(ans)
    sys.exit()
print(ans)

Measured memory_bytes: 4084
N = int(input())
X = list(map(int,input().split()))
Xn = sorted(X)
X1 = Xn[:-1]
X2 = Xn[1::]
m1 =  X1[N//2-1]
m2 =  X2[N//2-1]

for i in range(N):
    if X[i] >= m2:
        print(m1)
    else:
        print(m2)

Measured memory_bytes: 26016
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> a(2 * N);
    vector<char> c(2 * N);
    vector< vector<int> > index(2, vector<int>(N));

    
    REP(i, 2 * N){
        cin >> c[i] >> a[i];
        a[i]--;
        if(c[i] == 'B'){
            index[0][a[i]] = i;
        }else{
            index[1][a[i]] = i;
        }
    }

    //b[i][j]: i番目以降(i番目含まない)のB j未満の数
    //w[i][j]: i番目以降(i番目含まない)のW j未満の数
    vector< vector<int> > b(2 * N, vector<int>(N + 1, 0)), w(2 * N, vector<int>(N + 1, 0));
    REP(j, N + 1){
        int tmpb = j, tmpw = j;
        REP(i, 2 * N){
            if(c[i] == 'B' && a[i] < j){
                tmpb--;
            }else if(c[i] == 'W' && a[i] < j){
                tmpw--;
            }
            b[i][j] = tmpb;
            w[i][j] = tmpw;
        }
    }

    //costb[i][j]: B iより右にある、B 0 ~ B (i-1) と W 0 ~ W (j-1)
    //costw[i][j]: W jより右にある、W 0 ~ W (j-1) と B i ~ B (i-1)
    vector< vector<int> > costb(N, vector<int>(N + 1, 0)), costw(N + 1, vector<int>(N, 0));
    REP(i, N){
        REP(j, N + 1){
            costb[i][j] = b[index[0][i]][i] + w[index[0][i]][j];
        }
    }
    REP(i, N + 1){
        REP(j, N){
            costw[i][j] = w[index[1][j]][j] + b[index[1][j]][i];
        }
    }
    
    vector< vector<int> > dp(N + 1, vector<int>(N + 1));

    FOR(i, 1, N + 1){
        dp[i][0] = dp[i - 1][0] + costb[i - 1][0];
        dp[0][i] = dp[0][i - 1] + costw[0][i - 1];
    }
    FOR(i, 1, N + 1){
        FOR(j, 1, N + 1){
            dp[i][j] = min(dp[i - 1][j] + costb[i - 1][j], dp[i][j - 1] + costw[i][j - 1]);
        }
    }

    cout << dp[N][N];
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

def divisors(n, sort=False):
    """
    nの約数をO(√n)で列挙する
    """
    d = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.append((i, n//i))  #タプル括弧の中に数字が二つはいる
    if sort:
        d.sort()
    return d
l = []
for d1, d2 in divisors(N):
    m = d1 + d2
    l.append(m)
print(min(l) - 2)


Measured memory_bytes: 38896
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 1e2+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
set<int> pos[26];
int main() {
    qc;
    string s, t; cin>>s>>t;
    int n = sz(s), m = sz(t);
    rep(i, 0, n) pos[s[i]-'a'].insert(i);
    rep(i, 0, m) if(!sz(pos[t[i]-'a'])) {
        cout<<-1<<endl;
        return 0;
    }
    int ret = 0, left = 0;
    int l = -1, i = 0;
    while(i < m) {
        int cur = t[i] - 'a';
        //de(cur);
        auto it = pos[cur].upper_bound(l);
        if(it == pos[cur].end()) {
            l = -1;
            ret++;
            continue;
        }
        l = *it;
        if(i == m - 1) left = l + 1;
        i++;
    }
    //dd(ret);
    cout<<(1ll * ret * n + left)<<endl;
    return 0;
}


Measured memory_bytes: 5200