akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
ModInt pow(ModInt a,ll x){
	ModInt res = ModInt(1ll);
	while(x){
		if(x&1)res *= a;
		x >>= 1;
		a = a*a;
	}
	return res;
}
const int SIZE = 100100;
ModInt inv[SIZE+10],fac[SIZE+10],facinv[SIZE+10];
// notice: 0C0 = 1 
ModInt nCr(int n,int r){
	assert(!(n<r));
	assert(!(n<0||r<0));
	return fac[n]*facinv[r]*facinv[n-r];
}
void init(){
	fac[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)fac[i]=fac[i-1]*ModInt(i);
	inv[1]=ModInt(1ll);
	for(int i=2;i<=SIZE;i++)inv[i]=ModInt(0ll)-ModInt(MOD/i)*inv[MOD%i];
	facinv[0]=ModInt(1ll);
	for(int i=1;i<=SIZE;i++)facinv[i]=facinv[i-1]*inv[i];
	return;
}
int N,K;
ModInt dp[2010][2010][2];
int main(){
	init();
	cin >> N >> K;
	for(int i=1;i<=K;i++){
		ModInt a = nCr(K-1,i-1);
		int k = N-K-(i-1);
		if(k<0){
			cout << 0 << endl;
			continue;
		}
		ModInt b = nCr(k+i,i);
		cout << a*b << endl;
	}
    return 0;
}




Measured memory_bytes: 65664
inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end

N = inputs[0].split(" ").map(&:to_i)[0]
ws = inputs[1].split(" ").map(&:to_i)

all = ws.reduce(&:+)

arrs = []
i = 1
s1 = 0
s2 = all
while i < N
  s1 = s1 + ws[i - 1]
  s2 = s2 - ws[i - 1]
  arrs << (s1 - s2).abs

  i += 1
end

puts arrs.min

Measured memory_bytes: 1788
N = int(input())
A = [0]
A = A + list(map(int, input().split()))
A.append(0)
sumOfRoute = 0
tmp = 0
for a in A:
    sumOfRoute += abs(tmp-a)
    tmp = a

prev = 0
for i in range(1, N+1):
    nexti = A[i+1]
    print(sumOfRoute + abs(prev - nexti) - abs(A[i] - nexti) - abs(prev - A[i]))
    prev = A[i]


Measured memory_bytes: 13920
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] L = new int[2 * N];
    for (int i = 0; i < 2 * N; i++) {
      L[i] = sc.nextInt();
    }
    Arrays.sort(L);
    int ans = 0;
    for (int i = 0; i < 2 * N; i += 2) {
      ans += L[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n, m, b, c; cin >> n >> m;
	VI a(m), d(m, 0); VVI dp(m + 1, VI(pow(2, n), MOD)); 
	dp[0][0] = 0;
	REP(i, m) {
		cin >> a[i] >> b;
		REP(j, b) {
			cin >> c;
			d[i] += pow(2, c - 1);
		}
	}
	REP(i, m) {
		REP(j, pow(2, n)) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j | d[i]] = min(dp[i + 1][j | d[i]], dp[i][j] + a[i]);
		}
	}
	if (dp[m][pow(2, n) - 1] == MOD)
		cout << -1;
	else
		cout << dp[m][pow(2, n) - 1];
}

Measured memory_bytes: 16384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  string s;
  while (getline(cin, s)) {
    istringstream ss(s);
    stack<double> p;
    auto f = [&](F<double(double, double)> f) {
      double a, b;
      a = p.top();
      p.pop();
      b = p.top();
      p.pop();
      p.push(f(b, a));
    };
    while (ss >> s) {
      if (s == "+") {
        f(plus<double>());
        continue;
      }
      if (s == "-") {
        f(minus<double>());
        continue;
      }
      if (s == "*") {
        f(multiplies<double>());
        continue;
      }
      if (s == "/") {
        f(divides<double>());
        continue;
      }
      p.push(stod(s));
    }
    cout << prec(32) << p.top() << endl;
  }
}

