akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

//Range Minimum Query
struct segment {
    int n;
    vector<int64_t> dat;
    // n_は範囲
    segment(int n_) { // nはn_以上の2^?
        n = 1<<(32-__builtin_clz(n_));
        if(n == 2*n_) n >>= 1;
        dat.assign(2*n-1, INT64_MIN);
    }
    //更新の手順
    inline int64_t theorem(int i) {
        int64_t chld = dat[i*2+1];
        int64_t chrd = dat[i*2+2];
        return max(chld, chrd);
    }
    inline int chld(int i) {return 2*i+1;}
    inline int chrd(int i) {return 2*i+2;}
    //初期化(初期状態はINT64_MAX)
    void init(const vector<int64_t> &vec) {
        int num = vec.size();
        rep(i, num) {
            dat[i+n-1] = vec[i];
        }
        rep(i, n-1) {
            dat[n-2-i] = theorem(n-2-i);
        }
    }
    // k番目の値をaに変更
    void update(int k, int64_t a) {
        // 葉の節点
        k += n-1;
        dat[k] = a;
        // 登りながら更新
        while(k>0) {
            k = (k-1)/2;
            dat[k] = theorem(k);
        }
    }
    //kは節点の番号, [l, r)に節点が対応
    // (a, b, 0, 0, n)で呼ぶ
    int64_t query_(int a, int b, int k, int l, int r) {
        if(a>=r || l>=b) return INT64_MIN;
        if(a<=l && r<=b) return dat[k];
        else {
            int chl = k*2+1;
            int chr = k*2+2;
            int64_t vl = query_(a, b, chl, l, (l+r)/2);
            int64_t vr = query_(a, b, chr, (l+r)/2, r);
            return max(vl, vr);
        }
    }
};

int main() {
    int n;
    cin >> n;
    ll c;
    cin >> c;
    vector<pair<ll, ll> > x(n);
    rep(i, n) {
        cin >> x[i].first >> x[i].second;
    }


    vector<ll> migi(n), hidari(n);
    migi[0] = x[0].second - x[0].first;
    hidari[n-1] = x[n-1].second - c + x[n-1].first;
    rep(i, n-1) {
        migi[i+1] = migi[i] + x[i+1].second - x[i+1].first + x[i].first;
        hidari[n-2-i] = hidari[n-1-i] + x[n-2-i].second + x[n-2-i].first - x[n-1-i].first;
    }
    hidari.push_back(0);

    segment seg(n+1);
    seg.init(hidari);
    ll ans = 0;
    ll now;
    rep(i, n) {
        now = migi[i];
        ll g = seg.query_(i+1, n+1, 0, 0, seg.n+1);
        now = max(now-x[i].first + g, now);
        ans = max(ans, now);
    }

    reverse(all(migi));
    migi.push_back(0);
    seg.init(migi);
    rep(i, n) {
        now = hidari[n-1-i];
        ll g = seg.query_(i+1, n+1, 0, 0, seg.n+1);
        now = max(now-c+x[n-1-i].first+g, now);
        ans = max(ans, now);
    }

    cout << ans << endl;


}

Measured memory_bytes: 6256
fn input_t<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	s.trim().parse().ok().unwrap()
}

