akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

const int MAX = 10101010;

int main() {
    int s; cin >> s;
    vector<bool> exist(MAX);
    exist[s] = true;
    int cnt = 2;
    while (1) {
        if (s%2) s = 3 * s + 1;
        else s /= 2;
        if (exist[s]) break;
        else exist[s] = true;
        cnt++;
    }
    cout << cnt << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

class Prime {
  ll _size;
  vector<ll> _min;

 public:
  Prime(ll size) {
    _size = size;
    _min.resize(size);

    for (ll i = 2; i < _size; i++) {
      ll cur = i * 2;
      for (;;) {
        if (cur >= _size) {
          break;
        }
        if (_min[cur] != 0) {
          cur += i;
          continue;
        }
        _min[cur] = i;
      }
    }
  }

  void show() {
    for (ll i = 0; i <= 36; i++) {
      cout << i << ":" << _min[i] << endl;
    }
  }

  vector<ll> v(ll num) {
    vector<ll> result;
    for (;;) {
      ll v = _min[num];
      if (v == 0) {
        result.emplace_back(num);
        break;
      }
      num /= v;
      result.emplace_back(v);
    }
    return result;
  }

  map<ll, ll> m(ll num) {
    map<ll, ll> result;
    for (;;) {
      ll v = _min[num];
      if (v == 0) {
        result[num] += 1;
        break;
      }
      num /= v;
      result[v] += 1;
    }
    return result;
  }
};

void calc_cmul(map<ll, ll> &cmul, map<ll, ll> &primes) {
  for (auto e : primes) {
    ll num = e.first;
    ll count = e.second;

    if (cmul[num] < count) {
      cmul[num] = count;
    }
  }
}

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

ll gcd_arr(vector<ll> &a) {
  ll n = a.size();
  for (ll i = n - 2; i >= 0; i--) {
    a[i] = gcd(a[i], a[i + 1]);
  }
  return a.front();
}

int main() {
  ll N;
  scanf("%lld", &N);

  auto prime = Prime(1100000);

  // auto p = prime.v(1);
  // for (ll i = 0; i < p.size(); i++) {
  //   cout << (p[i]) << endl;
  // }

  // return 0;

  mll sum;

  // ll my;
  vector<ll> list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);

    auto m = prime.m(v);

    for (auto ite = m.begin(); ite != end(m); ite++) {
      ll key = (*ite).first;

      sum[key] += 1;
    }

    // if (i == 0) {
    //   my = v;
    // } else {
    //   my = __gcd(my, v);
    // }
  }

  //
  bool pairwise_coprime = true;
  for (auto ite = sum.begin(); ite != end(sum); ite++) {
    if ((*ite).first >= 2 && (*ite).second >= 2) {
      pairwise_coprime = false;
      break;
    }
  }
  if (pairwise_coprime) {
    cout << ("pairwise coprime") << endl;
    return 0;
  }

  //
  ll my = gcd_arr(list);
  if (my == 1) {
    cout << ("setwise coprime") << endl;
    return 0;
  }

  //
  cout << "not coprime" << endl;
}


Measured memory_bytes: 22992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++) cout << 'x';
    cout << endl;
} 

Measured memory_bytes: 256
N,M=map(int,input().split())
test = []
for i in range(M):
    s,c = map(int,input().split())
    test.append((s,c))


flag2=-1

for i in range(10**N):
    flag=1
    str_i = str(i)
    if len(str_i) ==N:
        for j in range(M):
            if str_i[test[j][0]-1] != str(test[j][1]):
                flag =0
        if flag == 1:
            flag2 =i
            break
print(flag2)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node{
  int key;
  struct Node *next, *prev;
}Node;

Node *nil;

