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

vector<string> split(string ss,string s){
    int first=0;
    int end=ss.length();
    vector<string> v;
 
    while(true){
        auto itr=ss.find(s,first);
        //cout << itr << endl;
        if(itr!=string::npos){
            v.emplace_back(ss.substr(first,itr-first));
        }    
        else{
            v.emplace_back(ss.substr(first,end-first));
            return v;
        }
        first=itr+s.length();
    }
}

long long int calc(string s){
    vector<string> v=split(s,"+");
    long long int ans=0;

    for(auto temp:v){
        ans+=stoll(temp);
    }

    return ans;
}

int main(){

    string s;
    cin >> s;
    long long int sum=0;

    vector<string> v;

    for(int bit =0;bit<(1<<(s.length()-1));bit++){
        string ss=s;
        int offset=0;
        for(int i=0;i<(s.length()-1);i++){
            if(bit & (1<<i)){
                ss.insert(ss.begin()+i+1+offset,'+');
                offset+=1;
            }
        }
        sum +=calc(ss);
    }
    
    cout << sum << endl;

    return 0;
}

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

vector<int> getperm(){
    int w;
    cin>>w;
    vector<int> ret = vector<int>{0,1,2};
    
    rep(i,w){
        int p;
        cin>>p;
        if(p==0)swap(ret[0],ret[1]);
        else    swap(ret[1],ret[2]);
    }
    
    return ret;
}

vector<int> f(vector<int> origin, vector<int> comb){
    vector<int> ret(3);
    rep(i,3){
        ret[i] = origin[comb[i]];
    }
    
    return ret;
}

int main(){
    int n;
    cin>>n;
    vector<vector<int>> v;
    map<vector<int>,int> mp;
    rep(i,n){
        vector<int> t = getperm();
        if(mp[t]<2){
            if(mp[t]==0 or t==vector<int>{2,0,1} or t==vector<int>{1,2,0}){
                v.pb(t);
            }}
        mp[t]++;
    }
    
    
    assert(v.size()<=8);
    
    if(mp[vector<int>{2,0,1}]>=3 or
       mp[vector<int>{1,2,0}]>=3 or
       mp[vector<int>{2,1,0}]>=2 or
       mp[vector<int>{1,0,2}]>=2 or
       mp[vector<int>{0,1,2}]>=2 or
       mp[vector<int>{0,2,1}]>=2){
        cout<<"yes"<<endl;
        return 0;
    }
    
    sort(all(v));
    
    do{
        vector<int> t = v[0];
        if(t==vector<int>{0,1,2}){
            cout<<"yes"<<endl;
            return 0;
        }
        for(int i=1;i<v.size();i++){
            t = f(t,v[i]);
            if(t==vector<int>{0,1,2}){
                cout<<"yes"<<endl;
                return 0;
            }
        }
    }while(next_permutation(all(v)));
    
    cout<<"no"<<endl;
}




Measured memory_bytes: 3172
// BFS

package main

