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

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int[] a = {1,5,10,50,100,500};
		int[] b = new int[6];

		int sum = 0;

		for(int i = 0; i < 6; i++){
			b[i] = in.nextInt();
			sum += b[i] * a[i];
		}

		int ans = (sum < 1000 ? 0 :1);

		System.out.println(ans);
	}
	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

Measured memory_bytes: 26400
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define repl(k,n) for(k=0;k<n;++k)

int main() {
	int A, B, C;
	int K;
	int i;
	cin >> A >> B >> C >> K;
	for (i = 0; i < K; i++) {
		if (B >= C) {
			C = 2*C;
		}else if (A >= B) {
			B = 2 * B;
		}
	}
	if (A < B && B < C) cout << "Yes";
	else cout << "No";
	return 0;
}

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	fast_io;
	
	ll n,p=100,ans=0,r;
	cin>>n;
	while(p<n)
	{
	    r=p/100;
	    p+=r;
	    ans++;
	}
	cout<<ans;
	return 0;
}


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

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

void extgcd(int a, int b, int& x, int& y){
    if(b != 0){
        extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return;
}

int main(){
    int n, m, x, y;
    cin >> n >> m;
    int g = gcd(n, m);
    extgcd(n / g, m / g, x, y);
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <map>

std::string str;

bool check(int x) {
  int len = str.length();
  std::map<std::string, int> m;
  for (int l = 0; l + x <= len; ++l) {
    auto sub_str = str.substr(l, x);
    if (m.find(sub_str) != m.end()) {
      if (m[sub_str] + x <= l) 
        return true;
    } else {
      m[sub_str] = l;
    }
  }
  return false;
}

int solve(int n) {
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    // std::cout << "check " << mid <<" "<< check(mid) << std::endl;
    if (check(mid)) l = mid;
    else r = mid;
  }
  return l;
}

int main() {
  int n;
  std::cin >> n >> str;
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 6660
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {

	int n = 0, m = 0, l = 0, k = 0;
	cin >> n >> m;

	l = powf(2, m);
	k = m * 1900 + (n - m) * 100;

	cout << l * k << endl;

}

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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  ll a_pos[n], a_neg[n];
  ll ans_pos=0, ans_neg=0;
  cin >> a_pos[0];
  a_neg[0] = a_pos[0];
  if(a_pos[0] <= 0){
    ans_pos += 1-a_pos[0];
    a_pos[0] = 1;
  }
  if(a_neg[0] >= 0){
    ans_neg += a_neg[0]+1;
    a_neg[0] = -1;
  }
  for(int i=1; i<n; i++){
    ll b;
    cin >> b;
    a_pos[i] = a_pos[i-1] + b;
    a_neg[i] = a_neg[i-1] + b;
    if(i%2==1){
      if(a_pos[i] >= 0){
        ans_pos += a_pos[i]+1;
        a_pos[i] = -1;
      }
      if(a_neg[i] <= 0){
        ans_neg += 1-a_neg[i];
        a_neg[i] = 1;
      }
    }else{
      if(a_pos[i] <= 0){
        ans_pos += 1-a_pos[i];
        a_pos[i] = 1;
      }
      if(a_neg[i] >= 0){
        ans_neg += a_neg[i]+1;
        a_neg[i] = -1;
      }
    }
  }
  ll ans = min(ans_pos, ans_neg);
  cout << ans << endl;
  return 0;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    int x;cin>>x;
    int a = x/200;
    cout <<10-a<<endl;
}

Measured memory_bytes: 3628
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C := getInt(), getInt(), getInt()

	ans := "No"
	if A <= C && C <= B {
		ans = "Yes"
	}
	out(ans)
}


Measured memory_bytes: 640
"use strict";

const main = (arg) => {
  const heights = arg
    .trim()
    .split("\n")[1]
    .split(" ")
    .map((item) => Number(item));

  let currentMax = heights[0];
  let stepSum = 0;

  const after = heights.map((height) => {
    if (height < currentMax) {
      const stepSize = currentMax - height;
      stepSum += stepSize;
      currentMax = height + stepSize;
      return stepSize;
    }
    currentMax = height;
    return 0;
  });
  console.log(stepSum);
  // console.log(heights);
  // console.log(after);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 51656
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int k=Integer.parseInt(sc.next());
//String s=sc.next();
//int[] a=new int[n];
//for(int i=0;i<n;i++){}
int ans;
if(n%k==0){ans=0;}else{ans=1;}
System.out.println(ans);
}}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int x,y;

