akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int b, f, r, v;
		int stay[][][] = new int[4][3][10];
		int i, j, k, l, m;
		for(i = 0; i < 4; i++) {
			for(j = 0; j < 3; j++) {
				for(k = 0; k < 10; k++) {
					stay[i][j][k] = 0;
				}
			}
		}
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			for(i = 0; i < n; i++) {
				b = sc.nextInt();
				f = sc.nextInt();
				r = sc.nextInt();
				v = sc.nextInt();
				stay[b-1][f-1][r-1] += v;
			}
			for(i = 0; i < 4; i++) {
				for(j = 0; j < 3; j++) {
					for(k = 0; k < 10; k++) {
						System.out.print(" " + stay[i][j][k]);
					}
					System.out.println();
				}
				if(i < 3) System.out.println("####################");
			}
		}
	}
}




Measured memory_bytes: 29908
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll x;
    cin >> x;
    cout << 1 - x << endl;
    return 0;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	if (a < b) {
	    cout << "a < b" << endl;
	} else if (a > b) {
	    cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
    }
    
    return 0;
    }


Measured memory_bytes: 3108
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var w = Array.ConvertAll(line, int.Parse);
        var a = new long[n];
        var d = new Dictionary<long, long>();
        a[0] = w[0];
        d[a[0] % m] = 1;
        if (d.ContainsKey(0)) d[0]++;
        else d[0] = 1;
        for (int i = 1; i < n; i++)
        {
            a[i] = a[i - 1] + w[i];
            var k = a[i] % m;
            if (d.ContainsKey(k)) d[k]++;
            else d[k] = 1;
        }
        Console.WriteLine(getAns(d));
    }
    public static long getAns(Dictionary<long, long> d)
    {
        var ret = 0L;
        foreach (var x in d.Where(y => y.Value >= 2))
            ret += (x.Value * (x.Value - 1)) / 2L;
        return ret;
    }
}


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

int main(){
	int n,a=0,b=0,c=0;
	cin>>n;
	int s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
		a+=s[i];
		if(s[i]%10!=0) c++;
	}
	sort(s,s+n);
	if(a%10==0){
		while(b<n&&s[b]%10==0) b++;
		if(c==0) a=0;
		else a-=s[b];
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
import numpy as np
S = [[0,0]]
for i in range(n):
  s,p = list(input().split())
  S.append([s,int(p),i])
del S[0]
newarr = sorted(S, key=lambda x:(x[0],-x[1]), reverse=False)
for i in range(n):
  print(newarr[i][2]+1)

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> k;
    vl A;
    rep(i, n) {
        cin >> x;
        A.push_back(x);
    }

    ans = INF;
    set<ll> S;
    vl V(MAX_N, 0);

    for (ll l = 0, r = 0;; l++) {
        while (r < n && S.size() < k) {
            if (A[r] <= k) S.insert(A[r]);
            V[A[r]]++;
            r++;
        }
        if (S.size() < k) break;
        //[l,r)は条件を満たす。
        ans = min(ans, r - l);
        V[A[l]]--;
        if (V[A[l]] == 0) S.erase(A[l]);
    }

    if (ans == INF)
        cout << 0 << endl;
    else
        cout << ans << endl;
}



