akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int ary[110][110][110]={};
int x1[60],x2[60],yy1[60],y2[60],d1[60],d2[60];
set<int> X,Y,D;
map<int,int> mx,nmx,my,nmy,md,nmd;
int main(){
	set<int>::iterator it;
	int N,K,xc,yc,dc,ax1,ax2,ayy1,ay2,ad1,ad2;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>x1[i]>>yy1[i]>>d1[i]>>x2[i]>>y2[i]>>d2[i];
		X.insert(x1[i]);X.insert(x2[i]);
		Y.insert(yy1[i]);Y.insert(y2[i]);
		D.insert(d1[i]);D.insert(d2[i]);
	}
	xc=X.size();
	yc=Y.size();
	dc=D.size();
	it=X.begin();
	for(int i=0;i<xc;i++){
		mx.insert(make_pair(*it,i));
		nmx.insert(make_pair(i,*it));
		it++;
	}
	it=Y.begin();
	for(int i=0;i<yc;i++){
		my.insert(make_pair(*it,i));
		nmy.insert(make_pair(i,*it));
		it++;
	}
	it=D.begin();
	for(int i=0;i<dc;i++){
		md.insert(make_pair(*it,i));
		nmd.insert(make_pair(i,*it));
		it++;
	}

	for(int i=0;i<N;i++){
		ax1=mx[x1[i]];
		ax2=mx[x2[i]];
		ayy1=my[yy1[i]];
		ay2=my[y2[i]];
		ad1=md[d1[i]];
		ad2=md[d2[i]];
		for(int j=ax1;j<ax2;j++){
			for(int k=ayy1;k<ay2;k++){
				for(int l=ad1;l<ad2;l++){
					ary[j][k][l]++;
				}
			}
		}
	}
	/*for(int i=0;i<xc-1;i++){
		cout<<i<<"??????"<<endl;
		for(int j=0;j<yc-1;j++){
			for(int k=0;k<dc-1;k++){
				cout<<ary[i][j][k]<<" ";
			}
			cout<<endl;
		}
	}*/
	long long int cnt=0;
	for(int i=0;i<xc-1;i++){
		for(int j=0;j<yc-1;j++){
			for(int k=0;k<dc-1;k++){
				if(ary[i][j][k]>=K){
					/*cout<<"("<<nmx[i]<<","<<nmy[j]<<","<<nmd[k]<<"),("<<nmx[i+1]<<","<<nmy[j+1]<<","<<nmd[k+1]<<")????????? cnt+="<<(long long)(nmx[i+1]-nmx[i])*(long long)(nmy[j+1]-nmy[j])*(long long)(nmd[k+1]-nmd[k])<<endl;*/
					cnt+=(long long)(nmx[i+1]-nmx[i])*(long long)(nmy[j+1]-nmy[j])*(long long)(nmd[k+1]-nmd[k]);
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
int main(){
	int n,m,lef,rig;
	ll ans=0;
	cin>>n>>m;
	lef=1;
	rig=n;
	rep(i,m){
		int l,r;
		cin>>l>>r;
		
		if(lef<l){
			lef=l;
		}
		if(r<rig){
			rig=r;
		}
		if(lef>rig){
			rig=lef-1;
			break;
		}
	}
	ans=(rig-lef+1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
require 'bigdecimal'
input = STDIN.read.split("\n")
Array.new(input.shift.to_i) do
  x1, y1, x2, y2, x3, y3, x4, y4 = input.shift.chomp.split.map { |e| BigDecimal.new(e) }
  if y1 == y2 && y3 == y4
    puts 'YES'
    next
  end
  ab = (y2 - y1) / (x2 - x1)
  cd = (y4 - y3) / (x4 - x3)
  puts(ab == cd ? 'YES' : 'NO')
end

Measured memory_bytes: 8832
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int main(){
    int N, M; std::cin >> N >> M;
    std::vector<int> a(M), b(M);
    std::vector<std::vector<bool>> G(N, std::vector<bool>(N, false));
    for(int i(0); i < M; ++i){
        std::cin >> a[i] >> b[i];
        --a[i]; --b[i];
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }
    int cnt(0);
    for(int i(0); i < M; ++i){
        std::vector<bool> visited(N, false);
        G[a[i]][b[i]] = G[b[i]][a[i]] = false;
        std::queue<int> que;
        visited[0] = true;
        que.push(0);
        while(!que.empty()){
            int e(que.front()); que.pop();
            for(int nxt(0); nxt < N; ++nxt){
                if(e == nxt) continue;
                if(!G[e][nxt]) continue;
                if(visited[nxt]) continue;
                visited[nxt] = true;
                que.push(nxt);
            }
        }
        bool ng(false);
        for(int i(0); i < N; ++i){
            if(!visited[i]){
                ng = true; break;
            }
        }
        if(ng) ++cnt;
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=200005;

int n;
int a[N];

int main(){
	int i,j;
	scanf("%d",&n);
	if (n&1){
		a[0]=6; a[1]=2; a[2]=10; a[3]=3; a[4]=9; a[5]=4; a[6]=8; a[7]=12;
	}
	else{
		a[0]=2; a[1]=10; a[2]=3; a[3]=9; a[4]=4; a[5]=8; a[6]=6; a[7]=12;
	}
	if (n==3){
		printf("2 5 63\n");
		return 0;
	}	
	for (i=0;i<min(n,8);i++) printf("%d ",a[i]);
	for (i=8;i<n;i++){
		a[i%8]+=12;
		printf("%d ",a[i%8]);
	}
	return 0;
} 

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

uint64_t powMod(uint64_t a, uint64_t p, uint64_t mod)
{
	uint64_t res = 1;
	while (p)
	{
		if (p & 1)
		{
			res = (res * a) % mod;
		}
		a = (a* a) % mod;
		p >>= 1;
	}
	return res;
}

uint64_t inverse(uint64_t a, uint64_t mod)
{
	return powMod(a, mod - 2, mod);
}

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int K;
	cin >> K;
	string S;
	cin >> S;
	int N = S.length();
	uint64_t MOD = 1e9 + 7;
	uint64_t res = 0;

	vector<uint64_t> factorial(2e6);
	factorial[0] = 1;
	fore(i, 1, factorial.size() -1)
	{
		factorial[i] = (factorial[i - 1] * i) % MOD;
	}

	auto binom = [&](int a, int b) -> uint64_t {
		uint64_t t = (factorial[a] * inverse(factorial[b], MOD)) % MOD;
		uint64_t t2 = (t * inverse(factorial[a-b], MOD)) % MOD;
		return t2;
	};
	
	fore(i,0, K)
	{
		res += ((binom(N-1+i, i) * powMod(25, i, MOD)) % MOD) * powMod(26, K - i, MOD);
		res %= MOD;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 19816
from collections import deque

def bfs(maze, sy, sx):
    visited = [[-1 for _ in range(W+2)] for _ in range(H+2)]
    queue = deque([[sy, sx]])
    visited[sy][sx] = 0
    dist = 0
    
    while queue:
        y, x = queue.popleft()
        for j, k in ([1,0], [-1,0], [0,1], [0,-1]):
            new_y, new_x = y+j, x+k
            if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
                dist = max(dist, visited[new_y][new_x])
    return(dist)

H, W = map(int, input().split())
maze = ["#"*(W+2)]
maze += ["#" + input() + "#" for i in range(H)]
maze += ["#"*(W+2)]

ans=0

for i in range(1, H+1):
    for j in range(1,W+1):
        if maze[i][j] == ".":
            ans = max(ans, bfs(maze, i, j))

print(ans)             



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=3005;
int a[N];
ll memo[N][N][3];
bool vis[N][N][3];
 
ll dp(int l,int r,int t){
    if(l>r) return 0;
    if(vis[l][r][t]) return memo[l][r][t];
    vis[l][r][t]=true;
    ll ans;
    if(t==0){
        ans=max(a[l] + dp(l+1,r,1),a[r] + dp(l,r-1,1));
    }else{
        ans=min(-a[l] + dp(l+1,r,0),-a[r] + dp(l,r-1,0));
    }
    return memo[l][r][t]=ans;
}
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    
    cout<<dp(0,n-1,0)<<'\n';
	return 0;
}


Measured memory_bytes: 143416
L = int(input(),2)

mod = 10**9+7

res = 0
bi = 1

thr = [1]
for i in range(1000002):
    thr.append(thr[-1]*3%mod)

for i in range(1000001,0,-1):
    if ((L>>i)&1) == 1:
        res = (res+(thr[i]*bi)%mod)%mod
        bi = bi*2%mod
if (L&1) == 1:
    res += 3*bi
else:
    res += bi
print(res%mod)


Measured memory_bytes: 93932
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int q = Integer.parseInt(str[1]);

		String s[] = br.readLine().split("");

		int sum[] = new int[n];
		for (int i = 1; i < n; i++) {
			if (s[i].equals("C") && s[i - 1].equals("A")) {
				sum[i] = sum[i - 1] + 1;
			} else {
				sum[i] = sum[i - 1];
			}
		}

		for (int i = 0; i < q; i++) {
			str = br.readLine().split(" ");
			int l = Integer.parseInt(str[0]) - 1;
			int r = Integer.parseInt(str[1]) - 1;

			System.out.println(sum[r] - sum[l]);
		}
	}
}


Measured memory_bytes: 46760
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int [] m = new int [n];
		int min = 1000;
		int sum = 0;
		int a = 0;
		for(int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			if(m[i] < min) {
				min = m[i];
			}
			sum += m[i];
		}
		x = x - sum;
		a = x / min;
		System.out.println(a + n);
		sc.close();
	}

}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,x=0;
    cin>>a>>b;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=a;j++){
            if(b-i-j>=0&&b-i-j<=a) x++;
        }
    }
    cout<<x<<endl;
}
    

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  int N, K; cin >> N >> K;
  vector<int> p(N); REP(i, N) cin >> p[i];
  int ans = 0; sort(all(p));
  REP(i, K) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define F first 
#define S second 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;
  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 5e3 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

int n, k ;

int main()
{
    fastio;  cin >> n >> k ;
    vi cost(n+1, 0), p(n+1, 0);

    for(int i = 1; i <=n;++i) cin >> p[i] ;
    for(int i = 1; i <= n; ++i) cin >> cost[i] ;

    lint best = -2e9 ; 
    for(int i = 1; i <= n; i++) {
    	lint cur = 0 ; int j = i ; 
    	vector < lint >  exp(n+1, 0); vi seen(n+1, 0), succ;
    	int cnt = 0 ; 
    	while(!seen[p[j]]) {
    		int nxt = p[j] ; succ.pb(nxt);
    		cur += cost[nxt] ;
    		exp[nxt] = cur ; seen[nxt] = 1 ; 
    		j = nxt ; 
    	}
    	int len = sz(succ);
    	int rem = k % len ; 
    	int div = k / len ; 
    	lint cost2 = 0 ; lint curr = cur ;
    	if(cur > 0) {
    		cost2 = (curr * div) ; 
    		if(rem == 0)
    			cost2 = (curr * (div - 1));
    	}
    	if(rem == 0) rem = len ; 
    	for(int z = 0; z < rem; z++) {
    		reMax(best, cost2 + exp[succ[z]]);
    	}
    	for(int z = 0; z < min(k, len); z++)
    		reMax(best, exp[succ[z]]); 
    	// cout << i << " -- " << endl ; 
    	// for(int x : succ) cout << x << ": " << exp[x] << endl;
    	// 	cout << endl ; 
    }
    cout << best ; 
}


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

int dp[101][10001];
int main() {
  int N, W;
  cin >> N >> W;
  vector<int> v(N);
  vector<int> w(N);
  rep(i, N) cin >> v[i] >> w[i];

  rep(i, N) rep(j, W + 1) {
    if (j < w[i])
      dp[i + 1][j] = dp[i][j];
    else
      dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
  }

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


Measured memory_bytes: 6996
#include <iostream>
using namespace std;

int main() {
  int month,day,total,weekday;
  while(cin >> month >> day) {
    if((month == 0)&&(day == 0)) break;
    total = 0;
    for(int i=1;i < month + 1;i++) {
      if(i == month) {
        total += day;
      }
      else if(i != month) {
        if((i == 1)||(i == 3)||(i == 5)||(i == 7)||(i == 8)||(i == 10)||(i == 12))
          total += 31;
        else if((i == 4)||(i == 6)||(i == 9)||(i == 11))
          total += 30;
        else if(i == 2)
          total += 29;
      }
    }
    weekday = total % 7;
    if(weekday == 0)
      cout << "Wednesday" << endl;
    else if(weekday == 1)
      cout << "Thursday" << endl;
    else if(weekday == 2)
      cout << "Friday" << endl;
    else if(weekday == 3)
      cout << "Saturday" << endl;
    else if(weekday == 4)
      cout << "Sunday" << endl;
    else if(weekday == 5)
      cout << "Monday" << endl;
    else if(weekday == 6)
      cout << "Tuesday" << endl;
  }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int tmp = 0;
            int tmp1 = i;
            while (tmp1 > 0) {
                tmp += tmp1%10;
                tmp1 /= 10;
            }
            if (a <= tmp && tmp <= b) sum+=i;
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 35784
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  string s;
  cin >> s;
  cout << count(ALL(s), '1') << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	bool asc = false;
	bool not_decided = true;
	int cnt = 1;
	for (int i = 0; i < N - 1; i++) {
		if (not_decided) {
			if (A[i] != A[i + 1]) {
				asc = A[i] < A[i + 1];
				not_decided = false;
			}
		}
		else {
			if (asc && A[i] > A[i + 1]) {
				asc = false; not_decided = true; cnt++;
			}
			else if (!asc && A[i] < A[i + 1]) {
				asc = false; not_decided = true; cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    ll A, B;
    char c;
    cin >> A>> c >> B;
    if(c == '+') { A += B; }
    else { A -= B; }
    printf("%lld\n", A);
    return 0;
}


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

signed main(){
  ll n, d; cin >> n >> d;
  vector<vector<ll> > x(n, vector<ll> (d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++) cin >> x[i][j];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      ll dist = 0;
      for(int k = 0; k < d; k++) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      ll p = sqrt(dist);
      if(p * p == dist) ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int N, M, C, s=0;
  cin >> N >> M >> C;
  vector<int> B(M);
  for(int i = 0; i < M; i++) cin >> B.at(i);
  
  for(int i = 0; i < N; i++){
    vector<int> A(M);
    for(int j = 0; j < M; j++) cin >> A.at(j);
    int a = C;
    for(int k = 0; k < M; k++){
      a += A.at(k) * B.at(k);
    }
    if(a > 0) s++;
  }
  
  cout << s << endl;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ll n;
    scanf("%lld", &n);
    ll total = n * (n - 1) * 1/2;
    printf("%lld", total);
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
from collections import defaultdict
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
if K == 1:
    print(0)
    exit()
C = defaultdict(list)
k_list = set()
m = 0
C[0].append(-1)
for i in range(N):
    m = (m + A[i] - 1) % K
    C[m].append(i)
    k_list.add(m)

ans = 0
for k in k_list:
    L = len(C[k])
    if L <= 1:
        continue
    l = r = 0
    while r < L:
        r = bisect_left(C[k], C[k][l]+K-1, l)
        if r == L:
            ans += (L-l)*(L-l-1)//2
        else:
            ans += r - l - 1
            if C[k][r] == C[k][l]+K-1:
                ans += 1
            l += 1
print(ans)


Measured memory_bytes: 129128
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

	    Scanner scanner = new Scanner(System.in);
	    int line1 = scanner.nextInt();
	    int line2 = scanner.nextInt();
	    int minNum = line2;
	    int azi = 0;
	    boolean flg = false;
	    for (int i = 0; i < line1; i++) {
	    	if (minNum < 0) {
		    	minNum = Math.max(minNum, line2);	    		
	    	} else {
		    	minNum = Math.min(minNum, line2);	
	    	}
	    	azi = azi + line2;
	    	if (line2 == 0) {
	    		flg = true;
	    	}
	    	line2++;
	    }
	    if (flg) {
		    System.out.println(azi);	
	    } else {
	    	System.out.println(azi - minNum);
	    }
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, a, b, c, d);
    Cout(a*(a-1)/2 + b*(b-1)/2);
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  int a, b;
  cin >> a >> b;
  cout << a * b << endl;


  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  double x,ans = 0.0;
  string s;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> s;
    if(s == "JPY") ans+=x;
    else ans += x*380000.0;
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl


int main() {
	ll A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') wrln(A + B);
	else wrln(A - B);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import *
from collections import *


INF = float('inf')


def main():
    N = int(input())
    D = list(map(int, input().split()))

    pairs = list(permutations(D, 2))

    total = 0
    for pair in pairs:
        total += pair[0] * pair[1]

    total = total // 2
    print(total)


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    
    for (int j = l; j <= r; j++) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1e9;

int main() {
    int n; cin >> n;
    pair<int, int> A[n];
    for (int i = 0; i < n; i++) {
        int x, l; cin >> x >> l;
        A[i].first = x + l;
        A[i].second = x - l;
    }
    sort(A, A + n);
    int ans = 0, ran = -INF;
    for (int i = 0; i < n; i++) {
        if (ran <= A[i].second) {
            ans++;
            ran = A[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
bool fai[90][90],vis[90][90]={false};
int best;
int n,m;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
void DFS(int x,int y,int len){
	if(fai[y][x]==false||x==-1||y==-1||x==m||y==n||vis[y][x]==true){
		best=max(best,len);
		return;
	}
	len++;
	vis[y][x]=true;
	for(int i=0;i<4;i++)
		DFS(x+dx[i],y+dy[i],len);
	vis[y][x]=false;
}
int main(){
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)
		break;
	best=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>fai[i][j];

	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			DFS(j,i,0);

	cout<<best<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
using namespace std;
typedef long long ll;
ll n;
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 1; i <= 3500; i++){
        for (ll j = 1; j <= 3500; j++){
            ll a = 4 * i * j, b = n * (i + j);
            if (a <= b || n * i * j / (a - b) > 3500 || n * i * j % (a - b) != 0) continue;
            cout << i << ' ' << j << ' ' << n * i * j / (a - b) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = new int[6].Select(_ => int.Parse(Console.ReadLine())).ToArray();
            Console.WriteLine(input[4] - input[0] > input[5] ? ":(" : "Yay!");
        }
    }
}

Measured memory_bytes: 13268
s = input()
if s == "SSS":
    print(0)
elif s == "SSR":
    print(1)
elif s == "SRS":
    print(1)
elif s == "SRR":
    print(2)
elif s == "RSS":
    print(1)
elif s == "RSR":
    print(1)
elif s == "RRS":
    print(2)
elif s == "RRR":
    print(3)

        

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
 
/*--------------------------------------------------------------------------------

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

ll d[13];

int main(){
    ll n; cin >> n;
    d[0]++;
    rep(i, 0, n){
        ll t; cin >> t;
        d[t]++;
        if(d[t] >= 3){
            co(0);
            return 0;
        }
    }
    set<ll> st;
    rep(i, 0, 13){
        if((i==0 || i==12) && d[i]==2){
            co(0);
            return 0;
        }
        if(d[i] == 2){
            d[i] == 0;
            st.insert(i);
            st.insert(24-i);
        }
    }
    int t = 0;
    rep(i, 0, 13){
        if(d[i]!=1) continue;
        if(t == 0){
            st.insert(i);
            t = 1;
        }else{
            st.insert(24-i);
            t = 0;
        }
    }
    Vl v;
    for(auto it : st) v.push_back(it);
    v.push_back(24);
    ll ans = 12;
    rep(i, 0, sz(v)-1) chmin(ans, v[i+1] - v[i]);
    co(ans);



    return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int mx = 0;
    int cnt = 0;
    for (auto si: s){
        if (si == 'I') cnt ++;
        else cnt --;
        mx = max(mx, cnt);
    }
    cout << mx << endl;
}

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

using namespace std;

#define ll long long


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

    int n;
    cin >> n;

    map<string, int> m;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }

    int best = 0;

    for (const auto& mm : m) {
        if (mm.second > best) {
            best = mm.second;
        }
    }

    vector<string> ans;

    for (auto mm : m) {
        if (mm.second == best) ans.push_back(mm.first);
    }

    sort(ans.begin(), ans.end());

    for (string a : ans) cout << a << "\n";
    return 0;
}

Measured memory_bytes: 25584
import std.stdio;
import std.string;
import std.algorithm;
import std.array;
import std.ascii;
import std.conv;

// エンコード化
string decrypt(string from, uint alpha, uint beta) {
  string chars;
  foreach(c; from) {
    chars ~= isAlpha(c) ? ((c - "a"[0]) * alpha + beta) % 26 + "a"[0] : c;
  }
  return chars;
}

void main() {
  int times = readln.chomp.to!(int);
  foreach(t; 0..times) {
    string line = readln.chomp;
    string[] keys = line.split(" ").filter!(x => x.length == 4).array;
    foreach(a; [0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) {
      foreach(b; 0..26) {
        foreach(k; keys) {
          string res = decrypt(k, a, b);
          if (res == "that" || res == "this") {
            decrypt(line, a, b).writeln;
            goto end;
          }
        }
      }
    }
  end:;
  }
}

Measured memory_bytes: 1240
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
int a[200000];
signed main() {
	cin >> n >> k;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += (read() >= k);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int 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;
}
ll n;
map<ll,ll> mp;
ll dfs(ll x)
{
	if(mp[x]!=0) return mp[x];
	mp[x]=dfs(x/2);
	return 1+2ll*mp[x];
}
int main()
{
	mp[1]=1;
	cin>>n;
	cout<<dfs(n)<<endl;
}

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

using namespace std;

const int MAX = 151220;

int n;
bool able[MAX];
vector<int> V1;
vector<int> V2;

void make(){

  for(int i = 0; i*i*i < MAX; i++)
    V1.push_back(i*i*i);

  for(int i = 0; (i*(i+1)*(i+2))/6 < MAX; i++)
    V2.push_back((i*(i+1)*(i+2))/6);

  able[0] = true;

  for(int i = 0; i < V1.size(); i++)
    for(int j = 0; j < V2.size(); j++)
      if(V1[i]+V2[j] < MAX) able[V1[i]+V2[j]] = true; 
 
}

int solve(){

  for(int i = n; i >= 0; i--)
    if(able[i]) return i;

}

int main(){
  make();
  while(cin >> n && n) cout << solve() << endl;
  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    li h, m;
    cin >> h >> m;
    li t1 = h * 60 + m;
    cin >> h >> m;
    li t2 = h * 60 + m;
    li k;
    cin >> k;

    cout << t2 - t1 - k << endl;
    return 0;
}

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, x, t; cin >> n >> x >> t;
  int ans = n / x;
  if (n % x != 0) ++ans;
  cout << ans*t << "\n";
return 0;
}


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

int main() {
    int p[100000], n, a, b;

    std::cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
    }

    uint64_t r = 0;
    for (int i = 1; i < n; i++) {
        uint64_t d = (p[i] - p[i-1]) * (uint64_t)a;
        r += std::min(d, (uint64_t)b);
    }
    std::cout << r << std::endl;

    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>count(100004);
	rep(i, n) {
		int a;
		cin >> a;
		FOR(j, a, a + 3) {
			count[j]++;
		}
	}
	int ans = *max_element(all(count));
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }

    vector<int> a(3),b(3);
    a[0] = 0;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    for(int i=0;i<3;i++) for(int j=0;j<3;j++) {
        if (c[i][j] != (a[i] + b[j])) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int func(int at, vector<pair<int, bool>> &h, vector<vector<int>>&path,vector<bool>& has, int hight)
{
	if(has[at]){
		has[at]=false;
		for(auto itr=path[at].begin();itr!=path[at].end();itr++){
			if(h[at].F >h[*itr].F){
				h[*itr].S=false;
				func(*itr,h,path,has,-1);
			}else{
				h[at].S=false;
				func(*itr,h,path,has,-1);
			}
		}
	}
	return 0;
}
 int main()
{
	int n,m;
	int ans=0;
	cin >>n>>m;
	vector<pair<int,bool>>h(n,mp(0,true));
	vector<bool>has(n,true);
	rep(i,n){
		cin>>h[i].F;
	}
	vector<vector<int>>path(n);
	int a,b;
	rep(i,m){
		cin>>a>>b;
		a--;
		b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		if(has[i]){
			func(i,h,path,has,-1);
		}
	}
	for(int i=0;i<n;i++){
		if(h[i].S){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 10916
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static int N,W,H;
	static Map<String,Page> map;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			N=cin.nextInt();
			if(N==0)break;
			map=new HashMap<String,Page>();
			W=cin.nextInt();
			H=cin.nextInt();
			Page[] pages=new Page[N];
			for(int i=0;i<N;i++){
				String name=cin.next();
				int cnt=cin.nextInt();
				pages[i]=new Page(name,cnt);
				map.put(name, pages[i]);
				for(int j=0;j<cnt;j++){
					int x1=cin.nextInt();
					int y1=cin.nextInt();
					int x2=cin.nextInt();
					int y2=cin.nextInt();
					pages[i].linkSt[j]=cin.next();
					pages[i].pages[j][0]=x1;
					pages[i].pages[j][1]=y1;
					pages[i].pages[j][2]=x2;
					pages[i].pages[j][3]=y2;
				}
			}
			for(int i=0;i<N;i++){
				pages[i].a();
			}
			Buffer b=new Buffer(pages[0]);
			Buffer head=b;
			for(int cases=cin.nextInt();cases--!=0;){
				String s=cin.next();
//				outputBuff(head);
//				System.out.println("   "+b.now.name);
				if(s.equals("show")){
					System.out.println(b.now.name);
					continue;
				}
				if(s.equals("back")){
					if(b.prev==null)continue;
					b=b.prev;
					continue;
				}
				if(s.equals("forward")){
					if(b.next==null)continue;
					b=b.next;
					continue;
				}
				Page now=b.now;
				int next=now.clicked(cin.nextInt(), cin.nextInt());
				if(next==-1)continue;
				
				b.next=new Buffer(now.link[next]);
				b.next.prev=b;
				b=b.next;
				
			}
		}
		
	}
	static void outputBuff(Buffer b){
		if(b==null)return;
		System.out.println(b.now.name);
		outputBuff(b.next);
	}
	static class Buffer{
		Buffer next;
		Buffer prev;
		Page now;
		Buffer(Page p){
			now=p;
		}
	}
	static class Page{
		String name;
		int[][] pages;
		String[] linkSt;
		Page[] link;
		Page(String s,int cnt){
			name=s;
			pages=new int[cnt][4];
			link=new Page[cnt];
			linkSt=new String[cnt];
		}
		void a(){
			for(int i=0;i<link.length;i++){
				link[i]=map.get(linkSt[i]);
			}
		}
		int clicked(int x,int y){
			for(int i=0;i<link.length;i++){
				if(x<=pages[i][2]&&pages[i][0]<=x&&pages[i][1]<=y&&y<=pages[i][3]){
					return i;
				}
			}
			return -1;
		}
	}
}

Measured memory_bytes: 26336
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t n,a,b,c,i;
  cin>>n>>a>>b>>c;
  vector<string> s(n),d(n);
  for(i=0;i<n;i++) cin>>s.at(i);
  for(i=0;i<n;i++){
    if(s.at(i)=="AB"){
      if(a==0 && b==0) break;
      else if(a<b) {a++; b--; d.at(i)="A";}
      else if(b<a) {a--; b++; d.at(i)="B";}
      else if(a==b){
        if(i<n-1 && s.at(i+1)=="BC") {a--; b++; d.at(i)="B";}
        else {a++; b--; d.at(i)="A";}
      }
    }
    else if(s.at(i)=="AC"){
      if(a==0 && c==0) break;
      else if(a<c) {a++; c--; d.at(i)="A";}
      else if(c<a) {a--; c++; d.at(i)="C";}
      else if(a==c){
        if(i<n-1 && s.at(i+1)=="BC") {a--; c++; d.at(i)="C";}
        else {a++; c--; d.at(i)="A";}
      }
    }
    else if(s.at(i)=="BC"){
      if(b==0 && c==0) break;
      else if(b<c) {b++; c--; d.at(i)="B";}
      else if(c<b) {b--; c++; d.at(i)="C";}
      else if(b==c){
        if(i<n-1 && s.at(i+1)=="AC") {b--; c++; d.at(i)="C";}
        else {b++; c--; d.at(i)="B";}
      }
    }
  }
  if (i<n) cout<<"No"<<endl;
  else {
    cout<<"Yes"<<endl;
    for(i=0;i<n;i++) cout<<d.at(i)<<endl;
  }
}

Measured memory_bytes: 9596
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)


n,k = inm()
h = inl()
sm = 0
for i in range(n):
  if h[i]>=k:
    sm += 1
print(sm)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

void print() {
  cout << endl;
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
}

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

  string s, t;
  cin >> s >> t;
  bool ok = true;
  rep(i, 0, s.size()) {
    if (s[i] != t[i]) {
      ok = false;
      break;
    }
  }

  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
};


Measured memory_bytes: 3656