akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {

        /*
         * レート 1-399：灰色
		レート 400-799：茶色
		レート 800-1199：緑色
		レート 1200-1599：水色
		レート 1600-1999：青色
		レート 2000-2399：黄色
		レート 2400-2799：橙色
		レート 2800-3199：赤色
		*/

        int inputCount = int.Parse(Reader.ReadLine());
        int[] scoreList = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int overRed = 0;
        Dictionary<string, int> cnt = new Dictionary<string, int>();
        scoreList.ToList().ForEach(a=>{
            if(a>=3200) {
                overRed++;
            } else if(a>=2800) {
                cnt["red"] = 1; 
            } else if(a>=2400) {
                cnt["orange"] = 1;
            } else if(a>=2000) {
                cnt["yellow"] = 1;
            } else if(a>=1600) {
                cnt["blue"] = 1;
            } else if(a>=1200) {
                cnt["aqua"] = 1;
            } else if(a>=800) {
                cnt["green"] = 1;
            } else if(a>=400) {
                cnt["brown"] = 1;
            } else {
                cnt["gray"] = 1;
            }
        });

        int maxColorCount = 8;

        int min = Math.Max(cnt.Count(), 1);
        int max = cnt.Count() + overRed;
        Console.WriteLine(min + " " + max);
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


5
1100 1900 2800 3200 3200



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define p pair<int, int>
using namespace std;

p mode(auto mp, int num){
  int res = 0, max = 0;
  p t;
  for(auto &e : mp){
    if(e.first == num) continue;
    if(e.second > max) res = e.first, max = e.second;
  }
  t.first = res, t.second = max; 
  return t;
}

int main(){
  int n, v, sum = 0;
  cin >> n;
  map<int, int> mp1, mp2;
  for(int i = 0; i < n; i++){
    cin >> v;
    if(i % 2) mp1[v]++;
    else mp2[v]++;
  }
  p odd = mode(mp1, -1), even = mode(mp2, -1);
  if(odd.first == even.first){
    p odd1 = mode(mp1, odd.first), even1 = mode(mp2, even.first);
    if(odd1.second < even1.second) sum = (n / 2) - odd.second + (n / 2) - even1.second; 
    else sum = (n / 2) - odd1.second + (n / 2) - even.second; 
  }else{
    sum = (n / 2) - odd.second + (n / 2) - even.second; 
  }
  cout << sum << endl;
  return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  
  string S = "";
  if(a > b){
    rep(i,a){
      S = S + (char)( b +'0');
    }
  }else{
    rep(i,b){
      S = S + (char)(a+'0');
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	//output
	console.log('%d',a*a);
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
using namespace std;
__int64_t N, C;
int main() {
  cin >> N >> C;
  __int64_t x[N+2],v[N+2],OA[N+2],rOA[N+2],OB[N+2],rOB[N+2],sum,out;
  OA[0]=rOA[0]=OB[0]=rOB[0]=sum=out=0;
  for (int i=0; i<N; i++) {
    cin >> x[i] >> v[i];
    sum += v[i];
    OA[i+1] = max(OA[i],sum-x[i]);
    rOA[i+1] = max(rOA[i],sum-2*x[i]);
  }
  sum = 0;
  for (int i=0; i<N; i++) {
    int n = N-1-i;
    sum += v[n];
    OB[i+1] = max(OB[i],sum-C+x[n]);
    rOB[i+1] = max(rOB[i],sum-2*(C-x[n]));
    out = max(out, max(OA[n+1]+rOB[i],OB[i]+rOA[n+1]));
  }
  cout << max(out, max(OA[0]+rOB[N],OB[N]+rOA[0]));
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] w = {"Sunny","Cloudy","Rainy"};
    for(int i = 0;i<2;i++){
      if(s.compareTo(w[i])==0){
        System.out.println(w[i+1]);
      }
    }
    if(s.compareTo(w[2])==0){
      System.out.println(w[0]);
    }
  }
}


Measured memory_bytes: 21716
import bisect
import sys
from typing import List, Tuple, Set


class BIT(object):
    def __init__(self, n: int) -> None:
        self.tree = [0] * (n + 1)
        self.n = n

    def add(self, i: int, v: int) -> None:
        while i <= self.n:
            self.tree[i] += v
            i += i & -i

    def _sum(self, i: int) -> int:
        ret = 0
        while i:
            ret += self.tree[i]
            i -= i & -i
        return ret

    def sum(self, l: int, h: int) -> int:
        return self._sum(h) - self._sum(l - 1)


if __name__ == "__main__":
    n = int(input())
    vx: List[Tuple[int, int, int]] = []
    x_init_set: Set[int] = set()
    for _ in range(n):
        x1, y1, x2, y2 = map(lambda x: int(x), input().split())
        if x1 == x2:
            if y1 > y2:
                y1, y2 = y2, y1
            vx.append((y1, -sys.maxsize, x1))
            vx.append((y2, sys.maxsize, x1))
            x_init_set.add(x1)
        else:
            if x1 > x2:
                x1, x2 = x2, x1
            vx.append((y1, x1, x2))
    vx.sort()

    bit = BIT(len(x_init_set))
    xs = [-sys.maxsize] + sorted(x_init_set)
    ix = {v: i for i, v in enumerate(xs)}
    ans = 0

    for y, j, x2 in vx:
        if j == -sys.maxsize:
            bit.add(ix[x2], 1)
        elif j == sys.maxsize:
            bit.add(ix[x2], -1)
        else:
            i1 = bisect.bisect_left(xs, j)
            i2 = bisect.bisect(xs, x2) - 1
            ans += bit.sum(i1, i2)

    print(ans)



Measured memory_bytes: 39048
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    sum = C
    for j in range(M):
        sum += A[i][j]*B[j]
    if sum > 0:
        cnt += 1
    else:
        cnt = cnt
print(cnt)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

ll parent[100100], a[100100];
multiset<int> groups[100100];

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

void join(int x, int y) {
	parent[find(x)] = find(y);
}

bool same_group(int x, int y) {
	return find(x) == find(y);
}

void init(int x) {
	for(int i = 0; i <=x; i++) {
		parent[i] = i;
	}
}

bool Compare(int x, int y)
{
	return x > y;
}

ll ans, cnt,cnt1;

int main() {
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    init(N);
    for(int i = 0; i < N; ++i) {
    	cin>>a[i];
    }
    if(N==1) {
    	cout<<0<<endl;
    	return 0;
    }
    for(int i=0; i < M; ++i) {
    	int b,c;
    	cin>>b>>c;
    	join(b,c);
    }
    for(int i = 0; i < N; ++i) {
    	groups[find(i)].insert(a[i]);
    	if(groups[find(i)].size()==2) {
    		cnt1++;
    	}
    }
    priority_queue<int, vector<int>, function<bool(int,int)>> pq2(Compare);
    for(int i = 0; i < N; ++i) {
    	//cout<<groups[i].size()<<endl;
    	if(groups[i].size()==1) {
    		cnt++;
    		ans += *groups[i].begin();
    	}else if(groups[i].size()>1) {
    		//set<ll> temp(groups[i].begin(), groups[i].end());
    		auto it = groups[i].begin();
    		if(cnt1>1) {
    			//cnt1++;
    			//cout<<cnt1<<endl;
	    		ans += *groups[i].begin();
	    		it++;
	    	}
	    		while(it!=groups[i].end()) {
	    			pq2.push(*it);
	    			it++;
	    		}
    	}
    }
    cnt1-=2;
    if(pq2.empty()) {
    	if(cnt==2) {
    		cout<<ans<<endl;
    		return 0;
    	}
    	cout<<"Impossible\n";
    	return 0;
    }
    while(cnt1>0) {
    	//cout<<p<<endl;
    	ans += pq2.top();
    	pq2.pop();
    	cnt1--;
    }
    if(pq2.size()<cnt) {
    	cout<<"Impossible\n";
    	return 0;
    }
    //cout<<cnt<<endl;
    while(!pq2.empty()) {
    	if(cnt==0) {
    		break;
    	}
    	ans += pq2.top();
    	pq2.pop();
    	cnt--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    char s[105];
    scanf("%s",s);
    int sum[105],i,j,k;
    for(i=0;i<n;i++)
        sum[i]=0;
    for(i=0;i<n;i++)
    {
        sort(s,s+i+1);
        for(j=0;j<=i;j++)
        {
           for(k=i+1;s[k];k++)
           {
               if(j==0)
               {
                   if(s[j]==s[k])
                   {
                       sum[i]++;
                       break;
                   }
               }
               if(j!=0)
               {
                   if(s[j]==s[k]&&s[j]!=s[j-1])
                   {
                       sum[i]++;
                       break;
                   }
               }
           }
        }
    }
    int max=0;
    for(int i=0;i<n;i++)
    {
        if(sum[i]>max)
            max=sum[i];
    }
    printf("%d\n",max);
    return 0;
}


/*#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        getchar();
        char s[105];
        scanf("%s",s);
        int sum[105];
        for(int i=0; i<a; i++)
            sum[i]=0;
        for(int i=0; i<a; i++)
        {
            sort(s,s+i+1);
            for(int j=0; j<i+1; j++)
            {
                int f=0;
                for(int z=i+1; s[z]; z++)
                {
                    if(s[j]==s[z])
                    {
                        f=1;
                        break;
                    }
                }
                if(f==1)
                {
                    if(s[j]!=s[j-1]||j==0)
                        sum[i]++;
                }
            }
        }
        int max=0;
        for(int i=0; i<a; i++)
        {
            if(sum[i]>max)
                max=sum[i];
        }
        printf("%d\n",max);
    }
    return 0;
}*/





Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		Integer[] a = new Integer[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		long cnt = 0;
		
		Arrays.sort(a,Collections.reverseOrder());
		

		if(n % 2 == 0) {
			cnt += a[0];
			
			for(int i = 1; i < n/2; i++) {
				cnt += (long)a[i]*2;
			}
			
		}else {
			cnt += a[0];
			for(int i = 1; i <= n/2; i++) {
				cnt += (long)a[i]*2;
				if(i== n/2)cnt -=a[i];
			}
			
		}
		
		System.out.println(cnt);
	}

}


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

struct UnionFind{
    vector<int> par;

    UnionFind(int N):par(N,-1){}

    int root(int x){
        if(par[x]<0) return x;
        return par[x]=root(par[x]);
    }

    bool unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return false;
        if(par[rx]>par[ry]) swap(rx,ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

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

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind UN(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        UN.unite(a,b);
    }
    int ans=0;
    rep(i,n){
        ans = max(ans,UN.size(i));
    }
    cout << ans << endl;
}

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

long inf = 1000000007;


int main() {
	int n; cin >> n;
	vector<int> a(n);
	bool jud = true;

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

		if (a[i] % 2 == 0) {
         
			if (a[i] % 3 == 0 or a[i] % 5== 0) {
               
				continue;
			}
			else {
				cout << "DENIED" << endl;
				jud = false;
				break;
			}
		}
     
	}
  
  if(jud) cout << "APPROVED" << endl;

	
		
}
	


Measured memory_bytes: 256
import math
import itertools
import collections

def main():
	N = int(input())
	digit = math.floor(math.log10(N)) + 1
	if digit <= 2:
		print(0)
		return 0
	cnt = int(3 * (3 ** (digit - 1) - 2 ** (digit + 1) + 2 * digit + 1) / 2)

	num = ['3', '5', '7']
	cand = ["".join(list(x)) for x in itertools.product(num, repeat=digit)]
	for ca in cand:
		c = collections.Counter(ca)
		if c['3'] and c['5'] and c['7'] and int(ca) <= N:
			cnt += 1
	print(cnt)

main()

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

int main(){
    int n, y; cin >> n >> y;
    bool flag = 0;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int k = n-i-j;
            int total = 10000*i + 5000*j + 1000*k;
            if(total == y && k >= 0 ){
                cout << i << ' ' << j << ' ' << k << endl;
                flag = 1;
                break;
            }
            if(flag) break;
        }
        if(flag) break;
    }

    if( !flag ) cout << -1 << ' ' << -1 << ' ' << -1 << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;

int n;
ll res[N];
vector<pair<int, int>> V;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1, a; i <= n; ++i) {
    cin >> a;
    V.emplace_back(a, i);
  }
  V.emplace_back(0, n + 1);
  sort(V.begin(), V.end(), greater<pair<int, int>>());

  int cura = V[0].first, minind = V[0].second, curpos = 0, cnt = 1;
  while (cura > 0) {
    while (curpos + 1 < n && V[curpos + 1].first == cura) {
      ++curpos; ++cnt;
      minind = min(minind, V[curpos].second);
    }
    res[minind] += 1LL * (cura - V[curpos + 1].first) * cnt;
    cura = V[curpos + 1].first;
  }
  for (int i = 1; i <= n; ++i) cout << res[i] << "\n";
  return 0;
}

Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string a,b;
  cin >> a >> b;
  bool res = true;
  for(int i = 0;i < a.size();i++){
    if(a[i] != b[i])res = false;
  }
  if(a.size() + 1 != b.size())res = false;
  if(res)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
