akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int N, candy[2][105], result;

void func(int x, int y, int count)
{
    if(x == N - 1 && y == 1)
    {
        result = max(result, count + candy[y][x]);
        return;
    }
    if(x != N - 1)
    {
        func(x + 1, y, count + candy[y][x]);
    }
    if(y == 0)
    {
        func(x, y + 1, count + candy[y][x]);
    }
}

int main()
{
    scanf("%d", &N);
    for(int i = 0; i < 2; i++)
    {
        for(int j = 0; j < N; j++)
        {
            scanf("%d", &candy[i][j]);
        }
    }
    func(0, 0, 0);
    printf("%d", result);
}

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

int main(){
    int N, K;
    cin >> K >> N;
    long nums[N];
    for(int i = 0; i < N; i++){
        cin >> nums[i];
    }
    sort(nums, nums + N);
    long differences[N - 1];
    for(int i = 0; i < N - 1; i++){
        differences[i] = nums[i + 1] - nums[i];
    }
    sort(differences, differences + N - 1);
    long ans = 0;
    for(int i = 0; i < N - K; i++){
        ans += differences[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Phuong // <3
typedef pair<int,int> ii;

const int inf = 1e9+1;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    vector<int> dp(n,inf);
    vector<int> h(n);
    for(int i=0;i<n; ++i)
    {
        cin >> h[i];
    }
    dp[0]=0;
    for(int i=1;i<n;++i)
    {
        for(int j=i-1;j>=max(0,i-k);--j)
        dp[i]=min(dp[j]+abs(h[j]-h[i]),dp[i]);
    }
    cout << dp[n-1];
    return(0);
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 1000000007;

int64_t gcd(int64_t a, int64_t b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}


int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t h, w, t; cin >> h >> w >> t;

	int64_t hgcd = gcd(h, t);
	int64_t wgcd = gcd(w, t);
	int64_t hn = h / hgcd;
	int64_t wn = w / wgcd;

	int64_t ans = pow_rem(2, hn, kRem);
	ans += pow_rem(2, wn, kRem);
	ans -= 1;
	ans %= kRem;
	int64_t ngcd = gcd(hn, wn);
	if (ngcd != 1) {
		ans += pow_rem(2, ngcd, kRem);
		ans -= 2;
		ans %= kRem;
	}

	int64_t ans2 = 0;
	ans2 = pow_rem(ans, hgcd * wgcd, kRem);
	ans2 %= kRem;
	
	cout << ans2 << endl;

	return 0;
}

Measured memory_bytes: 896
import numpy as np

H, W = list(map(int, input().split()))

tbl = np.zeros([H, W], dtype=np.uint8)
for col in tbl:
	x = input().replace('.', '1').replace('#', '0')
	col[:] = list(x)

def func(y,x):
    dp = np.ones([H, W]) * np.inf
    data = tbl.copy()
    data[y,x] = 0
    dp[y,x] = 0

    que = [[y,x]]

    def move(i, j, m, n):
        if m<0 or n<0 or m>=H or n>=W:
            return

        if data[m, n] == 1:
            data[m, n] = 0
            dp[m, n] = min(dp[i, j] + 1, dp[m, n])
            que.append([m, n])

    while len(que) > 0:
        i, j = que.pop(0)
        move(i,j,i-1,j)
        move(i,j,i+1,j)
        move(i,j,i,j-1)
        move(i,j,i,j+1)
       
    return dp[dp != np.inf].max() 

ans = 0
for i in range(H):
    for j in range(W):
        if tbl[i,j] == 0:
            continue
        
        num = func(i, j)    
        if num != np.inf:
            ans = max(ans, num)
            if ans == H + W - 2:
                break

if ans == np.inf:
	ans = 0
print(int(ans))

Measured memory_bytes: 12504
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= 100; ++i) {
        rep(j, 0, 100) {
            if (i + j == x && i * 2 + 4 * j == y) {
                cout << "Yes";
                return;
            }
        }
    }
    cout << "No";
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3644
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>

#define INT_MAX 2147483647
#define INT_MIN -2147483647
using namespace std;

int main()
{
	int num;
	int vals[100];
	cin >> num;
	int idx = 0;
	while (cin >> vals[idx++]);

	int count = 0;
	for (int i = 0; i < num-1; ++i)
	{
		int minIdx = i;
		for (int j = i; j < num; ++j)
		{
			if (vals[j] < vals[minIdx])
				minIdx = j;
		}
		count += (i != minIdx);
		swap(vals[i], vals[minIdx]);
	}
	for (int i = 0; i < num-1; ++i) cout << vals[i] << " ";
	cout << vals[num - 1] << endl;
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3064
n = int(input())
pos = [list(map(int, input().split())) for _ in range(n)]
d = {}
if n == 1:
  print(1)
else:
  for x, y in pos:
    for nx, ny in pos:
      dx = nx - x
      dy = ny - y
      key = (dx, dy)
      if key == (0, 0):
        continue
      if key in d:
        d[key] += 1
      else:
        d[key] = 1
  print(n - max([d[key] for key in d]))
    



Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n==0||n==2) {
    cout << 1 << endl;
  } else if (n==1) {
    cout << 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<(n);++i)
#define Endl endl
#define int long long
#define INF 1145141919810893

signed main(){
    int N;
    int A[364364];
    int E[114514]={};
    int D[114514]={};
    cin >> N;
    REP(i,3*N){
        cin >> A[i];
    }
    priority_queue<int,vector<int>,greater<int>> R;
    priority_queue<int,vector<int>> B;    
    
    int Rsum=0,Bsum=0;
    REP(i,N){
        R.push(A[i]);
        Rsum+=A[i];
    }
    for(int i=2*N;i<3*N;i++){
        B.push(A[i]);
        Bsum+=A[i];
    }
    E[0]=Rsum;
    for(int i=N;i<=2*N-1;i++){
        int f=R.top();
        if(f<A[i]){
            R.pop();
            Rsum-=f;
            R.push(A[i]);
            Rsum+=A[i];
        }
        E[i-N+1]=Rsum;
    }
    //REP(i,N+1){cout << E[i] << " ";}cout << Endl;
    D[N]=Bsum;
    for(int i=2*N-1;i>=N;i--){
        int g=B.top();
        //cout << g << " " << A[i] << endl;
        if(g>A[i]){
            B.pop();
            Bsum-=g;
            B.push(A[i]);
            Bsum+=A[i];
        }
        D[i-N]=Bsum;
    }
    int Ans=-INF;
    REP(i,N+1){
        Ans=max(Ans,E[i]-D[i]);
    }
    //REP(i,N+1){cout << D[i] << " ";}cout << Endl;
    
    cout << Ans << endl;
    return 0;
}


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

using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << EOL;
        return;
    }
    cout << min({a * b, b * c, c * a}) << EOL;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