Measured memory_bytes: 12260
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
    fast();
    ll i,n,w,j;
    cin>>n>>w;
    ll dp[n+2][w+2];
    vector<pair<ll,ll>> a(n);
    rep(i,n)
        cin>>a[i].ss>>a[i].ff;
    for(i=0;i<=n;i++)
        dp[i][0]=0;
    for(i=0;i<=w;i++)
        dp[0][i]=0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(a[i-1].ss<=j)
                dp[i][j]=max(dp[i-1][j],a[i-1].ff+dp[i-1][j-a[i-1].ss]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
    /*
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }
    */
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  int e = 2 * d + 1;
  cout << (n + e - 1) / e << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
// #undef DEBUG
// #define DEBUG
// DEBUG {{{
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT cerr
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<__debug_tap<<"\n";}()
template < class T > inline void dump2D(T &d, size_t sizey, size_t sizex) { for(size_t i = 0; i < sizey; i++) { DEBUG_OUT << "\t"; for(size_t j = 0; j < sizex; j++) DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t"); DEBUG_OUT << endl; } }
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { o << "{"; for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : ", ") << *ite; o << "}"; return o; }
#else
#define dump(...) (42)
#define dump2D(...) (42)
template < class T, class = typename iterator_traits< typename T::iterator >::value_type, class = typename enable_if<!is_same<T, string>::value>::type > ostream &operator<<(ostream &o, const T &a) { for(auto ite = a.begin(); ite != a.end(); ++ite) o << (ite == a.begin() ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  set<string> s;
  string f;
  cin >> f;
  s.insert(f);
  n--;
  while(n--) {
    string t;
    cin >> t;
    // dump(f,t, s.count(t) || f.back() != t.front()) return (cout << "No" << endl, 0);
    if(s.count(t) || f.back() != t.front()) return (cout << "No" << endl, 0);
    s.insert(t);
    f = t;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def parse_str(x):
    ret = {}
    for i, c in enumerate(x):
        ret.setdefault(c, [])
        ret[c].append(i)
    return ret


def main():
    s = input()
    t = input()

    s_parse = parse_str(s)
    t_parse = parse_str(t)

    spos = [pos for pos in s_parse.values()]
    spos.sort()
    tpos = [pos for pos in t_parse.values()]
    tpos.sort()

    if spos == tpos:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};

int N, M, S, T;
vector<int> adj[300000];
ll dist[300000];

ll bfs(){
    REP(i, 3 * N) dist[i] = INT64_MAX;
    dist[S] = 0;
    queue<int> que;
    que.push(S);
    while(!que.empty()){
        int i = que.front();
        que.pop();
        if(i == T) break;
        for(int next : adj[i]){
            if(dist[i] + 1 < dist[next]){
                que.push(next);
                dist[next] = dist[i] + 1;
            }
        }
    }
    return (dist[T] == INT64_MAX) ? -1 : dist[T] / 3;
}

signed main(){
    cin >> N >> M;
    REP(i, M){
        cin >> S >> T;
        adj[S - 1].push_back(T - 1 + N);
        adj[S - 1 + N].push_back(T - 1 + 2 * N);
        adj[S - 1 + 2 * N].push_back(T - 1);
    }
    cin >> S >> T;
    S--; T--;
    PRINT(bfs());
    return 0;
}

Measured memory_bytes: 18944
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Array{Int}(3,n)
	for i in 1:n
		a[:,i] = readline() |> split |> parseMap
	end
	dp = Array{Int}(3,n)
	dp[:,1] = [a[1,1],a[2,1],a[3,1]]
	for i in 2:n
		dp[1,i] = max(dp[2,i-1],dp[3,i-1])+a[1,i]
		dp[2,i] = max(dp[1,i-1],dp[3,i-1])+a[2,i]
		dp[3,i] = max(dp[1,i-1],dp[2,i-1])+a[3,i]
	end
	println(max(dp[1,n],dp[2,n],dp[3,n]))
end

main()


Measured memory_bytes: 175492
// Code for C - Step
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);

  REP(i, N) {
    cin >> A[i];
  }

  ll total = 0;
  ll min = 0;

  REP(i, N) {
    if (A[i] > min) {
      min = A[i];
    } else {
      total += min - A[i];
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 4784
#include <iostream>
using namespace std;
typedef long long ll;
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  ll p = 2;
  ll c = 1;
  for( int i=1; i<N; i++ ){
    ll d = c+p;
    p = c;
    c = d;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) = {
   // val seq = readLine.split("")
    val input=io.Source.stdin.getLines().mkString("\n")
   // println(solve(input).toString.trim())
    val a = input.split("\n")
    println(solve(a(0),a(1)).toString.trim())
   // print(input)
  }
 
 def solve(aaa:String,bbb:String): Int={
  var ctm = aaa.split(" ")(0).toInt + 1
  var gl = aaa.split(" ")(1).toInt
  val parr= bbb.split(" ").map(_ .toInt)
  var ps =0
  var ct =1
  for(i<-0 until ctm){
  	if(ps <= gl){
       val ss= if (i!= ctm-1) parr(i) else 0
    	ps = ps + ss
       ct =i
    }
  }
  ct+1
}
}

Measured memory_bytes: 25544
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

int main() {
	int n;
	int a[100000];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int mem = 0;
	ll sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += a[i];
		if (2 * sum < a[i + 1]) {
			mem = i + 1;
		}
	}
	cout << n - mem << endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int a[4],b,c,d,e,k;
  for(int i=0;i<5;i++)cin>>a[i];
  cin>>k;
  if(a[4]-a[0]<=k)cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int a[21][21];
int h, w;
bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}
int sy, sx, gy, gx;
int d[21][21][4];
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int ans;

void dfs(int y, int x, int level){
    if(level > 10) return;
    rep(i, 0, 4){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(!contain(ny, nx) || a[ny][nx] == 1) continue;
        if(a[ny][nx] == 3){
            chmin(ans, level);
            continue;
        }
        int py = ny, px = nx;
        bool f = true;
        while(1){
            ny = py + dy[i];
            nx = px + dx[i];
            if(!contain(ny, nx)){
                f = false; break;
            }
            if(a[ny][nx] == 1){
                a[ny][nx] = 0;
                break;
            }
            if(a[ny][nx] == 3){
                f = false;
                chmin(ans, level);
                break;
            }
            py = ny; px = nx;
        }
        if(!f) continue;
        dfs(py, px, level + 1);
        a[ny][nx] = 1;
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> w >> h;
        if(h + w == 0) break;
        rep(i, 0, h){
            rep(j, 0, w){
                cin >> a[i][j];
                if(a[i][j] == 2){
                    sy = i; sx = j;
                }
                if(a[i][j] == 3){
                    gy = i; gx = j;
                }
            }
        }
        a[sy][sx] = 0;
        ans = INF;
        dfs(sy, sx, 1);
        cout << (ans == INF ? -1 : ans) << endl;
    }
}


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

long k;
vector<string> anslist;
void aaa(long a,string b) {
  if(b.size()==0) {
    for(char i='1';i<='9';i++) {
      if(a==b.size()+1) anslist.push_back(b+i);
      else aaa(a,b+i);
    }
  } else {
    for(char i=b[b.size()-1]-1;i<=b[b.size()-1]+1;i++) {
      if(i<'0') continue;
      if(i>'9') break;
      if(a==b.size()+1) anslist.push_back(b+i);
      else aaa(a,b+i);
    }
  }
  return;
}

int main() {
  cin >> k;
  for(int i=1;i<11;i++) aaa(i,"");
  cout << anslist[k-1] << endl;
}

Measured memory_bytes: 13936
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

P getE(P p){return p/abs(p);}

double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=1;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                P c1=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,PI/2);
                P c2=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,-PI/2);
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                if(cnt>ans)ans=cnt;
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                if(cnt>ans)ans=cnt;
            }
       // if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 876