int main() {
  INCANT;
  cin >> x >> y;
  rep(i, x+1) {
    if (y == i*2+(x-i)*4) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3652
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
list = Hash.new(-1)
n.times do |i|
  list[a[i]] += 1
end
list = list.values
b = list.inject(:+)
if b%2 == 0
  puts list.size
else
  puts list.size-1
end

Measured memory_bytes: 16760
#include <bits/stdc++.h>
#define W 100010
using namespace std;
typedef long long ll;
ll w,mp[W];
ll l[W],r[W];

int main(){
  cin>>w;
  
  for(int i=0;i<w+2;i++)l[i]=r[i]=-10000000;
  l[0]=0;
  r[w+1]=0;

  for(int i=1;i<=w;i++) {
    cin>>mp[i];
    if(mp[i]<0) l[i]=r[i]=mp[i];
    if(mp[i]==0)l[i]=r[i]=-10000000;
  }
  w+=2;
  
  for(int i=1;i<w;i++){
    int j=w-i-1;
    if(mp[i]!=0)l[i]=max(l[i],l[i-1]+1);
    if(mp[j]!=0)r[j]=max(r[j],r[j+1]+1);
  }

  //  for(int i=0;i<w;i++)cout<<l[i]<<" ";cout<<endl;
  //for(int i=0;i<w;i++)cout<<r[i]<<" ";cout<<endl;

  ll ans=0;
  for(int i=0;i<=w;i++){
    if(mp[i]<=0)continue;
    ll a=l[i]<0? min(mp[i],abs(l[i])):0;  
    ll b=r[i]<0? min(mp[i],abs(r[i])):0;
    
    // cout <<a<<" "<<b<<endl;
    ans+=max(0LL,max(a,b));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5416
#include <stdio.h>

int main() {
	int a, b, c, d, e;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
	if (a == 0)printf("1");
	if (b == 0)printf("2");
	if (c == 0)printf("3");
	if (d == 0)printf("4");
	if (e == 0)printf("5");
}

Measured memory_bytes: 1648
#include <atcoder/scc>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }

    vector<vector<int>> ans = g.scc();

    cout << ans.size() << "\n";
    for (auto c : ans) {
        cout << c.size() << " ";
        for (auto v : c) {
            cout << v << " ";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 40604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()


int an=0;

void dfs(int cnt, int n, int m, int q, vector<int> a, vector<int> b, vector<int> c, vector<int> d, vector<int> ans){
    if(cnt==n){
        int kari=0;
        //rep(i,n){
        //    cout<<ans[i]<<" ";
        //}
        //cout<<endl;
        rep(i,q){
            if(ans[b[i]-1]-ans[a[i]-1]==c[i]){
                kari+=d[i];
            }
        }
        an=max(an,kari);
    }
    else{
        if(cnt==0){
            rep(i,m){
                vector<int> coans(n);
                rep(i,n) coans[i]=ans[i];
                coans[0]=i+1;
                dfs(cnt+1, n ,m ,q, a, b, c, d, coans);
            }
        }
        else{
            int x=ans[cnt-1];
            for(int i=x; i<=m; ++i){
                vector<int> coans(n);
                rep(i,n) coans[i]=ans[i];
                coans[cnt]=i;
                dfs(cnt+1, n, m, q, a, b, c, d, coans);
            }
        }
    }
}


int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vector<int> a(q), b(q), c(q), d(q);
    rep(i,q) cin>>a[i]>>b[i]>>c[i]>>d[i];
    vector<int> ans(n,0);
    dfs(0, n,m,q,a,b,c,d,ans);
    cout<<an<<endl;
    return 0;
}


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

#define ABS(x) ((x) > 0 ? (x) : -(x))
using namespace std;

const int ARR_SIZE = 1e2+5;

//int arr[ARR_SIZE];



int main() {
  long long x, k, d;
  scanf("%lld%lld%lld", &x, &k, &d);

  long long maxMove = ABS(x) / d;

  if (maxMove >= k) {
    if (x > 0) printf("%lld\n", x-k*d);
    else printf("%lld\n", -x-k*d);
  } else if ((k - maxMove)%2){
    if (x > 0) printf("%lld\n", d-x+maxMove*d);
    else printf("%lld\n", d+x+maxMove*d);
  } else {
    if (x > 0) printf("%lld\n", x-maxMove*d);
    else printf("%lld\n", -x-maxMove*d);
  }
  return 0;
}

Measured memory_bytes: 3776
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U

main = do
  [n,k] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  vs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let r = [ sum mm - sum (take l (takeWhile (< 0) mm))
          | i <- [0..min k n]
          , j <- [0..min (n - i) (k - i)]
          , let l = k - i - j
          , let mm = sort (U.toList (U.take i vs) ++ U.toList (U.drop (n - j) vs))
          ]
  print $ maximum r


Measured memory_bytes: 1020
#include<cstdio>
#include<vector>
#include<functional>
#include<algorithm>
using namespace std;

int main(){
	unsigned N, M;
	scanf("%u %u", &N, &M);
	vector<unsigned> divisor;
	for (unsigned i = 1; i*i <= M; ++i){
	if(!(M%i)){
		divisor.push_back(i);
			if(i != M/i) divisor.push_back(M/i);
		}
	}
	sort(divisor.begin(), divisor.end(), greater<unsigned>());
	for(unsigned gcd : divisor){
		if(M/gcd >= N){
			printf("%u\n", gcd);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;
using VLL = vector<long long>;
using VLL2D = vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n;
	cin >> n;
	VI a(n);
	VI b(n);
	REP(i, n) { cin >> a[i]; }
	REP(i, n) { cin >> b[i]; }

	ll result = 0;
	REP(i, n) {
		if(b[i] < a[i]) {
			result += (b[i] - a[i]);
		} else {
			result += (b[i] - a[i]) / 2;
		}
	}
	cout << (result < 0 ? "No" : "Yes") << endl;

	return 0;
}


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

int main(){
  ll n, d[2][101], cnt = 0, ans = 0;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> d[0][i] >> d[1][i];
  for(int i = 0; i < n; i++){
    if(d[0][i]==d[1][i]) cnt++;
    else cnt = 0;
    if(cnt == 3) ans++;
  }
  if (ans) cout <<"Yes" ;
  else cout << "No";
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

int main()
{
	int n;
	int s[10000];
	double ave[1000] = { 0 };
	double std[1000] = { 0 };

	int i, j=0;

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

		for (i = 0; i < n; i++)
		{
			scanf("%d", &s[i]);
			ave[j] += s[i];
		}
		ave[j] /= n;

		for (i = 0; i < n; i++)
		{
			std[j] += (pow(s[i] - ave[j], 2));
		}

		std[j] = sqrt(std[j] / n);

		j++;
	}

	for (i = 0; i < j; i++)
		printf("%lf\n", std[i]);

	return 0;
}



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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

int _runtimeTerror_()
{
    string s;
    cin>>s;
    int sum=0;
    for(auto j:s)
        sum+=j-'0';
    sum%=9;
    cout<<(sum?"No":"Yes");
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 3748
<?php
fscanf(STDIN, "%d %d", $N, $Y);
 
$k1 = $k5 = $k10 = 0;
$ans = array();
 
$tmp = $Y / 1000;
$k10max = floor($tmp / 10);
for ($i = $k10max; $i >= 0; $i--) {
    $k1 = $tmp - $i * 10;
    $k10 = $i;
 
    if ($k10 + $k1 == $N) {
        $ans[] = array("k10" => $k10, "k5" => 0, "k1" => $k1);
    } else if ($k10 + $k1 > $N) {
        $rdc = $k10 + $k1 - $N;
        if ($rdc % 4 === 0) {
            $k5 = $rdc / 4;
            $k1 -= $k5 * 5;
 
            if ($k1 >= 0) {
                $ans[] = array("k10" => $k10, "k5" => $k5, "k1" => $k1);
            }
        }
    }
}
 
if (count($ans) == 0) {
    echo "-1 -1 -1" . "\n";
} else {
    printf("%d %d %d\n", $ans[0]['k10'], $ans[0]['k5'], $ans[0]['k1']);
}


Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e10;

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

  int N;
  ll T;
  cin>>N>>T;
  vector<ll> A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];

  vector<int> zero;
  vector<int> ord;
  rep(i,N){
    if(A[i]==0) zero.push_back(i);
    else ord.push_back(i);
  }

  sort(ord.begin(),ord.end(),[&](int a,int b){
    return (A[a]*(B[b]+1)>A[b]*(B[a]+1));
  });

  int M=ord.size();
  vector<vector<ll>> dp(M+1,vector<ll> (32,INF));
  dp[0][0]=0;
  for(int i=0;i<M;i++){
    int now=ord[i];
    for(int j=0;j<=30;j++){
      if(dp[i][j]==INF) continue;
      chmin(dp[i+1][j],dp[i][j]);

      ll neco=A[now]*(dp[i][j]+1)+B[now];
      if(dp[i][j]+1+neco<=T) chmin(dp[i+1][j+1],dp[i][j]+1+neco);
    }
  }

  int P=zero.size();
  sort(zero.begin(),zero.end(),[&](int a,int b){
    return B[a]<B[b];
  });
  int ans=0;
  int pos=0;
  ll zs=0;
  for(int j=30;j>=0;j--){
    ll val=dp[M][j];
    if(val==INF) continue;
    while(pos<P&&val+zs+1+B[zero[pos]]<=T){
      zs+=B[zero[pos]]+1;
      pos++;
    }
    chmax(ans,j+pos);
  }
  cout<<ans<<endl;

  return 0;
}


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

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var dice1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dice2 = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(dice1.SequenceEqual(dice2) || "RRRNRRRNRRRSRRRSRRRNRRR".SkipWhile(c => !dice1.Roll(c).SequenceEqual(dice2)).Any() ? "Yes" : "No");
        }
    }
    static class Ex {
        public static int[] Roll(this int[] dice, char c) {
            switch (c) {
                case 'N':
                    Move(dice, 0, 1, 5, 4);
                    break;

                case 'S':
                    Move(dice, 0, 4, 5, 1);
                    break;

                case 'E':
                    Move(dice, 0, 3, 5, 2);
                    break;

                case 'W':
                    Move(dice, 0, 2, 5, 3);
                    break;
                
                case 'R':
                    Move(dice, 1, 2, 4, 3);
                    break;

                case 'L':
                    Move(dice, 1, 3, 4, 2);
                    break;
            }

            return dice;
        }

        static void Move(int[] dice, int a, int b, int c, int d) {
            var tmp = dice[a];
            dice[a] = dice[b];
            dice[b] = dice[c];
            dice[c] = dice[d];
            dice[d] = tmp;
        }
    }
}



Measured memory_bytes: 18352
#include <iostream>
     
    using namespace std;
     
    int n,k;
    int dp[100001]={0};
     
    int func(int *a){
        dp[n-1]= 0;
      for(int i=n-2;i>=0;i--){
      	    int b=a[i]-a[i+1],c;
            if(b<0)
                b=-b;
            dp[i]=dp[i+1]+b;
            for(int j=2;j<=k;j++)
                if(j+i<n){
                c=a[i]-a[j+i];
                if(c<0)
                    c=-c;
                dp[i]=min(dp[i],dp[j+i]+c);
                    
                }
                else break;
      }return dp[0];
    }
     
    int main()
    {
       cin>>n>>k;
       int a[n];
       for(int i=0;i<n;i++)
        cin>>a[i];
        cout<<func(a);
    }

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        ArrayList<int[]> jobList = new ArrayList<>();

        for (int i = 0; i < n; i++) {
        	int[] status = new int[2];
        	status[0] = input.nextInt();
        	status[1] = input.nextInt();
        	jobList.add(status);
        }

        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.valueOf(o1[1]).compareTo(Integer.valueOf(o2[1]));
            }
        };

        Collections.sort(jobList, comparator);

        long sum = 0;

        for (int[] job: jobList) {
        	sum += job[0];
        	if (job[1] - sum < 0) {
                System.out.println("No");
                return;
        	}
        }
        System.out.println("Yes");

    }
}


