akhauriyash/Code-Regression huggingface dataset:
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defvar *n* (read))
(defvar *k* (read))
(defvar *hi* (make-array *n*))

;dp[i]→i番目にたどり着くための最小コスト
(defvar *dp* (make-array *n* :initial-element nil))

(dotimes (i *n*)
         (setf (aref *hi* i) (read)))

(defun cost (now delta)
   (abs (- (aref *hi* now) (aref *hi* (- now delta)))))

;dpテーブル初期化
(setf (aref *dp* 0) 0)

(defun cand (i delta)
  (if (or (< *k* delta) (< (- i delta) 0))
    nil
    (cons (+ (ans (- i delta)) (cost i delta)) (cand i (+ delta 1)))))

(defun ans (i)
  (cond
    ((aref *dp* i) (aref *dp* i))
    (t
       (setf (aref *dp* i) (apply #'min (cand i 1))))))

(print (ans (1- *n*)))


Measured memory_bytes: 70716
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
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; }
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << a + b + c + d << endl;
  return 0;
}


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


int main(){

    int N, M;
    int A[100000];
    cin >> N >> M;
    for( int i = 0; i < N; i++ ) cin >> A[i];


    int B[100001] = {};
    for( int i = 0; i < N; i++ ){
        B[i+1] = B[i] + A[i] % M;
        B[i+1] %= M;
    }

    long ans = 0;
    map<long, long> MM; // map<key, type>
    for (int i = 0; i < N + 1; i++) {
        ans += MM[B[i]]; // B[i]の写像
        MM[B[i]]++; //
    }
 
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
       for(int j=1;j<=n;j++)
       {
           for(int k=1;k<=n;k++)
           {
               sum+=__gcd(i,__gcd(j,k));
           }
       }
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int a,b;
int main()
{
	cin >> a >> b;
	if(a + b == 15 && a * b == 15)
		cout << "x" << endl; 
	else if(a + b == 15)
		cout << "+" << endl;
	else if(a * b == 15)
		cout << "*" << endl;
	else 
		cout << "x" << endl;
	return 0;
}

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


void solve(long long K, std::string S){
    if (S.length() > K)
        cout << S.substr(0, K) << "..." << endl;
    else
        cout << S << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define modul 998244353
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,x,ans=1,a[200005];
int32_t main(){
CODE_START;
cout<<fixed;
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>a[i];
    if(a[i]==0)
        rc(0);
}
sort(a,a+n);
ans=1;
ll nr=1000000000000000000;
for(ll i=0;i<n;i++)
{
    x=a[i];
    ll val=(nr+1)/ans;
    if((nr+1)%ans!=0){
        val++;
    }
    if(x>=val){
        cout<<"-1";
        return 0;
    }
    ans=ans*x;
}
cout<<ans;
}



Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(all(A));
  int ans = 0;
  rep(i, K) ans += A[i];
  cout << ans << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200000

int main() {
    int N, K, C, dp1[MAXN + 3], dp2[MAXN + 3];
    char S[MAXN + 3];

    scanf("%d%d%d", &N, &K, &C);
    scanf("%s", S);

    dp1[0] = 0;
    for (int i = 1; i <= N; i++) {
        dp1[i] = dp1[i - 1];
        if (S[i - 1] == 'o')
            dp1[i] = max(dp1[i], 1 + dp1[max(0, i - C - 1)]);
    }

    dp2[N + 1] = 0;
    for (int i = N; i >= 1; i--) {
        dp2[i] = dp2[i + 1];
        if (S[i - 1] == 'o')
            dp2[i] = max(dp2[i], 1 + dp2[min(N + 1, i + C + 1)]);
    }

    for (int i = 1; i <= N; i++) {
        if (S[i - 1] == 'o' && dp1[i - 1] + dp2[i + 1] < K)
            printf("%d\n", i);
    }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct RMQ{
	using T = int;
	T operator()(const T &a, const T &b) { return min(a,b); };
	static constexpr T identity() { return INT_MAX; }
};

template<class Monoid>
class rangeUpdateQuery{
	private:
		using T = typename Monoid::T;
		Monoid op;
		const int n;
		vector<T> dat, lazy;
		int query(int a, int b, int k, int l, int r){
			evaluate(k);

			if(b <= l || r <= a) return op.identity();
			else if(a <= l && r <= b) return dat[k];
			else{
				int vl = query(a, b, k * 2, l, (l + r) / 2);
				int vr = query(a, b, k * 2 + 1, (l + r) / 2, r);
				return op(vl, vr);
			}
		}
		inline void evaluate(int k){
			if(lazy[k] == op.identity()) return;
			dat[k] = lazy[k];
			if(k < n){
				lazy[2 * k] = lazy[k];
				lazy[2 * k + 1] = lazy[k];
			}
			lazy[k] = op.identity();
		}
		inline void propTo(int k){
			dat[k] = op(dat[2 * k], dat[2 * k + 1]);
		}
		void update(int a, int b, int k, int l, int r, int x){
			evaluate(k);
			if(r <= a || b <= l) return;
			if(a <= l && r <= b){
				lazy[k] = x;
				evaluate(k);
			}else if(l < b && a < r){
				update(a, b, k * 2, l, (l + r) / 2, x);
				update(a, b, k * 2 + 1, (l + r) / 2, r, x);
				propTo(k);
				evaluate(k);
			}
		}
		int power(int n){
			int res = 1;
			while(n >= res) res*=2;
			return res;
		}
	public:
		rangeUpdateQuery(int n) : n(power(n)), dat(4 * n, op.identity()), lazy(4 * n, op.identity()) {}
		rangeUpdateQuery(const vector<T> &v) : n(v.size()), dat(4 * n), lazy(4 * n, op.identity()){
			copy(begin(v), end(v), begin(dat) + n);
			for(int i = n - 1; i > 0; i--) propTo(i);
		}
		int query(int a, int b){ return query(a,b,1,0,n); }
		void update(int s, int t, int x){ update(s, t, 1, 0, n, x); }
		int get(int a){ return query(a, a + 1); };
		void out(int n){
			rep(i,n + 1){ cout << get(i) << ' '; }
			cout << endl;
			//rep(i,n){ range(j,i,n){ cout << i << ' ' << j + 1 << ' ' << query(i + 0,j + 1) << endl; } }
		}
		void out(){
			rep(i,n * 2){
				cout << i << " " << dat[i + 1] <<endl;
			}
		}
};

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

	rangeUpdateQuery<RMQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(not com){
			int s, t, x;
			cin >> s >> t >> x;
			//cout << s << ' ' << t << endl;
			seg.update(s + 0, t + 1, x);
		}else{
			int s, t;
			cin >> s >> t;
			cout << seg.query(s + 0, t + 1) << endl;
		}
		//seg.out(n);
	}
	//seg.out();
}



Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
long long sum=0;
void cnt(long long a){
    if(a==1)
        sum +=300000;
    else if(a==2)
        sum +=200000;
    else if(a==3)
        sum +=100000;
    else
    {
        /* code */
    }
    
}
int main(){
    int x,y;
    cin>>x>>y;
    cnt(x);
    cnt(y);
    if(x==1 && y==1)
        sum +=400000;
    cout<<sum;
    return 0;
}

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

int main() {

	int n, t, i, min, max_profit;

	int *Rt;
	
	scanf("%d", &n);
	Rt = (int *)malloc(sizeof(int) * n);
	if (Rt == NULL) exit(0);

	for (t = 0; t < n; t++) {
		scanf("%d", &Rt[t]);
	}

	for (t = 0; t < n - 1; t++) {
		if (t == 0 || min > Rt[t]) {
			min = Rt[t];
			for (i = t + 1; i < n; i++) {
				if ((t == 0 && i == 1) || Rt[i] - Rt[t] > max_profit) {
					max_profit = Rt[i] - Rt[t];
				}
			}
		}
	}

	printf("%d\n", max_profit);

	free(Rt);
	return 0;

}

Measured memory_bytes: 3160
#include<stdio.h>
 
int a,b;
int t=0;
int main(void){
  scanf("%d",&a);
  scanf("%d",&b);
  if(a<=9){
    t=100*(10-a);
    printf("%d",t+b);
    return 0;
  }else{
    printf("%d",b);
       return 0;
       }
  
}

Measured memory_bytes: 128
import re
for i in range(int(input())):
 s=input().replace(" ","")
 print(re.sub(r'0.','',''.join([i+j for(i,j)in zip(str(10000+eval('+'.join([i[0]+{'m':'*1000','c':'*100','x':'*10','i':''}[i[1]]for i in ['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)])))[1:],list('mcxi'))]).replace('1','')))

Measured memory_bytes: 6584
#include <iostream>

using namespace std;

void maxHeapify(int tree[],int num,int H)
{
	int l = num*2+1;
	int r = num*2+2;
	int largest;

	if(l<H && tree[l]>tree[num])
	{
		largest = l;
	}
	else
	{
		largest = num;
	}
	if(r<H && tree[r]>tree[largest])
	{
		largest = r;
	}
	if(largest!=num)
	{
		int c = tree[num];
		tree[num] = tree[largest];
		tree[largest] = c;
		maxHeapify(tree,largest,H);
	}
	return;
}

void buildMaxHeap(int tree[],int H)
{
	for(int i=H/2; i>=0; i--)
	{
		maxHeapify(tree,i,H);
	}
	return;
}

int main(void)
{
	int H;
	cin >> H;
	int tree[H];

	for(int i=0;i<H;i++)
	{
		cin >> tree[i];
	}

	buildMaxHeap(tree,H);

	for(int i=0;i<H;i++)
	{
		cout << " " << tree[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  int n;
  cin >> n;
  using res = tuple<string, int, int>;
  vector<res> vec(n);
  rep(i, n) {
    string s;
    int p;
    cin >> s >> p;
    vec[i] = res(s, p, i + 1);
  }
  auto comp = [&](res a, res b) {
    if (get<0>(a) != get<0>(b)) {
      return get<0>(a) < get<0>(b);
    } else {
      return get<1>(a) > get<1>(b);
    }
  };
  sort(all(vec), comp);
  rep(i, n) cout << get<2>(vec[i]) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#include <chrono>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all() begin(),end()
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

ll n,m,m2;

struct kekka2{
    ll Sosuu;
    ll Shisuu;
};

class Modulo{
public:
    //以下x,y,mod>0を想定している
    ll mod;
    vector<ll> factable = {1};
    vector<ll> invtable = {1};
    Modulo(){
        mod = 1e9+7;
    }
    Modulo(ll _mod){
        mod = _mod;
    }
    ll mul(ll x,ll y){
        return ((x%mod)*(y%mod))%mod;
    }
    ll add(ll x,ll y){
        return ((x%mod)+(y%mod))%mod;
    }
    ll sub(ll x,ll y){
        ll d =((x%mod)-(y%mod))%mod;
        if(d>=0)return d;
        else return d+mod;
    }
    ll pow(ll x,ll y){
        //x^y % mod
        if(y<=0)return 1;
        if(y%2==0){
            ll d = pow(x,y/2);
            return ((d%mod)*(d%mod))%mod;
        }else{
            return (x*pow(x,y-1))%mod;
        }
    }
    ll div(ll x, ll y){
        //x/y % mod = x*y^(mod-2) % mod
        return mul(x,pow(y,mod-2));
    }
    ll fac(ll x){
        //x! % mod
        if(factable.size()<=x){
            ll s = factable.size();
            FOR(i,s,x+1){
                factable.push_back(mul(i,factable.back()));
                invtable.push_back(div(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    ll facinv(ll x){
        if(invtable.size()<=x){
            ll s = invtable.size();
            FOR(i,s,x+1){
                factable.push_back(mul(i,factable.back()));
                invtable.push_back(div(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    ll com(ll x,ll y){
        //xCy % mod = x!/((x-y)!*y!) % mod
        if(x-y<y)return com(x,x-y);
        return mul(fac(x),mul(facinv(x-y),facinv(y)));
    }
};


vector<kekka2> soinsu(ll n2){
    vector<kekka2> rtn;
    ll m2 = n2;
    for(ll i=2;i*i<=n2;++i){
        kekka2 k2;
        k2.Sosuu = i;
        k2.Shisuu = 0;
        while(m2%i==0){
            k2.Shisuu++;
            m2/=i;
        }
        if(k2.Shisuu>0){
            rtn.push_back(k2);
        }
    }
    if(m2>1){
        kekka2 k2;
        k2.Sosuu = m2;
        k2.Shisuu = 1;
        rtn.push_back(k2);
    }
    return rtn;
}

int main() {
    cin >> n >> m;
    m2 = m;
    Modulo mo(1e9+7);
    vector<kekka2> pd = soinsu(m);
    ll res = 1;
    REP(i,pd.size()){
        res = mo.mul(res,mo.com((pd[i].Shisuu+n-1),(ll)(n-1)));
    }
    put(res);
    return 0;
}


Measured memory_bytes: 2036
import java.util.*;

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      double r = sc.nextDouble();

      double menseki = r * r * Math.PI;
      double enshu = 2 * r * Math.PI;

      System.out.printf("%.5f %.5f\n", menseki, enshu);

      sc.close();
  }
}


Measured memory_bytes: 28244
n = int(input())
info = [list(input().split()) for i in range(n)]
ans = 0
for i in range(n):
  info[i][0]= float(info[i][0])
for i in range(n):
  if info[i][1] =="JPY":
    ans = ans + info[i][0]
  else:
    ans = ans + info[i][0]*380000
print(ans)


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

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n;
V<LL> a;

LL dp[2][100001];
int main(){
    INIT;
    cin >> n;
    a.resize(n+1);
    REP(i,n) cin >> a[i];
    dp[0][0] = a[0];
    dp[1][0] = -a[0];
    FOR(i,1,n-1) {
        dp[0][i] = std::max(dp[0][i-1]+a[i], dp[1][i-1]-a[i]);
        dp[1][i] = std::max(dp[0][i-1]-a[i], dp[1][i-1]+a[i]);
    }
    dp[0][n-1] = std::max(dp[0][n-2]+a[n-1], dp[1][n-2]-a[n-1]);
    cout << dp[0][n-1] << "\n";
}

Measured memory_bytes: 2560
from itertools import product
n=int(input())
ans=0

for l in range(1,11):
    for p in product('357',repeat=l): #3,5,7を組み合わせた要素数lのタプルを生成
        v=''.join(p) #p内の要素を結合
        u=v
        if '3' in v and '5' in v and '7' in v and int(u)<=n:
            ans+=1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int n, c, f, i, j;
vector<int> a(200000), vis(1000001), spf(1000001, 2);
int main()
{
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    for (i = 3; i < 1e6; i += 2)
        spf[i] = i;
    for (i = 3; i < 998; i += 2)
        if (spf[i] == i)
            for (j = i * i; j < 1e6; j += i)
                if (spf[j] == j)
                    spf[j] = i;
    cin >> n;
    for (i = 0; i < n; i++)
        cin >> a[i], vis[a[i]]++;
    if (vis[1])
    {
        cout << (vis[1] == 1 ? 1 : 0);
        return 0;
    }
    for (i = 0; i < n; i++)
        if (vis[a[i]] == 1)
        {
            if (a[i] != spf[a[i]])
                for (j = spf[a[i]]; j * j <= a[i]; j++)
                    if (a[i] % j == 0 && (vis[a[i] / j] || vis[j]))
                    {
                        c++;
                        break;
                    }
        }
        else c++;
    cout << n - c;
    return 0;
}

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

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

    int d = n % 10;
    n /= 10;
    int c = n % 10;
    n /= 10;
    int b = n % 10;
    n /= 10;
    int a = n % 10;

    if ((a == b && b == c) || (b == c && c == d)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n + 1, 0), sum(n + 1, 0), zero(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] ^ a[i];
        zero[i] = zero[i - 1] + (sum[i] == 0);
    }
    if (sum[n])
    {
        vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
        dp[0][0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i][0] = dp[i - 1][0];
            dp[i][1] = dp[i - 1][1];
            if (sum[i] == sum[n])
            {
                dp[i][1] += dp[i - 1][0];
                dp[i][1] %= MOD;
            }
            else if (sum[i] == 0)
            {
                dp[i][0] += dp[i - 1][1];
                dp[i][0] %= MOD;
            }
            else
            {
                /* code */
            }
        }
        cout << dp[n - 1][0] << endl;
        return 0;
    }
    vector<vector<int>> pos(1 << 20);
    for (int i = 1; i <= n; i++)
        pos[sum[i]].push_back(i);
    ll ret = 0;
    {
        ll p = 1;
        for (int i = 0; i < zero[n] - 1; i++)
            p = p * 2 % MOD;
        ret += p;
    }
    for (int i = 1; i < (1 << 20); i++)
    {
        if (pos[i].size() == 0)
            continue;
        vector<int> ps = {INF};
        int sz = pos[i].size();
        ps.push_back(zero[pos[i][0]]);
        ps.push_back(-1);
        for (int j = 1; j < sz; j++)
        {
            ps.push_back(zero[pos[i][j]] - zero[pos[i][j - 1]]);
            ps.push_back(-1);
        }
        n = ps.size() - 1;
        vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
        dp[0][0] = 1;
        for (int j = 1; j <= n; j++)
        {
            dp[j][0] = dp[j - 1][0];
            dp[j][1] = dp[j - 1][1];
            if (ps[j] == -1)
            {
                dp[j][1] += dp[j - 1][0];
                dp[j][1] %= MOD;
            }
            else
            {
                // 0 run length
                dp[j][0] += dp[j - 1][1] * ps[j] % MOD;
                dp[j][0] %= MOD;
            }
        }
        ret += dp[n][1];
        // cout << i << "  " << dp[n][0] << endl;
        // printv(ps);
        ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}


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

const int N = 100005;
int n, lf;
bool vis[N];
vector<int> adj[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	bool F = false;
	for(int i=0;i<n;i++) {
		if(adj[i].size() > 2) {
			F = true;
			break;
		}
	}
	if(!F) {
		puts("1");
		return 0;
	}
	for(int i=0;i<n;i++) {
		if(adj[i].size() != 1) continue;
		int I = i, P = -1;
		while(adj[I].size() <= 2) {
			for(auto &T : adj[I]) {
				if(T != P) {
					P = I;
					I = T;
					break;
				}
			}
		}
		if(vis[I]) {
			lf++;
			continue;
		}
		else vis[I] = true;
	}
	printf("%d\n",lf);
}


Measured memory_bytes: 6272
#include<stdio.h>
#define MAX 10000

int main(){
    int H[MAX], W[MAX];
    int i, j, k;

    for(i = 0; i < MAX; i++){
        scanf("%d %d", &H[i], &W[i]);
        if(H[i] == 0 && W[i] == 0) break;
    }

    for(i = 0; i < MAX; i++){
        if(H[i] == 0 && W[i] == 0) break;
        for(j = 0; j < H[i]; j++){
            for(k = 0; k < W[i]; k++){
                if(k >= 1 && k < W[i] - 1 && j >= 1 && j < H[i] - 1){
                    printf(".");
                }
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int n;  cin >> n;
    vector<vector<ll>> original(n, vector<ll>(n, LINF));
    REP(i, n) REP(j, n) cin >> original[i][j];
    vector<vector<ll>> copy = original;
    REP(k, n){
        REP(i, n){
            REP(j, n){
                copy[i][j] = min(copy[i][j], copy[i][k]+copy[k][j]);
            }
        }
    }
    if(copy!=original){
        cout << -1 << endl;
        return 0;
    }
    ll res=0;
    
    REP(i, n){
        
        REP(j, n){
            bool flag=false;
            REP(k, n)
                if(k!=i && k!=j &&copy[i][j]==copy[i][k]+copy[k][j]) flag =true; 
            if(!flag) res += copy[i][j];
        }
        
    }
    
    cout << res/2 << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,h;
    cin >> n >> h;
    vector<ll>A(n);
    vector<ll>B(n);
    REP(i,n){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(),A.end(),greater<ll>());
    sort(B.begin(),B.end(),greater<ll>());
    ll cnt= 0;
    REP(i,n){
        if(A[0]<B[i]){
            h-=B[i];
            cnt++;
            if(h<=0) break;
        }else{
            break;
        }
    }
    if(h>0) cnt+= (h+(A[0]-1))/A[0];
    cout << cnt << endl;
}
    

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map {it.toInt()}
    val A = Array(N) { readLine()!! }
    val B = Array(M) { readLine()!! }

    fun match(di: Int, dj: Int): Boolean {
        for (i in B.indices) for (j in B[i].indices) {
            if (A[di + i][dj + j]  != B[i][j]) {
                return false
            }
        }
        return true
    }

    var res = false

    for (i in 0 .. N - M) for (j in 0 .. N - M) {
        res = res || match(i, j)
    }

    println(if (res) "Yes" else "No")
}


Measured memory_bytes: 37860
from collections import deque


# INPUT
n = int(input())


# PROCESS
que = deque()

for _ in range(n):

    command = input()

    if   command == "deleteFirst":
        que.popleft()
    elif command == "deleteLast":
        que.pop()
    else:
        command, x = command.split()

        if   command == "insert":
            que.appendleft(int(x))

        elif command == "delete":
            try:
                que.remove(int(x))
            except:
                pass


# OUTPUT
print(*que)



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

int main() {
  int a=0,b=0,c=0,d=0,e=0;
  
  for(int i=1;i<=10000;i++){
  cin >> a >> b;
    if(a==0 && b==0){
      break;
    }
    if(a>b){
      swap(a,b);
    }
  cout << a << ' ' << b << endl;
  }
  return 0;
}



Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    string S; cin >> S;
    Pint bw[N + 1];
    bw[0] = mp(0, 0);//black, white
    rep(i, N) {
        bw[i + 1].first = bw[i].first + int(S[i] == '#');
        bw[i + 1].second = bw[i].second + int(S[i] == '.');
    }
    int ans = INF;
    rep(i, N + 1) {
        Pint l = bw[i], r = mp(bw[N].first - bw[i].first, bw[N].second - bw[i].second);
        ans = min(ans, l.first + r.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let s=ts()
  let w=0
  for(let i=0;i<s.length;i++){
    w+=Number(s[i])
  }
  to(Number(s)%w==0?'Yes':'No')
}
main()


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

int main()
{
	int c1x = 0, c1y = 0, c1r = 0, c2x = 0, c2y = 0, c2r = 0;
	double d = 0;

	cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;

	d = sqrt(pow(c1x - c2x, 2) + pow(c1y - c2y, 2));

	if (d > c1r + c2r)
		cout << 4 << endl;
	else if (d == c1r + c2r)
		cout << 3 << endl;
	else if (d > abs(c1r - c2r) && d < c1r + c2r)
		cout << 2 << endl;
	else if (d == abs(c1r - c2r))
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 3104
S = input()
y = 0
sum_t = 0
up = False
pre = 0
for c in S:
	if c == '<':
		if up:
			y += 1
		else:
			y = 1
			up = True
		sum_t += y
	elif c == '>':
		if up:
			pre = y
			y = 1
			up = False
		else:
			y += 1
			sum_t += y
			if y <= pre:
				sum_t -=1
print(sum_t)

Measured memory_bytes: 4104
import java.util.*;

public class Main {
  public static void main(final String[] args) throws Exception {
    final Scanner scanner = new Scanner(System.in);
    try {
      int h1 = scanner.nextInt();
      int m1 = scanner.nextInt();
      int h2 = scanner.nextInt();
      int m2 = scanner.nextInt();
      int k = scanner.nextInt();

      int ans = h2 * 60 + m2 - h1 * 60 - m1 - k;
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 35640
S=input()
tag = ["A","T","C","G"]
res = 0
for i in range(0,len(S)):
    if S[i] in tag:
        cnt = 1
        for j in range(i+1,len(S)):
            if S[j] in tag:
                cnt = cnt + 1
            else:
                break
        res = max(res,cnt)
print(res)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> cList = new ArrayList<>();
		for(int i = 0 ; i < 9 ; i++) {
			cList.add(sc.nextInt());
		}
		if(!verticalCheck(cList, 0) || !verticalCheck(cList, 3)) {
			System.out.println("No");
			return;
		}

		if(!horizonCheck(cList, 0) || !horizonCheck(cList, 1)) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");

	}

	private static boolean verticalCheck(ArrayList<Integer> cList, Integer start) {
		Integer v1 = cList.get(start + 3) - cList.get(start);
		Integer v2 = cList.get(start + 4) - cList.get(start + 1);
		Integer v3 = cList.get(start + 5) - cList.get(start + 2);
		return v1 == v2 && v2 == v3;
	}

	private static boolean horizonCheck(ArrayList<Integer> cList, Integer start) {
		Integer v1 = cList.get(start + 1) - cList.get(start);
		Integer v2 = cList.get(start + 4) - cList.get(start + 3);
		Integer v3 = cList.get(start + 7) - cList.get(start + 6);
		return v1 == v2 && v2 == v3;
	}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define s second
#define f first
#define N 20
#define M 16
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
string s[N];
int r,c;

bool bfs(){
  bool d[N][N][4][M];
  queue<P1> q;
  int dy[4]={-1,0,1,0};
  int dx[4]={0,1,0,-1};
  memset(d,0,sizeof(d));
  q.push(P1(P(0,0),P(1,0)));
  while(!q.empty()){
    P1 t=q.front(); q.pop();
    int y=t.f.f,x=t.f.s;
    int dir=t.s.f,mem=t.s.s;
    int ndir=dir,nmem=mem;
    if(d[y][x][dir][mem])continue;
    d[y][x][dir][mem]=true;
    if(s[y][x]=='@')return true;
    if(s[y][x]=='<')ndir=3;
    if(s[y][x]=='>')ndir=1;
    if(s[y][x]=='^')ndir=0;
    if(s[y][x]=='v')ndir=2;
    if(s[y][x]=='_'){
      if(!mem)ndir=1;
      else ndir=3;
    }
    if(s[y][x]=='|'){
      if(!mem)ndir=2;
      else ndir=0;
    }
    if('0'<=s[y][x]&&s[y][x]<='9')
      nmem=s[y][x]-'0';
    if(s[y][x]=='+')
      nmem=(mem+1)%16;
    if(s[y][x]=='-')
      nmem=(mem+15)%16;
    if(s[y][x]=='?'){
      for(int i=0;i<4;i++){
	int ny=y+dy[i];
	int nx=x+dx[i];
	if(ny<0)ny=r-1;
	if(nx<0)nx=c-1;
	if(r<=ny)ny=0;
	if(c<=nx)nx=0;
	q.push(P1(P(ny,nx),P(i,nmem)));
      }
    }else{
      int ny=y+dy[ndir];
      int nx=x+dx[ndir];
      if(ny<0)ny=r-1;
      if(nx<0)nx=c-1;
      if(r<=ny)ny=0;
      if(c<=nx)nx=0;
      q.push(P1(P(ny,nx),P(ndir,nmem)));
    }
  }
  return false;
}

int main(){
  cin>>r>>c;
  for(int i=0;i<r;i++)cin>>s[i];
  if(bfs())cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	ll res{0};
	for (ll i = 0; i < N; ++i)
	{
		ll a, b; cin >> a >> b;
		res += b - a + 1;
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pf printf
#define sc scanf
#define maxsize 1100005
#define lb cout<<endl;
#define F first
#define S second
#define print(i) cout<<i<<endl
#define print1(i,j) cout<<i<<" "<<j<<endl
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll dp[maxsize];

ll power(ll x, ll  y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

int main()
{
	IOS
	
	/*#ifndef ONLINE_JUDGE   
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif*/

	    
	    rep(i,maxsize)
	    dp[i]=mx;
	    ll n;
		cin>>n;
		ll a[n];
		rep(i,n)
		cin>>a[i];
		
		dp[0]=0;

		rep(i,n)
		{
			dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
			dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
		}

		cout<<dp[n-1]<<endl;

	/*
	#ifndef ONLINE_JUDGE
    	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif*/

    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <double> vd;

vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}

//int cnt =0;
//
//void SieveOfEratosthenes(int n)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
//

//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
long long int mx = 1000000000000000000;

long long int power(long long int base, long long int powerRaised)
{
    if (powerRaised != 0)
        return (base*power(base, powerRaised-1));
    else
        return 1;
}


int main() {
    int n;
    double a,b,c,m=0;
    string s,p;
    
    cin >> n;
    
    while(n--)
    {
        cin >> a >> s;
        
        if(s=="JPY")m+=a;
        else m+=(a*380000);
    }
    cout << fixed << setprecision(4) << m << endl;
    
    
    
    
    
    
    
    return 0;
}
 
 
 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    char s[16][16]={0};
    while(cin >> s[0])
    {
        int y,x; char c;
        for(y=1; y<8; y++)
        cin >> s[y];
 
        for(y=0; y<8; y++)
        for(x=0; x<8; x++)
        s[y][x]-='0';
 
        for(y=0; y<64; y++)
        if(s[y/8][y%8])break;
 
        x=y%8; y/=8;
 
             if(s[y+3][x  ]) c='B';
        else if(s[y  ][x+3]) c='C';
        else if(s[y+1][x+2]) c='E';     
        else if(s[y+2][x+1]) c='F';
        else if(s[y+1][x+1]) c='A';
        else if(s[y  ][x+1]) c='G';
        else                 c='D';
 
        cout << c << endl;
    }
}

Measured memory_bytes: 1132
const generateCombinations = (arr, count) => {
  const res = []
  for (let i = 0; i<arr.length; i++) {
    const el = arr[i]
    if (count > 1) {
      const clone = arr.slice(i+1)
      if (clone.length > 0) {
        const combs = generateCombinations(clone, count - 1)
        for (const t of combs) {
          res.push([el].concat(t))
        }
      }
    } else {
      res.push([el])
    }
  }
  return res
}

const processData = (lines) => {
  const [n, m, x] = lines[0].split(' ').map(x => +x)
  const books = []
  const total = Array(m).fill(0)
  for (let i=0; i<n; i++) {
    const l = lines[i+1].split(' ').map(x => +x)
    // console.log(l)
    const cost = l[0]
    const skills = l.slice(1).map(skill => Math.min(skill, x))
    // console.log(skills)
    for (let j=0; j<skills.length; j++) {
      total[j] += skills[j]
    }
    // console.log('t')
    books.push({cost, skills})
  }
  const isLess = total.some(skill => skill < x)
  if (isLess) {
    console.log(-1)
  } else {
    let price = Number.MAX_SAFE_INTEGER
    for (let i=1; i<=books.length; i++) {
      const combs = generateCombinations(books, i)
      for (const arr of combs) {
        let res = Array(m).fill(0)
        let sum = 0
        for (const curBook of arr) {
          for (let b=0; b<m; b++) {
            res[b] += curBook.skills[b]
          }
          sum += curBook.cost
        }
        const existsLess = res.some(skill => skill < x)
        if (!existsLess && price > sum) {
          price = sum
        }
      }
    }
    console.log(price)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


Measured memory_bytes: 37856
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[2][n];
    for(int i=0;i<n;i++)cin >> a[0][i];
    for(int i=0;i<n;i++)cin >> a[1][i];

    int ans = 0;
    for(int i=0;i<n;i++){
        int tmp = 0;
        for(int j=0;j<=i;j++)tmp += a[0][j];
        for(int j=i;j<n;j++)tmp += a[1][j];

        if(ans<tmp)ans = tmp;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list()
for i in range(n):
	x,y = map(str,input().split())
	y = int(y)
	if x == "S":
		a.append(y+0)
	elif x == "H":
		a.append(y+13)
	elif x == "C":
		a.append(y+26)
	elif x == "D":
		a.append(y+39)
for i in range(1,53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i-0))
		elif i <= 26:
			print("H {}".format(i-13))
		elif i <= 39:
			print("C {}".format(i-26))
		else:
			print("D {}".format(i-39))


Measured memory_bytes: 5592
Imports System.Collections.Generic
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim arrayA As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim a As List(Of Integer) = New List(Of Integer)
    Dim b As List(Of Integer) = New List(Of Integer)
    For i As Integer = 0 To n - 1
      a.Add(arrayA(i))
      b.Add(0)
    Next
    Dim sum As Integer = 0
    Dim m As Integer = 0
    For i As Integer = n - 1 To 0 Step -1
      sum = 0
      For j As Integer = n \ (i + 1) To 2 Step -1
        sum += b(j * (i + 1) - 1)
      Next
      sum = sum Mod 2
      If sum = a(i) Then 
        b(i) = 0
      Else
        b(i) = 1
        m += 1
      End If
    Next
    Console.WriteLine(m.ToString())
    For i As Integer = 0 To n - 1
      If b(i) = 1 Then Console.Write((i + 1).ToString() & " ")
    Next
  End Sub
End Class

Measured memory_bytes: 29908
//https://atcoder.jp/contests/abc153/tasks/abc153_b
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long h , n , sum = 0;
    cin >> h >> n ;
    while(n--)
    {
        long long a ;
        cin >> a ;
        sum += a ;
    }
    if(sum >= h) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int w[16];
int main()
{
    int n,p;
    scanf("%d%d",&n,&p);
    for(int i=1;i<=n;i++)
    {
        int input;
        scanf("%d",&input);
        w[input%2]++;
    }
    long long ans,m=0;
    if(p)
    {
        ans=pow(2,w[0]);
        for(int i=1;i<=w[1];i+=2)
        {
            int h=min(i,w[1]-i);
            long long f=1;
            long long u=1;
            for(int j=w[1];j>w[1]-h;j--){
                u*=j;
                if(f<=h){
                    if(u%f==0){
                    u/=f;
                    f++;
                    }
                }
            }
            m+=u;
        }
    }
    else
    {
        ans=pow(2,w[0]);
    for(int i=0;i<=w[1];i+=2)
        {
           int h=min(i,w[1]-i);
            long long f=1;
            long long u=1;
            for(int j=w[1];j>w[1]-h;j--){
                u*=j;
                if(f<=h){
                    if(u%f==0)
                    {
                    u/=f;
                    f++;
                    }
                }
            }
            m+=u;
        }
    }
    printf("%lld\n",ans*m);
}


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

string IntToString(int a){
	stringstream ss;
	ss << a;	
	return ss.str();
}

int main(){
	while(1){
		int n;
		string s, t;
	
		cin >> n;
		if(n==0) break;
		cin >> s;
	
		for(int i=0; i<n; ++i){
			t="";
			int j=0;
			while(j<s.size()){
				char c=s[j++];
			
				int count=1;
				while(c == s[j]){
					count++;
					j++;
				}
				t+=IntToString(count);
				t+=c;
			}
			s=t;
			//cout << " " << s << endl;
		}
	
		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 1356
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

using namespace std;

int main(void) {
    string s;
    int x, y;
    cin >> s >> x >> y;

    int start = 10'000;
    x += start;
    y += start;
    s.push_back('T');

    vector<int> v;
    int cnt = 0;
    for(int i=0; i<s.size(); i++) {
        if(s[i] == 'F') {
            cnt++;
        } else {
            v.push_back(cnt);
            cnt = 0;
        }
    }

    bool ok_x = false, ok_y = false;
    vector< bitset<20'000> > X(8000), Y(8000);
    X[0].set(start + v[0]);
    for(int i=1; i<8000; i++) {
        int index = 2*i;
        if(index >= v.size()) {
            if(X[i-1][x]) ok_x = true;
            break;
        }
        for(int j=0; j<20'000; j++) {
            if(X[i-1][j]) {
                X[i].set(j + v[index]);
                X[i].set(j - v[index]);
            }
        }
    }

    Y[0].set(start);
    for(int i=1; i<8000; i++) {
        int index = 2*i - 1;
        if(index >= v.size()) {
            if(Y[i-1][y]) ok_y = true;
            break;
        }
        for(int j=0; j<20'000; j++) {
            if(Y[i-1][j]) {
                Y[i].set(j + v[index]);
                Y[i].set(j - v[index]);
            }
        }
    }

    if(ok_x && ok_y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int n;
vector<int> adj[100001];

void input(){
	scanf("%d", &n);
	for(int i=2, a; i<=n; i++){
		scanf("%d", &a);
		adj[a].push_back(i);
	}
}

int dfs(int now){
	vector<int> v;
    for(int dest:adj[now])
		v.push_back(dfs(dest));
	sort(v.begin(), v.end());
	int ans=0;
	for(int i=v.size()-1, j=1; i>=0; i--, j++)
		ans=max(ans, j+v[i]);
	return ans;
}

int main(){
	input();
	printf("%d", dfs(1));
	return 0;
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
//cin.ignore();//better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout<<(A + B == C ? "YES" : "NO")<<endl;
//__gcd(a,b)
// string s=to_string(i);
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
    fast();
    float l;
    cin>>l;
    float m = l/3;
    float ans = m*m*m;
    cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
/*
  AOJ 1186
  Title:Integral Rectangles
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int table[20000];
int x,y,retx,rety;
void init()
{
  int i,j,t2;
  memset(table,0,sizeof(int)*20000);
  for(i=1;i<=150;i++)
    for(j=1;j<=150;j++)
      {
	t2=i*i+j*j;
	if(t2>20000)
	  break;
	table[t2]=-1;
      }
}
solve()
{
  int i,j,t,t2=x*x+y*y;

  //printf("x y t=%d %d %d\n",x,y,t2);

  if(table[t2])
    {
      for(i=x+1;i<=150;i++)
	for(j=i+1;j<=150;j++)
	  if(i*i+j*j==t2)
	    {
	      retx=i;
	      rety=j;
	      return;
	    }
    }
  for(t=t2+1;t<=20000;t++)
  if(table[t])
    {
      for(i=1;i<=150;i++)
	for(j=i+1;j<=150;j++)
	  if(i*i+j*j==t)
	    {
	      retx=i;
	      rety=j;
	      return;
	    }
    }
  //never reach    
}

main()
{
  init();
  while(scanf("%d %d",&x,&y) && (x || y))
    {
      solve();
      printf("%d %d\n",retx,rety);
    }
  return(0);
}

Measured memory_bytes: 684
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>
using namespace std;

int main()
{
	int a, b;
	int ans;
	while(cin >> a >> b) {
		if(a <= b) ans = min(a, b);
		else {  // a > b
			ans = a - 1;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;

main();

function main() {
    //console.log(cin);
    //   cin = cin.map(i => +i);
    let n = +cin.shift();
    let B = {};
    let C = {};
    for (let i = 0; i < n; i++) {
        const x = Number(cin[i]);
        B[i + 1 + x] = B[i + 1 + x] + 1 || 1;
        C[i + 1 - x] = C[i + 1 - x] + 1 || 1;
    }
    //console.log({ B, C })
    let keys = Object.keys(B);
    let ans = 0;
    keys.filter(i => C[i]).forEach(i => {
        ans += (B[i] * C[i]);
        //console.log(i, B[i], C[i]);
    });


    console.log(ans);
}

Measured memory_bytes: 95600
#include <queue>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
int dp[60000];
int hash_(string s) {
	int ret = 0;
	for(int i = 0; i < s.size(); i++) {
		ret *= 3;
		if(s[i] == 'g') ret += 1;
		if(s[i] == 'b') ret += 2;
	}
	return ret;
}
string s; int w, w2;
int main() {
	while(cin >> s, s != "0") {
		memset(dp, -1, sizeof(dp)); w = 0, w2 = 1;
		for(int i = 0; i < s.size(); i++) w += w2, w2 *= 3;
		int h2 = hash_(s); dp[h2] = 0;
		if(h2 % w == 0) {
			printf("0\n"); continue;
		}
		queue<string> que; que.push(s); bool flag = false;
		while(!que.empty()) {
			string t = que.front(); que.pop(); int h_ = hash_(t);
			for(int i = 1; i < t.size(); i++) {
				if(t[i - 1] != t[i]) {
					string u = t;
					if(t[i - 1] != 'r' && t[i] != 'r') u[i - 1] = 'r', u[i] = 'r';
					else if(t[i - 1] != 'g' && t[i] != 'g') u[i - 1] = 'g', u[i] = 'g';
					else u[i - 1] = 'b', u[i] = 'b';
					int h = hash_(u);
					if(h % w == 0) {
						printf("%d\n", dp[h_] + 1); flag = true; break;
					}
					if(dp[h] == -1) {
						dp[h] = dp[h_] + 1; que.push(u);
					}
				}
			}
			if(flag) break;
		}
		if(!flag) printf("NA\n");
	}
}

Measured memory_bytes: 3552