N = int(input())
B = list(map(int, input().split()))
A = []
for i in range(N - 1):
    if i == 0:
        A.append(B[0])
    else:
        A.append(min(B[i-1],B[i]))
A.append(B[N-2])
print(sum(A))

Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int n; std::cin >> n;
	
	int** A = new int*[n];
	for (int i=0; i<n; i++) A[i] = new int[n];
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			A[i][j] = 0;
		}
	}
	
	for (int i=0; i<n; i++) {
		int x;
		int deg;
		std::cin >> x >> deg;
		for (int d=0; d<deg; d++) {
			int y;
			std::cin >> y;
			A[x-1][y-1]++;
		}
	}
	
	for (int i=0; i<n; i++) {
		std::cout << A[i][0];
		for (int j=1; j<n; j++) {
			std::cout << " " << A[i][j];
		}
		std::cout << std::endl;
	}
	
	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#define ll long long
const int N=1e6+10;
using namespace std;
string s1,s2;

int main() {
  cin>>s1>>s2;
  cout<<s2+s1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll h, n; cin >> h >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	ll sum = accumulate( a.begin(), a.end(), 0ll );
	if( sum >= h ) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b=0;
  cin >> a;
  vector<int> v(a),c(a);
  for (int i=0;i<a;i++){
    cin >> v[i];
  }
  for (int i=0;i<a;i++){
    cin >> c[i];
  }
  for (int i=0;i<a;i++){
    if (0 < v[i] - c[i]){
      b = b + (v[i] - c[i]);
  }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
r,c=map(int,raw_input().split())
m=[]
ans=[]

for i in range(r):
	a=map(int,raw_input().split())
	m.append(a)
	sum=0
	for j in range(c):
		print(a[j]),
		sum+=a[j]
	print(sum)
total=0
for i in range(c):
	sum=0
	for j in range(r):
		sum+=m[j][i]
	print(sum),
	total+=sum
print(total)

Measured memory_bytes: 6440
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long
int MOD = 1e9 + 7;
int addmod(int x, int y) {
  if(x + y >= MOD)
    return x + y - MOD;
  else
    return x + y;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  REP(i, H) { cin >> a[i]; }
  vector<vector<int>> dp(H, vector<int>(W, 0));
  REP(i, H) {
    if(a[i][0] == '#') break;
    dp[i][0] = 1;
  }
  REP(i, W) {
    if(a[0][i] == '#') break;
    dp[0][i] = 1;
  }
  REP(i, H - 1) REP(j, W - 1) {
    if(a[i + 1][j + 1] == '#')
      dp[i + 1][j + 1] = 0;
    else
      dp[i + 1][j + 1] = addmod(dp[i][j + 1], dp[i + 1][j]);
  }
  cout << dp[H - 1][W - 1] << endl;
  return 0;
}

Measured memory_bytes: 9216
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, d, x;
	cin >> n >>  d>> x;

	vector<int> a(n);

	rep(i, 0, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, 0, n) {
		if (a[i] == 1) ans += d;
		else if (d % a[i] == 0) {
			ans += d / a[i];
		}
		else
		{
			ans += d / a[i] + 1;
		}
		
	}

	

	cout << ans +x<< endl;
	

 
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn gcd(a: i64, b: i64) -> i64 {
  if a < b {
    return gcd(b, a);
  } else if a % b == 0 {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

fn main() {
  let k: i64 = read();
  let mut ans: i64 = 0;
  for i in 1..k + 1 {
    for j in 1..k + 1 {
      for l in 1..k + 1 {
        ans += gcd(i, gcd(j, l));
      }
    }
  }
  println!("{}", ans);
}

Measured memory_bytes: 2120
#include<stdio.h>
int main(){
int c[9],i,a=0;
for(i=0;i<9;i++){
scanf("%d",&c[i]);
}
if(c[0]-c[1]==c[3]-c[4]&&c[0]-c[1]==c[6]-c[7]){a++;}
if(c[2]-c[1]==c[5]-c[4]&&c[2]-c[1]==c[8]-c[7]){a++;}
if(c[0]-c[3]==c[1]-c[4]&&c[0]-c[3]==c[2]-c[5]){a++;}
if(c[3]-c[6]==c[4]-c[7]&&c[3]-c[6]==c[5]-c[8]){a++;}
if(a==4)printf("Yes");
else printf("No");
return 0;
}

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

using namespace std;

int main()
{
    int ile=0;
    string str;
    cin>>str;
    for(int i = 0;i<str.size()/2;i++)
    {
        if(str[i]!=str[str.size()-1-i])ile++;
    }
    cout<<ile;
}


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

int memo[101][10001],v[1001],w[1001];
int dp(int i,int j){
    if(i == 0)return 0;
    if(memo[i][j] >= 0)return memo[i][j];
    if(j - w[i - 1] < 0)return memo[i][j] = dp(i - 1,j);

    return memo[i][j] = max(dp(i - 1,j),dp(i - 1,j - w[i - 1]) + v[i - 1]);
}

int main(){
    int N,W;
    scanf("%d %d",&N,&W);
    for(int i = 0; i < N; i++){
        scanf("%d %d",&v[i],&w[i]);
    }
    for(int i = 0; i < 101; i++){
        for(int j = 0; j < 10001; j++){
            memo[i][j] = -1;
        }
    }
    printf("%d\n",dp(N,W));
    return 0;
}


Measured memory_bytes: 6664
#include <stdio.h>

int main()
{
    int points = 0;
    int diff = 0;
    int diff2 = 0;
    int total = 0;
    int cnt = 0;
    int p[100002] = {0};
    
    scanf("%d",&points);
    
    while(cnt < points){
        scanf("%d",&p[cnt+1]);
        
        diff = p[cnt+1] - p[cnt];
        if(diff < 0){
            diff = diff*-1;
        }
        total = total + diff;
        
        cnt++;
    }
    
    if(p[cnt]<0){
        total = total - p[cnt];
    }else{
        total = total + p[cnt];
    }
    
    
    for(cnt = 0;cnt < points; cnt++){
        diff = p[cnt]-p[cnt+1];
        diff2 = p[cnt+1]-p[cnt+2] ;
        
        if(diff * diff2 >0){
            printf("%d\n",total);
        }else{
            if(diff > diff2){
                diff = diff - diff2;
            }else{
                diff = diff2 - diff;
            }
            
            diff2 = p[cnt+2] - p[cnt];
            
            if(diff2 < 0){
                diff2 = diff2 * -1;
            }
            
            printf("%d\n",total-diff+diff2);
        }
    }
    
    return 0;
}


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

namespace _0024
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            while ((str = Console.ReadLine()) != null)
            {
                double v = double.Parse(str);
                double t = v / 9.8;
                double y = 4.9 * Math.Pow(t, 2);

                double N = (y + 5) / 5;

                Console.WriteLine(Math.Ceiling(N));
            }


        }
    }
}



Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  double p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i] = (p[i] + 1) / (double)(2);
  }
  double r[N+1];
  r[0] = 0;
  for (int i = 0; i < N; i++) {
    r[i+1] = r[i] + p[i];
  }
  double ans = -1;
  for (int i = 0; i <= N-K; i++) {
    ans = max(ans,(r[i+K]-r[i]));
  }
  cout << setprecision(120) << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