N, C = map(int, input().split())
X = [[] for _ in range(C)]
A = []
for _ in range(N):
    s, t, c = map(int, input().split())
    A.append((s, t, c-1))

A = sorted(A)
for s, t, c in A:
    if X[c] and X[c][-1][1] == s:
        X[c][-1][1] = t
    else:
        X[c].append([s-1, t])
Y = []
for x in X:
    Y += x
Z = [0] * 101010
for s, t in Y:
    Z[s+1] += 1
    Z[t+1] -= 1

for i in range(1, 101010):
    Z[i] += Z[i-1]

print(max(Z))


Measured memory_bytes: 32452
#include <stdio.h>

int main(){
   char number[1001];
   int i, sum;
   while(1){
       scanf("%s", number);
       if(number[0]=='0')break;
       sum=0;
       for(i=0;number[i]!='\0';i++){
           sum+=number[i]-'0';
       }
       printf("%d\n", sum);
   }

   return 0;
}


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int T, D, L;

void solve(){
    int ans = 0, t = D;
    rep(_, T){
        int x;
        scanf("%d", &x);
        ++t;
        if(x >= L) t = 0;
        if(_ < T-1) ans += (t < D);
    }
    printf("%d\n", ans);
}

int main(){
    while(scanf("%d%d%d", &T, &D, &L) && T){
        solve();
    }
}


Measured memory_bytes: 3228
h, n = map(int, input().split())
dp = [0] * (h+1)
for i in range(n):
        a, b = map(int, input().split())
        for j in range(1, h+1):
            if i == 0 and j - a <= 0:
                dp[j] = b
            elif i == 0:
                dp[j] = dp[j-a] + b
            elif j - a <= 0:
                dp[j] = min(dp[j], b)
            else:
                dp[j] = min(dp[j], dp[j-a] + b)
print(dp[-1])

Measured memory_bytes: 45148
#include"bits/stdc++.h"
using namespace std;

#define MAX 1000000