Measured memory_bytes: 160024
N, M = map(int, input().split())
ka = [list(map(int, input().split())) for i in range(N)]

l = []
for i in range(N):
    for j in ka[i][1:]:
        l.append(j)

ans = 0
for i in range(M):
    if l.count(i+1) == N:
        ans += 1

print(ans)


Measured memory_bytes: 9188
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i==0 or i==H-1 or j==0 or j==W-1:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
    print()


Measured memory_bytes: 7004
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
#include <memory.h>
using namespace std;
#define N 51
#define mod 1000000007
#define ll long long

int add(int x, int y) {
	int ret = (x + y);
	if (ret < 0) {
		ret += mod;
	}
	else if (ret > mod) {
		ret -= mod;
	}
	return ret;
}
int mul(int x, int y) {
	return (ll)x*y%mod;
}
const int M = N * N * 4;

int dp[2][N][N][M];


void solve() {
	int cur = N * N * 2, k, n;
	scanf("%d %d", &n, &k);
	int bit = 0, x, y, v, mx, my, nx, ny, nv,cdp;
	dp[bit][0][0][cur] = 1;
	for (int i = 1; i <= n; ++i) {
		int nbit = bit ^ 1;
		memset(dp[nbit], 0, sizeof(dp[nbit]));
		for(x=0;x<i;++x)
			for (y = 0; y < i; ++y)
				for (v = 0; v < M; ++v) {
					if (dp[bit][x][y][v] == 0) continue;
					dp[nbit][x][y][v] = add(dp[nbit][x][y][v], dp[bit][x][y][v]);

					for (mx = 0; mx < 2; ++mx) {
						for (my = 0; my < 2; ++my) {
							nx = x, ny = y, nv = v;
							cdp = dp[bit][x][y][v];
							if (mx == 0) {
								++nx; nv -= i;
							}
							else {
								--ny, nv += i;
								cdp = mul(cdp, y);
							}
							if (my == 0) {
								++ny; nv -= i;
							}
							else {
								cdp = mul(cdp, x);
								--nx, nv += i;
							}
							if (nx >= 0 && ny >= 0 && nv >= 0) {
								dp[nbit][nx][ny][nv] = add(dp[nbit][nx][ny][nv], cdp);
							}
						}
					}
				}
		//end
		bit = nbit;
	}
	printf("%d\n", dp[bit][0][0][cur + k]);
}