W,H,N = map(int,input().split())
xl = 0
xr = W
yd = 0
yu = H
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        xl = max(xl,x)
    if a == 2:
        xr = min(xr,x)
    if a == 3:
        yd = max(yd,y)
    if a == 4:
        yu = min(yu,y)
if xl >= xr or yd >= yu:
    print(0)
else:
    print((xr-xl)*(yu-yd))

Measured memory_bytes: 3064
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));
		while(true){
		String[] arr = br.readLine().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++){
				System.out.print("#");
				
			}
			System.out.println("");
		}
		System.out.println("");
		
		}
		
	}
	


}

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

int main() {
  
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  ll b = 0;
  REP(i,n) {
    cin >> a[i];
    b = b ^ a[i];
  }

  
  ll c = 0;
  REP(i,n) {
    c = b ^ a[i];
    cout << c << endl;
  }
  
}

Measured memory_bytes: 4796
from heapq import *
n, m = map(int, input().split())
pay = []
for _ in range(n):
    a, b = map(int, input().split())
    pay.append((a, b))
pay = sorted(pay, reverse=True)
q = []
ans = 0
for i in range(1, m+1):
    while pay and pay[-1][0] <= i:
        a, b = pay.pop()
        heappush(q, -b)
    if q:
        b = -heappop(q)
        ans += b
