akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

long[] dijkstra(long from, long to, long[][] edges)
{
	long[] path;
	auto cost = new long[](edges.length); fill(cost, long.max); cost[from] = 0;
	long[][] open = [[from]];
	while (!open.empty)
	{
		auto n = open.front; open.popFront;
		auto p = n[0];
		foreach (i; 0..edges.length)
		{
			if (edges[p][i] == -1) continue;
			auto c = cost[p] + edges[p][i];
			if (c < cost[to] && c < cost[i]) { cost[i] = c; if (i == to) path = i ~ n; else open ~= i ~ n; }
		}
	}
	return cost[to] ~ path;
}

void main()
{
	auto N = RD;
	auto S = RD!string;

	long l, r;
	foreach (c; S)
	{
		if (c == '(') ++l;
		else if (l >= 1) --l;
		else ++r;
	}
	foreach (i; 0..r) write("(");
	write(S);
	foreach (i; 0..l) write(")");
	writeln();
	
	stdout.flush();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <queue>
using namespace std;

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

long long A, B, C, D;

long long endgame[16777216];

long long doit(long long x) {
  memset(endgame, 1, sizeof(endgame));
  endgame[0] = 0;
  FOR(i,16777216) {
    while (i && D+endgame[i] < endgame[i-1]) { endgame[i-1] = D+endgame[i]; i--; }
    #define X(x,y) if (x < 16777216) endgame[x] = min(endgame[x], endgame[i]+y);
    X(2*i, A);
    X(3*i, B);
    X(5*i, C);
    X(i+1, D);
  }
  long long bound = 0x7fffffffffffffffLL;
  std::unordered_map<long long, long long> dp;
  dp[x] = 0;
  std::priority_queue<long long> q;
  q.push(x);
  while (q.size()) {
    x = q.top(); q.pop();
    if (x < 16777216) bound = min(bound, endgame[x]+dp[x]);
    else {
      if (dp[x] > bound) continue;
      if (dp[x]+D*(double)x < (double)bound) bound = dp[x] + D*x;
      long long xnu = x/2;
      long long xnucost = dp[x] + A + D*(x%2);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
      xnu = (x+1)/2;
      xnucost = dp[x] + A + D*((2 - x%2)%2);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
      xnu = x/3;
      xnucost = dp[x] + B + D*(x%3);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
      xnu = (x+2)/3;
      xnucost = dp[x] + B + D*((3 - x%3)%3);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
      xnu = x/5;
      xnucost = dp[x] + C + D*(x%5);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
      xnu = (x+4)/5;
      xnucost = dp[x] + C + D*((5 - x%5)%5);
      if (!dp.count(xnu) || xnucost < dp[xnu]) dp[xnu] = xnucost, q.push(xnu);
    }
  }
  return bound;
}

int main() {
  int t;
  scanf("%i", &t);
  while(t--) {
    long long x;
    scanf("%lli%lli%lli%lli%lli", &x, &A, &B, &C, &D);
    printf("%lli\n", doit(x));
  }
}


Measured memory_bytes: 134560
n = gets.chomp.to_i
la = gets.split(" ").map(&:to_i)

def gcd(a, b)
  a, b = b, a if a < b
  return a if b == 0
  _mod = a.modulo(b)
  if _mod == 0
    b
  else
    gcd(b, _mod)
  end
end

def lcm(a, b)
  a * b / gcd(a, b)
end

ri = la.inject{|a,b| a.lcm(b)}-1

maxa = la.sort[-1]
m = maxa * 2 - 1

sum = 0
n.times do |i|
  sum += ri%la[i]
end
puts sum

Measured memory_bytes: 11384
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 110;
const int MAXK = 510;

ll a, b;

ll getXor(ll n) {
    if (n <= 0) return 0;
    if (n == 1) return 1;
    if (n == 2) return 3;
    if (n == 3) return 0;
    int x = 63 - __builtin_clzll(n);
    ll lb = (1LL << x);
    ll num = n - lb + 1;
    ll res = 0;
    if (num % 2) res = lb;

    return res + getXor(n - lb);
}

ll getXorTrau(int n) {
    ll res = 0;
    FOR(i,1,n) res ^= i;
    return res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b;
    // cout << getXor(a-1) << endl;
    // cout << getXor(b) << endl;
    // cout << getXorTrau(a-1) << endl;
    // cout << getXorTrau(b) << endl;
    ll res = getXor(b) ^ getXor(a-1);
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {

	int N,M,X; cin >> N >> M >> X;

	int r = 0;
	int l = 0;
	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		if (X < a) {
			r++;
		}else{
			l++;
		}
	}
	cout << min(r,l) << endl;
	return 0;
}


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

int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    long long cnt = 0, sum = 0;
    for (long long i = 0; i < a; i++)
    {
        if (cnt == k)
        {
            break;
        }
        sum += 1;
        cnt++;
    }
    for (long long i = 0; i < b; i++)
    {
        if (cnt == k)
        {
            break;
        }
        sum += 0;
        cnt++;
    }
    for (long long i = 0; i < c; i++)
    {
        if (cnt == k)
        {
            break;
        }
        sum -= 1;
        cnt++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3628
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


a, b, c, x, y = LI()


if 2*c <= a + b:
    if x > y:
        if a <= 2 * c:
            result = a * (x - y) + 2 * c * y
        else:
            result = 2 * c * max(x, y)
    elif x < y:
        if b <= 2 * c:
            result = b * (y - x) + 2 * c * x
        else:
            result = 2 * c * max(x, y)
    else:
        result = 2 * c * max(x, y)
else:
    result = a * x + b * y

print(result)

Measured memory_bytes: 6732
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll n;
    cin >> n;
    ll numNeg = 0;
    ll absmin = ll(1e10);
    ll sum = 0;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        if(tmp < 0){
            numNeg++;
        }
        if(absmin > abs(tmp)){
            absmin = abs(tmp);
        }
        sum += abs(tmp);
    }
    if(numNeg % 2 == 1){
        sum -= 2*absmin;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*
Code By: Sai Harsha K
 */

#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
#ifndef ONLINE_JUDGE
  // these lines to be executed in local machine not online judge
  // get input
  freopen("input.txt", "r", stdin);
  // put output
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);

  // solution
  int t = 1;
  while(t--) {
    int n;
    cin>>n;
    int a[n];
    for(int i = 0; i < n; i++) {
      cin>>a[i];
    }
    int dp[n];// 0 index
    // base case
    dp[0] = 0; dp[1] = abs(a[1] - a[0]);
    // populate dp
    for(int i = 2; i < n; i++) {
      dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),
                  dp[i-2] + abs(a[i] - a[i-2]));
    }
    cout<<dp[n-1];
  }

  return 0;
}