struct Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur ->key !=key){
    cur =cur->next;
  }
  return cur;
}
void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}
void printList(){
  Node *cur =nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d", cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}
void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev =x;
  nil->next =x;
  x->prev =nil;
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F')deleteFirst();
	else if(com[6]=='L')deleteLast();
      }else{
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a,b;
  a=(s.at(0)-48)*10+s.at(1)-48;
  b=(s.at(2)-48)*10+s.at(3)-48;
  if(a<13&&a>0&&b<13&&b>0)
    cout << "AMBIGUOUS";
  else if(a<13&&a>0)
    cout << "MMYY";
  else if(b<13&&b>0)
    cout << "YYMM";
  else
    cout << "NA";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(A), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	string S;

	vector<char> go;
	vector<char> back;

	ll vx=(tx-sx);
	ll vy=(ty-sy);
	REP(i,vx) cout<<"R";
	REP(i,vy) cout<<"U";
	REP(i,vx) cout<<"L";
	REP(i,vy) cout<<"D";
	cout<<"D";
	REP(i,vx+1) cout<<"R";
	REP(i,vy+1) cout<<"U";
	cout<<"L";
	cout<<"U";
	REP(i,vx+1) cout<<"L";
	REP(i,vy+1) cout<<"D";
	cout<<"R";
	cout<<"\n";
	//cout << go <<back << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ll binpow(ll x, ll y) {
	ll z = 1;
	while (y) {
		if (y % 2) z = (z * x) % mod;

		y = y / 2;
		x = (x * x) % mod;
	}
	return z % mod;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

//	cin >> tc;

	while (tc--) {

		ll n, m, x;
		cin >> n >> m >> x;
		ll c[n];
		ll a[n][m];
		for (int i = 0; i < n; i++) {
			cin >> c[i];
			for (int j = 0; j < m; j++) {
				cin >> a[i][j];
			}
		}


		ll ans = LLONG_MAX;


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

			ll mx[m] = {0};
			ll cost = 0;

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

				if ((i >> j) & 1) {

					cost += c[j];

					for (int k = 0; k < m; k++) {
						mx[k] += a[j][k];
					}


				}
			}


			bool f = 1;

			for (int j = 0; j < m; j++) {
				if (mx[j] < x) {
					f = 0;
					break;
				}
			}

			if (f) {
				ans = min(ans, cost);
			}
		}


		if (ans == LLONG_MAX)
			cout << -1 << endl;
		else
			cout << ans << endl;

	}

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000000;

int par[MAX_N], Rank[MAX_N], size[MAX_N];
void init(int n)
{
    for (int i = 0; i < n; i++)
    {
        par[i] = i;
        Rank[i] = 0;
        size[i] = 1;
    }
}

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

void unite(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y)
        return;
    if (Rank[x] < Rank[y])
    {
        par[x] = y;
        size[y] += size[x];
    }
    else
    {
        par[y] = x;
        size[x] += size[y];
        if (Rank[x] == Rank[y])
            Rank[x]++;
    }
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    vector<long long> ans(M);
    ans[M - 1] = (long long)N * (N - 1) / 2;
    init(N);

    for (int i = M - 1; i >= 1; i--)
    {
        ans[i - 1] = ans[i];

        if (!same(a[i], b[i]))
        {
            ans[i - 1] -= (long long)size[find(a[i])] * size[find(b[i])];
            unite(a[i], b[i]);
        }
    }

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

Measured memory_bytes: 11520
n = int(input())
XY = []
for i in range(n):
	xy = []
	for j in range(int(input())):
		x,y = map(int,input().split())
		x -= 1
		xy.append([x,y])
	XY.append(xy)

ans = 0
for i in range(1,2**n):
	cur_bit = bin(i)[2:].zfill(len(bin(2**n-1)[2:]))
	res = list(map(int,cur_bit))
	j = 0
	cnt = 0
	# print(cur_bit)
	for c,xy in zip(cur_bit,XY):
		flag = 1
		if c == "0":
			continue
		for x,y in xy:
			if res[x] != y:
				flag = 0
				break
		if not flag:
			break
		cnt += 1
	# print(cnt)
	if flag:
		try:
			ans = max(ans,cnt)
		except ValueError:
			pass