import (
	"bufio"
	"os"
		"fmt"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

var p = [15]int{}
var g = [13][4]int {
	// -1は存在しないマス目
	{2,-1,-1,-1},
	{2,5,-1,-1},{0,1,3,6},{2,7,-1,-1},
	{5,-1,-1,-1},{1,4,6,9},{2,5,7,10},{3,6,8,11},{7,-1,-1,-1},
	{5,10,-1,-1},{6,9,11,12},{7,10,-1,-1},
	{10,-1,-1,-1},
}

/*
　  ０ １ ２ ３ ４
 0 |／|／|  |／|／|
 1 |／|　|  |　|／|
 2 |　|　|  |　|　|
 3 |／|　|  |　|／|
 4 |／|／|  |／|／|
*/

var row = [13]int{0,1,1,1,2,2,2,2,2,3,3,3,4}
var col = [13]int{2,1,2,3,0,1,2,3,4,1,2,3,2}

type wolf struct {
	m [13]int
}

type pair struct {
	first wolf
	second int
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func print_board(board [13]int) {
	fmt.Println("--------------------------")
	fmt.Printf("        [%2d]\n", board[0])
	fmt.Printf("    [%2d][%2d][%2d]\n", board[1], board[2], board[3])
	fmt.Printf("[%2d][%2d][%2d][%2d][%2d]\n", board[4], board[5], board[6], board[7], board[8])
	fmt.Printf("    [%2d][%2d][%2d]\n", board[9], board[10], board[11])
	fmt.Printf("        [%2d]\n", board[12])
	fmt.Println("--------------------------")
}

func main() {
	for scanner.Scan() {
		p1, _ := strconv.Atoi(scanner.Text())
		if p1 == -1 {
			break
		}
		p[0]= p1
		scanner.Scan()
		buf1 := strings.Split(scanner.Text(), " ")
		p2, _ := strconv.Atoi(buf1[0])
		p3, _ := strconv.Atoi(buf1[1])
		p4, _ := strconv.Atoi(buf1[2])
		p[1], p[2], p[3] = p2, p3, p4
		scanner.Scan()
		buf2 := strings.Split(scanner.Text(), " ")
		p5, _ := strconv.Atoi(buf2[0])
		p6, _ := strconv.Atoi(buf2[1])
		p7, _ := strconv.Atoi(buf2[2])
		p8, _ := strconv.Atoi(buf2[3])
		p9, _ := strconv.Atoi(buf2[4])
		p[4], p[5], p[6], p[7], p[8] = p5, p6, p7, p8, p9
		scanner.Scan()
		buf3 := strings.Split(scanner.Text(), " ")
		p10, _ := strconv.Atoi(buf3[0])
		p11, _ := strconv.Atoi(buf3[1])
		p12, _ := strconv.Atoi(buf3[2])
		p[9], p[10], p[11] = p10, p11, p12
		scanner.Scan()
		p13, _ := strconv.Atoi(scanner.Text())
		p[12] = p13
		S := make(map[wolf]struct{})
		st := wolf{}
		for i := 0; i < 13; i++ {
			st.m[i] = p[i]
		}
		Q := make([]pair, 0)
		S[st] = struct{}{}
		Q = append(Q, pair{st, 0})
		yet := true
		for len(Q) > 0 {
			at := Q[0].first
			// print_board(at.m)
			cost := Q[0].second
			Q = Q[1:]
			ok := true
			for i :=1; i < 12; i++ {
				if at.m[i] != i {
					ok = false
				}
			}
			if ok {
				// print_board(at.m)
				yet = false
				fmt.Println(cost)
				break
			}
			now := cost
			for i := 0; i < 13; i++ {
				if at.m[i] != 0 {
					now += abs(row[i]-row[at.m[i]]) + abs(col[i]-col[at.m[i]])
				}
			}
			if now > 20 {
				continue
			}
			for i := 0; i < 13; i++ {
				if at.m[i] == 0 {
					for j := 0; j < 4; j++ {
						if ^g[i][j] != 0 {
							at.m[i], at.m[g[i][j]] = at.m[g[i][j]], at.m[i]
							if _, ok := S[at]; !ok {
								S[at] = struct{}{}
								Q = append(Q, pair{at, cost+1})
							}
							at.m[i], at.m[g[i][j]] = at.m[g[i][j]], at.m[i]
						}
					}
				}
			}
		}
		if yet {
			fmt.Println("NA")
		}
	}
}


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define ll long long
#define MAX 10000007
#define PI acos(-1)
#define eps 1e-10

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);

    int n,l;
    vector<string>v;
    string t;

    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        v.push_back(t);
    }

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

    for(int i=0;i<n;i++)
        cout<<v[i];
    cout<<endl;


    return 0;
}


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

#define DEBUG_ENABLED 0
typedef long long int ll;

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

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ab;
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        pair<int, int> p;
        p = make_pair(a, b);
        ab.push_back(p);
        p = make_pair(b, a);
        ab.push_back(p);
    }

    vector<int> order;
    for (int i = 1; i <= N; i++)
    {
        order.push_back(i);
    }

    int counter = 0;
    do
    {
        if (DEBUG_ENABLED)
        {
            for (int i = 0; i < N; i++)
                cout << order.at(i);
            cout << endl;
        }

        ll visited = 0L;
        if (order.at(0) != 1)
        {
            if (DEBUG_ENABLED)
                cout << "pass." << endl;
            continue;
        }
        visited |= (1 << 1);
        for (int i = 1; i <= N - 1; i++)
        {
            int from = order.at(i - 1);
            int to = order.at(i);

            if (DEBUG_ENABLED)
                cout << "from:" << from << " to:" << to << endl;

            bool found = false;
            for (int i = 0; i < ab.size(); i++)
            {
                auto p = ab.at(i);
                if (p.first == from && p.second == to)
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                visited |= (1 << (to));
                if (DEBUG_ENABLED)
                    cout << "marked:" << to << endl;
            }
        }

        if (DEBUG_ENABLED)
        {
            cout << "visited:" << visited << " count:" << __builtin_popcount(visited) << endl;
        }

        if (__builtin_popcount(visited) == N)
        {
            ++counter;
        }
    } while (next_permutation(order.begin(), order.end()));

    cout
        << counter << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#define LL long long
#define maxn 1000009
 
using namespace std;
 
const LL MOD = 1e9+7;
int aa[maxn];
int id[maxn];
LL fact[maxn+5];	//阶乘
LL a[maxn+10];	// 乘法逆元
//LL inv[maxn+10];	//快速幂
 
LL pow(LL x)
{
	LL n = MOD-2;
    LL res=1;
	while(n>0)
	{
	   if(n%2==1)
	   	 res=res*x%MOD;
	   x=x*x%MOD;
	   n>>=1;
	}
	return res;
}
 