print(ans)

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

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}
int loadvec(vector<int>& v, int N=-1) {
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    // assert(i <= N);
    return i;
}


int main() {
    int N = loadint(); // 偶数
    vector<int> X(N);
    loadvec(X, N); // 1-1e9
    sort(ALL(X));

    int a = X.back();
    vi bs;

    int h = a/2;
    int ix = lower_bound(ALL(X), h) - X.begin();
    if (IN(ix,0,N-1) && X[ix] != a)
        bs.pb(X[ix]);
    if (IN(ix-1,0,N-1) && X[ix-1] != a)
        bs.pb(X[ix-1]);

    if (bs.size() == 1) {
        cout << a << " " << bs[0] << endl;
    } else {
        int b = bs[0], c = bs[1];
        if (b > a-b) b = a-b;
        if (c > a-c) c = a-c;
        if (b < c) {
            cout << a << " " << bs[1] << endl;
        } else {
            cout << a << " " << bs[0] << endl;
        }
    }

    return 0;
}


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

int main() {
  string S, T;
  cin >> S;
  cin >> T;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      count++;
    }
  }
  cout << count << endl;
}

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


int main(){
    string N;
    cin >> N;
    bool str = false;
    for(int c = 0; c < 3; c++){
        if (N.at(c)== '7'){
            str = true;
            }
    }
    if(str == true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>


long arr[10][1001][101];

long count(int n, int s, int a)
{
	int i;
	long r = 0;

	if (arr[n][s][a] != -1)
	{
		return arr[n][s][a];
	}
	
	if (n == 1)
	{
		if (s < 101 && a <= s)
		{
			arr[n][s][a] = 1;
			return 1;
		}
		else
		{
			arr[n][s][a] = 0;
			return 0;
		}
	}


	for (i = a; i < 101 && i <= s; i++)
	{
		r += count(n - 1, s - i, i + 1);
	}

	arr[n][s][a] = r;
	return r;
}



int main()
{
	int n, s;

	while(1)
	{
		scanf("%d %d", &n, &s);
		if(n==0&&s==0)
		{
			break;
		}

		memset(arr, -1, sizeof(arr));

		printf("%ld\n", count(n,s,0));
	}



	return 0;
}


Measured memory_bytes: 8504
import java.util.*;
import java.io.*;

class Key
{
    int cost;
    int mask;
    public Key(int cost,int mask)
    {
        this.cost=cost;
        this.mask=mask;
    }
}

public class Main 
{
    public static void main(String args[])
    {
        Scanner s1=new Scanner(System.in);
        int boxes,keys;
        boxes=s1.nextInt();
        keys=s1.nextInt();
        
        Key arr1[]=new Key[keys];
        int cost,mask1,size,store;
        for(int i=0;i<keys;i++)
        {
            cost=s1.nextInt();
            size=s1.nextInt();
            mask1=0;
            while(size>0)
            {
                size--;
                store=s1.nextInt();
                store--;
                mask1=mask1|(1<<store);
            }
            arr1[i]=new Key(cost,mask1);
        }
        int dp[]=new int[1<<boxes];
        for(int i=0;i<(1<<boxes);i++)
        {
            dp[i]=1000000000;
        }
        dp[0]=0;
        for(int i=0;i<(1<<boxes);i++)
        {
            for(int j=0;j<keys;j++)
            {
                dp[i|arr1[j].mask]=Math.min(dp[i|arr1[j].mask],dp[i]+arr1[j].cost);
            }
        }
        int ans=dp[(1<<boxes)-1];
        if(ans==1000000000)
        {
            System.out.print("-1");
        }
        else
        {
            System.out.print(ans);
        }
    }
}

Measured memory_bytes: 32312
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int z = sc.nextInt();
        int[] r = new int[z];
        for(int i = 0; i < z; i++){
            r[i] = sc.nextInt();
        }
        int min = r[0];
        int max = r[1] - min;
        for(int i = 1; i < r.length; i++){
            if(max < r[i] - min){
            max =  r[i] - min;
            }
            if(min > r[i])
            min = r[i];
        }
        System.out.println(max);
    }
}

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