int main(){
    int l;
    cin >> l;

    vector<long long> a(l+1, 0);
    for (int i=1;i<l+1;i++){
        cin >> a[i];
    }

    vector<vector<long long>> dp;
    dp.resize(l+1);
    for (int i=0;i<l+1;i++){
        dp[i].resize(5);
    }

    for (int t=1;t<5;t++){
        dp[0][t] = 0;
    }

    for (int i=1;i<l+1;i++){
        int c;
        if (a[i]==0){c = 2;}
        else{c = 0;}
        dp[i][0] = dp[i-1][0] + a[i];
        dp[i][1] = min(dp[i-1][0], dp[i-1][1])+a[i]%2+c;
        dp[i][2] = min(min(dp[i-1][0], dp[i-1][1]), dp[i-1][2])+1-a[i]%2;
        dp[i][3] = min(dp[i-1][2], dp[i-1][3])+a[i]%2+c;
        dp[i][4] = min(dp[i-1][1], min(dp[i-1][2], min(dp[i-1][3], dp[i-1][4])))+a[i];
    }
    
    cout << *min_element(dp[l].begin(), dp[l].end()) << endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
  int main(){
  char a, b;
  cin >> a >> b;
  if(a == b){
    cout << "H\n";
  }
    else{
      cout << "D\n";
    }
  }


Measured memory_bytes: 3592
N, P = map(int, input().split())
A = [int(i)&1 for i in input().split()]
o = A.count(1)
e = N-o
on = en = 0
def ncr(n, r):
    r = min(r,n-r)
    res=1
    d=1
    for i in range(r):
        res*=n-i
        d *= i + 1
    return res//d

for r in range(e+1):
    en+=ncr(e,r)
for r in range(P, o+1, 2):
    on+=ncr(o,r)

print(on*en)

Measured memory_bytes: 60936
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var list = Array(n){0}
    for (i in 0 until n) {
        list[i] = readLine()!!.toInt()
    }
    val sorted = list.sorted()
    for (i in 0 until n) {
        if (list[i] == sorted[n-1]) println(sorted[n-2])
        else println(sorted[n-1])
    }
}


Measured memory_bytes: 57104
import java.util.*;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        int b[] =new int[n -1];
		for(int i = 0; i < n - 1; i++){
			b[i] = sc.nextInt();
        }
        int a[] =new int[n - 2];
        int total = b[0] + b[n - 2];
		for(int i = 0; i < (n - 2); i++){
			if(b[i] < b[i + 1]){
            	a[i] = b[i];
            }else if(b[i] >= b[i + 1]){
            	a[i] = b[i + 1];
            }
        }
        
        for(int i = 0; i < n - 2; i++){
        	total += a[i];
        }
        System.out.println(total);
	}
}

Measured memory_bytes: 35796
#include <algorithm>
#include <array>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

