akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define R(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 res = -1;
bool out = 0;
int64 n;
vector<int64> rv, now;
void dfs(const string& s, int64 d, int64 sum) {
    if (d == s.size()) {
        if (sum <= n) {
            if (res == -1) {
                rv = now; res = sum;
            } else if (res == sum) {
                out = 1;
            } else if (res < sum) {
                rv = now;
                res = sum;
                out = 0;
            }
        }
    }
    int64 nxt = 0;
    FOR(i, d, s.size()) {
        nxt = nxt * 10 + s[i]-'0';
        now.push_back(nxt);
        dfs(s, i+1, sum+nxt);
        now.pop_back();
    }
}

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

    string s;
    while (cin >> n && cin >> s && n != 0 && s != "0") {
        rv = vector<int64>();
        now = vector<int64>();
        res = -1;
        out = 0;
        dfs(s, 0, 0);
        if (out) {
            cout << "rejected" << endl;
        } else if (res == -1) {
            cout << "error" << endl;
        } else {
            cout << res << " ";
            REP(i, rv.size()) {
                cout << rv[i] << (i == rv.size()-1 ? "" : " ");
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 100005;
vector<int>g[maxn];
int in[maxn];
int dp[maxn];
void go() {
   	int n, m;
   	cin >> n >> m;
   	f(m) {
   		int x, y;
   		cin >> x >> y;
   		g[x].pb(y);
   		in[y]++;
   	}
   	queue<int>q;
   	f1(n) {
   		if (!in[i]) {
   			q.push(i);
   		}
   	}
   	int mx = 0;
   	while (q.size()) {
   		auto now = q.front();
   		q.pop();
   		mx = max(mx, dp[now]);
   		for (auto &i : g[now]) {
   			dp[i] = max(dp[i], dp[now] + 1);
   			in[i]--;
   			if (!in[i]) {
   				q.push(i);
   			}
   		}
   	}
   	cout << mx << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 9832
function Main(input){
var P = input.split(" ")[0];
var Q = input.split(" ")[1];
var R = input.split(" ")[2];
var A = new Number(P)+new Number(Q);
var B = new Number(Q)+new Number(R);
var C = new Number(R)+new Number(P);
if(A>=B&&C>=B){
  console.log(B);
}else if(B>=A&&C>=A){
  console.log(A);
}else if(B>=C&&A>=C){
  console.log(C);
}
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
#include<stdio.h>

int main(){
  int i,j,n,minj,a,c=0;
  int A[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj = j;
      }
    }
	a = A[i];
	A[i] = A[minj];
	A[minj] = a;
	if(i!=minj)c++;
   
  }

 for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }

  printf("\n%d\n",c);
  
  return 0;
}
  



Measured memory_bytes: 2140
import math
a,b,x = input().split()
a,b,x = int(a),int(b),int(x)


if(x<=(a*a*b)/2):
    S = x/a
    h = (2*S/b)
    print(90.-math.atan(h/b)/(2.*math.pi)*360)
else:
    #a,x = math.sqrt(a),math.sqrt(x)
    x /= a
    d = 2*x/a-b
    if(b==d):
        print(0)
    else:
        print(90.-math.atan(a/(b-d))*360/(2*math.pi))

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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)*}
    };
}

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<_>>()
    };

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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


#[allow(dead_code)]
fn solve(a: i64, b: i64, c: i64, d: i64) -> i64 {
    let sa = a * b;
    let sc = c * d;
    if sa > sc {
        sa
    } else {
        sc
    }
}

fn main() {
    input!{
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }
    println!("{}", solve(a, b, c, d));
}


Measured memory_bytes: 4352
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