void init(){
    a[0] = a[1] = 1;
    fact[0] = fact[1] = 1;
//  inv[1] = 1;
    for(int i = 2; i <= 1000005; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
		a[i] = a[i-1] * pow(i) % MOD;	//m!的MOD次方 = (m-1)!的MOD次方 * m的MOD次方
//      inv[i] = (MOD - MOD/i)*inv[MOD%i]%MOD;
//      a[i] = a[i-1] * inv[i] % MOD;
    }
}
 
LL C(int n, int m){	//乘法逆元
	if(n<0||m<0||n<m)return 0;
    return fact[n]*a[n-m]%MOD*a[m]%MOD;
}
 
int main()
{
	int n,m;
	init();
 
    cin>>n;
    int x1,x2;
    n++;
    for(int i=1;i<=n;i++)
    {
        cin>>aa[i];
        if(id[aa[i]]==0)
        {
            id[aa[i]]=i;
        }
        else
        {
            x1=id[aa[i]];
            x2=i;
        }
    }
   m=n-x2+x1-1;
   for(int i=1;i<=n;i++)
    {
        LL sum=C(n,i)-C(m,i-1);
        sum%=MOD;
        sum=(sum+MOD)%MOD;/////没加这步wa了两发。
        cout<<sum<<endl;
    }
	return 0;
}

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

using namespace std;

int main()
{ 
  int x,i,j,check=1,flag=1;
  bool isPrime=true;
cin>>x;

while(isPrime)
{
for(i=2;i*i<=x;i++)
{ 
  check=1;
  if(x%i==0)
  {
    check=0;
    break;
  }
}
if(check==1)
{
  cout<<x<<endl;
  isPrime=false;
}
else
{
  isPrime=true;
  x++;
}

}

return 0;
}
     


    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