int main()
{
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;
}


Measured memory_bytes: 211712
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a) memset((a),0,sizeof(a))
#define MCLR(a) memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
typedef pair<int,string> PIS;
 
const int INF = 0x3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-4,0,4};



int main(){
	map<string,int> ans;
	set<string> used;
	string now = "01234567";

	used.insert(now);
	ans[now] = 0;

	priority_queue<PIS, vector<PIS>, greater<PIS> > que;
	que.push(PIS(0,now));
	while(!que.empty()){
		PIS use = que.top();
		que.pop();

		int idx = 0;
		REP(i,8){
			if(use.second[i] == '0'){
				idx = i;
			}
		}
		if(idx != 0 && idx != 4){
			string ns = use.second;
			swap(ns[idx],ns[idx-1]);
			if(used.count(ns) == 0){
				used.insert(ns);
				ans[ns] = use.first+1;
				que.push(PIS(use.first+1,ns));
			}
		}
		if(idx != 3 && idx != 7){
			string ns = use.second;
			swap(ns[idx],ns[idx+1]);
			if(used.count(ns) == 0){
				used.insert(ns);
				ans[ns] = use.first+1;
				que.push(PIS(use.first+1,ns));
			}
		}
		if(idx < 4){
			string ns = use.second;
			swap(ns[idx],ns[idx+4]);
			if(used.count(ns) == 0){
				used.insert(ns);
				ans[ns] = use.first+1;
				que.push(PIS(use.first+1,ns));
			}
		}
		if(3 < idx){
			string ns = use.second;
			swap(ns[idx],ns[idx-4]);
			if(used.count(ns) == 0){
				used.insert(ns);
				ans[ns] = use.first+1;
				que.push(PIS(use.first+1,ns));
			}
		}
	}

	char buf;
	while(cin >> buf){
		string str = "";
		str += buf;
		REP2(i,1,8){
			cin >> buf;
			str += buf;
		}

		cout << ans[str] << endl;
	}
}

