akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
// const int N = 316330;


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);

    string s,t;
    cin >> s >> t;

    int n = sz(s);
    vector<vector<int>> v(n+1,vector<int>(26,-1));
    vector<int> lt(26,-1);

    repD(i,n-1,0) {
        lt[s[i] - 'a'] = i + 1;

        rep(j,26)
            v[i][j] = lt[j];
    }

    int ind = 0,iter = 0;
    rep(i,sz(t)) {
        if(v[ind][t[i] - 'a'] != -1) {
            ind = v[ind][t[i] - 'a'];
        }
        else {
            iter++;
            ind = 0;

            if(v[ind][t[i] - 'a'] == -1) {
                cout << "-1\n";
                return 0;
            }

            ind = v[ind][t[i] - 'a'];
        }
    }
    cout << n * iter + ind << '\n';
}


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

int main(void){
    int n; cin >> n;
    vector<int> A(n);
    for(int i=0; i<n; i++) cin >> A[i];

    ll cnt=0;
    int id=0;

    while(true){
        id=id%n;
        if(A[id]%2==0){
            A[id]/=2;
            cnt++;
            id++;
        }
        else break;
    }

    cout << cnt/n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int w, h, n;
	cin >> w >> h >> n;
	vector<vector<bool>> area(h, vector<bool>(w, true));
	rep(i, n)
	{
		int x, y, a;
		cin >> x >> y >> a;
		switch (a)
		{
		case 1:
			rep(i, h)
			{
				rep(j, x)
				{
					area[i][j] = false;
				}
			}
			break;
		case 2:
			rep(i, h)
			{
				REP(j, x, w)
				{
					area[i][j] = false;
				}
			}
			break;
		case 3:
			rep(i, y)
			{
				rep(j, w)
				{
					area[i][j] = false;
				}
			}
			break;
		case 4:
			REP(i, y, h)
			{
				rep(j, w)
				{
					area[i][j] = false;
				}
			}
			break;
		default:
			break;
		}
	}
	int ans = 0;
	rep(i, h)
	{
		rep(j, w)
		{
			ans += area[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	io.writer.Flush()
}

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func (io *Io) NextInt() int {
	res, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return res
}

func (io *Io) Next() string {
	if io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}

	res := io.tokens[io.nextToken]
	io.nextToken++
	return res
}

func (io *Io) NextLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = io.NextLine()
	}
	return res
}

func (io *Io) NextLine() string {
	if io.nextToken < len(io.tokens) {
		panic("io.nextToken < len(io.tokens)")
	}

	var buffer bytes.Buffer

	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer.Write(line)
		if !isPrefix {
			break
		}
	}

	return buffer.String()
}

func (io *Io) Println(a ...interface{}) {
	var values []string
	for i := 0; i < len(a); i++ {
		values = append(values, "%v")
	}
	io.Printfln(strings.Join(values, " "), a...)
}

func (io *Io) Printfln(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format+"\n", a...)
}

func solve(io *Io, d *Io) {
	N := io.NextInt()

	as := make([][]int, N)
	for i := range as {
		as[i] = make([]int, N-1)

		for j := range as[i] {
			as[i][j] = io.NextInt() - 1 // 0-based
		}
	}

	res := 0
	allCt := 0

	queue := []int{}

	for p := 0; p < N; p++ {
		op := as[p][0]

		if p < op && as[op][0] == p {
			queue = append(queue, p)
		}
	}

	for allCt < N*(N-1)/2 {
		if len(queue) == 0 {
			io.Println(-1)
			return
		}

		toBeChecked := map[int]bool{}
		nextQueueMap := map[int]bool{}

		for _, p := range queue {
			op := as[p][0]
			toBeChecked[p] = true
			toBeChecked[op] = true
			as[p] = as[p][1:]
			as[op] = as[op][1:]
			allCt++
		}

		for p := range toBeChecked {
			if len(as[p]) == 0 {
				continue
			}

			op := as[p][0]
			if as[op][0] == p && !nextQueueMap[op] {
				nextQueueMap[p] = true
			}
		}

		nextQueue := []int{}

		for p := range nextQueueMap {
			nextQueue = append(nextQueue, p)
		}

		queue = nextQueue

		res++
	}

	io.Println(res)
}

