akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	auto x = [&](int s, int t, int u) {
		return max(s, max(t, u)) - min(s, min(t, u));
	};
	int H, W; cin >> H >> W;
	int ans(INF);
	rep(i, 1, H - 1) {
		int a = i*W;
		int h = (H - i) / 2;
		int h2 = (H - i) - h;
		int b = h*W, c = h2*W;
		chmin(ans, x(a, b, c));
	}
	rep(i, 1, H) {
		int a = i*W;
		int b = (H - i)*(W / 2);
		int c = (H - i)*(W - W / 2);
		chmin(ans, x(a, b, c));
	}
	swap(H, W);
	rep(i, 1, H - 1) {
		int a = i*W;
		int h = (H - i) / 2;
		int h2 = (H - i) - h;
		int b = h*W, c = h2*W;
		chmin(ans, x(a, b, c));
	}
	rep(i, 1, H) {
		int a = i*W;
		int b = (H - i)*(W / 2);
		int c = (H - i)*(W - W / 2);
		chmin(ans, x(a, b, c));
	}
	cout << ans << endl;
	//if (H % 3 == 0 || W % 3 == 0)cout << 0 << endl;
	//else if (W == 2 && H == 2)cout << 1 << endl;
	//else {
	//	if (W % 3 == 1 && H % 3 == 1) {
	//		int n = W / 3, m = H / 3;
	//		int a = n*H, b = 2 * m*(n + n + 1), c = (m + 1)*(n + n + 1);
	//		cout << x(a, b, c) << endl;

	//	}
	//	else if (W % 3 == 1 && H % 3 == 2 || H % 3 == 1 && W % 3 == 2) {
	//		if (H % 3 == 1 && W % 3 == 2)swap(H, W);
	//		int n = W / 3, m = H / 3;
	//		int a = m*W, b = 2 * (m + 1)*H / 2, c = b;
	//		cout << x(a, b, c) << endl;
	//	}
	//	else {
	//		int n = W / 3, m = H / 3;
	//		int a = n*H, b = (2 * m + 1)*(n + 1) * 2, c = (m + 1)*(n + 1) * 2;
	//		cout << x(a, b, c) << endl;
	//	}
		//int ans(INF);
		////1

		//int h(H), w(W), a, b, c;
		//a = h / 3 * w; h -= h / 3; b = h / 2 * w; c = (h - h / 2)*w;
		//chmin(ans, x(a, b, c));
		//dump(a, b, c, ans);
		////2
		//h = H, w = W;
		//a = w / 3 * h; w -= w / 3; b = w / 2 * h; c = (w - w / 2)*h;
		//chmin(ans, x(a, b, c));
		//dump(a, b, c, ans);
		////3
		//h = H, w = W;
		//a = (w + 2) / 3 * h; w -= (w + 2) / 3; b = h / 2 * w; c = (h - h / 2)*w;
		//chmin(ans, x(a, b, c));
		//dump(a, b, c, ans);
		////4
		//h = H, w = W;
		//a = (h + 2) / 3 * w; h -= (h + 2) / 3; b = w / 2 * h; c = (w - w / 2)*h;
		//chmin(ans, x(a, b, c));
		//dump(a, b, c, ans);

		//cout << ans << endl;
//}

	return 0;
}

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

typedef long long ll;
ll k, a[55];
ll n = 50;
int main()
{
	ll i, j;
	cin >> k;
	for (i = 0; i < n; i++) a[i] = n - 1;
	for (i = 0; i < k % n; i++) {
		for (j = 0; j < n; j++) {
			if (i != j) a[j]--;
			else a[j] += n;
		}
	}
	cout << n << endl;
	for (i = 0; i < n; i++) printf("%lld ", a[i] + k / n);
    return 0;
}

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

using namespace std;