Measured memory_bytes: 5336
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007

const int maxn = 3010;

int dp[maxn][maxn];

string getLCS(string& s, string& t, int len)
{
	string ans;
	int i = 0, j = 0;
	while (len > 0)
	{
		if (s[i] == t[j])
		{
			ans.push_back(s[i]);
			i++;
			j++;
			len--;
		}
		else
		{
			if (dp[i][j + 1] > dp[i + 1][j])
				j++;
			else
				i++;
		}
	}
	return ans;
}
int lenLCS(string& s, string& t, int i, int j)
{
	if (i >= s.length() or j >= t.length())
	{
		return 0; // one of the string is empty
	}
	if (dp[i][j] != -1)
		return dp[i][j];

	if (s[i] == t[j])
	{
		return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
	}
	else
	{
		return dp[i][j] = max(lenLCS(s, t, i + 1, j), lenLCS(s, t, i, j + 1));
	}
}

string fun(string s, string t)
{
	memset(dp, -1, sizeof(dp));
	int len = lenLCS(s, t, 0, 0);
	return getLCS(s, t, len);
}

void solve()
{
	string s, t;
	cin >> s >> t;
	cout << fun(s, t);

}

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


Measured memory_bytes: 71296
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S,T;
	cin>>S>>T;
	int ci[26];
	rep(i,0,26)ci[i]=i;

	bool ans=true;
	set<int> cset;
	rep(i,0,SZ(S))
	{
		S[i]=ci[S[i]-'a']+'a';
		if(S[i]==T[i])continue;
		if(S[i]!=T[i]&&(cset.find(S[i])!=cset.end()||cset.find(T[i])!=cset.end()))
		{
			ans=false;
			break;
		}
		int idx1,idx2;
		rep(d,0,26)
		{
			if(ci[d]==(S[i]-'a'))idx1=d;
			if(ci[d]==(T[i]-'a'))idx2=d;
		}
		swap(ci[idx1],ci[idx2]);
		S[i]=T[i];
		cset.insert(T[i]);
	}

	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 916
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,n,nxt,code,divi,divj,MAX,sel;
int num[20],dist[20],wei[20],next[36000][20];
double time[36000][20],speed[36000],ttt,tim;

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

	for(i=0;i<n;i++){
		scanf("%d %d %d",&num[i],&dist[i],&wei[i]);
		wei[i]*=20;
	}

	MAX=(int)pow(2.0,n);
	for(i=MAX;i>=0;i--){
		for(j=0,divj=2;j<n;j++,divj*=2){
			if(i%divj>=divj/2)speed[i]+=wei[j];
		}
		speed[i]=2000.0/(speed[i]+70);
	}

	for(code=MAX-2;code>0;code--){
		for(i=0,divi=2;i<n;i++,divi*=2){
			if(code%divi>=divi/2){
				ttt=99999999;
				for(j=0,divj=2;j<n;j++,divj*=2){
					if(code%divj<divj/2){
						tim=time[code+divj/2][j]+abs(dist[i]-dist[j])/speed[code];
						if(tim<ttt){ttt=tim;sel=j;}
					}
				}
				time[code][i]=ttt;
				next[code][i]=sel;
			}
		}
	}

	ttt=99999999;
	for(j=0,divj=2;j<n;j++,divj*=2){
		tim=time[divj/2][j];
		if(tim<ttt){ttt=tim;sel=j;}
	}
	time[0][0]=ttt;
	next[0][0]=sel;


	for(i=0,j=0;i<MAX-1;){
		nxt=next[i][j];
		printf("%s%d",i>0?" ":"",num[nxt]);
		i+=(int)pow(2.0,nxt);
		j=nxt;
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 9084
// Problem Title : Next Alphabet
// Link : https://atcoder.jp/contests/abc151/tasks/abc151_a
// Date : 03-08-2020 23:39:41

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	char c;
	cin >> c;
	c++;
	cout << c << '\n';
	
	return 0;
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N = read.n()
local X = read.N(N)
local ans = 10^9
for p=1,100 do
    local sum = 0
    for i=1,N do
        sum = sum + (X[i] - p) * (X[i]-p)
    end
    ans = math.min(ans, sum)
end
print(ans)

Measured memory_bytes: 888
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int len, result = 0;
len = s.length() - 2;
  for(int i = len; i > 1; i -= 2) {
    if(s.substring(0, i / 2).equals(s.substring(i / 2 , i))) {
      result = i;
      break;
    }
  }
  System.out.println(result);
}}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
//#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch CountMedian | diff CountMedian.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address CountMedian.cpp && ./a.out