struct Node {
	int color = 0;
	int lock = -1;
	vector<int> nexts;
};

struct Query {
	int v, d, c;
	Query(int v, int d, int c) : v(v), d(d), c(c) {}
};

vector<Node> nodes;

void print(int now, int dist, int color) {
	if (nodes[now].lock >= dist) return;
	nodes[now].lock = dist;
	if (nodes[now].color == 0) nodes[now].color = color;

	if (dist == 0) return;
	for (int next : nodes[now].nexts) {
		print(next, dist - 1, color);
	}
}

signed main() {
	int N, M;
	cin >> N >> M;

	nodes.resize(N);

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		nodes[a].nexts.push_back(b);
		nodes[b].nexts.push_back(a);
	}

	int Q;
	cin >> Q;
	vector<Query> queries;
	rep(i, Q) {
		int v, d, c;
		cin >> v >> d >> c;
		v--;
		queries.push_back(Query(v, d, c));
	}

	reverse(all(queries));

	for (auto &query : queries) {
		print(query.v, query.d, query.c);
	}

	for (auto &node : nodes) { 
		cout << node.color << endl;
	}
}


Measured memory_bytes: 12528
import java.util.Scanner;

public class Main {

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

	    int a= gi();
	    int b= gi();
	    int c= gi();

        //System.out.print(aubstring(0,1));
        if (a<=c&&c<=b) {
        	System.out.print("Yes");
        }else{
        	System.out.print("No");
        }

	   
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35592
#include<stdio.h>
int a,b,c,d,i,j,k,l,p,r,s,arr[100005],arr1[100005];
int abss(int o,int u)
{
	if(o-u<0)
	return(u-o);
	else
	return(o-u);
}
int minn(int K,int L)
{
	if(K<L)
	return(K);
	else
	return(L);
}
int dp(int g)
{
	if(g>a)
	return 1000000000;
	if(arr1[g]!=1000000000)
	return(arr1[g]);
	if(g==a)
	{
		return(0);
	}
for(int J=1;J<=b;J++) {	arr1[g]=minn(arr1[g],dp(g+J)+abss(arr[g],arr[g+J]));
}
//printf("%d %d\n",c,d);
	return(arr1[g]);
}
int main ()
{
	scanf("%d %d",&a,&b);
	for(i=1;i<=a;i++)
	{
		scanf("%d",&arr[i]);
		arr1[i]=1000000000;
	}
	p=dp(1);
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 20000;
static const int MAX_M = 16;
static const int MAX_Y = 256;
static const int INF = 1 << 30;

int N, M;
int C[MAX_M], x[MAX_N];

int memo[MAX_Y][MAX_N + 1];

int main(){
	for(;;){
		scanf("%d %d", &N, &M);
		if(N == 0 && M == 0) break;
		for(int i = 0; i < M; i++) scanf("%d", &C[i]);
		for(int i = 0; i < N; i++) scanf("%d", &x[i]);
		fill(memo[0], memo[MAX_Y], INF);
		memo[128][0] = 0;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < MAX_Y; j++){
				if(memo[j][i] == INF) continue;
				for(int k = 0; k < M; k++){
					int num = min(255, max(0, j + C[k]));
					memo[num][i + 1] = min(memo[num][i + 1], memo[j][i] + (num - x[i]) * (num - x[i]));
				}
			}
		}
		int res = INF;
		for(int i = 0; i < MAX_Y; i++) res = min(res, memo[i][N]);
		printf("%d\n", res);
	}
	return 0;
}



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