func main() {
	io := NewIo()
	defer io.Flush()
	solve(io, nil)
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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<string> vs;
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<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B,C;
ll K;

int main(){
	cin>>A>>B>>C>>K;
	ll res=A-B;
	if(K%2==1) res*=-1;
	cout<<res<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod= 1000000007;

int n;
signed main() {
    cin >> n;
    int ans = n*(n-1)/2;
    cout << ans;
}

Measured memory_bytes: 764
program bt;
var a,b,c,k:integer;
begin
   readln(a,b,c);
   readln(k);
   while (b<=a) and (k>0) do
    begin
       b:=b*2;
       k:=k-1;
     end;
   while (c<=b) and (k>0) do
    begin
       c:=c*2;
       k:=k-1;
     end;
  if (b>a) and (c>b) then write('Yes') else write('No');
  readln;
 end.
   

Measured memory_bytes: 1376
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    REP(i, l, r+1){
        if(i % d  == 0){
            ans++;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf

int main(){

	int n,c=0;
	sf("%d",&n);
	int x[n];

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

	}
	int min=x[0];
	for(int i=0;i<n;i++){
		if(min>x[i]){
			min=x[i];
		}
	}
	for(int i=0;i<n;i++){
		if(min+i!=x[i]){
			c++;
		}
	}
	(c<=2)?pf("YES\n"):pf("NO\n");
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class EBalancedPath {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int H, W;
        in>>H>>W;
        vvc<int> A(H, vc<int>(W)), B(H, vc<int>(W));
        REP(i, H) REP(j, W) in>>A[i][j];
        REP(i, H) REP(j, W) in>>B[i][j];
        vector<vvc<bool>> dp(H, vvc<bool>(W, vc<bool>(12801, false)));
        dp[0][0][abs(A[0][0]-B[0][0])] = true;
        REP(i, H) REP(j, W) REP(k, 12801){
            if(not dp[i][j][k]) continue;
            if(i<H-1){
                dp[i+1][j][abs(k+A[i+1][j]-B[i+1][j])] = true;
                dp[i+1][j][abs(k+B[i+1][j]-A[i+1][j])] = true;
            }
            if(j<W-1){
                dp[i][j+1][abs(k+A[i][j+1]-B[i][j+1])] = true;
                dp[i][j+1][abs(k+B[i][j+1]-A[i][j+1])] = true;
            }
        }
        REP(k, 12801) if(dp[H-1][W-1][k]){
            out<<k<<'\n';
            return;
        }
    }
};


int main() {
	EBalancedPath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

typedef long long ll;
using namespace std;

int N;
vector<ll> A, B;

ll ans;


int main(){
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		ll x;
		scanf("%lld", &x); A.push_back(x);
		scanf("%lld", &x); B.push_back(x);
	}
	for(int i=N-1; i>=0; i--){
		A[i]+=ans; if(A[i]==0)	continue;
		if(A[i]%B[i]==0)	continue;
		ans+=B[i] - (A[i]%B[i]);		
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
 
long long int c[101][101]={0};
 
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            scanf("%d",&c[i][j]);
        }
    }
    long long int cost = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            cost += min(c[i][j], c[j][i]);
        }
    }
    cout << cost << endl;
 
    return 0;
}

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

using namespace std;

int main() {
  string s1,s2;
  
  cin >> s1 >> s2;
  bool good=true;
  if(s1.size()+1 !=s2.size())
    good=false;
  for(int i=0;i<s1.size();i++){
    if(s1.at(i) !=s2.at(i)){
      good=false;  break;
    }
  }
  if(good) cout << "Yes" <<endl;
  else cout << "No" <<endl;
    
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1e9;

const ll INF = 1LL << 60;

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


int main(){
  int n,m,x;cin>>n>>m>>x;
  vector<ll> cs(n);
  vector<vector<ll>> as(n);
  rep(i,n){
    cin>>cs[i];
    rep(j,m){ll a;cin>>a;as[i].pb(a);}
  }
  ll ans=mod;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    ll sums=0;
    vector<ll> res(m);
    bitset<12> s(tmp);
    // (ビット列sに対する処理)
    rep(i,n){
      if(s.test(i)){
        sums+=cs[i];
        rep(j,m){
          res[j]+=as[i][j];
        }
      }
    }
    for(auto y:res){if(y<x)goto bye;}
    chmin(ans,sums);
    bye:1==1;
  }
  if(ans==mod)cout<<-1;
  else cout<< ans;
}


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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M)  //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0) {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) {           //bit計算
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