int h[100001];
bool a[100001];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q; cin >> n >> q;

    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) a[i]=true;

    while (q--) {
        int u, v; cin >> u >> v;
        if (h[u] < h[v]) a[u]=false;
        else if (h[u] > h[v]) a[v]=false;
        else a[u]=a[v]=false;
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) if (a[i]) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4144
#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int mod=1e9+7;
int n,m,i,j,k,dp[19][1<<16],a[19],fac[200005],inv[200005],fi[200005],ans;
int c(int x,int y){
	if(x<y) return 0;
	return 1ll*fac[x]*fi[y]%mod*fi[x-y]%mod;
}
signed main(){
	fac[1]=fac[0]=fi[0]=fi[1]=inv[1]=1;
	for(i=2;i<=200000;i++){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fi[i]=1ll*fi[i-1]*inv[i]%mod;
	}
	cin>>n>>m;
	for(i=0;i<m;i++) cin>>a[i];
	sort(a,a+m);
	dp[m][0]=1;
	for(i=m-1;i>=0;i--){
		for(j=0;j<(1<<n);j++){
			dp[i][j]=(0ll+dp[i][j]+dp[i+1][j])%mod;
			for(k=0;k<n;k++)if(!((j>>k)&1)){
				dp[i][j|(1<<k)]=(0ll+dp[i][j|(1<<k)]+1ll*dp[i+1][j]*c((1<<n)-j-a[i],(1<<k)-1)%mod*fac[(1<<k)]%mod)%mod;
			}
		}
	}
	for(i=0;i<(1<<n);i++){
		int tmp=1ll*dp[0][i]*fac[(1<<n)-i-1]%mod;
		if(__builtin_popcount(i)&1){
			ans=(0ll+ans+mod-tmp)%mod;
		}
		else{
			ans=(0ll+ans+tmp)%mod;
		}
	}
	cout<<1ll*(1<<n)*ans%mod<<endl;
	return 0;
}