fn input_vt<T: std::str::FromStr>() -> Vec<T> {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	s.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn main() {
	let n     = input_t::<usize>();
    let xs    = input_vt::<usize>();
    let ys    = input_vt::<u32>();
    let zs    = input_vt::<u32>();
    let mut c = 0;
    
    for i in 0..n {
    	c += ys[xs[i] - 1];
        
        if 0 < i && xs[i - 1] + 1 == xs[i] {
        	c += zs[xs[i - 1] - 1];
        }
    }
    
	println!("{}", c);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main(){
    int N;
    long x;
    cin >> N >> x;
    long a[N];
    long between[N];
    for (int i=0; i<N; i++) {
        cin >> a[i];
        if (i>=1) {
            between[i] = a[i] + a[i-1] - x;
        }
    }   
    long ans = 0;
    for (int i=1; i<N-1; i++) {
        long aim = between[i] < between[i+1] ? between[i] : between[i+1];
        if (aim <= 0) continue;
        if (aim < a[i]) {
            ans += aim;
            between[i] -= aim;
            between[i+1] -= aim;
        }
        else {
            ans += a[i];
            between[i] -= a[i];
            between[i+1] -= a[i];
        }
    }   
    for (int i=1; i<N; i++) {
        long left = between[i] > 0 ? between[i] : 0;
        ans += left;
    }   
    cout << ans << endl;
        

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 1;										/* デバッグプリント 提出時は0 */
int main()
{
	int		ans = 0;

	int		N,X,i,j,L[100];
	
	scanf("%d %d", &N, &X);
	for(i=0;i<N;i++) {
		scanf("%d",&L[i]);
	}

	j=0;
	for(i=0;i<=N+1;i++) {
		j += L[i];
		if (j>X) break;



	}

	printf("%d\n",i+1);


	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=10000005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

struct node
{
    int id,pi,x;
    string pix,xx;
};

bool cmp1(node a,node b)
{
    if(a.pi==b.pi)
        return a.x<b.x;
    return a.pi<b.pi;
}

bool cmp2(node a,node b)
{
    return a.id<b.id;
}

int main()
{
    //read("in.txt"),write("out.txt");
    int n,m;
    ini(n),ini(m);
    node v[m];
    rep(i,0,m-1)
    ini(v[i].pi),ini(v[i].x),v[i].id=i+1;
    sort(v,v+m,cmp1);
    int p=1,g=v[0].pi,cnt=0;
    rep(i,0,m-1)
    {
        if(v[i].pi==g)
        {
            v[i].pix=to_string(v[i].pi);
            int len=(int)log10(v[i].pi)+1;
            rep(j,1,6-len) v[i].pix="0"+v[i].pix;
            v[i].xx=to_string(p);
            len=(int)log10(p)+1;
            rep(j,1,6-len) v[i].xx="0"+v[i].xx;
            p++;
        }
        else
        {
            g=v[i].pi,p=1;
            v[i].pix=to_string(v[i].pi);
            int len=(int)log10(v[i].pi)+1;
            rep(j,1,6-len) v[i].pix="0"+v[i].pix;
            v[i].xx=to_string(p);
            len=(int)log10(p)+1;
            rep(j,1,6-len) v[i].xx="0"+v[i].xx;
            p++;

        }
    }
    sort(v,v+m,cmp2);
    rep(i,0,m-1)
    cout<<v[i].pix<<v[i].xx,nl;
    return 0;
}



Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int N;
	cin>>N;
	vector<int> vec(N,0);
	vector<int> P(N,0);
	vector<int> Q(N,0);
	for(int i=0; i<N; i++){
		int p; cin>>p;
		P[i]=p;
	}
	for(int i=0; i<N; i++){
		int q; cin>>q;
		Q[i]=q;
	}
	for(int i=1; i<=N; i++){
		vec[i-1]=i;
	}
  	int cnt=1,a,b;
	do{
      //	cout<<cnt<<endl;
        for(int i=0; i<N; i++){
          	if (equal(vec.begin(), vec.end(), P.begin())) a=cnt;
          	if (equal(vec.begin(), vec.end(), Q.begin())) b=cnt;
            //cout<<vec[i];
            //if(i!=3)cout<<" ";
        }
       // cout<<endl;
      	cnt++;
    }while(next_permutation(vec.begin(),vec.end()));
  	cout<<abs(a-b)<<endl;
}
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 256
#include <stdio.h>

#define BUILDINGS 4
#define FLOORS 3
#define ROOMS 10

int main(int argc, char *argv[])
{
    const char *const line_separator = "####################\n";
    int counts[BUILDINGS][FLOORS][ROOMS] = {};
    int n;
    scanf("%d\n", &n);
    for (int i = 0; i < n; ++i)
    {
        int building, floor, room, fluctuation;
        scanf("%d %d %d %d\n", &building, &floor, &room, &fluctuation);
        counts[building - 1][floor - 1][room - 1] += fluctuation;
    }
    for (int building = 0; building < BUILDINGS; ++building)
    {
        printf("%s", building ? line_separator : "");
        for (int floor = 0; floor < FLOORS; ++floor)
        {
            for (int room = 0; room < ROOMS; ++room)
            {
                printf("%2d", counts[building][floor][room]);
            }
            printf("\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2060
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(ALL(a));
  ll INF = ll(1e18)+10, l = -INF, r = INF;
  while(l+1<r) {
    ll x = (l+r)/2;
    bool ok = [&] {
      ll total = 0;
      rep(i,n) {
        if(a[i] < 0) {
          int l = -1, r = n;
          while(l+1<r) {
            int c = (l+r)/2;
            if(a[i]*a[c] < x) r = c; else l = c;
          }
          total += n-r;
        } else {
          int l = -1, r = n;
          while(l+1<r) {
            int c = (l+r)/2;
            if(a[i]*a[c] < x) l = c; else r = c;
          }
          total += r;
        }
        if(a[i]*a[i] < x) total--;
      }
      return total / 2 < k;
    }();
    if(ok) l = x; else r = x;
  }
  cout << l << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split() ))
ans = 0
l = 0

for n in range(N):
    if n < N-1 :
        if H[n] >= H[n+1] :
            l += 1
        else :
            l = 0

    ans = max(ans, l)

print(ans)


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

int main() {
  int n, a, b, ans=0;
  cin >> n >> a >> b;

  for (int i=1; i<=n; i++) {
    int t=i, sum=0;
    
    while (t) {
      sum+=t%10;
      t/=10;
    }

    if (sum>=a && sum<=b) ans+=i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first<<"\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

bool isSym(vector<vector<char>>& s,int n){
    //bool rtn = true;
    REP(i,n){
        REP(j,n){
            if(s[i][j]!=s[j][i]){
                return false;
            }
        }
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }
    int res = 0;
    vector<vector<char>> t(n,vector<char>(n));
    Rep(i,n){
        int a = 0;
        int b = i;
        REP(j,n){
            REP(k,n){
                int t1 = (j+a)%n;
                int t2 = (k+b)%n;
                t[j][k] = s[t1][t2];
            }
        }
        if(isSym(t, n)){
            res+=n;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 512
N,A,B=map(int,input().split())
S=' '+input()
AB=A+B
j=1
num=0
for i in range(1,N+1):
    if S[i]=='b' and num<AB and j<=B:
        print('Yes')
        j+=1
        num+=1
    elif S[i]=='a' and num<AB:
        print('Yes')
        num+=1
    else:
        print('No')


Measured memory_bytes: 75864
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 998244353;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
int kai_size = 400001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);
vel dist;
int RE() {
	vel v(3, 2);
	return v.at(4); 
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, kai_size) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
int per(int n, int r) {
	int ans = kai[n] * ink[n - r];
	ans %= p;
	return ans;
}
vel dis(int mid1, vvel &way,vel &con) {
	int n = way.size();
	vel dist(n,-1);
	dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front();
		q.pop();
		con.push_back(st);
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
int gr(int now, vvel &chi) {
	int ret = 0;
	for(auto to:chi[now]) {
		ret = ret xor (gr(to, chi) + 1);
	}
	return ret;
}
signed main() {
	int h, w, q; cin >> h >> w >> q;
	vvel s(h,vel(w));
	rep(i, h) {
		string st; cin >> st;
		rep(j, w) {
			s[i][j] = st[j]-'0';
		}
	}
	vvel sum(h + 1, vel(w + 1, 0));
	rep(i, h) {
		rep(j, w) {
			sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + s[i][j];
		}
	}
	vvel sumt(h, vel(w + 1, 0));
	rep(i, h-1) {
		rep(j, w) {
			sumt[i + 1][j + 1] = sumt[i][j + 1] + sumt[i + 1][j] - sumt[i][j];
			sumt[i + 1][j+1] += s[i][j] * s[i + 1][j];
		}
	}
	vvel sumy(h+1, vel(w, 0));
	rep(i, h) {
		rep(j, w-1) {
			sumy[i + 1][j + 1] = sumy[i][j + 1] + sumy[i + 1][j] - sumy[i][j];
			sumy[i + 1][j+1] += s[i][j] * s[i][j + 1];
		}
	}
	rep(i, q) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--;
		y1--;
		int ans = sum[x2][y2] - sum[x2][y1] - sum[x1][y2] + sum[x1][y1];
		x2--;
		int ze = 0;
		int mx = x1;
		ans -= sumt[x2][y2] - sumt[x2][y1] - sumt[mx][y2] + sumt[mx][y1];
		x2++;
		y2--;
		int my =y1;
		ans -= sumy[x2][y2] - sumy[x2][my] - sumy[x1][y2] + sumy[x1][my];
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 134144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string S,T;
    cin >> S >> T;
    
    cout << T << S << "\n";
    return 0;
}


Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}



int32_t main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();
    string s,t;
    cin>>s>>t;
    int n = s.length()+1;
    int m = t.length()+1;

    int dp[n][m]={0};
    for(int i=0;i<n;i++){
        dp[i][0]=0;
    }
    for(int i=0;i<m;i++){
        dp[0][i] = 0;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(t[j-1]==s[i-1]){
                dp[i][j] = 1+dp[i-1][j-1];
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans="";
    int len = dp[n-1][m-1];
    int i = n-1,j=m-1;
    while(dp[i][j]>0){
        if(dp[i][j]!=dp[i-1][j] && dp[i][j]!=dp[i][j-1]){
            ans+=s[i-1];
            i--;
            j--;
        }else if(dp[i][j]==dp[i-1][j]){
            i--;
        }else{
            j--;
        }
    }
    reverse(all(ans));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 73940
#include<iostream>
#include<cmath>
using namespace std;
int main(){
char c;
double xa,ya,xb,yb,xc,yc,xd,yd,ab,bc,cd,da,aa,bb,cc,dd;
while(cin>>xa){
cin>>c>>ya>>c>>xb>>c>>yb>>c>>xc>>c>>yc>>c>>xd>>c>>yd;
ab=(xb-xa)*(yc-ya)-(yb-ya)*(xc-xa);
bc=(xc-xb)*(yd-yb)-(yc-yb)*(xd-xb);
cd=(xd-xc)*(ya-yc)-(yd-yc)*(xa-xc);
da=(xa-xd)*(yb-yd)-(ya-yd)*(xb-xd);
if(ab*bc<0||bc*cd<0||cd*da<0||da*ab<0)cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}


Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int[] a = new int[n];
        int odd = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (a[i] % 2 != 0) {
                odd++;
            }
        }
        if (odd == 0) {
            if (p == 0) {
                System.out.println((long) Math.pow(2, n));
            } else {
                System.out.println(0);
            }
            return;
        }
        System.out.println((long) Math.pow(2, n - 1));
    }

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int binary(vector<ll> &a,ll left,ll right,ll k,ll n){
  ll mid=(left+right)/2;
  ll cnt=0;
  rep(i,n)cnt+=(a[i]-1)/mid;
  if(left==mid){
    if(cnt<=k)return mid;
    else return right;
  }
  if(cnt<=k)return binary(a,left,mid,k,n);
  else return binary(a,mid,right,k,n);
}
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  cout << binary(a,(ll)1,(ll)1000000001,k,n) << endl;
}


Measured memory_bytes: 4772
Scanf.scanf "%d %d" (fun n m ->
    let nei = Array.make n [] in
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun a b ->
            let a = a - 1 in let b = b - 1 in
            nei.(a) <- b :: nei.(a);
            nei.(b) <- a :: nei.(b);
        )
    done;

    let light = Array.make n (-1) in
    let dist = Array.make n 1000000000 in
    let () = light.(0) <- 0 in
    let () = dist.(0) <- 0 in

    let module S = Set.Make (struct type t = int * int let compare = compare end) in

    let rec dijkstra set =
        if S.is_empty set then () else (
            let (cost, node) as elt = S.min_elt set in
            let set = S.remove elt set in
            let set = List.fold_left (fun set next ->
                if dist.(next) > cost + 1 then (
                    dist.(next) <- cost + 1;
                    light.(next) <- node;
                    S.add (cost + 1, next) set
                ) else set
            ) set nei.(node)
            in
            dijkstra set
        )
    in
    dijkstra (S.singleton (0, 0));
    let rec loop i =
        if i = n then true else
            if light.(i) < 0 then false else
                loop (i + 1)
    in
    if loop 1 then (
        print_endline "Yes";
        for i = 1 to n - 1 do
            Printf.printf "%d\n" (light.(i) + 1)
        done
    ) else print_endline "No"
)

Measured memory_bytes: 34892
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
int main(){
    
    
    
    while(1){
        
        ll n,m;
        
        ll ans;
        vector<pair<int,int>> dp;
        ll sum=0;
        ll dsum=0;
        
        cin>>n>>m;
        
        if(n==0 && m==0){break;}
        
        for(int i=0;i<n;++i){
            int d,p;
            cin>>d>>p;
            dp.push_back(pair<int,int>(d,p));
            sum+=((ll)d)*((ll)p);
            dsum+=d;
        }
        
        sort(dp.begin(),dp.end(),[](const pair<int,int>& a, const pair<int,int>& b)->bool{
            return (a.second > b.second);
        });
        
        if(dsum<=m){
            ans=0;
        }else{
            for(auto& e : dp){
                if(e.first >= m){
                    sum-=e.second * m;
                    break;
                }else{
                    sum-=e.first * e.second;
                    m-=e.first;
                }
            }
            ans=sum;
        }
        
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1332
import java.util.*;

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

    int n = sc.nextInt();
    String dummy = sc.nextLine();

    String[] s = sc.nextLine().split(" ");
    String[] t = sc.nextLine().split(" ");
    
    int[] a = new int[n+1];
    int[] b = new int[n];

    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(s[i]);
      if (i < n) b[i] = Integer.parseInt(t[i]);
    }
    
    long sum = 0;
    long rep = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= rep;
      sum += Math.min(a[i] + a[i+1], b[i]);
      if (a[i] > b[i]) {
        rep = 0;
      } else {
        rep = Math.min(b[i] - a[i], a[i+1]);
      }
      // System.out.println("a:" + a[i] + " m:" + m + " rep:" + rep + " sum:" + sum);
    }
    
    System.out.println(sum);
  }
}


Measured memory_bytes: 61392
num = int(input())

num2alpha = lambda c: chr(c+96)
ans = []
newans = []
string = ''

while num > 0:
    if num % 26 == 0:
        ans.append(26)
    else:
        ans.append(num%26)
    if num < 27:
        break
    num =  int((int(num) - 1) / 26)
    

for item in ans:
    newans.append(num2alpha(item))

for item in reversed(newans):
    string = string + item

print(string)





Measured memory_bytes: 9048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt() - 1;
		int B = sc.nextInt() - 1;
		if (B == 1) {
			System.out.println(0);
			System.exit(0);
		}
		if ((B % A) != 0) {
			System.out.println(B / A + 1);
		} else {
			System.out.println(B / A);
		}
	}
}


Measured memory_bytes: 35740
//Suplex
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
long long f[10000];

struct leo{
    int h,p;
}a[10000];

bool cmp(leo a,leo b)
{
    return a.h+a.p<b.h+b.p;
}

inline long long min(long long a,long long b)
{
    return a<b ? a : b;
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i].h,&a[i].p);
    sort(a+1,a+1+n,cmp);
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    for(int i=1;i<=n;i++)
        for(int j=i;j;j--)
            if(f[j-1]<=a[i].h) f[j]=min(f[j],f[j-1]+a[i].p);
    for(int i=n;i;i--) if(f[i]<1e18){printf("%d\n",i);break;}
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {
    
    public static void main(String[] args) {
        MyScanner ms = new MyScanner();
        int K = ms.nextInt();
        long sum=0;
        for(int i=1;i<=K;i++)
        for(int j=1;j<=K;j++)
        for(int c=1;c<=K;c++){
            sum+=(gcd(gcd(i,j),c));
        }
       System.out.println(sum);
    }
   static  int gcd (int a, int b) {
        return b != 0 ? gcd (b, a % b) : a;
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
    
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
    
     }
}

Measured memory_bytes: 32648
#include<stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int a[102];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int ans = 0;
    int x;
    int j;
    for (j = 0; j < 8; j++)
    {
        x = 0;
        for (i = 0; i < n; i++)
        {
            if (a[i] >= 400 * j && a[i] < 400 * (j + 1))
                x++;
        }
        if (x > 0)
            ans++;
    }
    x = 0;
    for (i = 0; i < n; i++)
        if (a[i] >= 3200)
            x++;
    if (ans == 0)
        printf("1 ");
    else
        printf("%d ", ans);
    ans += x;
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int a[200005], dem[200005];

int main()
{
    int n, maxn=200000;
    cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    for (int i=1; i<=maxn; ++i) dem[i]=0;
    for (int i=1; i<=n; ++i) ++dem[a[i]];
    long long kq = 0;
    for (int i=1; i<=maxn; ++i)
        kq+=((long long)dem[i]*(dem[i]-1)/2);
    for (int i=1; i<=n; ++i)
        cout << kq-dem[a[i]]+1 << '\n';
}


Measured memory_bytes: 4096
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a, s=0; cin>>a;
    vec<ll> m(a);
    for(int q=0; q<a; q++) cin>>m[q], s+=m[q];
    vec<ll> pl(a);
    for(int q=2; q<a; q+=2) pl[q] = pl[q-2] + (m[q-1]-m[q-2])*2;
    pl[1] = pl[a-1]+(m[0]-m[a-1])*2;
    for(int q=3; q<a; q+=2) pl[q] = pl[q-2] + (m[q-1]-m[q-2])*2;
    ll c = 0;
    for(ll i : pl) c+=i;
    ll x = (s-c)/a;
    for(int q=0;q <a; q++) cout<<x+pl[q]<<" ";
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	static Scanner scan = new Scanner(System.in);
	static int X = scan.nextInt();
	static int Y = scan.nextInt();
	
	//static long memo[][] = new long[Y+1][X+1];
	//static boolean check[][] = new boolean[Y+1][X+1];
	public static void main(String[]args) {
		COMinit();
		
		long goukei = 0;
		
		if((X+Y)%3!=0) {
			System.out.println(0);
		}else {
			int z = (X+Y)/3;
			for(int i = 0;i<=z;i++) {
				int s = 2*(z-i)+i;
				int t = z-i+2*i ;
				if(s==X&&t==Y) {
					goukei = (goukei+COM(z,i))%MOD;
				}
			}
			
			
			System.out.println(goukei);
			
		}
			
			
			
		
	}
	
	
		//拡張ユークリッドでの逆元の求め方でnCkをつくる、前処理必須。
	
	static  int MAX = 1000003;
	static  int MOD = 1000000007;

	 static long[] fac = new long[MAX]; 
	 static long[] finv = new long[MAX]; 
	 static long[] inv = new long[MAX]; 

	// テーブルを作る前処理
	static void COMinit() {
	    fac[0] = fac[1] = 1;
	    finv[0] = finv[1] = 1;
	    inv[1] = 1;
	    for (int i = 2; i < MAX; i++){
	        fac[i] = fac[i - 1] * i % MOD;
	        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
	        finv[i] = finv[i - 1] * inv[i] % MOD;
	    }
	}

	// 二項係数計算
	static long COM(int n, int k){
	    if (n < k) return 0;
	    if (n < 0 || k < 0) return 0;
	    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
		
		
	}
		




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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] w = sc.next().toCharArray();

		int flag = 0;
		Arrays.sort(w);

		for (int i = 0; i < w.length  ;i+=2) {

			if (i + 2 > w.length) {
				flag = 1;
				break;
			}

			if (w[i] != w[i+1]) {
				flag = 1;
				break;
			}
		}

		if (flag == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 9552
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <math.h>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = unsigned long long;
using pll = pair<ll,ll>;
using ii = pair<int,int>;
using iii = pair<pair<int,int>,int>;
using viii = vector<iii>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;
 




int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;

    if(a+b+c >=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;



    return 0;
}   

Measured memory_bytes: 256
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def pprint(M):
	for row in M:
		print(row)
	print("~~~")

def main():
	MOD = 10**9 + 7
	n, k = rli()
	A = list(rli())
	P = [A[0]]
	for i in range(1, len(A)):
		P.append(P[-1] + A[i])
	dp = [[0 for __ in range(k+1)] for _ in range(n)]
	psums = [[0 for __ in range(k+1)] for _ in range(n)]
	for c in range(min(k+1, A[0] + 1)):
		dp[0][c] = 1
	psums[0][0] = dp[0][0]
	for c in range(1, k+1):
		psums[0][c] = dp[0][c] + psums[0][c-1]
		psums[0][c] %= MOD
	for r in range(1, n):
		for c in range(min(k + 1, P[r] + 1)):
			cutoff = c - A[r] - 1
			dp[r][c] = psums[r-1][c] - (psums[r-1][cutoff] if cutoff >= 0 else 0)
			dp[r][c] %= MOD
		psums[r][0] = dp[r][0]
		for c in range(1, k + 1):
			psums[r][c] = dp[r][c] + psums[r][c-1]
			psums[r][c] %= MOD
	print(dp[n-1][k] % MOD)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 287448
//121B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n=0, m=0, c=0, cnt =0, tmp=0;
    cin >> n >> m >> c;
    vector<int>B(m,0);
    vector<int>A(m,0);
    rep(i, m) cin >> B[i];
    rep(j, n){
        rep(i, m) cin >> A[i];
        rep(i, m) tmp += A[i]*B[i];
        if(tmp + c>0) cnt+=1;
        //cout << tmp +c << endl;
        tmp=0;
        
    }
    cout << cnt;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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

int main(){
    ll a, b, c;
    cin>>a>>b>>c;
    bool flag = true;
    ll ans=0;
    while(flag){
        if(b>0 and c>0){
            ans+=2;
            b--;
            c--;
        }else if(a>0 and c>0){
            ans+=1;
            a--;
            c--;
        }else{
            flag=false;
        }
    }
    if(c>0){
        ans++;
    }
    ans += b;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    a = LIST()
    ans = [0]*n
    for i in range(n-1):
        ans[a[i] - 1] += 1

    for i in range(n):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 34572
import math


N, D = map(int, input().split())
X = []
for i in range(N):
    xs = list(map(int, input().split()))
    X.append(xs)


def dist(xs, ys):
    ret = 0
    for x, y in zip(xs, ys):
        ret += (x - y) ** 2
    return math.sqrt(ret)


ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        d = dist(X[i], X[j])
        if math.floor(d) == d:
            ans += 1
print(ans)


Measured memory_bytes: 3064
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt(),
            w=sc.nextInt();
        int[][] a=new int[n][2];
        for(int i=0;i<n;i++) {
            a[i][0]=sc.nextInt();
            a[i][1]=sc.nextInt();
        }
        long[][] dp=new long[n+1][w+1];
        for(int i=0;i<=n;i++) {
            for(int j=0;j<=w;j++) {
                if((i==0) || (j==0))
                    dp[i][j]=0;
                else {
                    dp[i][j]=dp[i-1][j];
                    if(a[i-1][0]<=j)
                        dp[i][j]=Math.max(dp[i][j],dp[i-1][j-a[i-1][0]]+a[i-1][1]);
                }
            }
        }
        pw.println(dp[n][w]);
        pw.close();
    }
}

Measured memory_bytes: 127060
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 25
using namespace std;
int n,m,c;
int B[M], in[M];
int main()
{
    while (~scanf("%d %d %d",&n,&m,&c)) {
        REP(i,1,m) scanf("%d", &B[i]);

        int ans = 0;
        REP(t,1,n) {
            REP(i,1,m) scanf("%d", &in[i]);
            int sum = 0;
            REP(i,1,m) sum += in[i] * B[i];
            if (sum+c > 0) ans++;
        }
        printf("%d\n", ans);
    }
    
    return 0;
}



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

int a[10003];
int b[103];

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int cnt = 1;
	int color = 1;
	while (cnt <= h) {
		if (cnt % 2 == 1) {
			for (int i = 1; i <= w; i++) {
				if (a[color] == 0) { color++; }
				b[i] = color;
				a[color]--;
			}
		}
		else {
			for (int i = w; i >= 1; i--) {
				if (a[color] == 0) { color++; }
				b[i] = color;
				a[color]--;
			}
		}
		cout << b[1];
		for (int i = 2; i <= w; i++) {
			cout << ' ' << b[i];
		}
		cout << endl;
		cnt++;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){

	int n,r;
	int p,c;
	vector<int> dek;
	vector<int>::iterator ite;
	queue<int> tmp;

	while(1){

		cin>>n>>r;
		if(n==0&&r==0) break;

		if(!dek.empty()) dek.clear();
		for(int i=1;i<=n;i++) dek.push_back(i);

		for(int i=0;i<r;i++){
			cin>>p>>c;
			ite=dek.begin();
			advance(ite,n-p-c+1);
			for(int i=0;i<c;i++){
				tmp.push(*ite);
				ite=dek.erase(ite);
			}
			while(!tmp.empty()){
				dek.push_back(tmp.front());
				tmp.pop();
			}
		}
		cout<<dek[n-1]<<endl;
	}

}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline
 
MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1
 
    dp = [0] * 13
    if S[0] == '?':
        for i in range(10):
            dp[i] = 1
    else:
        dp[int(S[0])] = 1
 
    for i in range(1,N):
        dppre = dp
        dp = [0] * 13
 
        if S[i] == '?':
            R = range(10)
        else:
            R = [int(S[i])]
        
        for j in range(13):
            for k in R:
                dp[(j * 10 + k) % 13 ] += dppre[j]
        for j in range(13):
            dp[j] %= MOD
 
    print(dp[5])
if __name__ == '__main__':
    main()

Measured memory_bytes: 43244
#include <stdio.h>

typedef struct {
	long long key;
	int id[2];
} data;
 
typedef struct {
	data obj[300000];
	int size;
} min_heap;
 
void push(data x, min_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key < h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}
 
data pop(min_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key < h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, M, S, u, w, c, t, cost[51][51] = {}, time[51][51] = {}, C[51], D[51];
	scanf("%d %d %d", &N, &M, &S);
	for (i = 1; i <= M; i++) {
		scanf("%d %d %d %d", &u, &w, &c, &t);
		cost[u][w] = c;
		cost[w][u] = c;
		time[u][w] = t;
		time[w][u] = t;
	}
	for (i = 1; i <= N; i++) scanf("%d %d", &(C[i]), &(D[i]));
	
	int j, flag[51][2501];
	long long min[51][2501];
	data d;
	min_heap h;
	for (i = 1; i <= N; i++) {
		for (j = 0; j <= 2500; j++) min[i][j] = (long long)1 << 60;
	}
	if (S > 2500) S = 2500;
	min[1][S] = 0;
	h.size = 0;
	d.key = 0;
	d.id[0] = 1;
	d.id[1] = S;
	push(d, &h);
	while (h.size > 0) {
		d = pop(&h);
		u = d.id[0];
		c = d.id[1];
		if (flag[u][c] == 1) continue;
		flag[u][c] = 1;
		for (w = 1; w <= N; w++) {
			if (cost[u][w] > 0 && cost[u][w] <= c &&  min[u][c] + time[u][w] < min[w][c-cost[u][w]]) {
				min[w][c-cost[u][w]] = min[u][c] + time[u][w];
				d.key = min[w][c-cost[u][w]];
				d.id[0] = w;
				d.id[1] = c - cost[u][w];
				push(d, &h);
			}
		}
		if (c + C[u] < 2500 && min[u][c] + D[u] < min[u][c+C[u]]) {
			min[u][c+C[u]] = min[u][c] + D[u];
			d.key = min[u][c+C[u]];
			d.id[0] = u;
			d.id[1] = c + C[u];
			push(d, &h);
		} else if (c + C[u] >= 2500 && min[u][c] + D[u] < min[u][2500]) {
			min[u][2500] = min[u][c] + D[u];
			d.key = min[u][2500];
			d.id[0] = u;
			d.id[1] = 2500;
			push(d, &h);
		}
	}
	
	long long ans;
	for (u = 2; u <= N; u++) {
		ans = (long long)1 << 60;
		for (c = 0; c <= 2500; c++) if (min[u][c] < ans) ans = min[u][c];
		printf("%lld\n", ans);
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4332
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll nk = double((N + 1) / 2);
    cout << double(nk) / double(N);
    
    //
    return 0;
}

Measured memory_bytes: 3208
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)

#define emb emplace_back
#define pub push_back
#define pob pop_back
#define me min_element
#define Me max_element
#define mp make_pair
#define fi first
#define se second
#define siz(xs) ((int)(xs).size())
#define all(xs) xs.begin(),xs.end()
#define lla(xs) xs.rbegin(),xs.rend()
#define sortup(xs) sort(all(xs))
#define sortdown(xs) sort(lla(xs))
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__)
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
void _cout(){}template<class Head,class...Tail>void _cout(Head&&head,Tail&&...tail){cout<<head<<endl;_cout(forward<Tail>(tail)...);}
template<class Type>void _cinvec(Type t,int n){}template<class Type,class Head,class...Tail>void _cinvec(Type t,int n,Head&&head,Tail&&...tail){rep(n){cin>>t;head.eb(t);}_cinvec(t,n,forward<Tail>(tail)...);}

#define VI vector<int>
#define VD vector<double>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVS vector<VS>

// #define int int64_t
// #define double long double

// map
// 横並びcout




signed main(){
  // in(int,a,b,c);
  // string ans;
  // if(c!=max({a,b,c})&&c!=max({a,b,c})) ans="Yes";
  // else ans="No";
  // out(ans);

  in(int,N);
  in(string,S);
  in(int,K);
  char c=S[K-1];
  fou(i,0,N){if(S[i]!=c)cout<<'*';else cout<<S[i];}
  cout<<endl;
}

Measured memory_bytes: 764
a,b,k = map(int,input().split())

for i in range(k):
    if i%2==0:
        if a%2==1:
            a=max(a-1,0)
        b+=(a//2)
        a//=2
    else:
        if b%2==1:
            b=max(b-1,0)
        a+=(b//2)
        b//=2
print(a,b)


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

using namespace std;

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1]) cout << "Bad";
  else if(s[1] == s[2]) cout << "Bad";
  else if(s[2] == s[3]) cout << "Bad";
  else cout << "Good";
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int Pt = 1e9 + 7;
using namespace std;
int n;
int main()
{
	long long ans = 1;
	scanf("%d" , &n);
	for(int i = 1;i <= n;i++)
		ans = (ans * i) % Pt;
	printf("%lld\n" , ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i < N; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

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

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;
typedef pair<long long, long long> pll;
// scanf("%d %d %d %d", &w, &b, &d, &s); %lld
// printf("%d\n", points);
// const double PI = acos(-1);

int main() 
{
	fastIO;
	int n;
	cin >> n;
	int ans = n + (n*n) + (n*n*n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608