signed main() {
    int N;
    cin >> N;
    int A[20];
    int x[20][20], y[20][20];
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int i = 1; i < (1 << N); i++) {
        for (int j = 1; j <= N; j++) {
            int bit = (i >> (j - 1)) & 1;
            if (bit == 0) {
                continue;
            }
            for (int k = 1; k <= A[j]; k++) {
                int v = (i >> (x[j][k] - 1)) & 1;
                if (v != y[j][k]) {
                    goto LABEL;
                }
            }
        }
        ans = max(counter(i), ans);
        LABEL:;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int k, n;
  cin >> k >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.push_back(k + a[0]);

  vector<ll> diffs;
  for (int i = 1; i < a.size(); i++) {
    ll diff = a[i] - a[i - 1];
    diffs.push_back(diff);
  }

  sort(all(diffs));
  reverse(all(diffs));

  ll ans = 0;
  for (int i = 0; i < diffs.size(); i++) {
    if (n > 2 && i == 0) continue;
    ans += diffs[i];
  }

  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 6884
n, q = map(int, input().split())
s = input()
ac = [0]*n
for i in range(n-1):ac[i+1] = ac[i] + (s[i:i+2]=="AC")
for i in range(q):
    l,r=map(int,input().split())
    print(ac[r-1]-ac[l-1])

Measured memory_bytes: 7748
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define all(v) (v).begin(),(v).end()
#define clr(a,b) memset((a),(b),sizeof(a))
#define sz size()
#define pb push_back
#define print(x) cout << x << endl
int n,m;
int a = 0;
int ans;
set<int> s;

int main(){
  cin >> n;
  rep(i,0,n){
    cin >> m;
    if(s.count(m))s.erase(m);
    else s.insert(m);
  }
  print(s.sz);
  return 0;
}


Measured memory_bytes: 4864
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int ans = (int)Math.pow(3,n);
        int count = 1;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            if(a[i]%2==0){
                count=count*2;
            }
        }
        
        System.out.println(ans-count);
        
    }
}


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

int main(void){
    int n,k,h,ans=0 ;
    cin >> n >> k ;
    for (int i=0; i<n; i++){
        cin >> h ;
        if (h>=k){
            ans++ ;
        }
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

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

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    union_find uf(n);
    vector<ll> a(m), b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
    }
    ll cnt = n * (n-1) / 2;
    vector<ll> ans(m);
    for(int i = m-1; i >= 0; --i){
        ans[i] = cnt;
        if(!uf.same(a[i], b[i])){
            cnt -= uf.show_size(a[i]) * uf.show_size(b[i]);
            uf.unite(a[i], b[i]);
        }
    }
    rep(i,m) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5248
main = do
   x <- getLine
   let y = words x 
   let a' = head y 
   let b' = last y
   let a = read a' ::Int
   let b = read b' ::Int
   let s' = (*) a  b
   let e = (*) 2 a
   let f = (*) 2 b
   let l' = (+) e f
   let s = show s'
   let l = show l' 
   putStrLn (s ++ " " ++ l)

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

int main() {
    ll n, limit;
    cin >> n >> limit;
    vector<pair<ll, ll>> luggage(n);
    ll quota_max = 0;
    for (int i = 0; i < n; ++i) {
        cin >> luggage[i].first >> luggage[i].second;
        quota_max += luggage[i].second;
    }
    vector<vector<ll>> dp(110, vector<ll>(300300, 1001001001001001));
    dp[0][0] = 0;
    for (int i = 0; i <= n; ++i) {
        ll new_w = luggage[i].first;
        ll new_v = luggage[i].second;
        for (int j = 0; j <= quota_max; ++j) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + new_v] = min(dp[i + 1][j + new_v], dp[i][j] + new_w);
        }
    }
    ll ans = 0;
    for (ll k = 0; k <= quota_max; ++k) if (dp[n][k] <= limit) ans = max(ans, k);
    cout << ans << endl;
}