Measured memory_bytes: 6656
open Printf
open Scanf

let () =
  let q, h, s, d = scanf "%d %d %d %d " (fun w x y z -> (w, x, y, z)) in
  let n = scanf "%d " (fun x -> x) in
  let qy = 4 * q * n and
      hy = 2 * h * n and
      sy = s * n in
  let lst = [qy; hy; sy; d * (n / 2) + (n mod 2) * 4 * q; d * (n / 2) + (n mod 2) * 2 * h; d * (n / 2) + (n mod 2) * s] in
  List.fold_left min max_int lst |> printf "%d\n"


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

int main()
{
	int d, n, m, k, res;
	while (cin >> d, d) {
		res = 0;
		cin >> n >> m;
		vector<int> D(n + 1, 0);
		D[n] = d;
		for (int i = 1; i < n; i++) {
			cin >> D[i];
		}
		sort(D.begin(), D.end());
		for (int i = 0; i < m; i++) {
			cin >> k;
			int lb = lower_bound(D.begin(), D.end(), k) - D.begin();
			if (lb != 0) {
				res += min(k - D[lb - 1], D[lb] - k);
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	int n;
	int max;
	int big;
	double mid;
	
	cin >> n;
	vector<int>a(n);
	FOR(i, 0, n - 1) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	max = a[n - 1];
	mid = max / 2.0;
	big = a[0];
	FOR(i, 1, n - 2) {
		if (abs(a[i] - mid) > abs(big - mid)) {
		}
		else {
			big = a[i];
		}
	}
	cout << max << " " << big << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2000+10,inf=0x3f3f3f3f;
int a[maxn],num[maxn],tmp,num1[maxn],tmp1;
int main(){
	int n=read(),k=read(),q=read();
	REP(i,1,n) a[i]=read();
	int ans=inf;
	REP(_,1,n){
		tmp=0;
		for(int i=1,j;i<=n;i=j+1){
			j=i;
			if(a[i]>=a[_]){
				while(a[j+1]>=a[_]) ++j;
				if(j-i+1>=k){
					tmp1=0;
					REP(l,i,j) num1[++tmp1]=a[l];
					nth_element(num1+1,num1+j-i+2-k,num1+tmp1+1);
					REP(l,1,j-i+2-k) num[++tmp]=num1[l];
				}
			}
		}
		if(tmp>=q){
			nth_element(num+1,num+q,num+tmp+1);
			chkmin(ans,num[q]-a[_]);
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;
int main(){
  ll n;cin>>n;
  set<ll> d;
  for(int i=0;i<n;i++){
    ll tmp;cin>>tmp;
    if(d.find(tmp)!=d.end()){
      d.erase(tmp);
    }else{
      d.insert(tmp);
    }

  }
  cout<<d.size()<<endl;
}


Measured memory_bytes: 7720
D = input().split(' ')
N = int(D[0])
K = int(D[1])
Q = int(D[2])

data = {}
for i in range(Q):
  user = str(int(input()) - 1)
  data[user] = data.get(user, 0) + 1
    
for i in range(N):
  if data.get(str(i), 0) + K - Q > 0:    
    print('Yes')
  else:
    print('No')
  



Measured memory_bytes: 10400
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;
const long double eps = 1e-12;

typedef long long ll;
typedef pair<int , int> pt;

#define sz(a) ((int) a.size() )
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)
#define For(i , a , b) for (int i = a ; i <= b ; i++)
#define Ford(i , a , b) for (int i = a ; i >= b ; i--)
#define Rep(i , n) for (int i = 0 ; i < n ; i++)

const int maxn = 1000000 + 1912;
string s;
int lenJ[maxn] , lenI[maxn];

void ReadData() {
    cin >> s;
}

void Process() {
    lenJ[0] = s[0] == 'J';
    For(i , 1 , sz(s) - 1) if (s[i] == 'J') lenJ[i] = lenJ[i - 1] + (s[i] == 'J'); else lenJ[i] = 0;
    Ford(i , sz(s) - 1 , 0) if (s[i] == 'I') lenI[i] = lenI[i + 1] + (s[i] == 'I'); else lenI[i] = 0;
    int res = 0;
    int last = 0;
    Rep(i , sz(s)) if (s[i] == 'O') {
        last++;
        if (i - last >= 0 && lenJ[i - last] >= last && lenI[i + 1] >= last) res = max(res , last);
    } else last = 0;
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  //  freopen("/users/youaremysky/documents/workspace/input.inp" , "r" , stdin);
    ReadData();
    Process();
}

Measured memory_bytes: 10096
#include<stdio.h>
#include<iostream>
using namespace std;
int v[101][101];
int k[101];
int d[101],f[101];
int n=0;
int u=0;
int t = 0;
void dfs(int l) {
	//cout << "l==" << l << endl;
	if (!d[l]) {
		d[l] = ++t;
	}
	for (int i = 0; i <= n; i++) {
		if (!d[v[l][i]]) {
			dfs(v[l][i]);
		}
	}
	f[l] = ++t;
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> v[u][j];
		}
	}
	for (int i = 0; i < n; i++) {
		f[i] = -1;
	}
	for (int i = 0; i < n; i++) {
		if (!d[i]) {
			dfs(i);
		}
	}

	for (int i = 1; i < n + 1; i++) {
		cout << i << " " << d[i]-2 <<" "<< f[i]-2 << endl;
	}

	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n), cnt(100010, 0);
    for(int i=0; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }

    int ans=0;
    for(int i=0; i<100000; i++){
        if(i==0){
            ans=cnt[i]+cnt[i+1];
        }
        else if(i==99999){
            ans=max(ans, cnt[i-1]+cnt[i]);
        }
        else{
            ans=max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
        }
    }
    cout << ans << endl;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
template<typename T>
void pr(T a){
  cout<<a<<endl;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,r;cin>>n>>r;
  if(n>=10)pr(r);
  else pr(r+100*(10-n));
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int stairs(){

  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1);
  for(int i=0;i<m;i++){
	int a;
	cin >> a;
	broken[a] = true;
  }
  vector<int> dp(n+2);
  const int mod = 1000000007;
  dp[n] = 1;
  for (int i=n-1; i>=0; i--){
	if(broken[i]){
	  dp[i] = 0;
	  continue;
	}
	dp[i] = (dp[i+1] + dp[i+2]) % mod;
  }
  cout << dp[0] << endl;
}

int main(){

  stairs();

  return 0;
}



Measured memory_bytes: 640
s = input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")

"""
#failed
import itertools

s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]

for i,_ in enumerate(add,1):
	for j in itertools.permutations(add,r=i):
		t.append("".join(j))

print(t)

temp=False
for i in range(len(t)):
	if(s==t[i]):
		temp=True
		break

if temp==True:
	print("Yes")
else:
	print("No")
	

"""

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,n,C;
while(cin>>n){
C=0;
a=0;
b=0;
c=0;
d=0;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
for(int k=0;k<10;k++){
for(int l=0;l<10;l++){
if(a+b+c+d==n){C++;}
d++;}
d=0;
c++;}
c=0;
b++;}
b=0;
a++;}
cout<<C<<endl;}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>

#include <cmath>
using namespace std;
typedef long long ll;

int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}


int main() {
    
    int N = in();
    int x = in();
    
    vector<int> v;
    int temp;
    
    ll ans = 0;
    
    for(auto i = 0; i<N; i++){
        cin >> temp;
        ans += temp;
        v.push_back(min(temp,x));  ///条件を満たすまで一様に減らす。
        
    }
    
    if (v.size()==1){ //corner
        cout << ans << endl;
        return 0;
    }
    
    for(auto i = (++v.begin()); i!= v.end(); i++){
        auto j = i;
        *i = min(*i,x-*(--j));
        
    }
    
    
    ll out = ans;
    
    for(auto i: v){
        out -= i;
    }
    
    cout << out << endl;
    return 0;
    
}




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

int main() {
  string S1,S2;
  cin >> S1 >> S2;
  if(S1[0]==S2[2] && S1[1]==S2[1] && S1[2]==S2[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 768
n, y = map(int, input().split( ))
if y > n*10000 or y < n*1000:
  print(-1, -1, -1)
  exit()
#面倒なのでnは1000で割っておく. 
y = y//1000
s = 0
for i in range(0,n+1):
  s = 10*n- 9*i
  if s == y:
    print(n- i, 0, i)
    exit()
  for j in range(1, n-i+1):
#    print(i,j, n-i-j)
    s -= 5
    if s == y:
      print(n-i-j, j, i)
      exit()
print(-1, -1, -1)
  
  
  

Measured memory_bytes: 9188
#include <stdio.h>
int main(void){
  int x,y,z;
  int a,b;
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&z);
  a=x;
  x=y;
  y=a;
  b=x;
  x=z;
  z=b;
  printf("%d %d %d\n",x,y,z);
  return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <vector>

int min(int a, int b)
{
    return a < b ? a : b;
}

int min(int a, int b, int c)
{
    return min(a, min(b, c));
}

int main()
{
    int N, Ma, Mb;
    scanf(" %d %d %d", &N, &Ma, &Mb);
    int a[N], b[N], c[N];
    for(int i=0; i<N; i++) scanf(" %d %d %d", &a[i], &b[i], &c[i]);

    int w[N], jmax = 8000;
    for(int i=0; i<N; i++) w[i] = a[i]*Mb - b[i]*Ma;
    std::vector<std::vector<int> > dp(N+1, std::vector<int>(jmax, 1e+9));
    for(int i=1; i<=N; i++){
        for(int j=0; j<jmax; j++){
            if(j - w[i-1] >= jmax || j - w[i-1] < 0) dp[i][j] = dp[i-1][j];
            else if(j == w[i-1]+4000){
                dp[i][j] = min(c[i-1], dp[i-1][j-w[i-1]] + c[i-1], dp[i-1][j]);
            }
            else dp[i][j] = min(dp[i-1][j-w[i-1]] + c[i-1], dp[i-1][j]);
        }
    }
    if(dp[N][4000] > 1e+8) std::cout << -1 << std::endl;
    else std::cout << dp[N][4000] << std::endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  ll x; cin >> x;
  ll a = x / 500;
  ll b = (x % 500) / 5;
  ll ans = a * 1000 + b * 5;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pll>
#define eb emplace_back
#define MAX 999999999999999
int main(){
	ll n, ans = 0;
	cin >> n;
	for (int i = 2; i <= 2000000; i++){
		if (n % i == 0){
			ll c = 0, bruh;
			while (n % i == 0) n /= i, c++;
			for (int j = 1; j < 100; j++){
				if (c < (j * (j + 1) / 2)){
					bruh = j;
					break;
				}
			}
			ans += bruh - 1;
		}
	}
	if (n != 1) ans++;
	printf("%lld\n", ans);
}

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

int main() {
    ll n;
    cin >> n;

    ll ans = 0;
    for (ll i = 2; i * i < n; i++) {
        int cnt = 0;
        while (n % i == 0) n /= i, cnt++;
        for (int j = 1; j <= cnt; j++) cnt -= j, ans++;
    }

    if (n != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
 
int mymin(int a, int b, int c) {
    int tmp = a;
    if (tmp > b)tmp = b;
    if (tmp > c)tmp = c;
    return tmp;
}
 
using namespace std;
 
int main() {
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int c, a, n, ct = 0;
        cin >> c >> a >> n;
        ct += mymin( c ,a ,n );
        c -= ct, a -= ct, n -= ct;
        if (a > 0 && c > 0 && a * 2 > c)ct += (c / 2);
        else if(c != 0)ct += (a + ((c - a * 2) / 3));
        cout << ct << endl;
 
    }
    return 0;
}
 

Measured memory_bytes: 1164