int main(){
	string S; cin>>S;
	string ans = "Yes";
	rp(i,S.size()){
		char s = S[i];
		if(s=='U' || s=='D') continue;
		if(i%2){
			if(s=='R'){
				ans = "No";
				break;
			}
		}
		else{
			if(s=='L'){
				ans = "No";
				break;
			}
		}
	}
	ote(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define frr(i,s,n) for(int i=s;i<=n;i++)
#define fr(i,s,n) for(int i=s;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;
void loop()
{
	int n;
	cin>>n;
	int cnt = 0;
	for(int i=1;i<=n-1;i++)
	{
		for(int j=1;j<=n-1;j++)
		{
			if((n-(i*j)) >= 1)
			{
				if((n-(i*j)) <= n)
					cnt++;
				else
					break;
			}
			else
				break;
		}
	}
	cout<<cnt<<"\n";
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	fast;
    int t=1;
    //cin>>t;
    while(t--)
    	loop();
}


Measured memory_bytes: 3648
<?php

$line = explode(' ', trim(fgets(STDIN)));

$plus1 = $line[0];
$plus0 = $line[1];
$minus1 = $line[2];
$pick = $line[3];
$result = 0;

if($pick > 0 && $pick-$plus1 >= 0)
{
  $result += $plus1;
  $pick -= $plus1;
}else{
  $result += $pick;
  $pick = 0;
}

if($pick > 0 && $pick-$plus0 >= 0)
{
  $pick -= $plus0;
}else{
  $pick = 0;
}

if($pick > 0 && $pick-$minus1 >= 0)
{
  $result -= $minus1;
  $pick -= $minus1;
}else{
  $result -= $pick;
  $pick = 0;
}

echo $result . PHP_EOL;



Measured memory_bytes: 16144
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>

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

ll dp[20005];
int main(){
    ll H, N;
    cin >> H >> N;
    for(int i = 1; i < 20005; i++) dp[i] = 1e18;
    for(int i = 0; i < N; i++){
        ll a, b;
        cin >> a >> b;
        for(int j = 0; j <= H; j++){
            dp[j+a] = min(dp[j+a], dp[j]+b);
        }
    }
    ll ans = 1e18;
    for(int i = H; i < 20005; i++)
        ans = min(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

string S, T;

int main() {
    cin >> S >> T;
    bool ans = T.length() == S.length() + 1;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] != T[i]) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		string s;
		cin >> s;
		ll ans=0;
		for (auto c : s) {
			ans = (ans+c-'0'+9)%9;
		}
		if (ans==0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


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

int N;
#define MAX_N 1000000
long long I[MAX_N + 1], F[MAX_N + 1], IF[MAX_N + 1];
#define MOD 1000000007LL
long long C[MAX_N + 1];
long long R;

int main() {
  cin >> N;
  I[1] = F[0] = F[1] = IF[0] = IF[1] = 1;
  for(int i = 2; i < N; ++i) {
    I[i] = MOD - (MOD / i) * I[MOD % i] % MOD;
    F[i] = i * F[i - 1] % MOD;
    IF[i] = I[i] * IF[i - 1] % MOD;
  }
  long long prev = 0;
  for(int k = (N + 1) / 2; k <= N - 1; ++k) {
    long long cur =
      F[k - 1] * IF[N - 1 - k] % MOD * IF[k - 1 - (N - 1 - k)] % MOD
      * F[k] % MOD * F[N - 1 - k] % MOD;
    (R += k * (cur + MOD - prev % MOD)) %= MOD;
    prev = cur;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll h, w, dp[200][200];
string s[200];

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> h >> w;
	zep(i, 0, h){
		cin >> s[i];
	}
	
	zep(i, 0, h){
		zep(j, 0, w){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = (s[0][0] == '.')? 0 : 1;
	
	zep(i, 0, h){
		zep(j, 0, w){
			if(i > 0){
				if(s[i-1][j] == '.'){
					if(s[i][j] == '.'){
						dp[i][j] = min(dp[i][j], dp[i-1][j]);
					}
					else{
						dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
					}
				}
				else{
					dp[i][j] = min(dp[i][j], dp[i-1][j]);
				}
			}
			
			if(j > 0){
				if(s[i][j-1] == '.'){
					if(s[i][j] == '.'){
						dp[i][j] = min(dp[i][j], dp[i][j-1]);
					}
					else{
						dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
					}
				}
				else{
					dp[i][j] = min(dp[i][j], dp[i][j-1]);
				}
			}
		}
	}
	print(dp[h-1][w-1])
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

const ll mod = 1e9 + 7;
ll invmod(ll v) {
  ll e = mod - 2;
  ll sum = 1;
  ll cur = v;
  while (e > 0) {
    if (e % 2) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}

int main(void){
  ll h, w, a, b;
  cin >> h >> w >> a >> b;
  // sum_(i = 0)^(h - a - 1) C(i + b - 1, b - 1) * C(h + w - 2 - b - i, w - 1 - b)
  vector<ll> tbl1(h + w), tbl2(h + w);
  REP(i, 0, b - 1) {
    tbl1[i] = 0;
  }
  ll cur = 1;
  REP(i, b - 1, h + w) {
    tbl1[i] = cur;
    cur = cur * (i + 1) % mod;
    cur = cur * invmod(i - b + 2) % mod;
  }

  REP(i, 0, w - b - 1) {
    tbl2[i] = 0;
  }
  cur = 1;
  REP(i, w - b - 1, h + w) {
    tbl2[i] = cur;
    cur = cur * (i + 1) % mod;
    cur = cur * invmod(i - w + b + 2) % mod;
  }
  ll sum = 0;
  REP(i, 0, h - a) {
    sum += tbl1[i + b - 1] * tbl2[h + w - 2 - b - i];
    sum %= mod;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3328
package main

import "fmt"

func main() {
	var K, A, B int
	fmt.Scan(&K, &A, &B)
	for i := A; i <= B; i++ {
		if i%K == 0 {
			fmt.Println("OK")
			return
		}
	}
	fmt.Println("NG")
}


Measured memory_bytes: 1772
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

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

const int MAX = 1010101;

long long fac[MAX], finv[MAX], inv[MAX];

void binom_init() {
  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;
  }
}

long long binom(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;
}

ll n;
ll a[101010];
set<ll> cnt;
ll dupnum;
ll dupl, dupr;

int main() {
  binom_init();
  cin >> n;
  rep(i, 0, n + 1) {
    cin >> a[i];
    if (cnt.count(a[i]) == 1) {
      dupnum = a[i];
    }
    cnt.insert(a[i]);
  }

  bool flag = false;
  rep(i, 0, n + 1) {
    if (a[i] == dupnum) {
      if (!flag) {
        dupl = i;
        flag = true;
      } else {
        dupr = i;
      }
    }
  }

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

  repe(i, 1, n + 1) {
    if (i == 1) {
      cout << n << "\n";
      continue;
    }

    ll ans = 0;

    ans += binom(n - 1, i);

    ans += binom(n - 1, i - 2);
    ans %= MOD;

    ans += binom(n - 1, i - 1) * 2LL;
    ans %= MOD;

    ans -= binom(dupl + (n - dupr), i - 1);
    ans += MOD;
    ans %= MOD;

    cout << ans << "\n";
  }

  // cout << dupl << " " << dupr << endl;
}


Measured memory_bytes: 32676
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int md=1000000007,mxn=131072;
int n,m,cur,a[16],f[2][mxn],fct[mxn],ifc[mxn];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=0;i<m;++i) scanf("%d",&a[i]);
	int N=1<<n;
	fct[0]=ifc[0]=1;
	for (int i=1;i<=N;++i) fct[i]=1ll*fct[i-1]*i%md;
	ifc[N]=1;
	for (int x=fct[N],p=md-2;p;p>>=1,x=1ll*x*x%md)
		if (p&1) ifc[N]=1ll*ifc[N]*x%md;
	for (int i=N-1;i;--i) ifc[i]=ifc[i+1]*(i+1ll)%md;
	f[cur][0]=1;
	for (int i=m-1;i>=0;--i){
		cur^=1;
		for (int j=0;j<N;++j)
			f[cur][j]=f[cur^1][j];
		for (int j=0;j<N;++j)
			for (int k=0;k<n;++k)
				if (!(j>>k&1)&&N-a[i]+1>=(j|1<<k))
					f[cur][j|1<<k]=(f[cur][j|1<<k]+1ll*f[cur^1][j]*fct[N-a[i]-j]%md*(1<<k)%md*ifc[N-a[i]-j-(1<<k)+1])%md;
	}
	int ans=0;
	for (int i=0;i<N;++i){
		int flg=1;
		for (int j=0;j<n;++j)
			if (i>>j&1) flg=-flg;
		ans=(ans+1ll*flg*f[cur][i]*fct[N-i-1])%md;
	}
	printf("%lld\n",(1ll*ans*N%md+md)%md);
	return 0;
}

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

int main(void) {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  } else {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] players =  new String[3];
        for(int i=0; i<3; i++){
            players[i] = scan.nextLine();
        }

        int i=0, j=0, k=0;
        char c = 'a';
        while(true){

            if(c == 'a') {
                if(i == players[0].length()){
                    System.out.println("A");
                    break;
                }
                c = players[c - 'a'].charAt(i++);
            }
            if(c == 'b') {
                if(j == players[1].length()){
                    System.out.println("B");
                    break;
                }
                c = players[c - 'a'].charAt(j++);
            }
            if(c == 'c') {
                if(k == players[2].length()){
                    System.out.println("C");
                    break;
                }
                c = players[c - 'a'].charAt(k++);
            }

        }
    }
}

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

int main(){
  int height[10];
  for(int i=0;i<10; i++){
    cin >> height[i];
  }
  for(int j=0;j<3;j++){
  int max=height[0];
  int number = 0;
    for(int i=0;i<10; i++){
      if(max < height[i]){
        max = height[i];
        number = i;
      }
    }
    cout << max << endl;
    height[number] = 0;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
int n;
int a[N];
int dp[N];
int main()
{
	//cwk;
	memset(dp,inf,sizeof(dp));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	dp[1]=0;
	for(int i=2;i<=n;i++) {
		if(i-1>=1)dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
		if(i-2>=1)dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N;
    int ans = 0;

    cout << 3*N*N << endl;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for (int i=1; i<=n; i++) {
    int tmp = i;
    int total = 0;
    int n = 10000;
    while(1) {
      total += (tmp / n);
      tmp = tmp % n;
      n /= 10;
      if (n == 0) break;
    }
    if (total >= a && total <= b) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j,k) for(ll i=(ll)j;i<(ll)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

vector<string> split(string s, char c){
    vector<string> v;
    int pos=0;
    rep(i,0,s.size()){
        if(s[i]==c){
            v.push_back(s.substr(pos,i-pos));
            pos=i+1;
        }
        if(i==s.size()-1 && s.substr(pos,i-pos)!="")v.push_back(s.substr(pos,i-pos));
    }
    return v;
}

int main(){
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<(1<<s.size()-1);i++){
        string temp="";
        for(int j=0;j<s.size();j++){
            if(j && (i>>(j-1)&1) )temp+="+";
            temp+=s[j];
        }
        temp+="+";
        
        vector<string> sp=split(temp,'+');
        rep(j,0,sp.size()){
            ans+=stol(sp[j]);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX_N 100000
#define MAX_M 100000
 
typedef struct EDGE {
    int to;
    struct EDGE *next;
} edge;
 
int buff_size;
edge buff[MAX_M + MAX_M];
edge *adj[MAX_N];
 
void init(int n, int m) {
    int i;
    for(i = 0; i < n; ++i) {
        adj[i] = NULL;
    }
    for(i = 0; i < m; ++i) {
        buff[i].next = NULL;
    }
    buff_size = 0;
}
 
edge *new_edge() {
    return buff + buff_size++;
}
 
void add_edge(int u, int v) {
    edge *e = new_edge();
    e->to = v;
    e->next = adj[u];
    adj[u] = e;
}
 
int head, tail;
int queue[MAX_N];
 
void enqueue(int data) {
    queue[tail++] = data;
}
 
int dequeue() {
    return queue[head++];
}
 
int empty() {
    return head == tail;
}
 
void clear() {
    head = tail = 0;
}
 
int next_label;
int label[MAX_N];
 
void bfs(int v) {
    edge *e;
 
    clear();
    enqueue(v);
 
    label[v] = next_label;
    while(!empty()) {
        const int v = dequeue();
        for(e = adj[v]; e != NULL; e = e->next) {
            if(label[e->to] == -1) {
                label[e->to] = next_label;
                enqueue(e->to);
            }
        }
    }
    ++next_label;
}
 
int main() {
    int n, m, q;
    int u, v;
    int s, t;
    int i;
 
    scanf("%d %d", &n, &m);
    init(n, m);
 
    for(i = 0; i < m; ++i) {
        scanf("%d %d", &u, &v);
        add_edge(u, v);
        add_edge(v, u);
    }
 
    memset(label, -1, sizeof(label));
    for(i = 0; i < n; ++i) {
        if(label[i] == -1) bfs(i);
    }
 
    scanf("%d", &q);
    while(q--) {
        scanf("%d %d", &s, &t);
        puts(label[s] == label[t] ? "yes" : "no");
    }
 
    return EXIT_SUCCESS;
}


Measured memory_bytes: 6356
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
     int h,n,x,s=0;
     cin>>h>>n;
     for(int i=1;i<=n;i++){
           cin>>x;
           s+=x;
     }
     if(s>=h)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
char lovgqt;
int main()
{
    cin>>a>>lovgqt>>b;
    if(lovgqt=='+')
	    cout<<a+b<<endl;
    else
    	cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b;
	char op;
	while(cin>>a>>op>>b){
		if(op=='?') break;
		if(op=='+') cout<<a+b<<endl;
		if(op=='-') cout<<a-b<<endl;
		if(op=='*') cout<<a*b<<endl;
		if(op=='/') cout<<a/b<<endl;
	}	
	return 0;
}

Measured memory_bytes: 1160
from functools import lru_cache

@lru_cache()
def f(n):
    if n==0:
        return 1
    return 2*f(n-1)+1

@lru_cache()
def g(n):
    if n==0:
        return 1
    return 2*g(n-1)+3

N, X = map(int, input().split())
total = [g(i) for i in range(N+1)]
p = [f(i) for i in range(N+1)]

ans = 0

def search(x, n):
    global ans
    if n==0 and x:
        ans += 1
        return
    if x > total[n-1] + 2:
        ans += p[n-1] + 1
        if n and x:
            search(x-(2 + total[n-1]), n-1)
    elif x == total[n-1] + 2:
        ans += p[n-1] + 1
    else:
        if n and x:
            search(x-1, n-1)

search(X, N)
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll ncr(ll x, ll y) {
	ll ans = 1;
	for (ll i = 1; i <= y; ++i) {
		ans *= (x - y + i);
		ans /= i;
	}

	return ans;
}
int main()
{
    fio;
    int x;
    cin>>x;
    for(int i=x;;i++)
    {
        if(isprime(i)){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    vector<int> a(3);
    REP(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[0]+a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int INF = 1001001001;
const ll LINF = 1e18;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

int main() {
    int N, K; cin >> N >> K;
    ll a, idx = 0, one_ind = 0; vl as(N, 0);
    while (cin >> a) {
        as[idx] = a;
        if(a == 1) one_ind = idx;
        idx++;
    }
   
    ll res = LINF;
    for(ll i = 1; i <= K; i++){
        ll count = 0;
        count++;
        ll l_id = one_ind - (K - i);
        while(l_id > 0){
            l_id -= K - 1;
            count++;
        }
        ll r_id = one_ind + (i - 1);
        while (r_id < N - 1) {
            r_id += K - 1;
            count++;
        }
        res = min(res, count);
    }
    
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
const int MAX = 1000;
const int INF = 1e9;

int main(){
    int a, b, c, ans;
    int n, m, d[MAX][MAX];
    vector<int> A,B,C;
    cin >> n;
    cin >> m;
    fill((int*)d, (int*)(d + n), 0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++) if (i != j) d[i][j] = INF;
    }
    for (int i = 0; i < m; i++){
        cin >> a;
        cin >> b;
        cin >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }
    for (int k = 0; k < n; k++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
    int res = 0;
    bool shortest;
    for (int i = 0; i < m; i++){
        shortest = false;
        for (int j = 0; j < n; j++){
            if (d[j][A[i]] + C[i] == d[j][B[i]]) shortest = true;
        }
        if (shortest) res += 1;
    }
    cout << m - res << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int x=0,ans=0;
	int siz;
	cin>>siz;
	string s;
	cin>>s;
	for (int i=0;i<siz;i++){
		if (s[i]=='I'){
			x++;
			ans=max(ans,x);
		}
		else if (s[i]=='D')  x--;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(p[i]==i+1){
      swap(p[i],p[i+1]);
      cnt++;
    }
  }
  if(p[n-1]==n){
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  Sort(a);
  rep(i,n-1) {
    if (a[i] == a[i+1]) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int maxn = 100000 + 5;

int n, m;
PII a[maxn];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].first, &a[i].second);
    sort(a + 1, a + 1 + n, [](PII a, PII b) {
        if (a.first != b.first) return a.first < b.first;
        return a.second > b.second;
    });
    ll ans = 0;
    for (int i = 1; i <= n && m > 0; i++) {
        if (m >= a[i].second) {
            ans += 1ll * a[i].first * a[i].second;
            m -= a[i].second;
        } else {
            ans += 1ll * a[i].first * m;
            m = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d;

	e = c - a;
	f = d - b;

	cout << c - f << " " << d + e << " " << c - f - e << " " << d + e - f << endl;

	return 0;
}


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

using namespace std;

int main()
{
    long long a,b;
    long long v,w;
    long long t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if(v>w){
        if((double)abs(a-b)/(v-w)<=t){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}


int main() {
    ll X;
    cin >> X;
    ll num = 100,ans = 0;

    while(num < X){
        long double tmp = num;
        ans++;
        tmp *= 1.01;
        num = (ll)tmp;
    }


    //string ans = ( flag ? "OK":"NG");
    cout << ans;
    //printf("%.8lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;

namespace ABC067
{
    class C
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long[] S = new long[N + 1];
            for (long i = 0; i < N; i++)
            {
                S[i + 1] = S[i] + a[i];
            }

            long res = long.MaxValue;
            for (long i = 1; i < N; i++)
            {
                long x = S[N] - S[i];
                long y = S[i];
                res = Math.Min(res, Math.Abs(x - y));
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 37624
#include <stdio.h>

int a, b, k;
int arr[500];

int main(){
    scanf("%d %d %d", &a, &b, &k);
    int idx =0;
    for(int i=a; i<a+k; i++){
        if(i > b)
            break;
        arr[idx] = i;
        idx++;
    }
    int dif = b-a+1, li = idx-1;
    if(idx < dif){
        for(int i=b-k+1; i<=b; i++){
            if(i > arr[li]){
                arr[idx] = i;
                idx++;
            }
        }
    }
    for(int i=0; i<idx; i++)
        printf("%d\n", arr[i]);
}


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

int main() {
  
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++){
    cin >> X.at(i);
  }
  sort(X.begin(), X.end());

 
  
  vector<int> sabun(M-1);
  for (int i = 1; i < M; i++){
    sabun.at(i-1) = X.at(i) - X.at(i-1);
  }
  sort(sabun.begin(), sabun.end());
  
  
  int sa = M-N;
  int ans;

  for (int i = 0; i < sa; i++){
    ans += sabun.at(i);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
  int i[5],j;
  for(j = 0; j < 5; j++) scanf("%d",&i[j]);

  int mi=0,sum=0,f=0,n=0;

  for(j = 0; j < 5; j++)
  {
    if(i[j]%10==0)
    {
      sum += i[j];
    }else
    {
      if(f==0) 
      {
        mi = i[j]%10;
        n = i[j];
        f++;
      }
      if(i[j]%10<mi)
      {
        mi = i[j]%10;
        n = i[j];
       // printf("%d",n);
      }
      sum += 10*(i[j]/10+1);
    }
  }
 // printf("%d",sum);
   if(f!=0)sum -= 10*(n/10+1)-n;
 printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

int mincost[51];
int cost[51][51];
bool used[51];
int g[51];

int main(){
	int s,d;
	while(cin>>s>>d){
		if(s==0&&d==0) break;
		for(int i=0; i<=d; ++i){
			mincost[i]=INF;
			used[i]=false;
			g[i]=INF;
			for(int j=0; j<=d; ++j){
				if(i!=j)cost[i][j]=INF;
				else cost[i][j]=0;
			}
		}
		for(int i=0; i<s; ++i){
			for(int j=0; j<d; ++j){
				int tmp;
				cin >> tmp;
				if(tmp!=0){
					g[j]=min(g[j],tmp);
				}
			}
		}
		for(int i=0; i<d; ++i){
			cost[i][d]=cost[d][i]=g[i];
		}
		for(int i=0; i<d; ++i){
			for(int j=i+1; j<d; ++j){
				int tmp;
				cin >> tmp;
				if(tmp!=0) cost[i][j]=cost[j][i]=tmp;
			}
		}
		mincost[0]=0;
		int res=0;
		while(true){
			int v=-1;
			for(int u=0; u<d+1; ++u){
				if(!used[u]&&(v==-1||mincost[v]>mincost[u])) v=u;
			}
			if(v==-1) break;
			used[v]=true;
			res+=mincost[v];
			for(int u=0; u<d+1; ++u){
				mincost[u]=min(mincost[u],cost[v][u]);
			}
		}
		cout << res << "\n";
	}
	return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>

int gcd(int a,int b,int c){
  int tmp,g1,g2,d;
  if(a>b){
    tmp=b;
    b=a;
    a=tmp;
  }
  while(1){
    d=b%a;
    if(d==0){
      g1=a; break;
    }
    b=a;
    a=d;
  }

  if(g1>c){
    tmp=c;
    c=g1;
    g1=tmp;
  }
  while(1){
    d=c%g1;
    if(d==0){
      g2=g1; break;
    }
    c=g1;
    g1=d;
  }
  return g2;

}
int main(void){
  int a, b, c,K,tot=0;
  scanf("%d",&K);
  for(a=1;a<=K;a++){
    for(b=1;b<=K;b++){
      for(c=1;c<=K;c++){
    tot+=gcd(a,b,c);
      }
  }
}
  printf("%d\n",tot);
  return 0;
}

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

	void printf(string str,int a, int b){
		cout << str.substr( a,b-a+1) << "\n"; //????????????????????????????????????????????????????????????????????§???????????????????????????
	}

	string reverse(string str,int a, int b ){
		string t = str;
		for(int i=a; i<=b; i++){
			str[i] = t[b+a-i];
		}
		return str;
	}


	string replace(string str,int a, int b,string x){
		for(int i=a; i<=b; i++){
			str[i] = x[i-a];
		}
		return str;
	}




int main() {
	string str;
	int q;
	cin >> str >> q;

	for(int i=0; i<q; i++){
		int a,b;
		string command,x;
		cin >> command;

		if( command == "print" ){
			cin >> a >> b ;
			printf(str,a,b);
		}
		if( command == "reverse" ){
			cin >> a >> b;
			str = reverse(str,a,b);
		}
		if( command == "replace" ){
			cin >> a >> b >> x;
			str = replace(str,a,b,x);
		}
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

int main()
{
    int n;
    cin >> n;
    vi v(n);
    vi c(n);
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<n;i++) cin >> c[i];

    int res=0;
    int resval=0;
    int rescost=0;
    for(int i=0;i<n;i++)
    {
        if(res + (v[i]-c[i]) >res){
            resval+=v[i];
            rescost+=c[i];
            res=resval-rescost;
        }
    }
    cout << res <<endl;
}


Measured memory_bytes: 256
n = int(input())
lst = [0] + list(map(int, input().split())) + [0]
d_all = sum(abs(lst[i] - lst[i+1]) for i in range(n+1))


for i in range(1, n+1):
    ans = d_all - abs(lst[i-1] - lst[i]) - abs(lst[i] - lst[i+1]) + abs(lst[i-1] - lst[i+1])
    print(ans)

Measured memory_bytes: 14048
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int n,a,b,c,x,y,aa[100010],ba[100010];
bool r=false;
string s;
char ca,cb;


int main(){
    cin>>n;
    while(n!=0){
        if(n%10==9)r=true;
        n/=10;
    }
    cout<<(r ? "Yes":"No")<<endl;
    
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll pow_mod(ll a, ll n, ll MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 0x01) { 
            res *= a;
            res %= MOD;
        }
        a = a*a;
        a %= MOD;
        n >>= 1;
    }
    return res;
}

ll recipro_mod(ll num, ll MOD) {
    return pow_mod(num, MOD - 2, MOD);
}

void fact_mod(vl& fact, vl& rFact, int size, ll MOD) {
    fact = vl(size + MGN, 0);
    rFact = vl(size + MGN, 0);

    fact[0] = 1;
    FOR(i, 1, size+1) fact[i] = fact[i-1 ] * (i) % MOD;

    rFact[size] = recipro_mod(fact[size], MOD);
    for (int i = size; i > 0; i--) rFact[i - 1] = rFact[i] * i % MOD;
}

ll combi_mod(vl fact, vl rFact, ll n, ll k, ll MOD){
    return fact[n] % MOD * rFact[k] % MOD * rFact[n - k] % MOD;
}
#endif



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

    const ll MOD = (ll)1e9 + 7;
    ll N, M, K;  cin >> N >> M >> K;


    ll tx = 0;
    FOR(i, 1, M) {
        tx += i * (M - i) % MOD;
    }
    tx *= N % MOD;
    tx *= N % MOD;

    ll ty = 0;
    FOR(i, 1, N) {
        ty += i * (N - i) % MOD;
    }
    ty *= M % MOD; 
    ty *= M % MOD;
    
    vl fact, rFact;
    fact_mod(fact, rFact, N*M, MOD);    
    ll ans = combi_mod(fact, rFact, N*M-2, K-2, MOD) * (tx % MOD + ty % MOD);
    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6528
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    bool check=false;
    int count=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(a==b)count++;
        else count=0;
        if(count==3){
            check=true;
        }
    }
    if(check)yes;
    else no;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d%d",&A,&B);
    int a,b,c;
    a=A+B;
    b=A-B;
    c=A*B;
    if(a>=b&&a>=c)
        {
            printf("%d\n",a);
        }
    else if(b>=a&&b>=c)
    {
        printf("%d\n",b);
    }
    else
    {
        printf("%d\n",c);
    }
}


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

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Integer a[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			Arrays.sort(a);
			System.out.println(a[n - 1] - a[0]);
		}

	}

}

Measured memory_bytes: 21844
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=100005;
char s[MAXN];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++)
	{
		if(s[i]==s[i+1])
		{
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(s[i]==s[i+2])
		{
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,n,a,b;
	cin>>n>>a>>b;

	k=(b-a);
	k--;
	if(k%2==1){
		cout<<"Alice";
	}
	else cout<<"Borys";
	return 0;
}
//ctrl H replace

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD_NUM 1000000007
using namespace std;

int main(){

	int N,div;
	scanf("%d %d",&N,&div);

	int* table = new int[N];
	int* indexTable = new int[200001];
	int index = N-1,tmp;
	priority_queue<int> Q;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		Q.push(tmp);
	}

	while(!Q.empty()){
		table[index--] = Q.top();
		Q.pop();
	}

	for(int i = 0; i <= 200000; i++)indexTable[i] = -1;

	for(int i = 0; i < N; i++){
		indexTable[table[i]] = i;
	}

	indexTable[0] = 0;
	for(int i = 1; i <= 200000; i++){
		if(indexTable[i] == -1){
			indexTable[i] = indexTable[i-1];
		}
	}

	ll ans = 1;

	for(int i = 0,k = 0; i <= N-1;i++){
		k = indexTable[table[i]+div]-(i-1);
		ans *= k;
		ans %= MOD_NUM;
	}

	printf("%lld\n",ans%MOD_NUM);

	return 0;
}

Measured memory_bytes: 4036