print(ans)

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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main() {
    string S;
    cin>>S;
    ll t = S.size();
    t--;
    ll A=0;
    rep(i,1<<t){
        ll ans = 0;
        ll c = 0;
        rep(j,t+1){
            c = c*10+(ll)(S[j]-'0');
            if(i&(1<<j)) {
                ans+=c;
                c=0;
            }
        }
        A+=ans+c;
    }
    cout<<A<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	string s;
	cin >> s;
	int w;
	cin >> w;
	for(int i=0;i<s.length();i=i+w){
		cout << s.at(i);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	char c;
	for (int a[5]; cin >> a[0]; ) {
		rep(i, 4) cin >> c >> a[i + 1];
		sort(a, a + 5);
		map<int, int> d;
		rep(i, 5) d[a[i]]++;
		int b[6];
		memset(b, 0, sizeof(b));
		tr(i, d) b[i->snd]++;
		if (b[4]) cout << "four card" << endl;
		else if (b[3] && b[2]) cout << "full house" << endl;
		else if (b[1] >= 4) {
			bool flg = true;
			rep(i, 4) if (a[i] + 1 != a[i + 1]) flg = false;
			if (flg) cout << "straight" << endl;
			else {
				flg = true;
				rep(i, 3) if (a[i + 1] + 1 != a[i + 2]) flg = false;
				if (flg && a[4] == 13 && a[0] == 1) cout << "straight" << endl;
				else cout << "null" << endl;
			}
		}
		else if (b[3]) cout << "three card" << endl;
		else if (b[2] == 2) cout << "two pair" << endl;
		else if (b[2] == 1) cout << "one pair" << endl;
		else cout << "null" << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
N = I()
A = readInts()
sumA = sum(A)
MIN = float('inf')
snuke = 0
for i in range(N-1):
    snuke += A[i]
    sumA -= A[i]
    MIN = min(MIN,abs(snuke - sumA))
print(MIN)


Measured memory_bytes: 32048
/* 
 Author:N_o_o_B 
 Created:September 27 2019 20:41:08
*/
#include <bits/stdc++.h>
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    string s;
    cin >> s;
    int n=s.size();
    int d;
    cin >> d;
    vector<vvl> dp(n+1,vvl(d,vl(2)));
    dp[n][0][0]=dp[n][0][1]=1;
    ford(i,n){
        fori(j,d){
            int lmt=s[i]-'0';
            fori(k,lmt+1){
                if(k!=lmt) dp[i][j][0]+=dp[i+1][(j-k%d+d)%d][1];
                else dp[i][j][0]+=dp[i+1][(j-k%d+d)%d][0];
                if(dp[i][j][0]>=mod) dp[i][j][0]-=mod;
            }
            lmt=9;
            fori(k,lmt+1){
                dp[i][j][1]+=dp[i+1][(j-k%d+d)%d][1];
                if(dp[i][j][1]>=mod) dp[i][j][1]-=mod;
            }
        }   
    }
    cout << (dp[0][0][0]-1+mod)%mod << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 55424
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int  m, k , i;
//=======================

void solve() {
    int n ;
    cin>>n;

    // vector<int> fre(101,0);

    // fo(i,n){
    //     cin>>m;
    //     fre[m]++;
    // }

    // int a = -1 , b = -1;
    // int c = 0;
    // for(i = 0 ; (i<101) && (c<2);i++){

    //     cout<<fre[i]<<" at "<<i<<endl;

    //     if(fre[i]>=2)continue;

    //     else if(fre[i] == 1 && a<0)a = i,c++;
    //     else if ( fre[i] ==1)b  =i , c++;
    //     else {
    //         if(a<0)a = i;
    //         if(b<0)b = i;
    //         c+=2;
    //     }
    // }

    unordered_set<int> a,b;

    fo(i,n){
        cin>>m;

        if(a.count(m)){
            b.insert(m);
        }else {
            a.insert(m);
        }
    }

    fo(i, 101)if(!a.count(i))break;

    int ans = i;

    fo(i,101)if(!b.count(i))break;

    ans +=i;

    cout<<ans<<"\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    ll a ,b ,c , d;
    cin >> a>>b>>c>>d;

    vector<long long> v{a*c,a*d,b*c,b*d,b*c};

    cout<<*max_element(v.begin(),v.end());

    return 0;
}

Measured memory_bytes: 50532
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var (
		n   int
		err error
	)
	if sc.Scan() {
		n, err = strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
	}

	list := []int{}
	for i := 0; i < n; i++ {
		sc.Scan()
		a, err := strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
		list = append(list, a)
	}

	// -- output --
	G, cnt := shellSort(list)
	fmt.Println(len(G))

	gs := ""
	for _, g := range G {
		gg := strconv.Itoa(g)
		gs = gs + gg + " "
	}
	gs = strings.TrimRight(gs, " ")
	fmt.Println(gs)

	fmt.Println(cnt)

	for _, l := range list {
		fmt.Println(l)
	}
}

// 髢馴囈縺ｮ蠑擾ｼ喇ttps://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
func hClosure() func() int {
	h := 0
	return func() int {
		h = 3*h + 1
		return h
	}
}

func insertionSort(list []int, g int, cnt int) int {
	for i := g; i < len(list); i++ {
		v := list[i]
		j := i - g
		for ; j >= 0 && list[j] > v; j -= g {
			list[j+g] = list[j]
			cnt++
		}
		list[j+g] = v
	}
	return cnt
}

func shellSort(list []int) ([]int, int) {
	tmpG, G := []int{}, []int{}
	h := hClosure()
	for i := 0; i < len(list); i++ {
		hRange := h()
		if hRange > len(list) {
			break
		}
		tmpG = append(tmpG, hRange)
	}
	for i := len(tmpG) - 1; i >= 0; i-- {
		G = append(G, tmpG[i])
	}

	cnt := 0
	m := len(G)
	for i := 0; i < m; i++ {
		cnt = insertionSort(list, G[i], cnt)
	}

	return G, cnt
}



Measured memory_bytes: 24496
main :: IO ()
main = do
  [a, b, h, m] <- map read . words <$> getLine
  print $ solve a b h m

solve :: Double -> Double -> Double -> Double -> Double
solve a b h m = sqrt $ (a_x - b_x) ^ 2 + (a_y - b_y) ^ 2
  where
    rad_a = 2 * pi * (h / 12 + m / 720)
    rad_b = 2 * pi * (m / 60)

    a_x = a * sin rad_a
    a_y = a * cos rad_a

    b_x = b * sin rad_b
    b_y = b * cos rad_b


Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int i = 0;
    string s, r = "";
    cin >> s;
    for (i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (r.size() > 0)
				r.pop_back();
		} else
			r += s[i];
	}
	cout << r << "\n";
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
    int n,x,c=0,c2=0;scanf("%d",&n);
    
    for (int i=1; i<=n; i++) {
        scanf("%d",&x);c+=x&1;
    }
    if(c%2==1)  printf("NO\n");
    else    printf("YES\n");
    return 0;
}


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