long long choose(vector<int> &ch_pos, int i, int j) {
  auto it = upper_bound(ch_pos.begin(), ch_pos.end(), j);
  long long ans = distance(it, ch_pos.end());
  bool found = binary_search(it, ch_pos.end(), 2 * j - i);
  if (found) {
    ans = max(0ll, ans - 1);
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n;
  string s;
  cin >> n >> s;

  array<vector<int>, 256> ch_pos;
  for (int i = 0; i < n; i++) {
    ch_pos[s[i]].push_back(i);
  }

  array<char, 3> kinds{'B', 'G', 'R'};
  long long ans = 0;
  do {
    for (int i : ch_pos[kinds[0]]) {
      for (int j : ch_pos[kinds[1]]) {
        if (i < j) {
          ans += choose(ch_pos[kinds[2]], i, j);
        }
      }
    }
  } while (next_permutation(kinds.begin(), kinds.end()));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int c[100];

int main() {
  int a,b,t;
  cin >> a >> b >> t;
  c[0] = t;
  for(int i = 0;i < 10;i++){
    c[i+1] = c[i] * a - b;
  }
  
  for(int i = 0;i < 10;i++){
    cout << c[i+1] << endl;
  }
  cout << endl;
}


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

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

vector<int> get_divisors(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    sort(res.rbegin(), res.rend());
    return res;
}

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

    int a, b, k;
    cin >> a >> b >> k;

    int num = gcd(a, b);
    vector<int> divs = get_divisors(num);

    cout << divs[k - 1] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int N, A, B, nat, os, sum;
	nat = 0;
	os = 0;
	sum = nat + os;
	string s;
	cin >> N >> A >> B >> s;
	for (int i = 0; i <= N-1; i++) {
		if (s[i] == 'a') {
			if (sum < A + B) {
				cout << "Yes" << endl;
				nat++;
				sum = nat + os;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b') {
			if (sum < A + B) {
				if (os < B) {
					cout << "Yes" << endl;
					os++;
					sum = nat + os;
				}
				else {
					cout << "No" << endl;
				}
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;


}

Measured memory_bytes: 896
N, M = map(int, input().split())
s_list = list(map(int, input().split()))
t_list = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, M + 1):
        if s_list[i - 1] == t_list[j - 1]:
            dp[i][j] += dp[i - 1][j - 1] + 1
            dp[i][j] %= mod
        dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]
        dp[i][j] %= mod
print((dp[N][M] + 1) % mod)


Measured memory_bytes: 75100
#include<iostream>

using namespace std;
bool prime(int x){
	if(x==2)return true;
	if(x==3)return true;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	int data[1000000];
	data[0]=0,data[1]=0;
	for(int i=2;i<1000000;i++){
		if(prime(i))data[i]=data[i-1]+1;
		else data[i]=data[i-1];
	}
	int n;
	while(cin>>n)cout<<data[n]<<endl;
}

Measured memory_bytes: 5064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>v(N + 1),w(N + 1);
	REP(i,N){
		cin >> v[i + 1] >> w[i + 1];
	}
	int Q;
	cin >> Q;
	vector<vector<pair<int,int>>>query(N + 1);
	REP(q,Q){
		int V,W;
		cin >> V >> W;
		query[V].emplace_back(W,q);
	}
	vector<pair<int,int>>vec;
	vector<int>ans(Q);
	vector<int>dp(100010);
	auto f1 = [&](int now) -> void{
		vector<int>v(vec.size() - 10),w(vec.size() - 10);
		REP(i,vec.size() - 10){
			v[i] = vec[i + 10].first;
			w[i] = vec[i + 10].second;
		}
		REP(i,1ll << v.size()){
			int vs = 0,ws = 0;
			REP(j,v.size()){
				if(!(i & (1ll << j)))continue;
				vs += v[j];
				ws += w[j];
			}
			for(auto[W,idx]:query[now]){
				if(W - ws >= 0)CHMAX(ans[idx],dp[W - ws] + vs);
			}
		}
	};
	auto f2 = [&](int now) ->void {
		vector<int>v(vec.size()),w(vec.size());
		REP(i,vec.size()){
			v[i] = vec[i].first;
			w[i] = vec[i].second;
		}
		REP(i,1ll << v.size()){
			int vs = 0,ws = 0;
			REP(j,v.size()){
				if(!(i & (1ll << j)))continue;
				vs += v[j];
				ws += w[j];
			}
			for(auto[W,idx]:query[now]){
				if(W >= ws)CHMAX(ans[idx],vs);
			}
		}
	};
	auto dfs = [&](auto&&f,int now,int dep) -> void {
		vec.emplace_back(v[now],w[now]);
		if(dep == 10){
			dp = vector<int>(100010,-INF);
			dp[0] = 0;
			REP(i,1ll << 10){
				int vs = 0,ws = 0;
				REP(j,10){
					if(!(i & (1ll << j)))continue;
					auto[value,weight] = vec[j];
					vs += value;
					ws += weight;
				}
				if(ws < 100010)CHMAX(dp[ws],vs);
			}
			REP(i,100009)CHMAX(dp[i + 1],dp[i]);
		}
		if(dep > 10){
			f1(now);
		}else{
			f2(now);
		}
		REP(k,2){
			if(now * 2 + k <= N)f(f,now * 2 + k,dep + 1);
		}
		vec.pop_back();
	};
	dfs(dfs,1,1);
	REP(i,Q){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 19096
#include <stdio.h>

int map[10][2];
int spn;

int abs(int x) {
  if(x < 0) x *= -1;
  return x;
}

int visit(int x, int y, int count) {
  int static d[12][2] = {{ 2, 0}, {2, -1}, {1, -2},{0,-2},
			 {-1,-2}, {-2, -1},{-2, 0},{-2, 1},
			 {-1, 2}, {0, 2},  {1, 2}, {2, 1}};
  int i;
  int nx, ny;
  int spx, spy;
  spx = map[count][0];
  spy = map[count][1];

  for(i = 0; i < 12; i++) {
    nx = x + d[i][0];
    ny = y + d[i][1];
    if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10) {
      if(abs(nx - spx) <= 1 && abs(ny - spy) <= 1) {
	if(count + 1 == spn) {
	  return 1;
	} else {
	  if(visit(nx, ny, count + 1) == 1) {
	    return 1;
	  }
	}
      }
    }
  }
  return 0;
}

int main() {
  int x, y;
  int i, j;

  while(1) {
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0) break;
    scanf("%d", &spn);
    for(i = 0; i < spn; i++) {
      scanf("%d %d", &map[i][0], &map[i][1]);
    }
    if(visit(x, y, 0)) {
      printf("OK\n");
    } else {
      printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
d = {}
for i in range(4):
    if s[i] in d.keys():
        d[s[i]] += 1
    else:
        d[s[i]] = 1
if len(d.items()) != 2:
    print('No')
    quit()
for i in d.items():
    if i[1] != 2:
        print('No')
        quit()
print('Yes')

Measured memory_bytes: 3060
#include<stdio.h>
#include <algorithm>
using namespace std;
int main()
{
  int n,k,sum=0;
  scanf("%d %d", &n, &k);
  int a[n],b[n+1];
  for(int i=0;i<=n;i++) b[i]=0;
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
    b[a[i]]++;
  } 
  sort(b,b+n+1);
  reverse(b,b+n+1);
  for(int i=k;i<=n;i++) sum+=b[i];
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define S second
#define mod 1000000007
#define int long long
using namespace std;
int k[3000000];
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
int nCr(int a, int b) {
	if (b < 0 || a < b)return 0;
	return k[a] * mypow(k[a - b], mod - 2, mod) % mod*mypow(k[b], mod - 2, mod) % mod;
}
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	k[0] = 1;
	f(i, c + d + 2) {
		k[i + 1] = k[i] * (i + 1) % mod;
	}
	cout << (nCr(a + b, a) + nCr(c + d + 2, c + 1) - nCr(a + d + 1, a) - nCr(b + c + 1, b) + mod + mod) % mod << endl;
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(aa) (aa).begin(), (aa).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<pill,int> PA;
//ll MOD;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	ll weight;
};
int A,B,M;
int a[114514];
int b[114514];
int m[114514];
int main(){
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	cin>>A>>B>>M;
	rep(i,A)cin>>a[i];
	rep(i,B)cin>>b[i];
	int mia=a[0],mib=b[0];
	rep(i,A){
		mia=min(mia,a[i]);
	}
	rep(i,B){
		mib=min(mib,b[i]);
	}
	int ans=mia+mib;
	rep(i,M){
		int x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<endl;

}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x = in.nextLong();

        long total = 0;
        for (int i = 1;; i++) {
            if (total >= x) {
                System.out.println(i - 1);
                return;
            }
            total += i;
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int K;
  cin >> K;
  vector<long long> A(K);
  int i;
  for(i=0;i<K;i++)cin >> A[K-i-1];
  long long l = 2,u = 2;
  bool f = true;
  for(i=0;i<K;i++) {
    l = ((l-1)/A[i]+1)*A[i];
    u = (u/A[i]+1)*A[i]-1;
    if(l > u)f = false;
  }
  if(f)cout << l << " " << u << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 4036
#include<stdio.h>
int main() {
	int i, j;
	int n, a, b;
	int sum = 0;
	int num1 = 0;
	int num2 = 0;
	scanf("%d %d %d", &n, &a, &b);
	for (i = 1; i <= n; i++) {
		num1 = i;
		num2 = 0;
		for (j = 10000; j > 0; j = j / 10) {
			num2 += num1 / j;
			num1 = num1 % j;
		}
		if (num2 >= a && num2 <= b)
			sum += i;
	}
	printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int N;
int K;
vll Max;
vll Max2;
vll Ans;
vll A;

int len(ll x)
{
    if (x==0) return 1;
    int ret = 0;
    while (x) {
        x/=2;
        ret++;
    }
    return ret;
}

class f {
public:
    bool operator()(const int i, const int j) const
    {
        if(A[i] > A[j]) return true;
        else if (A[i] == A[j] & i > j) return true;
        return false;
    }
};

int main(int argc, const char * argv[]) {
    cin >> N;
    A = vll((1<<N)+1);
    Max = vll(1<<N);
    Max2 = vll(1<<N, (1<<N));
    for (ll n=0; n<((1<<N)); ++n) {
        cin >> A[n];
        Max[n] = n;
    }

    for (ll n=0; n<1<<N; ++n) {
        for (int k=0; k<=N-1; ++k) {
            ll m = n|(1<<k);
            if (m <= n) continue;
            set<ll, f> Set;
            Set.insert(Max[n]);
            Set.insert(Max[m]);
            Set.insert(Max2[n]);
            Set.insert(Max2[m]);
            auto it  = Set.begin();
            Max[m] = *(it++);
            Max2[m] = *it;
        }
    }
    
    vll Ans(1<<N);
    for (int n=0; n<1<<N; ++n) {
        Ans[n] = A[Max[n]] + A[Max2[n]];
    }
    for (int n=1; n<1<<N; ++n) {
        Ans[n] = max(Ans[n], Ans[n-1]);
        cout << Ans[n] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> cnt(100005);
	rep(i, n) {
		int a;
		cin >> a;
		cnt[a]++;
		if (a - 1 >= 0) cnt[a - 1]++;
		cnt[a + 1]++;
	}
	int ans = *max_element(cnt.begin(), cnt.end());
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 640
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Measured memory_bytes: 19024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  string s;
  cin >> s;

  int q;
  cin >> q;

  vector<int> t(q), f(q);
  vector<char> c(q);
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    if (tmp == 1) {
      t[i] = tmp;
    } else {
      t[i] = tmp;
      cin >> f[i] >> c[i];
    }
  }

  // string ans = s;
  deque<char> ans;

  for (int i = 0; i < s.size(); i++) {
    ans.push_back(s[i]);
  }

  bool rev = false;
  for (int i = 0; i < q; i++) {
    if (t[i] == 1) {
      rev = !rev;
    } else {
      if (f[i] == 1) {
        if (rev) {
          ans.push_back(c[i]);
        } else {
          ans.push_front(c[i]);
        }
      } else {
        if (!rev) {
          ans.push_back(c[i]);
        } else {
          ans.push_front(c[i]);
        }
      }
    }
  }

  if (rev) {
    reverse(ans.begin(), ans.end());
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }

  cout << endl;

  return 0;
}

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

char GradeRank(int m,int f,int r){
    int sum=m+f;
    char Grade;
    if(m==-1||f==-1){
        Grade='F';
    }else if(sum>=80){
        Grade='A';
    }else if(sum>=65&&sum<80){
        Grade='B';
    }else if(sum>=50&&sum<65){
        Grade='C';
    }else if(sum>=30&&sum<50){
        if(r>=50)
            Grade='C';
        else Grade='D';
    }else if(sum<30){
        Grade='F';
    }
    return Grade;
}
int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1)break;
        cout<<GradeRank(m,f,r)<<endl;
    }
    return 0;
    }


Measured memory_bytes: 3084
#include <stdio.h>

int main(){
	
	int d,i,s;
	i=0;
	while(0<=scanf("%d",&d)){
		s=0;
		for(i=0;i<600;i=i+d){
			s=s+i*i*d;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 0
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, k, h[N], dp[N];

inline void readInput() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
}

inline void solve() {
	memset(dp, 63, sizeof dp), dp[0] = 0;
	for (int i = 1; i < n; i++)
		for (int j = max(i - k, 0); j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
	cout << dp[n - 1] << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[100005][4];
int dp[100005][4];
int n;
int f(int day,int game)

{  if (day==n)
return 0;
	if(dp[day][game]!=-1)
	return dp[day][game];
	int maxi=0;
	if(game==0)
	{
	  maxi=max(maxi,a[day][1]+f(day+1,1));
	  maxi=max(maxi,a[day][2]+f(day+1,2));
	  maxi=max(maxi,a[day][3]+f(day+1,3));
	}
	else if(game==1)
	{
		maxi=max(maxi,a[day][2]+f(day+1,2));
		maxi=max(maxi,a[day][3]+f(day+1,3));
	}
	else if(game==2)
	{
		maxi=max(maxi,a[day][1]+f(day+1,1));
	    maxi=max(maxi,a[day][3]+f(day+1,3));
	}
	else if(game==3)
	{
		maxi=max(maxi,a[day][1]+f(day+1,1));
		maxi=max(maxi,a[day][2]+f(day+1,2));
	}
	return dp[day][game]=maxi;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=3;j++)
		{
		
		cin>>a[i][j];}
	}
		memset(dp,-1,sizeof(dp));
		cout<<f(0,0);
		return 0;
	
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, k; cin >> a >> b >> k;
	int cnt = 0;
	int ans = 0;
	for(int i=100;i>=0;i--){
		if(a%i==0 && b%i==0){
			cnt++;
			if(cnt==k){
				ans = i;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define double long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define eb emplace_back
//#define ll long long
//#define int long long
using namespace std;

const int INF = 2e9;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n, r;
	cin >> n >> r;
	if (n <= 10) cout << r + 100 * (10 - n);
	else cout << r;
}

signed main() {
	/*
	freopen("caves.in", "r", stdin);
	freopen("caves.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

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

int main() {
  int n;
  cin >> n;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i];
  }
  sort(data.begin(),data.end());
  for(long long i = data[1];i > 0;i--){
    int c = 0;
    for(int j = 0;j < n;j++){
      if(data[j]%i != 0) c++;
      if(c == 2) break;
    }
    if(c < 2){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 4028
import java.util.Scanner

fun main(args:Array<String>){
    val cin = Scanner(System.`in`)

    while(true){
	val h = cin.nextInt()
	val w = cin.nextInt()

	if(h == 0 && w == 0){
	    break
	}else{
            for(i in 1..h){
	        for(j in 1..w){
	            print("#")
	        }
            print("%n".format())
            }
	    print("%n".format())
	}
    }
}



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

string f(string s,string t){
    string res;
    if(s.size()>t.size()) swap(s,t);
    int sn = s.size(), tn = t.size();
    reverse(s.begin(),s.end()), reverse(t.begin(),t.end());
    int x, y, z = 0;
    rep(i,sn){
        x = s[i] - '0', y = t[i] - '0';
        if(x+y+z<=9){ 
            res += (x + y + z + '0');
            z = 0;
        }else{
            res += (x + y + z) % 10 + '0';
            z = 1;
        }
    }
    if(tn == sn && z == 1) res += '1';
    else if( tn != sn){
        t = t.substr(sn);
        rep(i,tn-sn){
            int x = t[i] + z - '0';
            if(x<=9){ 
                res += x + '0';
                z = 0;
            }else{
                res += x%10 + '0';
                z = 1;
            }
        }
        if(z) res += '1';
    }

    reverse(res.begin(),res.end());
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
/*
    string s,t;
    cin >> s >> t;
    cout << f(s,t) << endl;
*/


    string eq;
	while(cin >> eq){
        if(eq == "") break;

        string x1;
        bool flag = true;
        int i = 0;
        vector<int> y1;
        while(flag){
            if(eq[i] == 'X') y1.push_back(i);
            if(eq[i] != '+'){ x1 += eq[i]; i++; }
            else flag = false;
        }

        string x2;
        i++;
        eq = eq.substr(i);
        flag = true; i = 0;
        vector<int> y2;
        while(flag){
            if(eq[i] == 'X') y2.push_back(i);
            if(eq[i] != '='){ x2 += eq[i]; i++; }
            else flag = false; 
        }

        i++;
        string x3 = eq.substr(i);
        vector<int> y3;
        rep( i, x3.size() ) if(x3[i] == 'X') y3.push_back(i);

        int ans = -1;
        rep(i,10){
            string z1 = x1, z2 = x2, z3 = x3;
            rep(j,y1.size()) z1.replace(y1[j],1,to_string(i));
            rep(j,y2.size()) z2.replace(y2[j],1,to_string(i));
            rep(j,y3.size()) z3.replace(y3[j],1,to_string(i));

            if(f(z1,z2) == z3) ans = i;
        }
        if(ans < 0) cout << "NA" << endl;
        else cout << ans << endl;

    }


    return 0;
}


Measured memory_bytes: 3244
shina = []
N, W = map(int, input().split())

for i in range(N):
    shina.append(list(map(int, input().split())))


def memoize(f):
    table = {}

    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func


@memoize
def dp(n, w):
    if n == 0:
        return 0
    elif w - shina[n - 1][1] >= 0:
        return max(dp(n - 1, w), dp(n - 1, w - shina[n - 1][1]) + shina[n - 1][0])
    else:
        return dp(n - 1, w)


print(dp(N, W))


Measured memory_bytes: 135324