Measured memory_bytes: 3192
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

	//------------------------------------------

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	//------------------------------------------



	public void exec() throws Exception{
		final String S = sc.next();
		for(int i=0;i<S.length();i++) {
			out.print("x");
		}
		out.println();
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(){
  long long n,a,i;
  scanf("%lld",&n);
  a=n/50;
  printf("50\n");
  if(a==0){
    for(i=0;i<50;i++){
      if(i)printf(" ");
      if(i<n)printf("50");
      else   printf("0");
    }
  }
  else{
    for(i=0;i<50;i++){
      if(i)printf(" ");
      if(i<n%50)printf("%lld",a+50);
      else      printf("%lld",a+49-n%50);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, a, b) for(i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 100010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
typedef pair<int, string> istr;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<istr> vistr;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	
	fastio;
	int a, b;
	cin >> a >> b;
	string s1;
	string s2;
	rep1(i, b){
		s1.pb(a+'0');
	}
	rep1(i, a){
		s2.pb(b+'0');
	}
	if(s1.compare(s2) < 0){
		cout << s1 << endl;
	}else{
		cout << s2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <deque>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define MP make_pair
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STRING(x) string x;cin>>x;
# define STR(x) STRING(x);
# define DOUBLE(x) double x;cin>>x;
# define DBL(x) DOUBLE(x); 
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl
# define INIT(a) memset(a,-1,sizeof a)
# define CLR(a) memset(a,0,sizeof a)
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const int M = 1000000007;
template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; }

const int MAXN = 100;
int main()
{
	while ( true )
	{
		int n, m, l, k, a, h;
		cin >> n >> m >> l >> k >> a >> h;
		if ( !n )break;

		int cost[MAXN][MAXN];
		bool stop[MAXN] = {};
		FOR(i, MAXN)FOR(j, MAXN)cost[i][j] = INF;

		FOR(i, l)
		{
			int s;
			cin >> s;
			stop[s] = true;
		}
		stop[h] = true;
		FOR(i, k)
		{
			int x, y, t;
			cin >> x >> y >> t;
			cost[x][y] = cost[y][x] = t;
		}
		FOR(i, MAXN)cost[i][i] = 0;

		FOR(p, MAXN)FOR(i, MAXN)FOR(j, MAXN)
			cost[i][j] = min(cost[i][j], cost[i][p] + cost[p][j]);
		
		priority_queue< piii, vector<piii>, greater<piii> >que;
		que.emplace(0, pii(a,-m));
		bool flag[MAXN] = {};
		while ( !que.empty() )
		{
			piii now = que.top();
			que.pop();
			if ( flag[now.second.first] )continue;
			flag[now.second.first] = true;
			if ( now.second.first == h )
			{
				cout << now.first+max(0,now.second.second) << endl;
				break;
			}

			FOR(i, n)
			{
				if ( cost[now.second.first][i] <=m &&!flag[i]&&stop[i])
				{
					que.emplace(now.first + cost[now.second.first][i], pii(i,now.second.second+cost[now.second.first][i]));
				}
			}
		}
		if ( !flag[h] )cout << "Help!" << endl;
	}
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  int X = max(A, B);
  int Y = min(A, B);
  int ans = X;
  int M =max(X-1,Y);
  ans += M;
  cout << ans;
}


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

using namespace std;

#define endl '\n'

typedef long long ll;

const int maxn = 1e5 + 5;

int n;
ll dp[maxn][4], a[maxn][4];


ll solve(int pos, int prv){
	if(pos == n)
		return 0;

	if(dp[pos][prv] != -1)
		return dp[pos][prv];
	
	ll ans = 0;
	for(int i = 0; i < 3; i++)
		if(i != prv)
			ans = max(ans, solve(pos + 1, i) + a[pos][i]);
	
	return dp[pos][prv] = ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++)
			cin >> a[i][j];
	
	memset(dp, -1, sizeof(dp));
	
	ll ans = 0;
	ans = max(ans, solve(1, 0) + a[0][0]);
	ans = max(ans, solve(1, 1) + a[0][1]);
	ans = max(ans, solve(1, 2) + a[0][2]);
	
	cout << ans << endl;
	
	return 0;
}

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

int ball[10];

bool DFS(int B,int C,int cnt){
  if(cnt == 10)
    return true;

  bool ans = false;
  if(B < ball[cnt])
    ans = DFS(ball[cnt],C,cnt+1);
  if(C < ball[cnt])
    ans = DFS(B,ball[cnt],cnt+1);

  return ans;
}

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

  while(n--){
    for(int i = 0; i < 10; i++)
      cin >> ball[i];

    if(DFS(0,0,0)==true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3056
def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
n=int(input())
L=[0]*100000
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            L[func(x,y,z)]+=1
for i in range(1,n+1):
    print(L[i])

Measured memory_bytes: 69724
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

struct Card {
  char suit;
  int value;
};

void print(std::vector<Card> cards);

vector<Card> bubble(std::vector<Card> C, int N) {
  rep(i, N) {
    int j = N - 1;
    while (j > i) {
      if (C[j].value < C[j - 1].value) {
        swap(C[j], C[j - 1]);
      }
      j--;
    }
  }
  return C;
}

vector<Card> selection(std::vector<Card> C, int N) {
  rep(i, N) {
    int minj = i;
    int j = i;
    while (j < N) {
      if (C[j].value < C[minj].value) {
        minj = j;
      }
      j++;
    }
    if (i != minj) {
      swap(C[i], C[minj]);
    }
  }
  return C;
}

void print(std::vector<Card> cards, int N) {
  Card card_last = cards[N - 1];
  rep(i, N - 1) {
    if (cards[i].value == 0) {
      break;
    }
    std::cout << cards[i].suit << cards[i].value << " ";
  }
  std::cout << card_last.suit << card_last.value << '\n';
}

void check(vector<Card> C1, vector<Card> C2, int N) {
  rep(i, N) {
    if (!(C1[i].suit == C2[i].suit)) {
      std::cout << "Not stable" << '\n';
      return;
    }
  }
  std::cout << "Stable" << '\n';
}

int main() {
  std::vector<Card> C1(36);
  std::vector<Card> C2(36);

  int N;
  cin >> N;
  rep(i, N) { cin >> C1[i].suit >> C1[i].value; }

  rep(i, N) { C2[i] = C1[i]; }

  // print(C1);

  C1 = bubble(C1, N);

  C2 = selection(C2, N);

  print(C1, N);
  std::cout << "Stable" << '\n';
  print(C2, N);
  check(C1, C2, N);

  return 0;
}



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

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

int main() {
	ll N, M;
	cin >> N >> M;
	string s, t;
	cin >> s >> t;

	ll lcm = (N * M) / gcd(N, M);
	vector<ll> p(N);
	p[0] = 1;
	vector<ll> q(M);
	q[0] = 1;
	for (ll i = 1; i < N; ++i) {
		p[i] = i * (lcm / N) + 1;
	}
	for (ll i = 1; i < M; ++i) {
		q[i] = i * (lcm / M) + 1;
	}

	bool exit = true;
	for (int i = 0; i < N; ++i) {
		int it = lower_bound(q.begin(), q.end(), p[i]) - q.begin();
		if (it != M) {
			if (p[i] == q[it]) {
				if (s[i] != t[it]) { exit = false; }
			}
		}
	}

	if (exit) { cout << lcm << endl; }
	else { cout << -1 << endl; }

	return 0;
}


Measured memory_bytes: 1792
int main(){
int S,a,b,c;
scanf("%d", &S);
if("S>=0" && "S<=86400"){
a=S/3600;
b=(S-a*3600)/60;
c=S-a*3600-b*60;
printf("%d:%d:%d\n", a,b,c);}
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
bool isLun(long long n) {
  	string s = to_string(n);	
 	for(int i = 1; i < s.length(); i++) {
    	if(abs(s[i] - s[i-1]) > 1) {
         	return false; 
        }
    }
	return true; 
}

int main(){
  	long long n=12, k;
  	cin >> k;
  	if( k <= 12 ) {
      	cout << k << endl;
    	return 0; 
    }
	string s;	
	int ii = 12;
	do {
		ii++;
      	n++;
      	if(!isLun(n)) {
          	int i;
        	s = to_string(n);
start:
          	for(i = 1; i < s.length(); i++) {
         
              if(s[i] - s[i-1] > 1) { //繰り上がり後上の桁で問題 or繰り上がりなし.
              	s[i-1]++;//条件から9ではないので
                
                for(int j = i; j < s.length(); j++) {
                 	s[j] = max(s[j-1] - 1, (int)'0');
                }
                if(!isLun(stoll(s))) {
                  goto start;
                }
                break;
              } else if(s[i-1] -s[i] > 1) { // 繰り上がりで0になったことで問題
                
                for(int j = i; j < s.length(); j++) {
                	s[j] = max(s[j-1] - 1, (int)'0');
                }
                if(!isLun(stoll(s))) {
                  goto start;
                }
               	break;
              }
            }
            n = stoll(s);
        }
    } while(ii < k);
  
  	cout << n << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N = II()
    factors = Counter()
    for k in range(1, N + 1):
        for i in (2,3,5,7):
            while k % i == 0:
                factors[i] += 1
                k //= i
        if k != 1:
            factors[k] += 1
    # 75 = 3 * 5 * 5
    nfactors = sorted(factors.values())
    ans = 0
    dp = [0] * 76
    dp[1] = 1
    for cnt in nfactors:
        pre = dp
        dp = [0] * 76
        for c in range(1, cnt + 2):
            for k in range(75 // c + 1):
                dp[k * c] += pre[k]
    ans = dp[75]
    return ans

print(main())

Measured memory_bytes: 3316
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return "".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = [-1 for i in range(N)]

for i in range(M):
    s,c = m()
    s -= 1
    if a[s] == -1 or a[s] == c:
        a[s] = c
    else:
        print(-1)
        exit()
for i in range(N):
    if i == 0:
        if a[i] == 0 and N != 1:
            print(-1)
            exit()
        elif a[i] == 0:
            break
        elif a[i] == -1 and N != 1:
            a[i] = 1
        elif a[i] == -1:
            a[i] = 0
    else:
        if a[i] == -1:
            a[i] = 0

print(jo(a))




Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define N 310
using namespace std;
vector<int> pc[N];
char grid[N][N];
int n,m,k,ans[N][N];
void fill2(int tp,int dn,int l,int r,int num)
{
	int i,j;
	for(i=tp;i<=dn;i++)
	{
		for(j=l;j<r;j++)
		{
			ans[i][j]=num;
		}
	}
	return;
}
int fill(int l,int mid,int r,int num)
{
	int i,lt=0;
	for(i=1;i<pc[mid].size();i++)
	{
		fill2(l,r,lt,pc[mid][i],num);
		num++;
		lt=pc[mid][i];
	}
	fill2(l,r,lt,m,num);
	num++;
	return num;
}
void solve()
{
	int i=0,x,cnt=1,hv;
	for(x=0;x<n;)
	{
		i=x;
		while(pc[i].size()==0&&i<n)
		{
			i++;
		}
		hv=i;
		i++;
		while(pc[i].size()==0&&i<n)
		{
			i++;
		}
		i--;
		cnt=fill(x,hv,i,cnt);
		x=i+1;
	}
	return;
}
int main(){
	int i,j;
	memset(ans,-1,sizeof(ans));
	cin>>n>>m>>k;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cin>>grid[i][j];
			if(grid[i][j]=='#')
			{
				pc[i].push_back(j);
			}
		}
	}
	solve();
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1920
H,W = map(int,input().split())
place = []
for i in range(H):
    S = input()
    place.append(S)
ans_list = []
for i in range(H):
    Z = [0] * W
    ans_list.append(Z)
for i in range(H):
    if i == 0:
        count = 0
        for j in range(W):
            if place[0][j] == "#":
                if j == 0:
                    count += 1
                else:
                    if place[0][j-1] != "#":
                        count += 1
            ans_list[0][j] = count
    else:
        for j in range(W):
            chk = 0
            if j == 0 :
                count = ans_list[i-1][j]
            else:
                count = ans_list[i][j-1]
            if place[i][j] == "#":
                if j == 0:
                    if place[i-1][j] != "#":
                        count += 1
                else:
                    if place[i][j-1] != "#":
                        count += 1
            if place[i][j] == "#":
                if place[i][j] != place[i-1][j]:
                    chk += 1
            ans_list[i][j] = min(count,ans_list[i-1][j]+chk)
print(ans_list[H-1][W-1])

Measured memory_bytes: 42096
import sys
input = sys.stdin.readline

N = int(input())
S = list(map(int, input().split()))
Q = int(input())

d = dict()
for num in S:
    d.setdefault(num, 0)
    d[num] += 1


ans = sum(s*t for s, t in d.items())

for _ in range(Q):
    b, c = map(int, input().split())
    d.setdefault(c, 0)
    d.setdefault(b, 0)
    ans += (c-b)*d[b]
    d[c] += d[b]
    d[b] = 0
    print(ans)


Measured memory_bytes: 93684
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

l = []
for a in A:
    for b in B:
        l.append(a+b)
l = sorted(l, reverse=True)[:K]


ans = []
for c in C:
    for k in l:
        ans.append(c+k)

ans = sorted(ans, reverse=True)
print(*ans[:K], sep="\n")

Measured memory_bytes: 221044
#include <cstdio>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cctype>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define llong long long
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;

vector<string> split(string str, char delim)
{
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos)
	{
		string tmp = string(str, current, found - current);
		res.push_back(tmp);
		current = found + 1;
	}
	string tmp = string(str, current, found - current);
	tmp.replace(tmp.size() - 1, tmp.size(), "\0");
	res.push_back(string(str, current, str.size() - current));
	return res;
}

char *StrToUpper(char *s)
{
	char *p;
	for (p = s; *p; p++)
	{
		*p = toupper(*p);
	}
	return s;
}

int main()
{
	char cword[11];
	cin >> cword;

	int cnt = 0;

	while (1)
	{
		char cstr[1001];
		cin >> cstr;

		if (string(cstr).find("END_OF_TEXT") != string::npos) break;

		string word = StrToUpper(cword);
		vector<string> vec = split(StrToUpper(cstr), ' ');
		//transform(word.begin(), word.end(), word.begin(), toupper);
		//transform(str.begin(), str.end(), str.begin(), toupper);
		int num = 0;

		for (int i = 0; i < vec.size(); i++)
		{
			if (vec[i] == word) cnt++;
		}
	}

	printf("%d\n", cnt);
}

Measured memory_bytes: 1208
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		scanner.nextLine();
		String[] array = new String[n];
		array = scanner.nextLine().split(" ");
		scanner.close();
        String[] arrayB = array.clone();
        String[] arrayS = array.clone();

        //バブルソート
       for(int i = 0; i < n; i++) {
    	   for(int j = n - 1; j > i; j--) {
    		   if((int)arrayB[j - 1].charAt(1) > (int) arrayB[j].charAt(1)) {
    			   String tmp = arrayB[j - 1];
    			   arrayB[j - 1] = arrayB[j];
    			   arrayB[j] = tmp;
    		   }
    	   }
       }
       //出力
       for(int i = 0; i < arrayB.length; i++){
           System.out.print((i == 0 ? "" : " ") + arrayB[i]);
       }
       System.out.println();
       System.out.println("Stable");

       //選択ソート
       for(int i = 0; i < n; i++) {
    	   int minIndex = i;
    	   for(int j = i; j < n; j++) {
    		   if((int)arrayS[minIndex].charAt(1) > (int) arrayS[j].charAt(1)) {
    			   minIndex = j;
    		   }
    	   }
    	   //最小値を持つ添え字の値が変わっていなければ値交換はしなくてよい
    	   if(minIndex == i) continue;
    	   //値交換
    	   String tmp = arrayS[i];
		   arrayS[i] = arrayS[minIndex];
		   arrayS[minIndex] = tmp;
       }
       //出力
       for(int i = 0; i < arrayS.length; i++){
           System.out.print((i == 0 ? "" : " ") + arrayS[i]);
       }
       System.out.println();
       if(Arrays.equals(arrayS, arrayB)) {
       	System.out.println("Stable");
       }else {
       	System.out.println("Not stable");
       }
	}
}


Measured memory_bytes: 26364
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 998244353
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline int tasu(int a, const int &b) {return (a += b) >= MOD ? a - MOD : a;}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

int K, N;
ll p2[4005] = {1}, fac[4005] = {1}, ifac[4005];

inline ll binom(const int &n, const int &m) {return n < m || m < 0 ? 0 : fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;}

inline int calc(const int &x, const int &y, const int &n){  // x pairs of conflict numbers, y free numbers, n sides of dices
	register int res = 0;
	for(register int i = 0, lim = min(x, n); i <= lim; i++)
		res = tasu(res, binom(x, i) * p2[i] % MOD * binom(n + y - 1, i + y - 1) % MOD);
	return res;
}

int main(){
	getint(K), getint(N);
	for(register int i = 1; i <= N + K; i++) fac[i] = fac[i - 1] * i % MOD, p2[i] = (p2[i - 1] << 1) % MOD;
	ifac[N + K] = fastpow(fac[N + K], MOD - 2);
	for(register int i = N + K; i >= 1; i--) ifac[i - 1] = ifac[i] * i % MOD;
	for(register int i = 2; i <= (K << 1); i++){
		const int cnt = min(i, (K + 1 << 1) - i) - 1 >> 1;
		if(i & 1) printf("%d\n", calc(cnt, K - (cnt << 1), N));
		else printf("%d\n", tasu(calc(cnt, K - (cnt << 1) - 1, N), calc(cnt, K - (cnt << 1) - 1, N - 1)));
	}
	return 0;
}

Measured memory_bytes: 384
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
--
local N = read.l():totable()
local s = 0
for i=1,#N do
    s = s + tonumber(N[i])
end
print(s % 9 == 0 and 'Yes' or 'No')

Measured memory_bytes: 6636
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n-k;i++){
        if(a[k+i]>a[i]) cout<<"Yes\n";
        else cout<<"No\n";
    }
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4760
S = str(input())
l = list(S)
s = int(len(S))

num = 0
for i in range(s):
    for j in range(i+1, s):
        if l[i] == l[j]:
            num += 1
        else:
            num += 0

if num == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int n = Integer.parseInt(sc.nextLine());
            int[][] m = new int[n][n];
            int i = 0;
            while (sc.hasNext()) {
                int[] u_k_vs = Stream.of(sc.nextLine().split(" "))
                        .mapToInt(Integer::parseInt)
                        .toArray();
                for (int j = 2; j < u_k_vs.length; j++) {
                    m[i][u_k_vs[j] - 1] = 1;
                }
                ++i;
            }
            if (i != n) {
                System.out.println("Conditions is invalid.");
            }
            for (int[] l: m) {
                System.out.println(IntStream.of(l).boxed()
                        .map(Object::toString)
                        .collect(Collectors.joining(" ")));
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}



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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void chmax(int &a, int b) {
  if (a < b) a = b;
}

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  vector<int> d(k + 1);
  d[0] = 1;
  for (auto &i : a) {
    for (int j = k; j >= i; j--) {
      if (d[j - i]) d[j] += d[j - i];
    }
  }
  int ans = 0;
  for (auto &i : a) {
    for (int j = i; j <= k; j++) {
      if (d[j - i]) d[j] -= d[j - i];
    }
    int b = 0;
    for (int j = max(k - i, 0LL); j < k; j++) {
      if (d[j]) {
        b = 1;
        break;
      }
    }
    if (!b) ans++;
    for (int j = k; j >= i; j--) {
      if (d[j - i]) d[j] += d[j - i];
    }
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3716
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------

int div2(int k) {
  int res = 0;
  while(k % 2 == 0) {
    k /= 2;
    res++;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, n) {
    int a;
    cin >> a;
    ans += div2(a);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#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 k;
  cin >> k;
  queue<ll> q;
  vector<ll> l;
  rep(i, 9) {
    q.push(i + 1);
    l.push_back(i + 1);
  }
  while (l.size() < k) {
    ll now = q.front();
    q.pop();
    for (int i = -1; i < 2; i++) {
      int n = now % 10 + i;
      if (0 <= n && n <= 9) {
        ll m = now * 10 + n;
        l.push_back(m);
        q.push(m);
      }
    }
  }
  // rep(i, k) cout << l[i] << endl;
  cout << l[k - 1] << endl;
  return 0;
}

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[311][311];
ll ans=0;
int main()
{
	cin >>n;
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	cin >>a[i][j];
	for (int i=0;i<n;i++)
	for (int j=0;j<i;j++)
	{
		ll w=a[i][j]+1;
		for(int k=0;k<n;k++)
		{
			if(i==k||j==k)
			continue;
			w=min(w,a[i][k]+a[k][j]);
		}
		if(w<a[i][j])
		{
			puts("-1");
			return 0;
		}
		if(w>a[i][j])
		ans+=a[i][j];
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll h[100000];
int main()
{
	int n;
	ll t;
	cin>>n>>t;
	for(int i=0;i<n;i++)
		cin>>h[i];
	ll ans=0;
	ll st=0; //最初の検査の開始時間
	ll nagai=h[0]; //最も検査時間の長い人
	ans=(t-st)/h[0]+1;
	cout<<ans<<endl; //最初の人の検査項目数
	for(int i=1;i<n;i++)
	{
		st+=h[i-1];
		if(nagai<h[i])
			nagai=h[i];
		if(st>t)
			ans=1;
		else{
			ans=(t-st)/nagai+1;
			if((t-st)%nagai>=h[i])
				ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3888
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

void virus(){
        ll len, xr = 0;
        cin>>len;
        ll arr[len];
        //vector<ll> arr(len);
        for(auto i=0;i<len;i++){
            cin>>arr[i];
            xr ^= arr[i];
        }
        //cout<<xr<<endl;
        for(auto i=0;i<len;i++){
            cout<<((arr[i]) ^ xr)<<" ";
        }
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<string> ans = {"Yes", "No"};
    int turn = 0;

    while (a>0 && c>0) {
        if (!turn) {
            c -= b;
        }
        else {
            a -= d;
        }
        turn ^= 1;
    }

    cout << ans[turn^1] << '\n';

    return 0;
}

Measured memory_bytes: 3532
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static int cnt = 0;
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		int[] array = new int[length];
		for (int i=0; i<length; i++) {
			array[i] = scanner.nextInt();
		}
		scanner.close();

		shellSort(array, length);
		
		
	}
	
	public static void insertionSort(int[] array, int length, int interval) {
		for (int i=interval; i<length; i++) {
			int key = array[i];
			int j = i - interval;
			while (j>=0 && key<array[j]) {
				array[j+interval] = array[j];
				j -= interval;
				cnt++;
			}
			array[j+interval] = key;
		}
	}
	
	public static void shellSort(int[] array, int length) {
		List<Integer> intervals = new ArrayList<Integer>();
		for (int i=1; i<=length; i = 3*i+1) {
			intervals.add(i);
		}
		
		int size = intervals.size();
		
		System.out.println(size);
		
		for (int i=size-1; i>=0; i--) {
			if (i>0) System.out.print(intervals.get(i) + " ");
			else System.out.println(intervals.get(i));
			
			insertionSort(array, length, intervals.get(i));
		}
		
		System.out.println(cnt);
		printArray(array);
	}
	
	public static void printArray(int[] array) {
		for (int i = 0; i < array.length; i++) {
			System.out.println(array[i]);
		}
	}
}



Measured memory_bytes: 299652
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    char X, Y;
    cin >> X >> Y;
    if (X == Y) {
        cout << "=" << endl;
    }
    else if (X < Y) {
        cout << "<" << endl;
    }
    else {
        cout << ">" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int N = 505;
pii p[N];
int n, vis[N *  N];

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &p[i].first), p[i].second = i;
	sort(p + 1, p + n + 1);
	for (int i = 1, j = 1, k; i <= n; ++i) {
		k = p[i].second;
		for (; k > 1 && j < p[i].first; ++j) if (!vis[j]) --k, vis[j] = p[i].second;
		if (k > 1) return puts("No"), 0;
		vis[p[i].first] = p[i].second;
	}
	for (int i = n, j = n * n, k; i; --i) {
		k = n - p[i].second;
		for (; k > 0 && j > p[i].first; --j) if (!vis[j]) --k, vis[j] = p[i].second;
		if (k > 0) return puts("No"), 0;
	}
	puts("Yes");
	for (int i = 1; i <= n * n; ++i) printf("%d ", vis[i]);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
  int n;
  cin >> n;
  vector<int> p(n+1);
  rep(i,n) {
    int x;
    cin >> x;
    p[i]=x-1;
  }
  p[n]=0;
  int ans = 0;
  int i = 0;
  while(i<n) {
    if(i==p[i]) {
      swap(p[i],p[i+1]);
      ans++;
    }
    i++;
  }
  cout << ans << endl;
  return 0;
}

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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
string s;
int n;
bool dp[100005];
string subs[] = {"dream", "dreamer", "erase", "eraser"};

signed main() {
  string s;
  cin >> s;
  n = s.size();
  REPS(i,0,n-4) {
    REP(j,4) {
      if(i > 0) {
        if(!dp[i-1]) continue;
      }
      string sub = subs[j];
      int sub_length = sub.size();
      if(i+sub_length > n)
        continue;

      auto itr = s.begin();
      if(equal(itr+i, itr+i+sub_length, sub.begin(), sub.end())) {
        dp[i+sub_length-1] = true;
      }
    }
  }
  if(dp[n-1]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep (i, N) A[i] = i;
  vector<P> mp(N);
  rep (i, N) {
    int x, y;
    cin >> x >> y;
    mp[i] = make_pair(x, y);
  }

  double sum = 0;
  int cnt = 0;
  do {
    P current = mp[A[0]];
    for (int i = 1; i < N; i++) {
      int dx = abs(current.first - mp[A[i]].first);
      int dy = abs(current.second - mp[A[i]].second);
      sum += sqrt(dx*dx + dy*dy);
      current = mp[A[i]];
    }
    cnt++;
  } while (next_permutation(A.begin(), A.end()));
  cout << fixed << setprecision(15) << sum / cnt << endl;
  return 0;
}


Measured memory_bytes: 3864
#include <iostream>
#include <queue>

using namespace std;

int main() {
  int a, b;
  priority_queue<int> results;

  cin >> a >> b;

  results.push(a + b);
  results.push(a - b);
  results.push(a * b);

  cout << results.top() << endl;

  return 0;
}


Measured memory_bytes: 256