int main()
{
	char a[30];
	int fg = 1;
	
	scanf("%s", a);
	int x = strlen(a);
	sort(a, a + x);
	for (int i = 1; i < x; i++) {
		if (a[i] == a[i - 1]) {
			fg = 0;
		}
	}
	puts(fg ? "yes" : "no");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int a[110000],b[110000],c[110000];
int f[110000][3];
int main()
{
    int n;

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    f[1][0] = max(b[1],c[1]);
    f[1][1] = max(a[1],c[1]);
    f[1][2] = max(a[1],b[1]);
    for(int i=2;i<=n;i++)
    {
        f[i][0] = max(f[i-1][1] + b[i],f[i-1][2] + c[i]);
        f[i][1] = max(f[i-1][0] + a[i],f[i-1][2] + c[i]);
        f[i][2] = max(f[i-1][1] + b[i],f[i-1][0] + a[i]);
    }
    int ans=max(f[n][0],f[n][1]);
    ans=max(ans,f[n][2]);
    cout<<ans;
}   

Measured memory_bytes: 2560
# ABC046C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report (ARC062C)
def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    t, a = 1, 1
    for i, j in arr:
        r = max((t - 1) // i + 1, (a - 1) // j + 1)
        t, a = i * r, j * r
    print(t + a)


if __name__ == "__main__":
    main()

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

using ll = long long;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> K(Q); cin >> K;

    vector<int> sumd(N), summ(N), ic;
    vector<ll> sumdm(N);
    sumd[0] = S[0] == 'D';
    summ[0] = S[0] == 'M';
    sumdm[0] = 0;
    for (int i = 1; i < N; i++) {
        sumd[i] = sumd[i-1] + (S[i] == 'D');
        summ[i] = summ[i-1] + (S[i] == 'M');
        sumdm[i] = sumdm[i-1] + (S[i] == 'M' ? sumd[i] : 0);
        if (S[i] == 'C') ic.push_back(i);
    }

    for (const int& k : K) {
        ll ans = 0;
        for (const int& i : ic) {
            ll dm = sumdm[i-1];
            if (i - k >= 0) {
                dm -= sumdm[i-k];
                dm -= (ll)sumd[i-k] * (summ[i-1] - summ[i-k]);
            }
            ans += dm;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 23832
#include <stdio.h>
int main(int argc, char **argv)
{
    int val;
    int h,m,s;

    scanf("%d", &val);

    s = val % 60;
    m = (val / 60) % 60;
    h = (val / 3600) % 24;

    printf("%d:%d:%d\n", h, m, s);
    return 0;

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans = gcd(ans,a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())
Ai = list(map(int, input().split()))
Bi = list(map(int, input().split()))
Ci = list(map(int, input().split()))

bonus = []
for i in range(N-1):
    if Ai[i + 1] - Ai[i] == 1:
        bonus.append(Ci[Ai[i]-1])

print(sum(Bi) + sum(bonus))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


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

	int a, b;
	cin >> a >> b;
	for (int i = 1; i <= 10000; i++) {
		double d = i;
		if ((int)(d*1.08) == a + i && (int)(d*1.1) == b + i) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            Console.WriteLine(Math.Min(input[0] * input[1], input[2]));
        }
    }
}


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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n/i; ++j) {
            if(n - i * j > 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int mod = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

const int maxn = 45;
const int maxs = 18;

int d[maxn][1 << maxs];

int main() {
    #ifdef LOCAL
    assert(freopen("e.in", "r", stdin));
    #else
    #endif
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int masks = 1 << (x + y + z + 1);
    d[0][1] = 1;
    forn (i, n)
        forn (mask, masks)
            for (int num = 1; num <= 10; ++num) {
                int nmask = (mask << num) | 1;
                if ((nmask & (1 << z)) && (nmask & (1 << (y + z))) && (nmask & (1 << (x + y + z))))
                    continue;
                nmask &= masks - 1;
                add(d[i + 1][nmask], d[i][mask]);
            }
    int res = 0;
    forn (mask, masks)
        add(res, d[n][mask]);
    int ans = 1;
    forn (i, n)
        ans = (ans * 10ll) % mod;
    add(ans, mod - res);
    cout << ans << '\n';
}


Measured memory_bytes: 41216
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int x;
  cin >> x;
  if(x >= 1800) cout << 1 << endl;
  else if(x >= 1600) cout << 2 << endl;
  else if(x >= 1400) cout << 3 << endl;
  else if(x >= 1200) cout << 4 << endl;
  else if(x >= 1000) cout << 5 << endl;
  else if(x >= 800) cout << 6 << endl;
  else if(x >= 600) cout << 7 << endl;
  else cout << 8 << endl;
}

Measured memory_bytes: 3596
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int N, M, l, r, maxL = 0, minR = INF;
  cin >> N >> M;
  REP(i, M)
  {
    cin >> l >> r;
    maxL = max(maxL, l);
    minR = min(minR, r);
  }

  if (maxL <= minR)
  {
    cout << minR - maxL + 1 << '\n';
  }
  else
  {
    cout << 0 << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
/**/

int main(){
    ll p[110];
    ll x,n;cin>>x>>n;
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    ll k=0;
    bool flag;
    while(1){
        for(ll c=-1;c<=1;c+=2){
            flag=true;
            for(ll i=0;i<n;i++){
                if(p[i]==x+c*k){
                    flag=false;
                    break;
                }
            }
            if(flag){
                cout<<x+c*k<<endl;
                return 0;
            }
        }
        k++;
    }
    return 0;
}


Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s;
	cin >> s;
	while (s.size() != 0)
	{
		s.pop_back();
		s.pop_back();
		string a = s.substr(0, s.size() / 2);
		string b = s.substr(s.size() / 2, s.size() / 2);
		if (a == b)
		{
			cout << s.size() << endl;
			break;
		}
	}
}

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

int main() {
  int n;
    int a[110];  // 最大 100 個ですが余裕をもたせます
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];

    sort(a, a + n, greater<int>());
  int sum1=0;
    int sum2=0;
  for(int i=0;i<n;i=i+2){
  	sum1+=a[i];
  }
  for(int i=1;i<n;i=i+2){
  	sum2+=a[i];
  }
  
  cout << sum1-sum2 << endl;

}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
	string s; cin >> s;
	string S = "CODEFESTIVAL2016";
	int res = 0;
	for(int i = 0; i < S.size(); i++) {
		if(s[i] != S[i]) res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXVALS = 100;

int nvals;
int cnt[MAXVALS];
vector<int> ans;

int rem[MAXVALS];

int state[MAXVALS];
int nrem[MAXVALS];


bool solve() {
	ans.clear();
	REP(i, nvals) rem[i] = cnt[i];
	while (true) {
		//printf("prefix:"); REPSZ(i, ans) printf(" %d", ans[i] + 1); puts("");
		bool done = true; REP(i, nvals) if (rem[i] > 0) done = false; if (done) break;
		vector<int> best;
		REPE(overlap, nvals - 1) {
			if (overlap > SZ(ans)) continue;
			REP(i, nvals) state[i] = nvals;
			REP(i, overlap) state[ans[SZ(ans) - overlap + i]] = i;
			REP(i, nvals) nrem[i] = rem[i] - (state[i] == nvals ? 1 : 0);
			int mn = nrem[0], mx = nrem[0]; FOR(i, 1, nvals) { if (nrem[i] < mn) mn = nrem[i]; if (nrem[i] > mx) mx = nrem[i]; }
			if (mn < 0) continue;
			if (mx > 2 * mn + 1) continue;
			vector<int> cur;
			if (mx == 2 * mn + 1) {
				int firstmn = nvals + 1, lastmx = -1;
				REP(i, nvals) { if (nrem[i] == mn && state[i] < firstmn) firstmn = state[i]; if (nrem[i] == mx && state[i] > lastmx) lastmx = state[i]; }
				if (firstmn < lastmx) continue;
				int nmx = 0; REP(i, nvals) if (state[i] == nvals && nrem[i] == mx) ++nmx;
				REP(i, nvals) if (state[i] == nvals && (nrem[i] != mn || nmx == 0)) { cur.PB(i); if (nrem[i] == mx) { --nmx; if (nmx == 0) REP(j, i) if (state[j] == nvals && nrem[j] == mn) cur.PB(j); } }
				assert(nmx == 0);
			} else {
				REP(i, nvals) if (state[i] == nvals) cur.PB(i);
			}
			assert(SZ(cur) == nvals - overlap);
			//if (SZ(ans) == 5) { printf("%d:", overlap); REPSZ(i, cur) printf(" %d", cur[i] + 1); printf(" [%d,%d]\n", mn, mx); }
			if (SZ(best) == 0 || cur < best) best = cur;
		}
		if (SZ(best) == 0) return false;
		REPSZ(i, best) ans.PB(best[i]);
		REPSZ(i, best) --rem[best[i]];
	}
	return true;
}

void run() {
	scanf("%d", &nvals);
	REP(i, nvals) scanf("%d", &cnt[i]);
	if (!solve()) { printf("-1\n"); return; }
	REPSZ(i, ans) { if (i != 0) printf(" "); printf("%d", ans[i] + 1); } puts("");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 3784
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	s=RD()[::-1]+"DDDDD"

	i=0
	cnt=0
	ans=0

	#print(s)

	while i<=len(s)-3:
		if s[i:i+2]=="CB":
			cnt+=1
			i+=2
		elif s[i]=="A":
			ans+=cnt
			i+=1
		else:
			cnt=0
			i+=1
	print(ans)





if __name__ == "__main__":
	main()


Measured memory_bytes: 9268
n = int(input())
As  = list(map(int, input().split()))

if n == 0:
    if As[0] == 1: print(1)
    else: print(-1)
    exit()
    
# 下から見る
As_r = As[::-1]
p = As_r[0]
# とりうる最大値
a_pre = p
qs = [p]
# とりうる最小値
mn = As_r[0]

# 深さ n-1から0まで
# 最後の葉の数がA_N < 10**8、N<=10**5より、10**(8+5)以上の葉は生まれない。
# なので、高々50回くらいの2冪で上等
for i,a in enumerate(As_r[1:]):
    d = min(n - i - 1, 50)
    p = min(2**d, p + a)
    mn = (mn+1)//2 + a
    a_pre = a
    qs.append(p)

if mn != 1:
    print(-1)
    exit()

qs.reverse()
# print(qs,As)
ans = qs[0]
cnt = qs[0]
# 上から見る
for i in range(1,n+1):
    qs[i] = min(qs[i-1]*2, 2*(qs[i-1]-As[i-1]),qs[i])
print(sum(qs))

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


int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int GCD=1;
  for(int i=0;i<max(A,B);i++){
    if(A%(i+1)==0 && B%(i+1)==0)GCD=max(GCD,i+1);
  }
  
  if(GCD==1 || C%GCD==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n , m ; 
	cin >> n >> m ; 
	int r , c ; 
	cin >> r >> c ; 
	int ans = n * m - r * m - (n - r)*c; 
	cout << ans << endl;
	return 0; 
}


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

int main(){
    int card[51];
    int tmp[50];
    int n,r, from, num;

    while(1){
        cin >> n >> r;
        if(n == 0 && r == 0) break;
        for(int i=1; i<=n; i++){
            card[i]=n-i+1;
        }
        for(int i=0; i<r; i++){
            cin >> from >> num;
            for(int j=0; j<num; j++){
                tmp[j] = card[from+j];
            }
            for(int j=from-1; j>0; j--){
                card[j+num] = card[j];
            }
            for(int j=0; j<num; j++){
                card[j+1] = tmp[j];
            }
        }
        cout << card[1] << endl;
    }
        
    return 0;
}

Measured memory_bytes: 3080
n = gets.chomp.to_i

while n != 0 do 
    count = 0
    (1..(n-1)).each do |v|
        #引数に気をつける。　これが動きをつける。
        i = v
        sum = 0
        while sum < n do
            sum += i
            i += 1
        end
        if n == sum       
            count += 1
        end
    end
    
    p count
    n = gets.chomp.to_i   
end


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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll kaijo(ll n){
  ll res = 1;
  repi(i, 1, n+1) res = res * i % MOD;
  return res;
}

ll comb(ll n, ll r) {
  ll res = 1;
  res = res * kaijo(n) % MOD;
  res = res * modinv(kaijo(r), MOD) % MOD;
  res = res * modinv(kaijo(n-r), MOD) % MOD;
  return res;
}

int main(){
  ll x, y;
  cin >> x >> y;
  if(x < y) swap(x, y);
  ll ans = 0;
  if((x + y) % 3 == 0 && x <= y * 2){
    ll nx, ny;
    nx = x - (x + y) / 3;
    ny = y - (x + y) / 3;
    ans = comb(nx + ny, nx);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll n,h;
    ll cnt=0;
    cin>>n>>h;
    vector<ll>a(n),b(n);
    ll max_a=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        max_a=max(max_a,a[i]);
    }
    sort(b.begin(),b.end(),greater<ll>());
    int memo=n+5;
    rep(i,n){
        if(max_a>=b[i]){
            memo=i;
            break;
        }
    }
    rep(i,n){
        if(i==memo){
            break;
        }
        h=h-b[i];
        ++cnt;
        if(h<=0){
            cout<<cnt<<endl;
            return 0;
        }
    }
    cnt+=h/max_a+(h%max_a!=0);
    cout<<cnt<<endl;
    return 0;
}

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

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

int main(){
        int n,p;
        while(cin>>n>>p&&n,p){
                vector<int>a(n);
                int num=p,ans;
                bool ok=true;
                while(ok){
                        for(int i=0;i<n;i++){
                                if(num)num--,a[i]++;
                                else if(a[i]&&!num)num+=a[i],a[i]=0;
                                if(a[i]==p){
                                        ok=false;
                                        ans=i;
                                        break;
                                }
                        }
                }
                cout<<ans<<endl;
        }
        return 0;
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
        s = s + "es";
    else
        s = s + "s";

    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int h[n];
    for(int i = 0; i < n; i++) cin >> h[i];
    bool allzero = true;
    int c = 0;
    while(allzero){
        int sum = h[0];
        bool f = h[0] != 0, inzero = true;
        if(h[0] != 0) h[0]--;
        for(int i = 1; i < n; i++){
            sum += h[i];
            if(h[i] != 0){
                f = true;
                h[i]--;
            }else{
                if(f) c++;
                f = false;
                inzero = false;
            }
        }
        if(f) c++;
        allzero = sum != 0;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int64_t lcd(int64_t x,int64_t y){
  int64_t u,v,z;
  u=min(x,y);
  v=max(x,y);
  z=v%u;
  while(z>0){
    v=u;
    u=z;
    z=v%u;
  }
  return x/u*y;
}
int main(){
  int n,i;
  int64_t t,ans=1;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>t;
    ans=lcd(ans,t);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  if(T1*A1+T2*A2==T1*B1+T2*B2){
    cout<<"infinity"<<endl;
  }else{
    ll dx1=T1*B1-T1*A1;
    ll dx2=T1*B1+T2*B2-T1*A1-T2*A2;
    if((dx1>0&&dx2>0)||(dx1<0&&dx2<0)){
      cout<<0<<endl;
    }else{
      if(dx1<0){
        dx1=-dx1;
      }else{
        dx2=-dx2;
      }
      if(dx1%dx2==0){
        cout<<dx1/dx2*2<<endl;
      }else{
        cout<<dx1/dx2*2+1<<endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


int G[100003];
int couse[100003];

struct P {
  int p;
  int cost;

  bool operator >(const P& p) const {
    return cost > p.cost;
  }
};

int main() {
  fill_n((int *)G, 100003, (int)1e9);
  int n;
  cin >> n;
  REP(i, n){
    cin >> couse[i];
  }

  G[0] = 0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push({0, 0});
  while(!que.empty()) {
    P p = que.top(); que.pop();
    if (p.p >= n-1) {
      cout << p.cost << endl;
      break;
    }

    if (couse[p.p] == 0) {
      FOR(d, 1, 6 + 1){
        int next_p = min(n, p.p + d);
        int next_c = p.cost + 1;
        if (G[next_p] > next_c) {
          G[next_p] = next_c;
          que.push({next_p, next_c});
        }
      }
    }else{
      int next_p = min(n, p.p + couse[p.p]);
      int next_c = p.cost;
      if (G[next_p] > next_c) {
        G[next_p] = next_c;
        que.push({next_p, next_c});
      }
    }
  }
}

Measured memory_bytes: 3940
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.nextLine();
		String b = sc.nextLine();
		String c = sc.nextLine();
		char al = a.charAt(0);
		char bl = b.charAt(1);
		char cl = c.charAt(2);
		String ax = String.valueOf(al);
		String bx = String.valueOf(bl);
		String cx = String.valueOf(cl);
		
		
		System.out.println(ax+bx+cx);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll k;
vector<ll> cand;

void dfs(string s) {
  if (SZ(s) >= 12) {
    return;
  }
  cand.push_back(stoll(s));
  ll last = (ll)(s[SZ(s) - 1] - '0');
  FOR(i, last - 1, last + 2) {
    if (i < 0 || i > 9) {
      continue;
    }
    char c = (char)('0' + i);
    dfs(s + c);
  }
}

int main() {
  cin >> k;
  FOR(i, 1, 10) {
    string s = to_string(i);
    dfs(s);
  }
  sort(ALL(cand));
  cout << cand[k - 1] << endl;
}

Measured memory_bytes: 10604