Measured memory_bytes: 260864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
//cout<<fixed<<setprecision(20);



signed main(){
    int n;cin>>n;
    string s;cin>>s;
    if(n%2==1){
        cout<<"No"<<endl;
    }else{
        rep(i,0,n/2){
            if(s[i]!=s[i+n/2]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;
    }
    

}


//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,output_format?

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=0;
    for (int x = a; x <= b; x++){
        if(c%x==0){d=d+1;}
    }
    printf("%d\n",d);
}



Measured memory_bytes: 2760
import bisect
import math
import sys
input = sys.stdin.readline
#####segfunc######
def segfunc(x,y):    
    return x+y

def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0
#input
data = []
n, d, a = map(int, input().split())
x_point = []
for i in range(n):
    x, h = map(int, input().split())
    data.append([x,h])
    x_point.append(x)
x_point.sort()
data.sort()
##初期化
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
ans = 0
for i in range(n):
    x, h = data[i]
    index = bisect.bisect_left(x_point, x - 2*d)
    sum_damage = query(index, i)
    h -= sum_damage
    count = max(((h+a-1)//a), 0)
    ans += count
    update(i, count * a)
print(ans)

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


Measured memory_bytes: 2112
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> P;

constexpr int INF = 1e9 + 7;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int H,W;
char s[100][100];
int rec[100][100];

void bfs(){
    queue<P> q;
    rec[0][0]=0;
    q.push(P(0,0));
    while(!q.empty()){
        int x=q.front().first,y=q.front().second;q.pop();
        REP(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=0&&nx<W&&ny>=0&&ny<H&&s[ny][nx]=='.'&&rec[ny][nx]==-1){
                rec[ny][nx]=rec[y][x]+1;
                q.push(P(nx,ny));
            }
        }
    }
}

int main(){
    cin>>H>>W;
    REP(i,H)REP(j,W)cin>>s[i][j];
    REP(i,100)REP(j,100)rec[i][j]=-1;
    bfs();
    int cnt=0;
    REP(i,H)REP(j,W)if(s[i][j]=='.') cnt++;
    if(rec[H-1][W-1]==-1) cout << -1;
    else cout << cnt-rec[H-1][W-1]-1;
}





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

using namespace std;

int n, m;
char g[10][10];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%s", g[i]);
    }
    for (int a = 0; a < n; a++) {
        for (int b = 0; b < m; b++) {
            if (g[a][b] == '.') continue;
            for (int c = 0; c < a; c++) {
                for (int d = b+1; d < m; d++) {
                    if (g[c][d] == '#') {
                        puts("Impossible");
                        return 0;
                    }
                }
            }
        }
    }
    puts("Possible");
    return 0;
}

Measured memory_bytes: 256
PROGRAM piyo
      IMPLICIT NONE
      integer(16) :: n,k
      integer(16),allocatable :: p(:)
      real(8),allocatable :: re(:)
      integer(16) :: i,loc,ma,buffer
      
      read*,n,k
      allocate( p(n) )
      read*,p(:)
      
      
      loc = 1;ma = sum( p(1:k) )
      do i = 2,n-k+1
        !buffer = sum( p(i:i+k-1) )
        buffer = buffer - p(i-1) + p(i+k-1)
        if( buffer>ma ) then
          loc = i
          ma = buffer
        end if
      end do
      
      allocate( re(k) )
      re = p(loc:loc+k-1)
      
      
      print*,sum( (re+1.)/2. )
      
      
      END PROGRAM