int main() 
{
	string s, a="Sunny", b="Cloudy", c="Rainy";
	cin>>s;
	if(s==a)s=b;
	else if(s==b)s=c;
	else if(s==c)s=a;
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

namespace Math {
// Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

    int n; cin >> n;
    bool ok = true;
    for (int i = 0; i < n; i++) {
        int t; cin >> t;
        if (t % 2 == 0) {
            ok &= ((t % 3 == 0) || (t % 5 == 0));
        }
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)




signed main(){
    cout << fixed << setprecision(10);
    intl n, k;
    cin >> n >> k;
    intl p[n], c[n];
    rep(i,n)cin >> p[i];
    rep(i,n)cin >> c[i];
    pair<intl, intl> cnt[n];
    m0(cnt);
    intl ans = -INF;
    rep(i,n){
        bool flag[n];
        m0(flag);
        intl idx = i;
        while(true){
            idx = p[idx] - 1;
            if(flag[idx])break;
            cnt[i].first += c[idx];
            ans = max(ans, cnt[i].first);
            cnt[i].second++;
            if(cnt[i].second >= k)break;
            flag[idx] = true;
        }
    }
    //for(auto i : cnt)cout << i.first << ":" << i.second << endl;
    //debug(ans);
    rep(i,n){
        intl m = k % cnt[i].second;
        m += cnt[i].second;
        m++;
        intl b[m];
        m0(b);
        intl num = k / cnt[i].second;
        num--;
        if(num < 0)break;
        b[0] = cnt[i].first * num;
        //if(b[0] < 0)break;
        //debug(b[0]);
        intl idx = i;
        repi(j, 1, m){
            idx = p[idx] - 1;
            b[j] = b[j - 1] + c[idx];
            //debug(b[j]);
        }
        //debug(m);
        repi(j, 1, m){
            ans = max(ans,b[j]);
            //cout << j << ":" << b[j] << endl;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3852
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)
# T = gets.chomp

i = 0
max_r = 0

while i < (H.size - 1)
  r = 0
  while (i < (H.size - 1)) && (H[i] >= H[i+1])
    i += 1
    r += 1
  end
  # For Debug
  # p "r: #{r}"
  max_r = [max_r, r].max
  i += 1
end

p max_r


Measured memory_bytes: 12036
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	// change CR into Space
	sc.Split(bufio.ScanWords)

	N, _ := strconv.Atoi(nextString())
	A := make([]int, N)

	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(nextString())
	}

	cnt := 0
	flag := false
	for {
		for j := 0; j < N; j++ {
			if A[j]%2 == 1 {
				flag = true
				break
			}
			A[j] = A[j] / 2
		}
		if flag {
			break
		}

		cnt += 1
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

string a, b;
llong dp[3001][3001], s[3001][3001];

int main(){
    cin >> a >> b;
    a = '#' + a;
    b = '@' + b;
    for (int i = 1; i < a.size(); i ++){
        for (int j = 1; j < b.size(); j ++){
            if(a[i] == b[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                s[i][j] = 1;
            }else{
                if(dp[i][j - 1] < dp[i - 1][j]){
                    dp[i][j] = dp[i - 1][j];
                    s[i][j] = 2;
                }else{
                    dp[i][j] = dp[i][j - 1];
                    s[i][j] = 3;
                }
            }
        }
    }llong n = a.size() - 1, m = b.size() - 1;
    ///cout << dp[n][m] << endl;
    vector <char> v;
    while (n >= 1 && m >= 1){
        if(s[n][m] == 1){
            v.pb(a[n]);
            n --, m --;
        }else if(s[n][m] == 2){
            n --;
        }else{
            m --;
        }
    }reverse(v.begin(), v.end());
    for (int i = 0; i < v.size(); i ++){
        cout << v[i];
    }return 0;
}


Measured memory_bytes: 140928
a,b,k = map(int,input().split())
if b-a <= 2 * k - 1:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
    using namespace std;
    int main() {
    	int a,b;
      	cin >> a >> b;
      	if (a > 9 || b > 9) {
        	cout << -1 << endl;
        } else {
        	cout << a * b << endl;
        }
      	
      	return 0;
    }

Measured memory_bytes: 256
import collections

N = int(input())
A = list(input().split())

ca = collections.Counter(A)
cc = ca.most_common()

cnt = 0
for i in range(len(cc)):
    if cc[i][1]>=int(cc[i][0]):
        cnt += cc[i][1] - int(cc[i][0])
    else:
        cnt += cc[i][1]


print(cnt)

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

int ice[100000 + 5] = { 0 };
int len;
int mtim=0;
int n;

void right( int , int );

void left( int , int );

int main()
{
	int i;
	int tim=0;

	cin >> n >> len;

	for (i = 1; i <= n; i++)
	{
		cin >> ice[i];
	}
	for (i = 1; i <= n; i++)
	{
		if (ice[i - 1] < ice[i] && ice[i] > ice[i + 1])
		{
			tim = len - ice[i];
			left(tim , i-1);
			right(tim , i+1);
		}
	}
	cout << mtim << endl;
	return 0;
}

void left( int tim , int now)
{
	if (now == 0)
	{
		if (mtim < tim)
		{
			mtim = tim;
		}
		return;
	}

	tim += len - ice[now];
	
	if (ice[now] > ice[now - 1])
	{
		left( tim, now - 1);
	}
	else if(mtim < tim)
	{
		mtim = tim;
	}
	return;
}

void right(int tim, int now)
{
	if (now == n + 1)
	{
		if (mtim < tim)
		{
			mtim = tim;
		}
		return;
	}

	tim += len - ice[now];
	
	if (ice[now] > ice[now + 1])
	{
		right(tim, now + 1);
	}
	else if (mtim < tim)
	{
		mtim = tim;
	}
	return;
}

Measured memory_bytes: 3464
n = int(input())
a = list(map(int, input().split()))
b = [0] * 9
for i in a:
    if 1 <= i <= 399:
        b[0] += 1
    elif 400 <= i <= 799:
        b[1] += 1
    elif 800 <= i <= 1199:
        b[2] += 1
    elif 1200 <= i <= 1599:
        b[3] += 1
    elif 1600 <= i <= 1999:
        b[4] += 1
    elif 1999 <= i <= 2399:
        b[5] += 1
    elif 2400 <= i <= 2799:
        b[6] += 1
    elif 2800 <= i <= 3199:
        b[7] += 1
    else:
        b[8] += 1
cnt = 0
for i in range(len(b)-1):
    if b[i] != 0:
        cnt += 1
print(cnt if cnt != 0 else 1 if b[-1] != 0 else 0, cnt if b[-1] == 0 else cnt + b[-1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
#define M 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	fastio;
	LL n, m, l, i, q;
	cin>>n>>m>>l;
	LL dist1[n+1][n+1], dist2[n+1][n+1];
	for(i=0; i<=n; i++){
		for(LL j=0; j<=n; j++){
			if(i==j)
				dist1[i][j] = dist2[i][j] = 0;
			else
				dist1[i][j] = dist2[i][j] = INT_MAX;
		}
	}
	for(i=0; i<m; i++){
		LL u, v, c;
		cin>>u>>v>>c;
		dist1[u][v] = dist1[v][u] = c;
	}
	for(LL k=1; k<=n; k++){
		for(i=1; i<=n; i++){
			for(LL j=1; j<=n; j++){
				dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
			}
		}
	}
	for(i=1; i<=n; i++){
		for(LL j=1; j<=n; j++){
			if(dist1[i][j]<=l)
				dist2[i][j] = 1;
		}
	}
	for(LL k=1; k<=n; k++){
		for(i=1; i<=n; i++){
			for(LL j=1; j<=n; j++){
				dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
			}
		}
	}
	cin>>q;
	while(q--){
		LL u, v;
		cin>>u>>v;
		if(dist2[u][v]==INT_MAX)
			cout<<-1<<endl;
		else
			cout<<dist2[u][v]-1<<endl;
	}
	return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	int ans = 0;
	int A;
	rep(i, 0, N)
	{
		cin >> A;
		if (i % 2 == 0 && A % 2 == 1)
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int path[26][26];
int visited[26];

int dfs(int src,int* visited){
	visited[src] = 1;
	int res = 1;
	for(int i=0;i<26;i++){
		if(path[src][i] && visited[i] == 0){
			res += dfs(i,visited);
		}
	}
	return res;
}

int main(){
	int n;
	
	while(~scanf("%d",&n)){
		if(n==0) break;
		memset(path,0,sizeof(path));
		memset(visited,0,sizeof(visited));
		set<int> src;
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			path[*str.begin()-'a'][*(str.end()-1)-'a']++;

			src.insert(*(str.end()-1)-'a');
			src.insert(*str.begin()-'a');
		}
				
		if(src.size() != dfs(*src.begin(),visited)){
			printf("NG\n");
			continue;
		}

		bool isok=true;

		for(set<int>::iterator it = src.begin(); it != src.end(); it++){
			int out=0;
			for(int j=0;j<26;j++){
				out += path[*it][j];
			}

			int in=0;
			for(int j=0;j<26;j++){
				in += path[j][*it];
			}

			if(out != in) isok = false;
		}

		printf("%s\n",isok ? "OK" : "NG");
	}
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int N,K;
  	cin >>N>>K;
  	long long int a=N/K,b,mini;
  	b=N-K*a;
  	mini=b;
  	for(int i=0;i<3;i++){
    long long int g=abs(b-K);
      mini=min(mini,g);
     
    }
  cout <<mini<<endl;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
import bisect
def main():
    N, K = MI()
    ans = 0
    p = 1
    while p <= N:
        p *= K
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 74324
N = int(input())
W = list(map(int, input().split()))
mini = 999999

for i in range(N-1):
    S1 = sum(W[0:i+1])
    S2 = sum(W[i+1:N])
    if mini > abs(S1-S2):
        mini = abs(S1-S2) 
print(mini)


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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    replace(all(s), ',', ' ');
    cout << s;

    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_s
ary =[]
min2 = 999
(n.size-2).times do |i|
  ary << n[i,3]
end
ary.each do |j|
  min = (753 - j.to_i).abs
  min2 = min if min2 > min
end
puts min2

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

using namespace std;

int main(int argc, char *argv[]) {

	int A,B; cin >> A >> B;
	int C,D; cin >> C >> D;

	while(1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,n,sum;
int main(){
	cin>>a>>b>>c>>n;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==n)
					sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
C = [list(map(int,input().split())) for _ in range(3)]
D1 = [[] for _ in range(3)]
D2 = [[] for _ in range(3)]
for i in range(3):
    for j in range(2):
        D1[i].append(C[i][j] - C[i][j + 1])
for j in range(3):
    for i in range(2):
        D2[j].append(C[i][j] - C[i + 1][j])
print('Yes' if D1[0] == D1[1] == D1[2] and D2[0] == D2[1] == D2[2] else 'No')

Measured memory_bytes: 9224
#include <stdio.h>

#define MAX 26

int main(void)
{
	char c;
	while ((c=getchar()) != '\n') {
		if ((c>='A') && (c<='Z')) {
			c += ' ';
		}
		else if ((c>='a') && (c<='z')) {
			c -= ' ';
		}
		else {
			;
		}
		printf("%c",c);
	}
	printf("\n");
	return 0;
}




Measured memory_bytes: 2536
p = "Possible"
imp = "Impossible"

n = int(raw_input())
a = map(int, raw_input().split())
mx = max(a)
mn = min(a)
if mx == 1 and  mn == 1:
    if n == 2:
        print p
        exit()
    else:
        print imp
        exit()
cnt = [0] * 100
for i in xrange(n):
    cnt[a[i]] += 1
if mx % 2 == 0:
    if mx / 2 != mn:
        print imp
        exit()
    if cnt[mn] != 1:
        print imp
        exit()
    for i in xrange(mn + 1, mx + 1):
        if cnt[i] < 2:
            print imp
            exit()

else:
    if mx / 2 + 1 != mn:
        print imp
        exit()
    if cnt[mn] != 2:
        print imp
        exit()
    for i in xrange(mn + 1, mx + 1):
        if cnt[i] < 2:
            print imp
            exit()
print p


Measured memory_bytes: 2696
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,f[N],p[N],a[N],b[N],x;ll ans;
struct node{int x,y,id;};
inline bool operator <(node a,node b){return 1ll*a.x*b.y<1ll*b.x*a.y;}
__gnu_pbds::priority_queue<node> pq;
__gnu_pbds::priority_queue<node>::point_iterator it[N];
int gfa(int x){return (f[x]^x)?(f[x]=gfa(f[x])):x;}
int main(){
	scanf("%d",&n);
	rep(i,1,n) f[i]=i;
	rep(i,2,n) scanf("%d",p+i);
	rep(i,1,n) scanf("%d",&x),a[i]=!x,b[i]=x,it[i]=pq.push((node){!x,x,i});
	while(!pq.empty()){
		node x=pq.top();pq.pop();
		int u=gfa(x.id);f[u]=gfa(p[u]);
		ans+=1ll*b[f[u]]*a[u];a[f[u]]+=a[u];b[f[u]]+=b[u];
		if(f[u]) pq.modify(it[f[u]],(node){a[f[u]],b[f[u]],f[u]});
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

int main(){

  int n;
  vector<int> a(100000);
  
  cin >> n;
  
  rep(i, n){
    cin >> a[i];
  }
  
  int buttom = 0;
  int num = 0, ans = -1;

  rep(i, n){
    if(a[buttom] == 2){
      ans = num + 1;
      break;
    }
    buttom = a[buttom] - 1;
    num++;
  } 
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		char c[][] = new char[h][w];

		for(int i=0;i<h;i++) {
			String str =scan.next();
			c[i]=str.toCharArray();
		}
		scan.close();

		for(int i=0;i<2*h;i++) {
			for(int j=0;j<w;j++) {
				System.out.print(c[(i)/2][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 27468
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());d=lambda s:csgraph.dijkstra(csr_matrix(([1]*len(a),(a,b)),[n+1]*2),0,s);n,=f();a,b=zip(*map(f,[0]*~-n));g=d(1);h=d(n);print'Fennec'if sum(g[i]>h[i] for i in range(n+1))*2<n else'Snuke'

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    if( N%2 == 0 ) cout << N/2 << endl;
    else cout << N/2 + 1 << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    for j in range(max(0, i - K), i):
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))
print(dp[N - 1])

Measured memory_bytes: 54752
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[100];
    for(int i = 0; i<n; i++){
      cin>>a[i];
    }
    for(int i = n-1; 0<i ; i--){
        cout<<a[i]<<" ";

    }
    cout<<a[0]<<endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


const ll mod = 1e9+7;
const double eps = 1e-9;


string s;
int dp[2019];
int tdp[2019];

void solve(){
    cin>>s;
    int n=(int)s.size();
    ll ans=0;
    for(int i=0;i<n;i++) {
        memset(tdp,0,sizeof(tdp));
        int d=(s[i]-'0');
        tdp[d%2019]=1;
        for(int j=0;j<2019;j++) {
            if(dp[j]>0) { 
                int rem=(10*j+d)%2019;
                if(rem==0)ans += dp[j];
                tdp[rem]+=dp[j];
            }
        }
        for(int i=0;i<2019;i++) {
            dp[i]=tdp[i];
        }
    }
    cout<<ans;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3784
program dont_be_a_subsequence
  implicit none
  character(200000) :: a, s
  integer :: n, dp(0:200000,26), i, j, m, k, l
  dp = 0
  read(*,*) a
  a = trim(adjustl(a))
  n = len_trim(a)
  do i = n, 1, -1
    m = 1
    do j = 1, 26
      if (dp(i,j).lt.dp(i,m)) m = j
    end do
    do j = 1, 26
      dp(i-1,j) = dp(i,j)
    end do
    k = ichar(a(i:i))-96
    dp(i-1,k) = dp(i,m)+1
  end do
  k = dp(0,1)
  m = 1
  do i = 1, 26
    if (dp(0,i).lt.k) then
      k = dp(0,i)
      m = i
    end if
  end do
  j = 1
  s = ""
  do i = 1, k+1
    do while (j.le.n.and.m.ne.ichar(a(j:j))-96)
      j = j+1
    end do
    if (j.gt.n) exit
    do l = 1, 26
      if (dp(j-1,m).eq.dp(j,l)+1) then
        s = trim(adjustl(s))//achar(m+96)
        m = l
        exit
      end if
    end do
    j = j+1
  end do
  s = trim(adjustl(s))//achar(m+96)
  write(*,'(a)') trim(adjustl(s))
  stop
end program dont_be_a_subsequence

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int s;cin >> s;
    map<int,int> m;
    m[s]=1;
    // cout << m.count(s) << endl;
    int count = 1;
    while(1){
        if(s%2==0)s = s/2;
        else s = s*3+1;
        count++;
        if(m.count(s)==1)break;
        else m[s]=1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3608
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	N := readInt()
	A := readIntArray(N)
	m := make(map[int]struct{})
	for _, a := range A {
		if _, ok := m[a]; ok {
			fmt.Println("NO")
			return
		}
		m[a] = struct{}{}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 15232
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    ll ans = T;
    int t[200010];
    rep(i, N) cin >> t[i];
    rep(i, N - 1) {
        ans += min(T, t[i + 1] - t[i]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
typedef long long lint;
using namespace std;
const int N=18;
int n,xval[1<<N][2];

namespace utils{
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

void apl(int x[2],int v){
	if(x[0]<v) swap(x[0],v);
	if(x[1]<v) swap(x[1],v);
}

int main(){
	n=nxi();
	for(int i=0; i<1<<n; ++i){
		xval[i][0]=nxi();
	}
	for(int i=1; i<1<<n; i<<=1){
		for(int j=0; j<1<<n; j+=i<<1){
			for(int k=0; k<i; ++k){
				apl(xval[j+k+i],xval[j+k][0]);
				apl(xval[j+k+i],xval[j+k][1]);
			}
		}
	}
	int res=0;
	for(int i=1; i<1<<n; ++i){
		apx(res,xval[i][0]+xval[i][1]);
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 5724
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var sum = Console.ReadLine().Split().Select(elem => int.Parse(elem)).Sum();

            var answer = (N < sum) ? -1 : N - sum;
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 29064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  string s;cin>>s;
  int ans=0;
  REP(i,s.size()-1) if(s.at(i)!=s.at(i+1)) ans++;
  cout<<ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n ; cin >> n ;
	vll cnt(n+1,0) ;
	for(int i=1;i<=n;i++){
		ll num = i ;
		while(num<=n){
			cnt.at(num)++ ;
			num += i ;
		}
	}
	ll ans = 0 ;
	for(int i=1;i<=n;i++){
		ans += i*cnt.at(i) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 81404
x, y = map(int,input().split())
m = []
r = []
while x > 0:
  m.append(list(map(int,input().split())))
  x -= 1
while y > 0:
  r.append(int(input()))  
  y -= 1
for i in range(len(m)):
  result = 0
  for j in range(len(r)):
    result +=  m[i][j] * r[j]
  print(result)


Measured memory_bytes: 6008
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int H,W,K;
    string fie[6];
    cin>>H>>W>>K;
    int ans=0;
    for(int i=0;i<H;i++)cin>>fie[i];
    for(int i=0;i<(1<<H);i++){
        for(int j=0;j<(1<<W);j++){
            int cou=0;
            for(int k=0;k<H;k++){
                for(int l=0;l<W;l++){
                        //puts("hoge");
                    if(fie[k][l]=='#'){
                        if(i&(1<<k)){
                            //puts("hoge");
                        }
                        else if(j&(1<<l)){
                            //puts("hoge");
                        }
                        else{
                            //puts("hoge");
                            cou++;
                        }
                    }
                }
            }
            if(cou==K)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        string s;
        s = to_string(i);
        if(s.size()%2!=0)ans++;
    }
    cout << ans <<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
using namespace std;
struct Node
{
	Node* pre;
	Node* next;
	int data;
};
typedef Node* no;
int main(void) {
	int n;
	cin >> n;
	Node* head=(Node *)malloc(sizeof(Node));
	Node* end = (Node*)malloc(sizeof(Node));
	head->data = -1;
	end->data = -1;
	head->next = end;
	head->pre = NULL;
	end->pre = head;
	end->next = NULL;
	for (int i = 0; i < n; i++) {
		int data;
		char s[20];
		scanf("%s", s);	
		if (s[0] == 'i') {
			scanf("%d", &data);
			no p = head->next;
			head->next = new Node();
			head->next->data = data;
			head->next->pre = head;
			head->next->next = p;
			p->pre = head->next;
		}
		else if (s[0] == 'd' && strlen(s)<10) {
			cin >> data;
			Node* t = head->next;
			while (t)
			{
				if (t->data == data) {
					t->next->pre = t->pre;
					t->pre->next = t->next;
					break;
				}
				t = t->next;
			}
		}
		else if (s[6]=='F') {
			head->next->next->pre = head;
			head->next = head->next->next;
		}
		else{
			end->pre->pre->next = end;
			end->pre = end->pre->pre;
		}
	}
	no t = head->next;
	while (t != end->pre) {
		printf("%d ", t->data);
		t = t->next;
	}
	printf("%d\n", t->data);
}


Measured memory_bytes: 37488
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }


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

    ll A, B, C; cin >> A >> B >> C;
    ll ans = B+C-A;
    if (ans>0) cout << ans << '\n';
    else cout << 0 << '\n';
    return 0;
}



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

using namespace std;

int main() {
	int N;
	string s;
	cin >> N >> s;

	vector<int> W(N + 1, 0);
	vector<int> R(N + 1, 0);
	for (int i = 0; i < N; ++i) {
		W[i + 1] = W[i] + (s[i] == 'W');
		R[i + 1] = R[i] + (s[i] == 'R');
	}
	if (R[N] == 0 || W[N] == 0) {
		cout << "0\n";
		return 0;
	}

	int ans = N - R[N];
	for (int i = 1; i < N; ++i) {
		int Rr = R[N] - R[i];
		int Wl = W[i];
		if (Wl == 0 && Rr == 0) {
			cerr << "in if\n";
			ans = 0;
			continue;
		}
		if (Wl < Rr) { continue; }
		ans = min(ans, Wl);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    rep(i,1000){
        int num[3],p=i;
        rep(j,3) num[j]=p%10,p/=10;
        reverse(num,num+3);
        int y=0;
        rep(j,n){
            if(num[y]==s[j]-'0'&&y<3) y++;
        }
        if(y==3) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256