int main()
{
  int a,b;

  while(cin>>a>>b){
    int ans = 0;
    int sum = a + b;

    while(1){
      sum = sum / 10;
      ans++;
      if(sum == 0){
        break;
      }
    }
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3084
from collections import deque

k = int(input())
q = deque([1,2,3,4,5,6,7,8,9])

for i in range(1,k):
    l = q.popleft()
    if (len(q) < k):
        m = l % 10
        if (m != 0):
            q.append(l * 10 + m - 1)
        q.append(l * 10 + m)
        if (m != 9):
            q.append(l * 10 + m + 1)

print(q.popleft())

Measured memory_bytes: 8040
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  LL n,k,cur=1;
  cin >> n >> k;
  
  REP(i,0,n){
    if(cur >= k){
      cur += k;
    }
    else{
      cur *= 2;
    }
  }
  
  cout << cur << endl;
  
  return 0;
}


Measured memory_bytes: 3532
#include<iostream>

using namespace std;

int N, a, i;
long long ans[21], memo[21];

void Initialization(){
	for(int j= 0; j< 21; j++){
		memo[j]= 0;
		ans[j]= 0;
	}
}

void memoinitial(){
	for(int j= 0; j< 21; j++)
		memo[j]= 0;
}

void Calc(int x){

	if(i== 0)
		ans[x]++;
	else{
		for(int j= 0; j< 21; j++){
			if(ans[j]!= 0){
				if(0<= j+ x && j+ x<= 20)
					memo[j+ x]+= ans[j];
				if(0<= j- x && j- x<= 20)
					memo[j- x]+= ans[j];
			}
		}
		for(int j= 0; j< 21; j++)
			ans[j]= memo[j];
		memoinitial();
	}
}
void Input(){
	cin>> N;
	Initialization();
	for(i= 0; i< N; i++){
		cin>> a;
		if(i!= N- 1)
			Calc(a);
	}
}

void disp(){
	cout<< ans[a]<< endl;
}

int main(){
	Input();
	disp();
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    string s,ss;
    cin >> s >> ss;
    vector<int> t;
    rep(i,n-1) {
        if (s[i]==s[i+1]) {
            t.push_back(2);
            ++i;
        } else t.push_back(1);
    }
    if (n==1 || s[n-1]!=s[n-2]) t.push_back(1);
    ll ans=3*t[0];
    int state=t[0];
    repr(i,1,t.size()) {
        if (state==2 && t[i]==2) ans=(ans*3)%MOD;
        else if (!(state==2 && t[i]==1)) ans=(ans*2)%MOD;
        state=t[i];
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int mod=1e9+7;
int n;
int inv(int x)
{
    int r,y;
    for(r=1,y=mod-2;y>0;x=(x*x)%mod,y/=2)
        if(y%2==1)
            r=r*x%mod;
    return r;
}
int32_t main()
{
    IOS;
    cin>>n;
    int arr[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum+=arr[i];
    }
    sum%=mod;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int val=(sum-arr[i]+5*mod)%mod;
        int curr=(val*arr[i])%mod;
        ans=(ans+curr)%mod;
    }
    ans=(ans*inv(2))%mod;
    print(ans);
}


Measured memory_bytes: 5172
#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;
	cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.begin(),l.end());
	ll ans(0);
	for(int i(0);i<n-2;++i){
		for(int j(i+1);j<n-1;++j){
			for(int k(j+1);k<n;++k){
				int a(l[i]),b(l[j]),c(l[k]);
				if(a<b+c && b<c+a && c < a+b) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int L, R, d, ans;;
  cin >> L >> R >> d;
  ans=0;
  for(int i = L; i<=R; i++){
    if(i%d==0){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define ll long long int
#define MOD 1000000007

int main()
{
  ll n ;
  cin >> n ;
  ll nor, noc ;
  ll ans = 999999999999999999 ;
  for(ll i = 1 ; i*i <= n ; i++)
  {
    if(n % i == 0)
    {
      ans = min(ans, (i - 1) + (n / i - 1) ) ;
    }
  }
  cout << ans ;
  return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 7;

int main()
{
	int d1 = -1, d2=-1;
	string st1, st2;
	cin >> st1 >> st2;
	int k = st1.size() - 1;
	while (d1<=int(st1.size()-1)||d2<=int(st2.size()-1))
	{
		if(++d1<=st1.size()-1)cout << st1[d1];
		if (++d2 <= st2.size() - 1)cout << st2[d2];
	}
}

Measured memory_bytes: 3036
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

a,b = inp
p r_up(a+b,2)

Measured memory_bytes: 2300
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int a,b;
    cin >> a >> b;
    if(a > b){
        ll x=a;
        while(x%b!=0){
            x+=a;
        }
        cout << x << endl;
    }else{
        ll x=b;
        while(x%a!=0){
            x+=b;
        }
        cout << x << endl;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int nmax=8;
bool graph[nmax][nmax];
int dfs(int v,int n,bool visited[nmax]){
  bool all_visited=true;
  for(int i=0;i<n;i++){
    if(visited[i]==false){
      all_visited=false;
    }
  }
  if(all_visited){
    return 1;
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(graph[v][i]==false){
      continue;
    }
    if(visited[i]){
      continue;
    }
    visited[i]=true;
    ans+=dfs(i,n,visited);
    visited[i]=false;
  }
  return ans;
}

int main(){
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    graph[a-1][b-1]=graph[b-1][a-1]=true;
  }
  bool visited[nmax];
  memset(visited,false,sizeof(visited));
  visited[0]=true;
  cout << dfs(0,n,visited) << endl;
}

Measured memory_bytes: 256
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int k,a,b;
    cin>>k>>a>>b;
    int ans=0;
    if(a+1>=b||k<=a){
        ans=k+1;
    }
    else{
        ans=b;
        int t=k-a-1;
        ans+=(b-a)*(t/2);
        if(t%2)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=200005;
int n,q,i;
int tree[4*N],a[N],m;
#define p(a,b) a+b
inline int ask(int l,int r,int i,int j,int nod){
	if(i>j)return 0;
    int mid=(l+r)>>1;
	if (l==i&&j==r) return tree[nod];
	if (j<=mid) return ask(l,mid,i,j,nod<<1);
	else if(i>mid) return ask(mid+1,r,i,j,(nod<<1)+1);
	int left=ask(l,mid,i,mid,nod<<1);
	int right=ask(mid+1,r,mid+1,j,(nod<<1)+1);
	return p(left,right);
}
inline void insert(int l,int r,int i,int nod){
	int mid=(l+r)>>1;
	if (l==r){tree[nod]=0; return;}
	if (i<=mid)insert(l,mid,i,nod<<1);
	else insert(mid+1,r,i,(nod<<1)+1);
	tree[nod]=p(tree[nod<<1],tree[(nod<<1)+1]);
}
inline void build(int l,int r,int nod){int mid=(l+r)>>1;
	if (l==r) {tree[nod]=1; return;}
	build(l,mid,nod<<1); build(mid+1,r,(nod<<1)+1);
	tree[nod]=p(tree[nod<<1],tree[(nod<<1)+1]);
}
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
char ch[N];
int vis[N],tong[26],sum;
long long ans;
#include<vector>
vector<int> que[26];
int main(){
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for(int i=1;i<=n;i++)tong[ch[i]-'a']++;
	for(int i=0;i<26;i++)sum+=tong[i]&1;
	if(sum>1){
		puts("-1"); return 0;
	}
    build(1,n,1);
	for(int i=1;i<=n;i++)que[ch[i]-'a'].push_back(i);
	for(int i=1;i<=n;i++){
		int pos=que[ch[i]-'a'][que[ch[i]-'a'].size()-1];
		que[ch[i]-'a'].pop_back();
		if(vis[i])continue;
		if(pos==i){
			ans+=ask(1,n,i+1,n,1)/2; insert(1,n,i,1); vis[i]=1;
		}else{
			//cout<<pos<<" "<<i<<" "<<ask(1,n,pos+1,n,1)<<endl;
			ans+=ask(1,n,pos+1,n,1);
			insert(1,n,pos,1); insert(1,n,i,1); vis[i]=vis[pos]=1;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

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

signed main() {
    int n, v, w, u;
    cin >> n;
    vector<vector<pair<int, int>>> tree(n, vector<pair<int, int>>(0));
    rep(i, n - 1) {
        cin >> u >> v >> w;
        tree[u - 1].emplace_back(make_pair(v - 1, w % 2));
        tree[v - 1].emplace_back(make_pair(u - 1, w % 2));
    }
    vector<bool> col(n, 0);
    vector<bool> visited(n, false);
    visited[0] = true;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (auto p : tree[t]) {
            if (visited[p.first])
                continue;
            else {
                q.push(p.first);
                visited[p.first] = true;
                if (p.second)
                    col[p.first] = !col[t];
                else
                    col[p.first] = col[t];
            }
        }
    }
    rep(i, n) cout << col[i] << endl;
}

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

int main() {
	string T;
	cin>>T;
	if(T=="SUN"){
		cout<<7<<endl;
	}
	else if(T=="MON"){
		cout<<6<<endl;
	}
	else if(T=="TUE"){
		cout<<5<<endl;
	}
	else if(T=="WED"){
		cout<<4<<endl;
	}
	else if(T=="THU"){
		cout<<3<<endl;
	}
	else if(T=="FRI"){
		cout<<2<<endl;
	}
	else if(T=="SAT"){
		cout<<1<<endl;
	}
	return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int n;
ll a, b;
vector<ll> h;
bool enough(ll temp)
{
    ll counter = 0;
    rep(i,n)
    {
        ll rm = h[i]-temp*b;
        if(rm>0)
        {
            counter += (rm-1)/(a-b)+1;
        }
    }
    if(counter<=temp)
    {
        return true;
    }
    return false;
}

ll bs(ll limit)
{
    ll mx,mn;
    mx = limit;
    mn = 0;
    ll med = (mn+mx)/2;
    while(mx-mn > 1)
    {
        if (enough(med))
        {
            mx = med;
            med = (mn + med) / 2;
            
        }else
        {
            mn = med;
            med = (med + mx)/2;
        }
    }
    return mx; 
}

int main()
{
    cin >> n >> a >> b;
    h.resize(n);
    ll hmax = -1;
    rep(i,n)
    {
        cin >> h[i];
        hmax = max(hmax, h[i]);
    }
    ll limit = (hmax-1)/b+1;
    cout << bs(limit) << endl;
    // cout << enough(2) << endl;
}

Measured memory_bytes: 3960
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};

struct Data{
	Data(int arg_node_id,int arg_total_cost,int arg_changed_count){
		node_id = arg_node_id;
		total_cost = arg_total_cost;
		changed_count = arg_changed_count;
	}
	bool operator<(const struct Data &arg) const{
		return total_cost > arg.total_cost;
	};
	int node_id,total_cost,changed_count;
};

int N,M,C;
int min_cost[101][101];

void func(){

	for(int i = 1; i <= N; i++){
		for(int k = 0; k < N; k++)min_cost[i][k] = BIG_NUM;
	}

	vector<Info> V[N+1];

	int from,to,cost;

	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&from,&to,&cost);
		V[from].push_back(Info(to,cost));
	}

	min_cost[1][0] = 0;

	priority_queue<Data> Q;

	for(int i = 0; i < V[1].size(); i++){

		min_cost[V[1][i].to][1] = 0;
		Q.push(Data(V[1][i].to,0,1));

		min_cost[V[1][i].to][0] = V[1][i].cost;
		Q.push(Data(V[1][i].to,V[1][i].cost,0));
	}

	while(!Q.empty()){

		if(Q.top().node_id == N){
			Q.pop();
		}else if(Q.top().total_cost > min_cost[Q.top().node_id][Q.top().changed_count] || Q.top().changed_count >= N-1){
			Q.pop();
		}else{

			for(int i = 0; i < V[Q.top().node_id].size(); i++){

				if(min_cost[V[Q.top().node_id][i].to][Q.top().changed_count+1] > Q.top().total_cost){
					min_cost[V[Q.top().node_id][i].to][Q.top().changed_count+1] = Q.top().total_cost;
					Q.push(Data(V[Q.top().node_id][i].to,Q.top().total_cost,Q.top().changed_count+1));
				}

				if(min_cost[V[Q.top().node_id][i].to][Q.top().changed_count] > Q.top().total_cost+V[Q.top().node_id][i].cost){
					min_cost[V[Q.top().node_id][i].to][Q.top().changed_count] = Q.top().total_cost+V[Q.top().node_id][i].cost;
					Q.push(Data(V[Q.top().node_id][i].to,min_cost[V[Q.top().node_id][i].to][Q.top().changed_count],Q.top().changed_count));
				}
			}
			Q.pop();
		}
	}

	int ans;
	for(int i = 0; i < N; i++){
		if(min_cost[N][i] <= C){
			ans = i;
			break;
		}
	}

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


int main(){

	while(true){
		scanf("%d %d %d",&N,&M,&C);
		if(N == 0 && M == 0 && C == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int n;
vvi dp,c;
vector<bool>ha;
vector<string>in;
int add(string a,string b){//a+b
	int t=min(a.size(),b.size());
	int c=a.size();
	for(int i=t;i>=0;i--){
		bool h=true;
		rep(j,i)if(a[c-i+j]!=b[j])h=false;
		if(h)return b.size()-i;
	}
}
int main(){
	while(cin>>n,n){
		in=vector<string>(n);
		rep(i,n)cin>>in[i];
		sort(all(in));
		n=unique(all(in))-in.begin();
		ha=vector<bool>(n,true);
		rep(i,n)rep(j,n)if(i!=j&&in[i].find(in[j])!=string::npos)ha[j]=false;
		vector<string>tmp;
		rep(i,n)if(ha[i])tmp.pb(in[i]);
		in=tmp;n=in.size();
		int w=(1<<n);
		c=vvi(n,vi(n));
		rep(i,n)rep(j,n)c[i][j]=add(in[i],in[j]);
		dp=vvi(w,vi(n,inf));
		rep(i,n)dp[1<<i][i]=in[i].size();
		loop(i,1,1<<n)rep(j,n)if(i&1<<j)rep(k,n)if((i&1<<k)==0){
			int t=i^1<<k;
			dp[t][k]=min(dp[t][k],dp[i][j]+c[j][k]);
		}
		w--;
		int out=inf;
		rep(i,n)out=min(out,dp[w][i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 3936
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
	int p, lc, rc;
}node;

node T[MAX];
int i,j,n, deg;

void degree(int id){
	deg = 0;
	if (T[id].lc != NIL || T[id].rc != NIL){
		if (T[id].lc != NIL && T[id].rc != NIL)
			deg = 2;
		else deg = 1;
	}
}

int height(int u){
	int hl = 0, hr = 0;
	if(T[u].lc != NIL)
		hl = height(T[u].lc) + 1;
	if(T[u].rc != NIL)
		hr = height(T[u].rc) + 1;
	if (hr>hl)
		return hr;
	else return hl;
}

int main(void) {
	int id, l, r, dep=0, count;
	
	scanf("%d", &n);
	//initialize
	for (i=0; i<n; i++){
		T[i].p = T[i].lc = T[i].rc = NIL;
	}
	
	for(i=0; i<n; i++){
		scanf("%d", &id);
		scanf("%d %d", &l, &r);
		T[id].lc = l;
		T[id].rc = r;
		T[l].p = T[r].p = id;
	}

	for(i=0; i<n; i++){
		printf("node %d: parent = %d, ", i, T[i].p);
		count = i;
		
		if (T[T[i].p].lc != NIL && T[T[i].p].lc != i){
			if (T[T[i].p].lc == 0 && T[T[0].p].rc == i)
				printf("sibling = %d, ", T[T[i].p].lc);
			else if  (T[T[i].p].lc != 0)
				printf("sibling = %d, ", T[T[i].p].lc);
			else printf("sibling = -1, ");
		}
		else if (T[T[i].p].rc != NIL && T[T[i].p].rc != i){
			if (T[T[i].p].rc == 0 && T[T[0].p].lc == i)
				printf("sibling = %d, ", T[T[i].p].rc);
			else if  (T[T[i].p].rc != 0)
				printf("sibling = %d, ", T[T[i].p].rc);
			else printf("sibling = -1, ");
		}
		else printf("sibling = -1, ");
		
		degree(i);
		printf("degree = %d, ", deg);

		while(T[count].p != NIL){
			dep++;
			count = T[count].p;
		}
		printf("depth = %d, height = %d, ", dep, height(i));
		dep=0;
		
		if (T[i].p == NIL)
			printf("root\n");
		else if (T[i].lc == NIL && T[i].rc == NIL)
			printf("leaf\n");
		else printf("internal node\n");
	
	}
	
	return 0;
}






Measured memory_bytes: 2112
//******\\
**udc321**	 
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fr(e,r,v) for(int e=r;e<v;e++)
#define bc(e,r,v) for(int e=r;e>v;e--)
#define all(n) (n.begin(),n.end())
#define ft first
#define sd second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mpr make_pair
#define db  double
using namespace std;

ll mod=1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*pair(sort and all) implementation and upper bound implementation*/
vector<vector<ll>> v;
vector<ll> h;
ll ps=0;
void dfs1(ll a,ll p)
{

	fr(j,0,v[a].size())
	{
		if(v[a][j]==p){continue;}
		dfs1(v[a][j],a);
		h[a]+=h[v[a][j]];
	}
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x)*t+(n%x!=0)*t<<endl;

}









Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N, P;
    cin >> N >> P;
    map<lli, lli> mp;
    lli p = P;
    for (lli i = 2; i * i <= P; i++) {
        while (p % i == 0) {
            mp[i]++;
            p /= i;
        }
    }
    mp[p]++;

    lli ans = 1;
    for (auto &it : mp) {
        while (it.second >= N) {
            ans *= it.first;
            it.second -= N;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    char S[51];
    char T[51];

    scanf("%50s", S);
    scanf("%50s", T);

    int S_len = strlen(S);
    int T_len = strlen(T);

    if (S_len >= T_len) {
        for (int i = S_len - T_len; i >= 0; --i) {
            int flag = 0;
            for (int j = 0; j < T_len; ++j) {
                if (S[i+j] != T[j] && S[i+j] != '?') {
                    flag = 1;
                }
            }
            if (flag) {
                continue;
            }
            for (int j = 0; j < T_len; ++j) {
                S[i+j] = T[j];
            }

            for (int j = 0; j < S_len; ++j) {
                if (S[j] == '?') {
                    S[j] = 'a';
                }
            }
            printf("%s\n", S);
            return 0;
        }
    }
    printf("UNRESTORABLE\n");
    return 0;
}


Measured memory_bytes: 128
N = int(input())
H = list(map(int, input().split()))
h0 = H[0]
temp = 0
res = 0
for h in H[1:]:
    if h0>=h:
        temp += 1
        res = max(temp,res)
    else:
        temp = 0
    h0 = h
print(res)

Measured memory_bytes: 85536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans=0;
  ll sum1=0,sum2=0;
  if(n%2==0){
    rep(i,n/2){
      sum1+=a[i];
    }
    FOR(i,n/2,n){
      sum2+=a[i];
    }
    cout << 2*(sum2-sum1)-a[n/2]+a[n/2-1] << endl;
  }
  else{
    ll sum3,sum4;
    rep(i,(n-1)/2){
      sum1+=a[i];
    }
    sum3=sum1+a[(n-1)/2];
    FOR(i,(n-1)/2,n){
      sum2+=a[i];
    }
    sum4=sum2+sum1-sum3;
    if(n>=3){
      ans=2*(sum4-sum3)+a[(n-1)/2]+a[(n-3)/2];
    }
    ans=max(ans,2*(sum2-sum1)-a[(n-1)/2]-a[(n+1)/2]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = long.Parse(Console.ReadLine());
            
            for(int i = 0 ; i < n ; i++)
            {
                if(s[i] == '1' && i == n-1)
                {
                    Console.WriteLine(s[i]);
                    return;
                }
                else if(s[i] != '1' && i < n)
                {
                    Console.WriteLine(s[i]);
                
                    return;
                }
            
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void read(int &x)
{
    int f = 1;
    x = 0;
    char s = getchar();
    while (s < '0' || s > '9')
    {
        if (s == '-')
            f = -1;
        s = getchar();
    }
    while (s >= '0' && s <= '9')
    {
        x = x * 10 + s - '0';
        s = getchar();
    }
    x *= f;
}
int wei(ll x){
    int ans=0;
    while(x){
        ans++;
        x/=10;
    }
    return ans;
}
#define ll long long
int main()
{
    int n, m;
    
    cin >> n;
    ll ans = 1;
    int flag = 0;
    for (int i = 0; i < n; i++)
    {
        ll t;
        cin >> t;
        if ((wei(t)+wei(ans)>=20&&t*ans!=1000000000000000000LL)||t*ans>1000000000000000000LL)
        {
            flag = 1;
        }
        ans *= t;
        if (t == 0)
        {
            flag = 2;
        }
    }
    if (flag == 2)
    {
        cout << "0" << endl;
        return 0;
    }
    if (flag)
    {
        cout << "-1";
        return 0;
    }
    cout << ans;
    return 0;
}

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

int main(){
    unsigned long N, Q;
    cin >> N >> Q;
    vector<unsigned long> A(N), S(N), X, a;
    for(auto& i : A)cin >> i;
    partial_sum(A.rbegin(), A.rend(), S.begin());
    for(unsigned long i{(N + 1) / 2}, AS{0}; i--; AS += A[N - i * 2 - 1])a.push_back(S[i] + AS);
    for(unsigned long i{(N + 1) / 2}; --i;)X.push_back(A[N - i - 1] + A[N - i * 2 - 1]);
    auto beg = begin(X), edn = end(X);
    for(long long i{0}, x; i < Q; ++i){
        cin >> x;
        cout << a[lower_bound(beg, edn, x * 2) - beg] << endl;
    }
    return 0;
}

Measured memory_bytes: 4216
var t = require('fs').readFileSync('/dev/stdin', 'utf8');
t = ~~t;
h = Math.floor(t / 3600);
t -= 3600 * h;
m = Math.floor(t / 60);
t -= 60 * m;
s = t

console.log(`${h}:${m}:${s}`);



Measured memory_bytes: 15096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;

int main(){
    while(1){
        int h;
        cin >> h;
        if(h == 0) break;//終了条件
        vector< vector<int> > d(h, vector<int>(5));
        rep(i, h){//入力
            rep(j, 5){
                cin >> d.at(i).at(j);
            }
        }
        bool flag = false;//データセット終了フラグ
        long long score = 0;//獲得スコア
        while(1){
            vi f(5, 0);
            rep(i, h){
                int count = 1;//連結数カウント→初期状態として一つのブロックが繋がっていると考える。
                int cnt_num = 0;//連結元の数字保存用
                int k_ = 0;//連結最終尾のx座標保存用
                rep(j, 4){//5でないのは、隣り合う二つのブロックをみているため
                    if(d.at(i).at(j) == d.at(i).at(j+1)){//連結してるなら
                        if(d.at(i).at(j)!=0)count++;
                        cnt_num = d.at(i).at(j);
                    }
                    else {//連結が途切れたら
                        if(count < 3){
                            count = 1;
                        }
                        else{//連結数が3以上なら確定(max５までしか連結しないので)
                            k_ = j;
                            break;
                        }
                    }
                    k_ = j+1;
                }
                if(count >= 3){//スコア計算
                    score += cnt_num*count;
                    flag = true;//消えるブロックがあるので処理をもう一周させる
                    rep(k, count){//消えたブロックは0（無）に変換
                        d.at(i).at(k_-k) = 0;
                    }
                }
            }
            while(1){//全部落としきるまで
                bool ex = false;//このループの終了フラグ
                for(int i = h-1; 0 < i; i--){//下から上を見て一段ずつ対象のブロックを落とす。
                    rep(j, 5){//下のブロックが0（無）なら落とす。
                        if(d.at(i).at(j)==0&&d.at(i-1).at(j)!=0){
                            d.at(i).at(j) = d.at(i-1).at(j);
                            d.at(i-1).at(j) = 0;
                            ex = true;
                        }
                    }
                }
                if(!ex) break;
            }
            if(!flag) break;
            flag = false;
        }
        cout << score << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
package main

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

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()

	// 全て偶数(nC2)
	a := (N * (N - 1)) / 2
	// すべて奇数(mC2)
	b := (M * (M - 1)) / 2
	fmt.Println(a + b)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define pqb             	priority_queue<int>
#define pqs             	priority_queue<int,vi,greater<int> >
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)  	type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=inf,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n,m,k;cin>>n>>m>>k;
    vector<vector<int>> v(n);
    int price[n];
    fo0(i,n){
    	int y;cin>>y;
    	price[i]=y;
    	for(int j=0;j<m;j++){
    		int x;cin>>x;
    		v[i].push_back(x);
    	}
    }
    // for(int i=0;i<n;i++){
    // 	for(int j=0;j<m;j++){
    // 		cout<<v[i][j]<<" ";
    // 	}
    // 	cout<<endl;
    // }
    // return;
    
    for(int i=1;i<(1<<n);i++){
    	int curr_price=0;
    	int algo[m];
    	mset(algo,0);
    	int flag=0;
    	for(int j=0;j<n;j++){
    		if(i&(1<<j)){
    			curr_price+=price[j];
    			for(int l=0;l<m;l++){
    				algo[l]+=v[j][l];
    			}
    		}
    	}
    	for(int j=0;j<m;j++){
    		if(algo[j]<k){
    			flag=1;
    		}
    	}
    	if(!flag){
    		ans=min(ans,curr_price);
    	}
    }
    if(ans==inf){
    	cout<<-1<<endl;
    	return;
    }
    cout<<ans<<endl;
    
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();cerr<<"\nExecution time: "<<(double)(clock()-beg)/1000<<" seconds\n";}
}

Measured memory_bytes: 3848
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
long long p[110000];
long long ans[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%lld",p+i);
	}
	long long sum=0;
	for(int i=0;i<a;i++)sum+=p[i];
	long long tmp=0;
	for(int i=0;i<a-1;i+=2)tmp+=p[i]*2;
	int at=a-1;
	for(int i=0;i<a;i++){
		ans[at]=sum-tmp;
		tmp-=p[(a+at-(a-1))%a]*2;
		tmp+=p[at]*2;
		at+=2;
		at%=a;
	}
	for(int i=0;i<a;i++)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 2816
from collections import deque

def maze(h, w, sh, sw, list1):
    if list1[sh][sw]=="#":
        return 0
    flag = True
    for i in range(h):
        for j in range(w):
            if list1[i][j]=="#":
                flag=False
    if flag:
        return h+w-2
    
    que = deque()
    que.append([sh, sw, 0])
    list2 = list1.copy()
    direct = [(0,1), (0,-1), (1,0), (-1, 0)]
    count = 0
    while que:
        nh, nw, co = que.pop()
        count = co
        co +=1
        li=list(list2[nh])
        li[nw]="#"
        list2[nh]="".join(li)
        for i, j in direct:
            if nh+i<0 or nh+i>=h or nw+j<0 or nw+j>=w:
                pass
            elif list2[nh+i][nw+j]==".":
                que.appendleft([nh+i, nw+j, co])
    return count
        
h, w = (int(x) for x in input().split())
list1 = []
ans = 0
for i in range(h):
    list1.append(input())
for i in range(h):
    for j in range(w):
        ans_ij = maze(h, w, i, j , list1)
        if ans_ij>ans:
            ans=ans_ij
print(ans)

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

int main() {
    std::priority_queue<int> S;

    while (true) {
        std::string command;
        std::cin >> command;
        if (command == "end") {
            break;
        } else if (command == "insert") {
            int k;
            std::cin >> k;
            S.push(k);
        } else if (command == "extract") {
            std::cout << S.top() << std::endl;
            S.pop();
        }
    }
}



Measured memory_bytes: 7068
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll sum=0;
  ll sumnozoki = 0;
  ll b[n];
  rep(i,n){
    cin >> a[i];
    sum += a[i];
    if(i % 2 == 1){
      sumnozoki += a[i];
    }
  }
  b[0] = sum - 2 * sumnozoki;
  rep(i,n-1){
    b[i+1] = a[i]*2 - b[i];
  }
  rep(i,n){
    cout << b[i] << " ";
  }
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
const ll INF = 9223372036854775807;
const ll mod = 1000000007;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> St(M);
  rep(i, M) cin >> St[i];
  if (M == 0)
    St = {10010};

  ll j = 0;
  vector<ll> dp(100100, 0);
  dp[0] = 1;
  dp[1] = 1;
  rep(i, N)
  {
    if(M){
          if (i == St[j] - 1)
    {
      dp[i] = 0;
      j++;
    }
    }
    

    dp[i + 1] =(dp[i+1]+dp[i])% mod;
    dp[i + 2] =(dp[i+2]+dp[i])% mod;
  }
  cout << dp[N-1] % mod << endl;
}


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

//ゆうせンド付きキューを使えばすぐできる


int main(){
    priority_queue<int> pq;
    long long ans=0;
    int a,n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a;
        pq.push(a);
    }
    for(int i=0;i<m;i++){
        a=pq.top();
        pq.pop();
        pq.push(a/2);
    }
    
    for(int i=0;i<n;i++){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"29"# => "Yes",
// r#"24"# => "No",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        a: usize,
    }

    (n * n - a).to_string()
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

pll A[1005];
ll dp[1005][10005];

int main() {
    ll H, N;
    cin >> H >> N;
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    REP(i, N + 1) {
        REP(j, H + 1) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    REP(i, N) {
        REP(j, H + 1) {
            dp[i + 1][j] = std::min(dp[i + 1][j], dp[i][j]);
            ll h = std::min(H, j + A[i].first);
            dp[i + 1][h] = std::min(dp[i + 1][h],
                                    std::min(dp[i][j] + A[i].second, dp[i + 1][j] + A[i].second));
        }
    }
    cout << dp[N][H] << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n, t, cnt;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> t;
        if (t > i) {
            cnt++;
        }
    }
    if (cnt > 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3644
def main(a: int, b: int, c: int, k: int):
    ans = 0

    _a = min(a, k)
    ans += _a
    k -= _a

    if b >= k:
        print(ans)
        return

    _b = min(b, k)
    k -= _b

    _c = min(c, k)
    ans -= _c

    print(ans)


if __name__ == "__main__":
    a, b, c, k = map(int, input().split())
    main(a, b, c, k)


Measured memory_bytes: 9196
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var R = cin.ReadInt();
            var G = cin.ReadInt();
            WriteLine((- R + G) * 2 + R);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 11220
def main():
    N, Ma, Mb = map(int, input().split())
    ABC = [list(map(int, input().split())) for _ in range(N)]

    INF = 10000000

    dp = [[[INF for _ in range(10*N)] for _ in range(10*N)] for _ in range(N)]

    for i, (a, b, c) in enumerate(ABC):
        a -= 1
        b -= 1
        if i == 0:
            dp[0][a][b] = c
            continue
        for ai in range(10*N):
            for bi in range(10*N):
                if a > ai or b > bi:
                    dp[i][ai][bi] = dp[i-1][ai][bi]
                elif ai == a and bi == b:
                    dp[i][ai][bi] = min(dp[i-1][ai][bi], c)
                else:
                    dp[i][ai][bi] = min(dp[i-1][ai-a-1][bi-b-1]+c, dp[i-1][ai][bi])

    ans = INF
    for i in range(10*N):
        for j in range(10*N):
            if (i+1)*Mb == (j+1)*Ma:
                #print(i, j, dp[N-1][i][j])
                ans = min(dp[N-1][i][j], ans)
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N, M;
vector<vector<int>> G;

//差分取って<=0のポイントで区切る。
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	G.resize(N);
	for(int i=0; i<N; i++){
		G[i].clear();
	}
	for(int i=0; i<M; i++){
		int a, b;
		cin >> a >> b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
	}


	int possible = 0;
	for(auto nv : G[0]){
		for(auto nnv : G[nv]){
			if(nnv == N-1){
				 possible = 1;
				 break;
			}
		}
		if(possible == 1){
			break;
		}
	}
	if(possible == 1){
		printf("POSSIBLE\n");
	}
	else{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


Measured memory_bytes: 12016