Measured memory_bytes: 4412
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  if(n*a<=b)
    printf("%d\n",n*a);
  else
    printf("%d\n",b);
  return 0;
}


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

int main() {
	
	int k, a, b;; cin >> k >> a >> b;
	bool can = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			can = true;
		}
	}
	if (can) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <list>
#include <stack>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <memory>
#include <regex>
#include <functional>
using namespace std;

int input[1007];
int main() {
    int N;
    cin >> N;
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> input[i];
    }
    sort(input, input + N, greater<int>());
    for (int i = 0; i < N; i++)
    {
        if ((i & 1) == 0) alice += input[i];
        else bob += input[i];
    }
    cout<<(alice - bob) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
int main (){
	int N=0;
	int l[1000],r[1000];
	//int seki[100000];
	int count=0;
	for(int i=0;i<100000;i++){
		//seki[i]=0;
	}
	scanf("%d",&N);

	for(int i=0;i<N;i++){
		scanf("%d %d",&l[i],&r[i]);
		for(int f=l[i]-1;f<r[i];f++){
			count++;
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[1100000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a==1&&b){
		printf("-1\n");return 0;
	}else if(a==1){
		printf("0 0 1 1\n");return 0;
	}else if(a==0){
		if(b){printf("-1\n");return 0;}
		printf("0 0\n");return 0;
	}
	int sz=0;
	p[sz++]=0;
	p[sz++]=1;
	p[sz++]=0;
	for(int i=2;i<(1<<a);i++)p[sz++]=i;
	p[sz++]=1;
	for(int i=(1<<a)-1;i>=2;i--)p[sz++]=i;
	int v=b^1;
	for(int i=0;i<sz;i++){
		p[i]^=v;
		if(p[i]>=(1<<a)){printf("-1\n");return 0;}
	}
	for(int i=0;i<sz;i++)printf("%d ",p[i]);printf("\n");
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int seica[111];
int ans;


void dfs(int depth,int now){
	if(now > 75)return;
	if(depth == 100){
		if(now == 75)ans++;
		return;
	}
	dfs(depth + 1,now);
	if(seica[depth] >= 2)dfs(depth + 1,now * 3);
	if(seica[depth] >= 4)dfs(depth + 1,now * 5);
	if(seica[depth] >= 14)dfs(depth + 1,now * 15);
	if(seica[depth] >= 24)dfs(depth + 1,now * 25);
	if(seica[depth] >= 74)dfs(depth + 1,now * 75);
}

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

	for(int i = 2;i <= n;i++){
		int tmp = i;
		for(int j = 2;j < 100;j++){
			while(tmp % j == 0){
				tmp /= j;
				seica[j]++;
			}
		}
	}

	dfs(0,1);
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N, M, X; cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
    for (int j = 0; j < M; j++) cin >> A.at(i).at(j);
  }
  const int INF = 1000000007;
  int ans = INF;

  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> score(M, 0);
    int cost = 0;

    for (int i = 0; i < N; i++) {
      if ((bit >> i) & 1) {
        cost += C.at(i);
        for (int j = 0; j < M; j++) {
          score.at(j) += A.at(i).at(j);
        }
      }
    }

    bool ok = true;
    for (int i = 0; i < M; i++) {
      if (score.at(i) < X) ok = false;
    }
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

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

int main() {
  ll n,m;
  cin >> n >> m;
  vector<set<ll>> v(n);
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    v[a].insert(b);
  }
  ll s,t;
  cin >> s >> t;
  s--;
  t--;
  vector<vector<ll>> dis(n,vector<ll> (3,-1));
  queue<pll> q;
  q.push(pll(s,0));
  dis[s][0]=0;
  while(q.size()) {
    ll f=q.front().first;
    ll d=q.front().second;
    q.pop();
    for(ll t:v[f]) {
      if(dis[t][(d+1)%3]<0) {
        dis[t][(d+1)%3]=d+1;
        q.push(pll(t,d+1));
      }
    }
  }
  if(dis[t][0]<0) {
    cout << -1 << endl;
  }
  else {
    cout << dis[t][0]/3 << endl;
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    using ll = long long;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        // a[i] += (i == 0 ? 0LL : a[i - 1]);
    }
    for (int i = 0; i < m; ++i) {
        cin >> b[i];
        // b[i] += (i == 0 ? 0LL : b[i - 1]);
    }

    auto sa = 0LL;
    auto sb = accumulate(b.begin(), b.end(), 0LL);
    int r = m - 1;
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        sa += (i == 0 ? 0LL : a[i - 1]);
        while (r >= 0 && sa + sb > k) {
            sb -= b[r];
            --r;
        }
        if (sa + sb <= k) ans = max(ans, i + r + 1);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)



int main(){
    ll n;cin>>n;
    ll a[n];rep(i,n)cin>>a[i];
    ll absmin=1000000009;
    ll minusctr=0;
    ll abssum=0;
    bool zfinder=0;
    rep(i,n){
        if(a[i]<0)minusctr++;
        else if(a[i]==0){
            zfinder=1;
        }
        chmin(absmin,llabs(a[i]));
        abssum+=llabs(a[i]);
    }
    if(zfinder)cout<<abssum<<endl;
    else if(minusctr%2==0)cout<<abssum<<endl;
    else cout<<abssum-(2*absmin)<<endl;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  ll ng = 0;
  ll ok = 1001001001;
  while(abs(ok-ng)>1){
    ll mid = (ok+ng)/2;
    ll dif = a-b;
    ll need = 0;
    rep(i,n){
      if(h[i] <= mid*b) continue;
      need += (h[i]-mid*b+dif-1)/dif;
    }
    if(need <= mid) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 4044
import sys
N = int(input())
A = list(map(int,input().split()))

if 0 in A:
    print(0)
    sys.exit()

INF = 10 ** 18
ans = 1
for i in range(N):
    ans *= A[i]
    if ans > INF:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 21784
let () =
  let n, c, k = Scanf.scanf "%d %d %d\n" (fun n c k -> n, c, k) in
  let ts = Array.init n (fun _ -> Scanf.scanf "%d " (fun n -> n)) in
  Array.sort compare ts;
  Array.fold_left (fun (acc, i, j) t ->
    if ts.(i) + k < t then (acc + 1, j, j + 1)
    else if c <= j - i then (acc + 1, i + c, j + 1)
    else (acc, i, j + 1)) (0, 0, 0) ts
  |> (fun (acc, _, _) -> Printf.printf "%d\n" (1 + acc))

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//d
int main(){

    int64_t N; cin >> N;
    int64_t n=N;

    if(N==1){
        cout << 0 << endl;
        return 0;
    }

    vector<int> x(1000000);
    rep(i, 1000000){
        if(i==0) continue;
        while(N%(i+1)==0){
            x[i]++;
            N/=(i+1);
        }
    }

    if(n>1000000 && N==n){
        cout << 1 << endl;
        return 0;
    }

    int ans=0;
    rep(i, 1000000){
        if(i==0) continue;
        int cnt=1;
        while(x[i]>=cnt){
            ans++;
            x[i]-=cnt;
            cnt++;
        }
    }

    if(N!=1) ans++;

    cout << ans << endl;

}

Measured memory_bytes: 7212
import java.util.*;

/**
 * A
 */
public class Main {

    void run() {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        sc.close();

        System.out.println(fib(n));

    }

    int fib(int n) {

        /*
        if(n==0 || n==1) {
            return 1;
        }
        */

        int a = 1;
        int b = 1;
        int tmp = 1;;

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

            tmp = a+b;
            a = b;
            b = tmp;

        }

        return tmp;

    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(void)
{
  int N,max;

  cin >> N;
  
  vector<int> d(N);
  for(int i=0;i<N;i++) cin >> d[i];
  
  sort(d.begin(),d.end() );
  
  int sum=1;
  for(int i=0; i<N-1; i++)
  {
    if(d[i]==d[i+1])
    {
    }
    else
    {
      sum++;
    }
  }
  cout << sum;
  
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  string p;
  cin >> p;
  vll dp(n, vl(n));
  rep (i, n) {
    int j = n - 1 - i;
    dp[i][j] = 1;
  }
  vll sum(n, vl(n + 1));
  rep (i, n) {
    if (n - 1 - i < 0) {
      sum[n - 1][i + 1] = sum[n - 1][i];
    }
    else {
      sum[n - 1][i + 1] = sum[n - 1][i] + dp[i][n - 1 - i];
    }
    sum[n - 1][i + 1] %= MOD;
  }
  int cnt = 0;
  for (int nokori = n - 2; nokori >= 0; nokori--) {
    rep (i, n) {
      int j = nokori - i;
      if (j < 0) continue;
      if (p[cnt] == '<') {
        dp[i][j] = (sum[i + j + 1][i + j + 2] - sum[i + j + 1][i + 1]) % MOD;
      }
      else {
        dp[i][j] = sum[i + j + 1][i + 1] % MOD;
      }
    }
    cnt++;
    rep (i, n) {
      if (nokori - i < 0) {
        sum[nokori][i + 1] = sum[nokori][i];
      }
      else {
        sum[nokori][i + 1] = sum[nokori][i] + dp[i][nokori - i];
      }
      sum[nokori][i + 1] %= MOD;
    }
    
  }
  cout << (dp[0][0] + MOD) % MOD<< endl;
}


Measured memory_bytes: 141184
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2:
    print("infinity")
    exit()
if a1 < b1:
    tnp = a1
    a1 = b1
    b1 = tnp
    tnp = a2
    a2 = b2
    b2 = tnp
if (a1-b1) * t1 + (a2-b2) * t2 > 0:
    print(0)
    exit()
num = -(a1-b1) * t1 - (a2-b2) * t2
ans = 1

ans += ((a1-b1)*t1 // num)*2
if (a1-b1)*t1 % num == 0:
    ans -= 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    long long n; cin >> n;
    int b,digit;
    int minf=11;
    for (int i = 1; i <= (int)sqrt(n); i++)
    {
        if(n%i==0) {
            b = n/i;
            digit=0;
            while(b){
                digit++;
                b /= 10;
            };
            if(minf>digit) minf = digit;
        }
    }
    
    cout << minf << endl;
    
    
    return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll cnt[5];
ll one, two;
int main() {
	REP(i,0,3){
		int a, b;
		cin>>a>>b;
		cnt[a]++;
		cnt[b]++;
	}
	REP(i,1,5){
		if(cnt[i]==1){
			one++;
		}else if(cnt[i]==2){
			two++;
		}
	}
	if(one==2 && two==2){
		p("YES");
	}else{
		p("NO");
	}
	return 0;
}


Measured memory_bytes: 256
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1

h_mx = max(h_cnt)
w_mx = max(w_cnt)

cnt = h_cnt.count(h_mx) * w_cnt.count(w_mx)
for h, w in hw:
    val = h_cnt[h] + w_cnt[w]
    if val == h_mx + w_mx:
        cnt -= 1

if cnt:
    ans = h_mx + w_mx
else:
    ans = h_mx + w_mx - 1

print(ans)


Measured memory_bytes: 68268
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    cout << 3 * r * r << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

N, D = list(map(int, input().split()))
X = []
for _ in range(N):
  X += [list(map(int, input().split()))]

X = np.atleast_3d(X)
L = np.linalg.norm(X - X.T, axis=1)
c = (np.count_nonzero(L == L.astype(int)) - N) // 2

print(c)

Measured memory_bytes: 12504
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n = II()
    ans = []
    sosu = [2]
    i = 2
    while len(ans) != n:
        for k in sosu:
            if i % k == 0:
                i += 1
                break
        else:
            sosu.append(i)
            if i % 5 == 1:
                ans.append(i)
            i += 1
    for i in ans:
        print(i, end=" ")
    print()
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 5992
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define all(a) a.begin(),a.end()
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18
# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

int main(){
    IOS;
    make2(double,a,b);
    make2(double,h,m);
    h=60*h+m;
    double th1=(M_PI/30)*m;
    double th2=(M_PI/360)*h;
   // cout<<th1<<" "<<th2;
    double ans=a*a+b*b-2*a*b*cos((abs(th1-th2)));
    cout<<setprecision(12)<<sqrt(ans)<<endl;

    return 0;
}


Measured memory_bytes: 4244
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, H, D = map(int, input().split())
    imos = [0] * (H+2)
    ans = [0] * (H+1)
    M = 0
    f = 1
    for i in range(1, N+1):
        f = (f * i)%mod
        M = (M + f)%mod
    imos[1] += f
    imos[D+1] -= f
    for i in range(1, H):
        ans[i] = (ans[i-1] + imos[i])%mod
        imos[i+1] = (imos[i+1] + (ans[i] * M)%mod)%mod
        if i+D+1 <= H:
            imos[i+D+1] = (imos[i+D+1] - (ans[i] * M)%mod)%mod
    print((ans[H-1] + imos[H])%mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81672
N,K = map(int,input().split())
d = {}
for _ in range(N):
    a,b = map(int,input().split())
    d[a] = d.get(a,0) + b
f = 0
for c in sorted(d.keys()):
    f += d[c]
    if f >= K:
        print(c)
        break

Measured memory_bytes: 10592
use strict;
use warnings;

my ($n, $y);
{
    my $in = <STDIN>;
    ($n, $y) = split(" ", $in);
    $y/=1000;
}
for (my $i=0; $i<=$n; $i++)
{
    for (my $j=0; $j<=$n-$i; $j++)
    {
        my $k=$n-$i-$j;
        print "$i $j $k\n" if $y==$i*10+$j*5+$k;
        exit if $y==$i*10+$j*5+$k;
    }
}
print "-1 -1 -1\n";

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// 998244353;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<LL>v;
map<LL, LL>ma;
set<Pll>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum[210000], ans, dp[210000], a[210000], b[210000];
string str, ss;
bool f;
char c;
struct lowlink {
	vector<vector<LL>>g;
	vector<LL>low, ord;
	vector<bool>visited;
	set<Pll>bridge;
	LL n = 0, cnt;
	lowlink(vector<vector<LL>>G) :g(G), n(G.size()) {
		low.resize(n);
		ord.resize(n);
		visited.resize(n);
		rep(i, n)low[i] = INF;
		dfs(0, -1);
		rep(i, n)rep(j, g[i].size()) {
			if (ord[i] < low[g[i][j]]) {
				bridge.insert(Pll(min(i, g[i][j]), max(i, g[i][j])));
			}
		}
	}
	void dfs(LL cur, LL par) {
		visited[cur] = 1;
		ord[cur] = cnt;
		low[cur] = ord[cur];
		cnt++;
		rep(i, g[cur].size()) {
			LL u = g[cur][i];
			if (u == par)continue;
			if (visited[u]) {
				low[cur] = min(low[cur], ord[u]);
			}
			else {
				dfs(u, cur);
				low[cur] = min(low[cur], low[u]);
			}
		}
	}
	bool is_bridge(LL u, LL v) {
		if (bridge.count(Pll(min(u, v), max(u, v))))return 1;
		return 0;
	}
	void print() {
		for (auto it = bridge.begin(); it != bridge.end(); it++) {
			cout << it->first << " " << it->second << endl;
		}
	}
};
int main() {
	cin >> n >> m;
	g.resize(n);
	rep(i, m) {
		LL x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	lowlink low(g);
	low.print();
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; string s; cin>>n>>s;
	string left,right;
	for(int i=0,cnt=0;i<n;++i){
		if(s.at(i)=='(')++cnt;
		else if(cnt)--cnt;
		else left+='(';
	}
	for(int i=n-1,cnt=0;i>=0;--i){
		if(s.at(i)==')')++cnt;
		else if(cnt)--cnt;
		else right+=')';
	}
	cout<<left<<s<<right<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<vector>
#include<list>
#include<queue>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  string S;
  cin >> S;

  string ans = "Yes";
  int n = S.size();

  rep(i, n){
    if(i%2 == 0){
      if(S[i] == 'L'){
	ans = "No";
	break;
      }
    }
    else{
      if(S[i] == 'R'){
	ans = "No";
	break;
      }
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/

vector<vector<int> > G(200005);
int cost[200005];
int flag[200005];
int ans[200005];

void solve(int now, int value) {

	//cout << "now= " << now << " value = " << value << endl;
	ans[now] = value;
	flag[now] = 1;
	//cout << ans[now] << endl;

	for (auto itr : G[now]) {

		if (flag[itr] == 0) {
			solve(itr, value + cost[itr]);
		}
	}
}

int main() {

	int n, q;
	cin >> n >> q;

	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (a > b) {
			swap(a, b);
		}

		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < q; i++)
	{
		int p, x;
		cin >> p >> x;
		p--;
		cost[p] += x;
	}




	solve(0, cost[0]);


	for (int i = 0; i < n; i++)
	{
		if (i == 0) {
			cout << ans[i];
		}
		else
		{
			cout << " " << ans[i];
		}
	}
	cout << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    string s;int k;cin >> s >> k;
    char ans = '1';
    for(int i = 0; i < s.size() && i < k; ++i) {
        if(s[i] != '1') {
            ans = s[i]; break;
        }
    }
    cout << ans << endl;

    

    return 0;
}

Measured memory_bytes: 256
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
li = [A, B, C, D, E]
temp = 9
idx = -1
for i in range(len(li)):
    if 0 != li[i] % 10 and temp >= li[i] % 10:
        temp = li[i] % 10
        idx = i

result = 0
for i in range(len(li)):
    if idx == i:
        result += li[i]
    else:
        result += math.ceil(li[i] / 10) * 10
print(result)


Measured memory_bytes: 3064
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = list(map(int, sys.stdin.buffer.readline().split()))
    print('Even' if (A*B)%2 == 0 else 'Odd')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
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))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

vector<int> solve(ll n) {
	if(n==1) return vector<int>();
	if(n%2==1) {
		vector<int> ret=solve(n-1);
		ret.insert(ret.begin(),SZ(ret));
		return ret;
	} else {
		vector<int> ret=solve(n/2);
		ret.push_back(SZ(ret));
		return ret;
	}
}

ll n;

void run() {
	scanf("%lld",&n);
	vector<int> p=solve(n+1);
	vector<int> ret=p; REPSZ(i,p) ret.PB(i);
	printf("%d\n",SZ(ret));
	REPSZ(i,ret) { if(i!=0) printf(" "); printf("%d",ret[i]+1); } puts("");
}

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


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

int main()
{
  long long int x, y;
  cin >> x >> y;
  long long int ans = 1LL << 60;
  if (x <= y)
    ans = min(ans, y - x);
  if (-x <= y)
    ans = min(ans, y + x + 1);
  if (x <= -y)
    ans = min(ans, -y - x + 1);
  if (-x <= -y)
    ans = min(ans, -y + x + 2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        h: [i64; n]
    }

    let mut dp = vec![1<<30; n];
    dp[0] = 0;
    for i in 0..n {
        for j in i+1..=min(i+k, n-1) {
            let cost = (h[i] - h[j]).abs();
            dp[j] = min(dp[j], dp[i] + cost);
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <bitset>
#include <vector>
#include <algorithm>
using namespace std;

typedef bitset<100> Node;

bool comp2(const Node& n1, const Node& n2)
{
	int p1=99, p2=99;
	while (!n1.test(p1)) p1--;
	while (!n2.test(p2)) p2--;

	p1--; p2--;
	while (p1>=0 && p2>=0)
	{
		bool t1=n1.test(p1), t2=n2.test(p2);
		if (!t1 && t2)
			return true;
		if (t1 && !t2)
			return false;
		p1--; p2--;
	}

	if (p1 > p2)
		return !n1.test(p1);
	if (p1 < p2)
		return n2.test(p2);
	return false;
}

void parse(string s, vector<Node>& t, Node n)
{
	if (s.empty())
		return;
	t.push_back(n);

	s = string(s.begin()+1, s.end()-1);
	int c=0, i=0;
	for (; i<s.size(); i++)
		if (s[i]=='(')
			c++;
		else if (s[i]==')')
			c--;
		else if (s[i]==',' && c==0)
			break;

	string s1=string(s.begin(), s.begin()+i), s2=string(s.begin()+i+1, s.end());
	n <<= 1;
	if (!s1.empty())
		parse(s1, t, n);
	n = n.set(0);
	if (!s2.empty())
		parse(s2, t, n);
}

string rec(vector<Node> t)
{
	if (t.empty())
		return "";

	vector<Node> t1, t2;
	vector<Node>::iterator it=find(t.begin(), t.end(), Node(1));
	t1 = vector<Node>(t.begin(), it);
	t2 = vector<Node>(it+1, t.end());

	for (int i=0; i<t1.size(); i++)
		t1[i] >>= 1;

	for (int i=0; i<t2.size(); i++)
		t2[i] >>= 1;

	return "(" + rec(t1) + "," + rec(t2) + ")";
}

int main()
{
	string s;
	while (getline(cin, s))
	{
		char c=s[0];
		s = string(s.begin()+1, s.end());
		for (int i=0; i<s.size(); i++)
			if (s[i]==' ')
			{
				s.erase(s.begin()+i); i--;
			}

		int p = s.find(")(", 0);
		string s1 = string(s.begin(), s.begin()+(++p));
		string s2 = string(s.begin()+p, s.end());

		vector<Node> t1, t2;
		parse(s1, t1, Node(1));
		parse(s2, t2, Node(1));

		sort(t1.begin(), t1.end(), comp2);
		sort(t2.begin(), t2.end(), comp2);

		vector<Node> res(200, Node());
		vector<Node>::iterator it;
		if (c == 'i')
			it = set_intersection(t1.begin(), t1.end(), t2.begin(), t2.end(), res.begin(), comp2);
		else
			it = set_union(t1.begin(), t1.end(), t2.begin(), t2.end(), res.begin(), comp2);
		res = vector<Node>(res.begin(), it);

		cout << rec(res) << endl;
	}
}

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

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


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

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


void moveAll(vector<vector<char>> &map, vector<vector<int>> &dijkstra, int y, int x, int h, int w);

void
on(vector<vector<char>> &map, vector<vector<int>> &dijkstra, int fromY, int fromX, int toY, int toX, int h, int w) {
    int fromCost = dijkstra[fromY][fromX];
    int toCost = dijkstra[toY][toX];
    if (map[toY][toX] == '#') return;
    if (fromCost + 1 >= toCost) return;

    dijkstra[toY][toX] = fromCost + 1;
    moveAll(map, dijkstra, toY, toX, h, w);

}


void moveAll(vector<vector<char>> &map, vector<vector<int>> &dijkstra, int y, int x, int h, int w) {
    if (x + 1 < w) {
        on(map, dijkstra, y, x, y, x + 1, h, w);
    }
    if (y + 1 < h) {
        on(map, dijkstra, y, x, y + 1, x, h, w);
    }
    if (x - 1 >= 0) {
        on(map, dijkstra, y, x, y, x - 1, h, w);
    }
    if (y - 1 >= 0) {
        on(map, dijkstra, y, x, y - 1, x, h, w);
    }

}

int main() {

    int h, w;
    cin >> h >> w;
    vector<vector<char>> map(h, vector<char>(w));
    rep(y, h)rep(x, w) cin >> map[y][x];
    vector<vector<int>> dijkstra(h, vector<int>(w, INF));
    dijkstra[0][0] = 1;
    moveAll(map, dijkstra, 0, 0, h, w);

    int start_white = 0;
    rep(y, h)rep(x, w) if (map[y][x] == '.') start_white++;

    int dijkstra_difference = dijkstra[h - 1][w - 1];

    if (dijkstra_difference == INF) {
        cout << -1 << endl;
        return 0;
    }

    int ans = start_white - dijkstra_difference;

    cout << ans << endl;
}

Measured memory_bytes: 512
N,W=map(int,input().split())

dp=[[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
	w,v=map(int,input().split())
	j=0
	for j in range(1,W+1):
		if j-w>=0:
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-w]+v)
		else:
			dp[i][j]=dp[i-1][j]
			j+=1
print(dp[-1][-1])

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int q;

int main() {
    cin >> q;
    rep(i,q) {
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a == b) {
            cout << (a-1)*2 << endl;
        } else {
            ll x = (ll)sqrt(a*b);
            if ((x+1)*(x+1) <= a*b) x++;
            if (x*x == a*b) x--;
            if (x*(x+1) < a*b) {
                cout << (x-1)+2+(a-1)+min(x-a-1, b-(x+1)-1) << endl;
            } else {
                cout << (x-1)+1+(a-1)+min(x-a-1, b-x-1) << endl;
            }
        }
    }
}
































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

int main(){
  ll k,n;
  cin >> k >> n;
  ll a[n+2];
  a[0] = 0;
  rep(i,1,n+1) cin >> a[i];
  a[n+1] = k;
  ll dis = 0;

  rep(i,1,n+1){
    ll d;
    if(i==1){
      d = a[1] + (a[n+1]-a[n]);
    }
    else{
      d = a[i] - a[i-1];
    }
    dis = max(dis,d);
  }

  cout << k-dis << endl;

  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,m;
  cin>>n>>m;
  int p[m],y[m];
  vector<int>vec[n+1];
  map<int,int>mp;
  rep(i,m) {
    cin>>p[i]>>y[i];
    mp[y[i]]=p[i];
    vec[p[i]].push_back(y[i]);
  }
  rep(i,n) {
    sort(vec[i+1]);
  }
  rep(i,m) {
    printf("%06Ld",mp[y[i]]);
    printf("%06Ld\n",low(all(vec[p[i]]),y[i])-vec[p[i]].begin()+1);
  }
}

Measured memory_bytes: 14720
N, M = map(int, input().split())
A = list(map(int,input().split()))

A = sorted(A, reverse=True)
sumVote = int(sum(A))

flag = 1

for i in range(M):
    if A[i] < (sumVote / (4 * M)):
        flag = -1

if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import math


def p_b():
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            d = sum([(X[i][k] - X[j][k]) ** 2 for k in range(D)])
            if math.sqrt(d).is_integer():
                ans += 1
    print(ans)
    
p_b()

Measured memory_bytes: 38256