/*

 5/31/2020

 5:21-

 */

const int MAX_N=1e6+1;
LL A[MAX_N],B[MAX_N];
int N;

LL f(LL good, LL bad) {
  while(abs(good-bad)>1) {
    LL m=(good+bad)/2;
    LL a=0,b=0,c=0;
    REP(i,N) {
      if(B[i]<m) ++a;
      else if(A[i]>m) ++b;
      else ++c;
    }
    LL l1=a,r1=N-b,l2=N/2-(1-(N%2)),r2=N/2+1;
    bool res=l2>=l1&&r2<=r1;
    dump(m,res,a,b,c,l1,r1,l2,r2);
    (res?good:bad)=m;
  }
  return good;
}
void solve() {
  if(N%2==0) REP(i,N)A[i]*=2,B[i]*=2;
  vector<LL> xs(A,A+N),ys(B,B+N);
  sort(ALL(xs)),sort(ALL(ys));
  LL med1=xs[N/2],med2=ys[N/2];
  if(N%2==0) med1=(med1+xs[N/2-1])/2,med2=(med2+ys[N/2-1])/2;
  LL mina=*min_element(A,A+N),maxb=*max_element(B,B+N);
  LL lb=f(med1, mina-1),hb=f(med2, maxb+1);
  dump(med1,med2,lb,hb);
  cout<<hb-lb+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i]>>B[i];
  solve();

  return 0;
}