vector<int> ki[220000],ans;
int main()
{
    int n,q;
    cin >> n >> q;
    ans.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    queue<int> que;
    que.push(0);
    vector<bool> vis(n,false);
    while(!que.empty()){
        int now = que.front();que.pop();
        vis[now] = true;
        for(int next :ki[now]){
            if(vis[next])continue;
            ans[next] += ans[now];
            que.push(next);
        }
    }
    rep(i,n)cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 15988
#include <iostream>
#include <cstdio>
using namespace std;
void search(char farm[102][102], int x, int y);
int main(){
    int h,w;
    char farm[102][102];
    while (true) {
        cin>>h>>w;
        if (h==0&&w==0) break;
        for (int i=0; i<h+2; i++) {
            for (int j=0; j<w+2; j++) {
                if(i==0||i==h+1||j==0||j==w+1){
                    farm[i][j]='.';
                }
                else{
                    cin>>farm[i][j];
                }
            }
        }
        
        int ans=0;
        for (int i=1; i<h+1; i++) {
            for (int j=1; j<w+1; j++) {
                if(farm[i][j]!='.'){
                    ans++;
                    search(farm,i,j);
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

void search(char farm[102][102], int y, int x){
    char tmp=farm[y][x];
    farm[y][x]='.';
    if (farm[y][x+1]==tmp) {
        search(farm,y,x+1);
    }
    if (farm[y][x-1]==tmp) {
         search(farm,y,x-1);
    }

    if (farm[y+1][x]==tmp) {
         search(farm,y+1,x);
    }

    if (farm[y-1][x]==tmp) {
         search(farm,y-1,x);
    }

}

Measured memory_bytes: 3936
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<pair<int, int>> vec;
int N, K, result;
char S[100005];

int main()
{
    scanf("%d %d %s", &N, &K, S);
    int count = 1;
    for(int i = 0; i < N; i++)
    {
        if(S[i] != S[i + 1])
        {
            vec.push_back({count, S[i] - '0'});
            count = 0;
        }
        count++;
    }
    vec.push_back({0, -1});
    int hap = 0, feedCount = 0, left = 0, right = 0;
    while(right < vec.size())
    {
        hap += vec[right++].first;
        result = max(result, hap);
        if(vec[right - 1].second == 0)
        {
            feedCount++;
            if(feedCount == K)
            {
                hap += vec[right++].first;
                result = max(result, hap);
                if(vec[left].second != 0)
                {
                    hap -= vec[left++].first;
                }
                hap -= vec[left++].first;
                feedCount--;
            }
        }
    }
    printf("%d", result);
}

Measured memory_bytes: 1528
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll n;

int main(){
	cin>>n;
	ll ans=n/11*2;
	n%=11;
	if(n==0);
	else if(n<=6) ans++;
	else ans+=2;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;

namespace Atcoder0121_3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int t = int.Parse(input[0]);
                int x = int.Parse(input[1]);
                int y = int.Parse(input[2]);

                if (x + y > t)
                {
                    Console.WriteLine("No");
                    Environment.Exit(0);
                }
                else if ((t % 2) != ((x + y) % 2))
                {
                    Console.WriteLine("No");
                    Environment.Exit(0);
                }
            }

            Console.WriteLine("Yes");


        }
    }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<ll, ll> P;


string to_upper(string str) {
    int diff = 'a' - 'A';
    for (int i = 0; i < str.size(); i++) {
        char c = str[i];
        if ('A' <= c && c <= 'Z') {
            c += diff;
            str[i] = c;
        }
    }
    return str;
}


int main() {

    int n;
    cin >> n;

    rep(k, n) {

        string s1, s2;
        cin >> s1 >> s2;
        vector<vector<pair<int, pair<int, int> > > > dp(s1.size() + 1,
                                                        vector<pair<int, pair<int, int> > >(s2.size() + 1));
        for (int i = 0; i <= s1.size(); i++) {
            for (int j = 0; j <= s2.size(); j++) {
                if (i == 0 || j == 0) {
                    dp[i][j] = make_pair(0, make_pair(-1, -1));
                } else {
                    dp[i][j] = dp[i][j - 1];
                    if (dp[i][j].first < dp[i - 1][j].first) {
                        dp[i][j] = dp[i - 1][j];
                    }
                    if (s1[i - 1] == s2[j - 1] && dp[i][j].first < dp[i - 1][j - 1].first + 1) {
                        dp[i][j] = make_pair(dp[i - 1][j - 1].first + 1, make_pair(i - 1, j - 1));
                    }
                }
            }
        }
        vector<char> subseq_stack;
        for (int i = s1.size(), j = s2.size(); i > 0 && j > 0;) {
            pair<int, int> next = dp[i][j].second;
            //make_pair(i,j) = next;
            i = next.first;
            j = next.second;
            if (i < 0 || j < 0) break;
            subseq_stack.push_back(s1[i]); // s1[i] == s2[j]
        }
        cout << subseq_stack.size() << endl;
    }
}


Measured memory_bytes: 14764
N = int(input())
A = [int(input()) for _ in range(N)]

max_num = max(A)
max_ind = A.index(max(A))
for i in range(N):
  if max_ind == i:
    print(max(A[0:i]+A[i+1:N]))
  else:
    print(max_num)
    



Measured memory_bytes: 15808
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())

    # 桁数の差をなるべく小さくする
    # = ルート
    ans = 10000000005
    M = math.ceil(math.sqrt(N))
    for i in range(1, M + 1):
        if N % i == 0:
            ans = min(ans, len(str(N // i)))
    print(ans)


Measured memory_bytes: 39276
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  rep(i, N-K){
    if(A.at(i) < A.at(i+K)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

int main () {
  ll n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  ll m = min({a, b, c, d, e});
  cout << dup(n,m)+4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
int main()
{
       int n,k;
       cin>>n>>k;
       int a[n];
       arrin(a,n);
       memset(dp,0,sizeof dp);
       fri(i,0,a[0]+1){dp[0][i] = 1;}
       fri(i,1,n)
       {
              dp[1][0] = dp[0][0];
              fri(j,1,k+1)
              {
                     dp[1][j] = dp[1][j-1]+dp[0][j];
                     dp[1][j] %= mod;
              }
              for(ll j = k ; j >= 1 ; j--)
              {
                     dp[0][j] = dp[1][j];
                     if(j>a[i])dp[0][j] += (mod-dp[1][j-a[i]-1]);
                     dp[0][j] %= mod;
              }
       }
       cout<<dp[0][k]<<endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;

vector<vector<int> > split_vector(vector<int> &a, int pivot){
    vector<vector<int> > res;
    a.push_back(pivot - 1);
    for(int i = 0; i < a.size(); i++){
        vector<int> tmp;
        while(i < a.size() && a[i] >= pivot){
            tmp.push_back(a[i++]);
        }
        if(tmp.size() != 0) res.push_back(tmp);
    }
    a.pop_back();
    return res;
}

signed main(){
    int n, k, q, ans = INF;
    cin >> n >> k >> q;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> b = a;
    sort(b.begin(), b.end());
    for(int i = 0; i < n; i++){
        vector<vector<int> > d = split_vector(a, b[i]);
        vector<int> c;
        for(int j = 0; j < d.size(); j++){
            sort(d[j].begin(), d[j].end());
            for(int l = 0; l < (int)d[j].size() - k + 1; l++){
                c.push_back(d[j][l]);
            }
        }
        if(c.size() >= q){
            sort(c.begin(), c.end());
            ans = min(ans, c[q - 1] - c[0]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        final long MOD = (long)1e9 + 7;
        
        int N = sc.nextInt();
        
        // A:0, G:1, C:2, T:3
        long[][][][] dp = new long[N+1][4][4][4];
        dp[0][3][3][3] = 1;
        
        for(int i = 1; i <= N; i++){
            for(int j = 0; j < 4; j++){
                for(int k = 0; k < 4; k++){
                    for(int l = 0; l < 4; l++){
                        for(int m = 0; m < 4; m++){
                            
                            if (k == 0 && l == 1 && m == 2) continue;
                            if (k == 1 && l == 0 && m == 2) continue;
                            if (k == 0 && l == 2 && m == 1) continue;
                            if (j == 0 && k == 1 && m == 2) continue;
                            if (j == 0 && l == 1 && m == 2) continue;
                            
                            dp[i][k][l][m] += dp[i-1][j][k][l];
                            if( dp[i][k][l][m] > MOD ) dp[i][k][l][m] %= MOD;
                        }
                    }
                }
            }
        }
        
        long ans  = 0;
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 4; j++){
                for(int k = 0; k < 4; k++){
                    ans += dp[N][i][j][k];
                    if ( ans > MOD ) ans %= MOD;
                }
            }
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N =sc.nextInt();
		int h =sc.nextInt();
		int count=1;
		
		for(int i=1;i<N;i++) {
			int j=sc.nextInt();
			if(j>=h) {
				count++;
				h=j;
			}
		}
		System.out.println(count);
		sc.close();
	}
}


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

#define INF             1e9
#define INFL            1e19
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cout << endl;
#define HOISE           cerr << "hoise" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("alu.txt", "r", stdin)
#define WRITE           freopen("vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)

#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

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

const int MAX = 100 + 2;
const int MAXLOG = log2(MAX) + 2;
const int MAXN = 1e6 + 2;
const int MOD = 1000000007;


int main()
{
//    READ;
//    WRITE;
    FASTIO;

    int r;
    cin >> r;
    cout << r*r;

    return 0;
}




Measured memory_bytes: 256
import math
N, P = map(int, input().split())
root_P = int(math.sqrt(P)) + 5
is_prime = [False] * 2 + [True] * root_P
primes = []
for i in range(2, root_P):
    if is_prime[i]:
        primes.append(i)
        for j in range(i * i, root_P, i):
            is_prime[j] = False
prime_factor = dict()
for p in primes:
    if P % p != 0:
        continue
    prime_factor[p] = 0
    while P % p == 0:
        prime_factor[p] += 1
        P //= p
if P > 1:
    prime_factor[P] = 1
ans = 1
for key in prime_factor:
    if prime_factor[key] >= N:
        ans *= key ** (prime_factor[key] // N)
print(ans)

Measured memory_bytes: 24568
#include <bits/stdc++.h>
using namespace std;
int a[15][15]; 
int main(){
	int n,d;
	cin>>n>>d;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=d;j++){
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++) {
	    for(int j=i+1;j<=n;j++) {
	    	int s=0;
	    	for(int k=1;k<=d;k++) {
	    		s+=pow(a[i][k]-a[j][k],2);
	    	}
	    	for(int l=0;l<=500;l++) {
		        if(s==pow(l,2)) {
		        	ans++;
		        }
	      	}
		}
	}
	cout<<ans;
	return 0;
}


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

namespace _0or1_Swap
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] p = new int[N];
            int[] q = new int[N];
            int count = 0;
            p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (int i = 0; i < N; i++)
            {
                
                q[i] = i + 1;
                
                if(p[i] != q[i])
                {
                    count++;
                }
            }

            if(count <= 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 1e5 + 5;
const int N = 1e5 + 5;
const double PI = acos(-1.0);
int m, n;

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        printf( "%.4lf\n", 2*PI*n );
    }
    return 0;
}


Measured memory_bytes: 3816
from itertools import *

MAX=10**5+1
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]+list(accumulate(a))

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])


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

struct SegmentTree {
	static const int N = 1 << 17;

	struct node {
		node *l = nullptr;
		node *r = nullptr;
		long long seg = 0;
		long long add = 0;
	};

	node *root = nullptr;

	long long getval(node *x) {
		return x ? x->seg + x->add : 0;
	}

	node *update(node *x, int a, int b, long long v, int l, int r) {
		x = x ? new node(*x) : new node();
		if (r <= a || b <= l) return x;
		if (a <= l && r <= b) {
			x->add += v;
			return x;
		}
		x->l = update(x->l, a, b, v, l, (l + r) / 2);
		x->r = update(x->r, a, b, v, (l + r) / 2, r);
		x->seg = min(getval(x->l), getval(x->r)) + x->add;
		return x;
	}

	void update(int a, int b, long long v) {
		root = update(root, a, b, v, 0, N);
	}

	long long query(node *x, int a, int b, int l, int r) {
		if (!x) return 0;
		if (r <= a || b <= l) return 1e17;
		if (a <= l && r <= b) return getval(x);
		long long vl = query(x->l, a, b, l, (l + r) / 2);
		long long vr = query(x->r, a, b, (l + r) / 2, r);
		return min(vl, vr) + x->add;
	}

	long long query(int a, int b) {
		return query(root, a, b, 0, N);
	}
};

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

	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x[i]);
	}

	int L, Q;
	cin >> L >> Q;

	vector<int> a(Q), b(Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d %d", &a[i], &b[i]);
		if (a[i] > b[i]) swap(a[i], b[i]);
		a[i]--; b[i]--;
	}

	vector<vector<int>> pos(n);
	for (int i = 0; i < Q; i++) {
		pos[a[i]].push_back(i);
	}

	vector<SegmentTree> st(n + 1);

	vector<int> ans(Q);

	for (int i = n - 1; i >= 0; i--) {
		int ok = i;
		int ng = n;

		while (ng - ok > 1) {
			int mid = (ok + ng) / 2;

			if (x[mid] - x[i] <= L) {
				ok = mid;
			} else {
				ng = mid;
			}
		}

		st[i] = st[ok];
		st[i].update(i + 1, st[i].N, 1);

		for (int id : pos[i]) {
			ans[id] = st[i].query(b[id], b[id] + 1);
		}
	}

	for (int i = 0; i < Q; i++) {
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 161920
n = int(input())
h = list(map(int, input().split()))

maxi = 0
now = h[0]
cnt = 0
for i in range(1, n):
    if h[i] <= now:
        cnt += 1
        now = h[i]
        maxi = max(maxi, cnt)
    else:
        cnt = 0
        now = h[i]
print(maxi)

Measured memory_bytes: 85136
const bingo = (card,nums)=>{
  'use strict';
  for(let n of nums){
    card.forEach(line =>{
      const i = line.indexOf(n);
      if(i!==-1){line[i] = -1}
    })
  }

  let lines = [
    [card[0][0], card[1][1], card[2][2]],
    [card[2][0], card[1][1], card[0][2]]
  ];
  for (let i = 0; i < 3; i++){
    lines.push([card[0][i],card[1][i],card[2][i]]);
    lines.push([card[i][0],card[i][1],card[i][2]]);
  }

  return lines.some(line=>check_line(line));
};

const check_line = line=>(line.reduce((a,b)=>a+b)) === -3;

function Main(input) {
  const input_ary = input.trim().split('\n')
  const card = [input_ary[0],input_ary[1],input_ary[2]].map(line=>line.split(' ').map(s=>parseInt(s)));
  const nums = input_ary.slice(4).map(n=>parseInt(n));
  const result = bingo(card,nums)
  console.log(result?'Yes':'No');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
def main(m):
    a, b = list(map(int, m.split(' ')))
    if a > b:
        print(int(a + max(a - 1, b)))
    else:
        print(int(b + max(a, b - 1)))
        
if __name__ == '__main__':
    try:
        m = input().strip()
        main(m)
    except EOFError:
        pass


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

bool is_ok(const string& s) {
    int N = (int)s.size();
    rep(i, 0, N / 2) {
        if (s[i] != s[N - i - 1]) {
            return false;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = (int)S.size();
    if (is_ok(S) && is_ok(S.substr(0, N / 2)) && is_ok(S.substr((N + 1) / 2, N / 2))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    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 <iomanip>
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)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<ll> A(n);
    REP(i, n) cin >> A[i];
    sort(A.rbegin(), A.rend());

    // A[lb]: 採用可能, A[ub]: 採用不可能 
    int lb = 0, ub = n;
    while(ub > lb+1) {
        int x = (lb + ub) / 2;
        ll tmp = m * ((p - 1) + (n - 1 - x));
        FOR(i, p-1, x-1) {
            tmp += A[x] + m - A[i];
        }

        if(x <= p - 1) {
            lb = x;
        }
        else if((A[x] + m < A[p-1]) || (tmp < m * (v - 1) )) {
            ub = x;
        } else {
            lb = x;
        }
    }
    cout << lb + 1 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

int a, b, c;

void solve() {
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3572
#include<iostream>
#include<cmath>
#include<vector>
#include<iostream>

#define ll long long
using namespace std;

int main()
{
    ll A, B, C, X;
    cin >> A >> B >> C >> X;
    ll counter=0;
    for (ll i=0; i<=A; i++) {
      for (ll j=0; j<=B; j++) {
        if (X >= 500*i + 100*j && X - 500*i - 100*j <= 50*C) {
          counter++;
        }
      }
    }
    cout << counter;
    return 0;
}


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

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		long X = long.Parse(S[0]);
		long Y = long.Parse(S[1]);

		//カウンター
		long cnt = 0;
		long max = X;

		//maxがYを超えるまで、2をかけ続ける
		while(max <= Y){
				cnt++;
				max *= 2;
			}

		//出力
		Console.WriteLine(cnt);

	}
}



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

int A,B;

int main(){
    cin>>A>>B;
    int ans=0;
    for(int i=1;i<=9;++i){
        for(int j=0;j<=9;++j){
            for(int k=0;k<=9;++k){
                int test=10001*i+1010*j+100*k;
                if(test>=A && test<=B){
                    ++ans;
                }
            }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int p=0;
int base[5];
void goNext(int b){
	if(b==0){
		base[b]++;
		if(base[b]==1)return;
	}
	if(!base[b])return;

	base[b]--;
	base[b+1]++;

}
int main(){
	int n,i,j,out;
	char command[10];
	scanf("%d",&n);
	for(j=0;j<5;j++)base[j]=0;
	for(i=0,out=0;i<n;){
		scanf("%s",command);
		if(!strcmp(command,"HIT")){
			for(j=3;j>=0;j--)goNext(j);
			if(base[3]==1){
				p++;
				base[3]=0;
			}
		}
		else if(!strcmp(command,"HOMERUN")){
			for(j=0;j<3;j++){
				if(base[j]>0)p++;
			}
			p++;
			for(j=0;j<5;j++)base[j]=0;
		}
		else if(!strcmp(command,"OUT")){
			out++;
			if(out==3){
				i++;
				out=0;
				printf("%d\n",p);
				p=0;
				for(j=0;j<5;j++)base[j]=0;
				continue;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))
q = int(input())
p = []
for _ in range(q):
    b, c = map(int, input().split())
    p.append([b,c])

from collections import defaultdict
ddict = defaultdict(lambda: 0)
for A in a:
    ddict[A] += 1


ans =0
for k,v in dict(ddict).items():
    ans += k*v
# print(ans)
# print(ddict)

for P in p:
    bef = P[0]
    aft = P[1]
#     print(ddict[bef])
    diff = +aft*ddict[bef]- bef*ddict[bef]
    print(ans+diff)
    ans += diff
    ddict[aft] += ddict[bef]
    ddict[bef] = 0
#     print(diff)
#     print(ddict)
    
    
    

Measured memory_bytes: 36916
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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

#define P (1'000'000'007)

template<int MOD=P>
struct Mod {
public:
    long long signed value;

    Mod(long long signed val): value(val % MOD) {
        if (value < 0) value += MOD;
    }

    constexpr Mod& operator+=(const Mod& other) noexcept { 
        value += other.value;
        value %= MOD;
        return *this;
    }
    constexpr Mod& operator-=(const Mod& other) noexcept {
        value -= other.value;
        if (value < 0) value += MOD;
        return *this;
    }
    constexpr Mod& operator*=(const Mod& other) noexcept {
        value *= other.value;
        value %= MOD;
        return *this;
    }

    constexpr Mod operator-() noexcept {
         return value == 0 ? 0 : MOD - value;
    }

    constexpr Mod operator+(const Mod& other) const noexcept { return Mod(*this) += other; }
    constexpr Mod operator-(const Mod& other) const noexcept { return Mod(*this) -= other; }
    constexpr Mod operator*(const Mod& other) const noexcept { return Mod(*this) *= other; }
    constexpr bool operator==(const Mod& other) const noexcept { return this->value == other.value; }
    constexpr bool operator!=(const Mod& other) const noexcept { return this->value != other.value; }
};

signed main() {
    int n, k;
    cin >> n >> k;

    vi vp;
    vi vn;
    Mod ans(1);

    rep(i, n) {
        capi(a);
        if (a >= 0) { vp.push_back(a); }
        else { vn.push_back(a); }
    }

    if (vp.empty() && k % 2 == 1) {
        sort(all(vn), greater());
        rep(i, k) {
            ans *= vn[i];
        }
        cout << ans.value;
        return 0;
    }

    if (n == k) {
        rep(i, vp.size()) {
            ans *= vp[i];
        }
        rep(i, vn.size()) {
            ans *= vn[i];
        }
        cout << ans.value;
        return 0;
    }

    sort(all(vp), greater());
    sort(all(vn));

    int pp = 0, pn = 0;

    for(int c = 0; c < k;) {
        if (k - c == 1) {
            ans *= vp[pp];
            break;
        }

        if (pn + 1 >= vn.size() || (pp + 1 < vp.size() && vp[pp] * vp[pp + 1] > vn[pn] * vn[pn + 1])) {
            ans *= vp[pp];
            pp += 1;
            c += 1;
        } else {
            ans *= vn[pn] * vn[pn + 1];
            pn += 2; c += 2;
        }
    }

    cout << ans.value;

    return 0;
}

Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,c,f=0;
  cin>>a>>b;
  vector<vector<int>> d(a,vector<int>(b)),e(250005,vector<int>(4));
  fo(i,a){
    fo(j,b){
      cin>>c;
      d[i][j]=c%2;
    }
  }
  fo(i,a){
    fo(j,b-1){
      if(d[i][j]%2==1){
        d[i][j]--;
        d[i][j+1]++;
        e[f][0]=i;
        e[f][1]=j;
        e[f][2]=i;
        e[f][3]=j+1;
        f++;
      }
    }
  }
  fo(i,a-1){
    for(int j=b-1;j==b-1;j++){
      if(d[i][j]%2==1){
        d[i][j]--;
        d[i+1][j]++;
        e[f][0]=i;
        e[f][1]=j;
        e[f][2]=i+1;
        e[f][3]=j;
        f++;
      }
    }
  }
  cout<<f<<endl;
  fo(i,f){
    fo(j,4){
      cout<<e[i][j]+1;
      if(j==3)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}

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

int main() {
   int S,h,m,s;
   cin >> S;
   h=S/3600;
   m=(S-h*3600)/60;
   s=S%3600%60;
   
   cout<<h<<":"<<m<<":"<<s<<endl;
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
static const int MAX_M=30;
int S[MAX_M];
int main(void){
	int N,M;
		cin >> N >> M;
	int ans=0;
	for(int i=0;i<N;i++){
		int k;
			cin >> k;
		for(int j=0;j<k;j++){
			int a;
				cin >> a;
			a--;
			S[a]++;
			if(S[a]>=N)
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

const ll INF = 1e18;

struct edge {
    int from;
    int to;
    int cost;
};

bool BellmanFord(vector<edge> &es, vector<ll> &dist, int V, int s) {
    dist.resize(V, INF);
    dist.at(s) = 0;
    for (int i = 0; i < V; ++i) {
        for (auto &e : es) {
            if (dist.at(e.from) == INF) continue;
            dist.at(e.to) = min(dist.at(e.to), dist.at(e.from) + e.cost);
        }
    }
    for (auto &e : es) {
        if (dist.at(e.from) == INF) continue;
        if (dist.at(e.to) > dist.at(e.from) + e.cost) return false;
    }
    return true;
}

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

    int N, M;
    cin >> N >> M;
    vector<edge> es;
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        es.push_back(edge{a - 1, b - 1, -1 * c});
    }
    vector<ll> dist(N, INF);
    dist.at(0) = 0;
    for (int i = 0; i < N; ++i) {
        for (auto &e : es) {
            if (dist.at(e.from) == INF) continue;
            dist.at(e.to) = min(dist.at(e.to), dist.at(e.from) + e.cost);
        }
    }
    ll ans = dist.at(N - 1);
    for (int i = 0; i < N; ++i) {
        for (auto &e : es) {
            if (dist.at(e.from) == INF) continue;
            dist.at(e.to) = min(dist.at(e.to), dist.at(e.from) + e.cost);
        }
    }
    if (dist.at(N - 1) == ans) {
        cout << -1 * ans << endl;
    } else {
        cout << "inf" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()

"""
最小値から最大値
の間には絶対収まる
1111155なら1でいい
なら、
各数字のカウントを保持する
"""
char_counts = [0]*(10**5+5)

for a in A:
    char_counts[a] += 1

#  print(char_counts[:10])

ans = 0
for i in range(min(A), max(A)+1):
    ans = max(ans, char_counts[i] + char_counts[i-1] + char_counts[i+1])
print(ans)


Measured memory_bytes: 16280
import sys
input=sys.stdin.readline
from collections import deque

def check(l0,l1,l2):
    return (l2[1]-l1[1])*(l1[0]-l0[0])>=(l1[1]-l0[1])*(l2[0]-l1[0])
def f(l,x):
    return l[0]*x+l[1]
def add_line(a,b):
    while len(deq)>=2 and check(deq[-2],deq[-1],(a,b)):
        deq.pop()
    deq.append((a,b))
def query(x):
    while len(deq)>=2 and f(deq[0],x)>=f(deq[1],x):
        deq.popleft()
    return f(deq[0],x)

n,c=map(int,input().split())
H=list(map(int,input().split()))
DP=[0]*n
deq=deque()
add_line(-2*H[0],H[0]**2+DP[0])
for i in range(1,n):
    DP[i]=query(H[i])+H[i]**2+c
    add_line(-2*H[i],H[i]**2+DP[i])
print(DP[-1])

Measured memory_bytes: 40140
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	int K; cin >> K;
	int L = s.size();
	for (int i = 0; i < L && K >= 0; i++) {
		if (s[i] != 'a') {
			if (26-(s[i]-'a') <= K) {
				K -= 26 - (s[i]-'a');
				s[i] = 'a';
			}
		}
	}
	if (K > 0) {
		s[L - 1] -= 'a';
		s[L - 1] = (s[L - 1] + K) % 26 + 'a';
	}
	cout << s << endl;
}


Measured memory_bytes: 512
#include <iostream>
//#include <string>
//#define rep(i, n) for(unsigned int i = 0; i < (unsigned int)(n); i++)
using namespace std;

int main(){
  long N,A,B;
  cin >> N >> A >> B;
  //Input

  if(A==0){
    cout << 0 << endl;
    //0除算を例外処理
  }else{
    long Ans = 0;

    Ans += (N/(A+B))*A;
    if(N%(A+B) > A){
      Ans += A;
    }else{
      Ans += N%(A+B);
    }
    cout << Ans << endl;
    //青いボールの数を処理
  }
}

Measured memory_bytes: 256