Measured memory_bytes: 5504
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#define N 1010
#define ll long long
#define mo ((ll)1e9+7)
//10000000000037ll
//21993833369ll
#define db double
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
bool cmp(int a, int b) {return a > b;}
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
int n, m, f[N][N];
char A[N][N];
struct po {
	int x, y;
	po() {}
	po(int a, int b) {x = a, y = b;}
	friend bool operator ==(po a, po b) {
		return (a.x == b.x && a.y == b.y);
	}
} S, T;
deque<po> q;
bool vis[N][N];
void bfs() {
	q.push_back(S);
	mst(f, 0x3f), f[S.x][S.y] = 0;
	while (!q.empty()) {
		po u = q.front();
		q.pop_front();
		if (u == T) {printf("%d\n", f[T.x][T.y]); return;}
		if (vis[u.x][u.y])continue;
		vis[u.x][u.y] = 1;
		rep(i, 0, 4) {
			int nx = u.x + dx[i], ny = u.y + dy[i];
			if (nx < 1 || ny < 1 || nx > n || ny > m || A[nx][ny] == '#' || vis[nx][ny])continue;
			cmin(f[nx][ny], f[u.x][u.y]);
			q.push_front(po(nx, ny));
		}
		rep(i, u.x - 2, u.x + 2)rep(j, u.y - 2, u.y + 2) {
			if (i < 1 || j < 1 || i > n || j > m || A[i][j] == '#' || vis[i][j])continue;
			cmin(f[i][j], f[u.x][u.y] + 1);
			q.push_back(po(i, j));
		}
	}
	puts("-1");
}
int main() {
	n = read(), m = read();
	S.x = read(), S.y = read();
	T.x = read(), T.y = read();
	rep(i, 1, n)scanf("%s", A[i] + 1);
	bfs();
	return 0;
}


Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = lcm(a, b);
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> s(n);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            s[a - 1]++;
        }
    }
    int ans = 0;
    rep(i, n) {
        if (s[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    200010
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")

const  double pi=acos(-1);

using namespace std;


int main()
{


    double a,b,x,n,p,i,j,k,m;

    cin>>a>>b>>x;

    p=a*a*b/2.0;

    if(p<=x)
    {
        k=atan(2*(a*a*b-x)/(a*a*a));
    }
    else
    {
        k=pi/2.0-atan(2*x/(a*b*b));
    }

   k=k*180.0/pi;


   printf("%0.10lf\n",k);

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int i,j,n,x;
  scanf("%d",&n );
for(i=0;i<14;i++){
  for(j=0;j<26;j++){
    x=7*i+4*j;
  if(x==n){
printf("Yes");
return 0;
   }
 }
}
printf("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int sum = accumulate(w.begin(), w.end(), 0);
  auto cal = [&] (int T) {
    int s = accumulate(w.begin(), w.begin() + T, 0);
    return abs(s - (sum - s));
  };
  constexpr int inf = 1 << 30;
  int ret = inf;
  for (int i = 0; i <= n; i++) {
    cmn(ret, cal(i));
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n+10,0);
  a[0] = 1;
  for(int i = 3;i <= n;++i){
    a[i] = a[i-1] + a[i-3];
    a[i] %= INF;
  }
  print(a[n]);
  return 0;
}

Measured memory_bytes: 3624
import heapq

N, M = [int(x) for x in input().split()]
AB = [0] * N

for i in range(N):
    AB[i] = [int(x) for x in input().split()]

AB = sorted(AB)

jobs = set()
answer = 0
nextpush = 0
candidates = []

for day in range(M)[::-1]:
    while nextpush < N:
        a, b = AB[nextpush]
        if day + a <= M:
            heapq.heappush(candidates, (-b, a))
            nextpush+=1
        else:
            break
    if candidates:
        b, a = heapq.heappop(candidates)
        answer -= b
print(answer)





Measured memory_bytes: 31580
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const H = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    let cnt = 0;
    
    for(let i=1; i<N; i++) {
        // 増えたらリセット
        if(H[i-1] < H[i]) {
            answer = Math.max(answer, cnt);
            cnt = 0;
        } else {
            cnt++;
        }
    }
    
    answer = Math.max(answer, cnt);
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17804
import java.util.IntSummaryStatistics;
import java.util.Scanner;
import java.util.stream.IntStream;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		IntSummaryStatistics o=IntStream.range(0,s.nextInt()).map(i->s.nextInt()).summaryStatistics();
		System.out.println(o.getSum()>o.getMax()*2?"Yes":"No");
	}
}

Measured memory_bytes: 29780
#include<stdio.h>

int main(){
  int i,j,k,n,v;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  
  for(k=0;k<n;k++){
    printf("%d",A[k]);
    if(k<n-1){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  
  for(i=1;i<=n-1;i++){
    v=A[i];
    
    for(j=i-1;j>=0&&A[j]>v;j--){
      A[j+1]=A[j];
    }
    A[j+1]=v;
    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k<n-1){
	printf(" ");
      }else{
	printf("\n");
      }
    }
  }
  return 0;
}



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

constexpr int INF =1e9;

int main() {
    int n;
    cin >> n;
    vector<int> v(26, INF);
    for(int i=0; i<n; ++i) {
        string s;
        cin >> s;
        vector<int> w(26, 0);
        for(int j=0; j<s.size(); ++j) {
            w[s[j]-'a']++;
        }
        for(int i=0; i<26; ++i) {
            v[i] = min(v[i], w[i]);
        }
    }
    string res;
    for(int i=0; i<26; ++i) {
        for(int j=0; j<v[i]; ++j) {
            res += 'a' + i;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
ll dp[151][152],inf=1e18;
int N;
ll A,B,r[150],s[150];
int lef;
int geteasy(int i,ll x){
	return upper_bound(dp[i],dp[i]+151,x)-dp[i]-1;
}
int get(int i,ll x){
	int ret=0;
	chmax(ret,lef-geteasy(i+1,-x-r[i]));
	if(x>0){
		chmax(ret,geteasy(i+1,x-1-r[i]));
	}
	return ret;
}
int main(){
	int N;
	cin>>N>>A>>B;
	rep(i,N) cin>>r[i]>>s[i];
	rep(i,151) rep(j,152) dp[i][j]=inf;
	dp[N][0]=-inf;
	for(int i=N-1;i>=0;i--){
		lef+=s[i];
		rep(j,lef+1){
			ll ub=inf,lb=-inf;
			while(ub-lb>1){
				ll m=(ub+lb)/2;
				if(get(i,m)>=j) ub=m;
				else lb=m;
			}
			dp[i][j]=ub;
		}
	}
	ll x=geteasy(0,A-B);
	cout<<x<<" "<<lef-x<<endl;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
#define x1 xxx
#define y1 yyy
#define x2 xx
#define y2 yy
using namespace std;
typedef long long ll;
bool b[1009];
int main()
{
    ll n;
    ll k;
    cin>>n>>k;
    for(int i=0;i<k;i++){
        ll c;
        cin>>c;
        b[c]=1;
    }
    bool res=0;
    while(res==0){
            ll len=0;
        for(int i=0; ;i++){
            if(n>=ceil(pow(10,i)))len=i+1;
            else break;
        }
        for(int i=0;i<len;i++){
            ll dig=n/(ll)ceil(pow(10,i));
            dig=dig%10;
            if(b[dig]==1){res=0; n++; break;}
            if(i==len-1)res=1;
        }

    }
    cout<<n;

        return 0;
}




Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
 
unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
// generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
 
unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned i,count = 0;
  for(i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
 
void shell_sort(unsigned a[], unsigned n){
  int i;
  unsigned gap_num = 0;
  while(gaps[++gap_num] < n);
  gap_num--;
 
  unsigned count = 0;
  for(i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
 
  printf("%u\n",(gap_num+1));
 
  for(i = gap_num; i; i--) printf("%u ",gaps[i]);
  printf("%u\n",gaps[0]);
 
  printf("%u\n",count);
}
 
int main(){
  unsigned n,i;
  scanf("%u",&n);
  unsigned* a = (unsigned*)malloc(sizeof(unsigned)*n);
  for(i = 0; i < n; i++) scanf("%u",&a[i]);
  shell_sort(a,n);
  for(i = 0; i < n; i++) printf("%u\n",a[i]);
  free(a);
  return 0;
}

Measured memory_bytes: 4252
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;


int main() 
{  
	int a;
	cin >> a;
	int s;
	cin >> s;
	int saityou = 0;
	for (int b = 0; b < a; b++) {
		int c, d;
		cin >> c >> d;
		s += c - d;
		if (s < 0) { cout << 0 << endl; goto i; }
		if (saityou < s)saityou = s;
	}
	cout << saityou << endl;
i:;
}

Measured memory_bytes: 3076
import math
n,p = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x%2, a))
a0 = 0
a1 = 0
for i in range(n):
    if a[i] == 0:
        a0 += 1
    else:
        a1 += 1
if p == 0:
    cnt = 0
    for i in range(0, a1+1, 2):
        cnt += math.factorial(a1) // (math.factorial(i)*math.factorial(a1-i))
    print(2**a0*cnt)
else:
    cnt = 0
    for i in range(1,a1+1,2):
        cnt += math.factorial(a1) // (math.factorial(i) * math.factorial(a1 - i))
    print(2 ** a0 * cnt)







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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if ( a - b * 2 < 0 ){
    cout << 0 << endl;
  }else{
    cout << a - b * 2 << endl;
  }
  
}



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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();

  cout << (t.substr(0, n) == s ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3608
N = gets.to_i
H = gets.split(' ').map(&:to_i)
count = 1
max = H[0]

(1..H.length - 1).each do |i|
  if max <= H[i] && H[i] >= H[i - 1]
    count += 1
    max = H[i]
  end
end

puts count

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    int l = (b/k)*k;

    if(a<=l) {
       cout << "OK" << "\n";
    }

    else {
       cout << "NG" << "\n";
    }

    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    int cnt = 0;
    repl(i, 2, n) {
      if ((i & 1) && n % i == 0 && n / i > (i / 2)) cnt++;
      else if (!(i & 1) && n * 2 % i == 0 && n % i != 0 && n / i >= (i / 2)) cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<int> X(N);
	REP(i,N) cin >> X[i];

	vector<int> Y = X;
	SORT(Y);

	int idx = (N+1)/2-1;
	int mid = Y[idx];
	int ans;
	REP(i,N){
		if(X[i] <= mid) ans = Y[idx+1];
		else ans = mid;
		cout << ans << endl;
	}





	return 0;

}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
struct edge {int /*from,*/to,cost;};

main(){
    int n,l;
    cin >> n >> l;
    string s[114];
    REP(i,n) cin >> s[i];
    sort(s,s+n);
    REP(i,n) cout << s[i];
    puts("");

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<long long int> t(n);
  long long int LCM=1;
  for(int i=0;i<n;i++){
    cin>>t.at(i);
    long long int x=__gcd(LCM,t.at(i));
    LCM/=x;
    LCM*=t.at(i);
  }
  cout<<LCM<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    ll a, b; cin >> a >> b;
    ll n = __gcd(a,b);
      
    ll ans = 1;
    if(n % 2 == 0){
        ans++;
        while(n % 2 == 0) n /= 2;
    }
  
    for (ll i = 3; i*i <= n; i+=2) {
        if(n % i == 0){
            ans++;
            while (n%i == 0) n /= i;
        }
      	if(n == 1) break;
	}
  	if(n != 1) ans++;

    cout << ans << endl;
}


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

int check(vector<vector<int>> card,int x){
  for(int j=0;j<3;j++){
	for(int i=0;i<3;i++){
      if(card.at(i).at(j) == x){
        return(3*j+i);
      }
    }
  }
  return(-1);
}

int isbingo(vector<vector<int>> isappear){
  int sum=0;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      sum += isappear.at(i).at(j);
    }
    if(sum == 3){
      return(1);
    }else{
      sum = 0;
    }
  }
  
  sum = 0;
  
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      sum += isappear.at(j).at(i);
    }
    if(sum == 3){
      return(1);
    }else{
      sum = 0;
    }
  } 
  
  if(isappear.at(0).at(0) == 1 && isappear.at(1).at(1) == 1 && isappear.at(2).at(2) == 1){
    return(1);
  }else if(isappear.at(0).at(2) == 1 && isappear.at(1).at(1) == 1 && isappear.at(2).at(0) == 1){
    return(1);
  }
  
  return(-1);
}
      

int main() {
  vector<vector<int>> card(3,vector<int>(3));
  vector<vector<int>> isappear(3,vector<int>(3));
  for(int j=0;j<3;j++){
    for(int i=0;i<3;i++){
      cin >> card.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  int b;
  for(int i=0;i<N;i++){
    cin >> b;
    int tmp = check(card,b);
	if(tmp != -1){
      isappear.at(tmp%3).at(tmp/3) = 1;
    }
  }
  
  if(isbingo(isappear) == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return(0);
  
}

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

int main(){
    int x;
    cin >> x;
    long long int sum = 0;
    for(int i=1;i<=1e9;++i){
        sum += i;
        if(sum >= x){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256