Measured memory_bytes: 9488
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	int n;
	cin>>n;
	vector<int> t(n),x(n),y(n);
	rep(i,n){
		cin>>t[i]>>x[i]>>y[i];
	}
	if(t[0]<x[0]+y[0] || (t[0]-(x[0]+y[0]))%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	rep(i,n-1){
		if(t[i+1]-t[i] < abs(x[i+1]-x[i])+abs(y[i+1]-y[i]) || ((t[i+1]-t[i])-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


int N;
int light[100005];
int dp[3][100005] = {};
int main() {
	cin >> N;
	rep(i, N) cin >> light[i];
	for (int i = 1; i < N; i++) {
		if (light[i - 1] != light[i]) {
			dp[0][i] = dp[0][i - 1] + 1;
			dp[1][i] = dp[1][i - 1] + 1;
			dp[2][i] = dp[2][i - 1] + 1;
		}
		else
		{
			dp[1][i] = dp[0][i - 1] + 1;
			dp[2][i] = dp[1][i - 1] + 1;
		}
	}
	int ans = 0;
	rep(i, 3)rep(j, N) ans = max(ans, dp[i][j]);
	cout << ans+1 << endl;

	return 0;
}


Measured memory_bytes: 4660
def insertionSort(A, n, g):
	global cnt

	for i in range(g, n):
		v = A[i]
		j = i - g
		while j >= 0 and A[j] > v:
			A[j + g] = A[j]
			j = j - g
			cnt = cnt + 1
		A[j + g] = v

def shellSort(A, n):
	global m
	global G

	h = 1
	while (True):
		if h > n:
			break
		G.append(h)
		h = 3 * h + 1

	m = len(G)
	G.reverse()

	for i in range(m):
		insertionSort(A, n, G[i])

if __name__ == '__main__':
	N = int(input())
	R = [int(input()) for i in range(N)]

	cnt = 0
	G = []
	m = 0

	shellSort(R, N)

	print(m)
	print(" ".join(map(str, G)))
	print(cnt)
	for i in range(N):
		print(R[i])

Measured memory_bytes: 47556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll d;
    ll n,x,y,ans=0;
    cin>>n>>d;
    d*=d;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        //if(vis[x][y])
        ll t=x*x+y*y;
        if(t<=d)ans++;
    }
    printf("%lld\n",ans);
    return 0;
}


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


int main(){

    ll n, m;
    cin >> n >> m;
    
    vector<pair<bool, ll>> P(n);
    rep(i,n) P[i] = make_pair(false, 0);

    rep(i,m) {
        ll p;
        string s;
        cin >> p >> s;
        --p;
        
        if (P[p].first) continue;
        if (s == "AC") P[p].first = true;
        if (s == "WA") P[p].second += 1;
    }

    ll ans = 0;
    ll penalty = 0;
    rep(i,n) {
        if(P[i].first) {
            ++ans;
            penalty += P[i].second;
        }
    }

    cout << ans << " " << penalty << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
using namespace std;

int main()
{
int x,y; cin>>x>>y;
if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
        cout << "Yes";
else if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
        cout << "Yes";
else if (x==2&&y==2)
        cout << "Yes";
else
    cout<<"No";
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int arr[2*100000+10];
int mp[2*100000+10];

int main() {

  int n;
  cn n;

  for (int i = 0; i < n; ++i)
    {
    	cn arr[i];
    	mp[arr[i]]++;
    }  

  ll res=0;

  for (int i = 0; i < 2*100000+10; ++i)
  {
  	if(mp[i]>=2){
        ll x=mp[i];

  		x=x*(x-1);
  		x/=2;
  		res+=x;
  	}
  }

  for (int i = 0; i < n; ++i)
  {

  	if(mp[arr[i]]>=2){

        if(mp[arr[i]]==2){
          ct res-1;
          nl;
        }	
        else{


        ll x=mp[arr[i]];
  		x=x*(x-1);
  		x/=2;

  		ll y=mp[arr[i]]-1;

            y=y*(y-1);
            y/=2;
            ct res-x+y;nl;


  	}
  		
  	}
  	else {
  		ct res;nl;
  	}
  	
  }




    return 0;
}


Measured memory_bytes: 3712
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; }
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; }
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; }
ll modPow(ll x,ll n,ll mod=MOD){
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod);
}
int main(void){
    ll N;cin>>N;
    vi v(N);
    REP(i,N)cin>>v[i];
    REPS(i,N-1){
        v[i]=GCD(v[i],v[i-1]);
    }
    cout<<v[N-1]<<"\n";
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

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

	map<int, int> cnt;

	for (int i = 0; i < n; ++i) {
		int x; cin >> x;

		for (int p = 2; p * p <= x; ++p) {
			if (x % p) continue;
			cnt[p] = cnt[p] + 1;
			while (!(x % p)) x /= p;
		}

		if (x != 1) cnt[x] = cnt[x] + 1;
	}

	{
		bool pw = true;
		for (auto kv : cnt)
			if (kv.second != 1) pw = false;
		if (pw) {
			cout << "pairwise coprime" << endl;
			return 0;
		}
	}

	{
		bool sw = true;
		for (auto kv : cnt)
			if (kv.second == n) sw = false;
		if (sw) {
			cout << "setwise coprime" << endl;
			return 0;
		}
	}

	cout << "not coprime" << endl;

	return 0;
}


Measured memory_bytes: 6696
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
	int n;
	ll res=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)res+=1ll*(n-i+2)*(n-i+1)/2;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v)swap(u,v);
		res-=1ll*u*(n-v+1);
	}
	printf("%lld\n",res);
	return 0;
}


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vi64 a(x), b(y), c(z);
  cin >> a >> b >> c;
  vi64 ab;
  rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);
  sort(all(ab));
  reverse(all(ab));
  vi64 abc;
  rep(i, min(k, (int) ab.size())) rep(j, z) abc.push_back(ab[i] + c[j]);
  sort(all(abc));
  reverse(all(abc));
  rep(i, k) cout << abc[i] << endl;
}


Measured memory_bytes: 42984
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define prime 1000000007
#define INF 40000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
signed main(void){
    int n,k;cin>>n>>k;
    int hight[n];rep(i,n)cin>>hight[i];
    vector<int>V(n,0);
    rep(i,k)V[n-i-1]=1;
    int ans=INF;
    do{
        vector<int>see;
        rep(i,n){
            if(V[i])see.push_back(i);
        }
        int now=0,highest=0,sum=0;
        rep(i,n){
            if(i==see[now]){
                if(hight[i]<=highest){
                    highest++;
                    sum+=highest-hight[i];
                }
                now++;
            }
            highest=max(highest,hight[i]);
        }
        ans=min(ans,sum);
    }while(next_permutation(all(V)));
    cout<<ans<<endl;
}
        


Measured memory_bytes: 256