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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev, col;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n) cin>>a[i];

    Array con(30,0);
    ll r=0;
    ll ans=0;
    REP(l,n){
        while(r<n){
            bool flag=true;
            REP(j,30) if((a[r]>>j&1) && con[j]) flag=false;
            if(!flag) break;
            REP(j,30) if(a[r]>>j&1) con[j]=1;
            r++; 
        }
        ans+=r-l;
        REP(j,30) if(a[l]>>j&1) con[j]=0;
    }
    cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  ll now = 0;
  ll res = 0;
  for(int i = 0;i < n - 1;i++){
    now += a[i];
    if(now * 2 < a[i + 1]){
      res = i + 1;
      //cout << i << " "<<  res << endl;
    }
  }
  cout << n - res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    ll n, k;
    cin >> n >> k;
    vl v;
    while(n){
        v.pb(n%k);
        n/=k;
    }
    out(v.size());
}

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

typedef long long ll;
ll n, t, a, b, s1, s2, num1, num2;
//ll g(ll p, ll q) {
//	if (p % q == 0) return q;
//	g(q, p % q);
//}

int main()
{
	int i;
//	freopen ("input.txt", "r", stdin);
	cin >> n;
	scanf ("%lld %lld", &a, &b);
	s1 = a;
	s2 = b;
	for (i = 1; i < n; i++) {
		scanf ("%lld %lld", &a, &b);

//		num1 = a / s1;
//		num2 = b / s2;
//		if (a % s1 > 0) num1++;
//		if (b % s2 > 0) num2++;
//		s1 = max(s1, num1 * a);
//		s2 = max(s2, num2 * b);
		if (s1 <= a && s2 <= b) {
			s1 = a;
			s2 = b;
		} else if (s1 <= a && s2 > b) {
			num2 = s2 / b;
			if (s2 % b > 0) num2++;
			s2 = b * num2;
			s1 = a * num2;
		} else if (s1 > a && s2 <= b) {
			num1 = s1 / a;
			if (s1 % a > 0) num1++;
			s1 = a * num1;
			s2 = b * num1;
		} else {
			num1 = s1 / a;
			if (s1 % a > 0) num1++;
			num2 = s2 / b;
			if (s2 % b > 0) num2++;
			t = max(num1, num2);
			s1 = a * t;
			s2 = b * t;
		}
	}
    cout << s1 + s2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if(a*b %2 ==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


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

int main(){
 
  long long Y,ans;
  string s;
  ans=0;
 cin>>s>>Y;

for(int i=0;i<s.size();i++){
  if(i%Y==0){
  cout<<s[i];
  }
}
  cout<<endl;
    
}


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

int main(){
	int a,b,c,d,e,k;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;
	cin>>k;
	if(e-a<=k){
        	cout<<"Yay!"<<endl;
	}else{
        	cout<<":("<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] && S[0] == S[2]) {
    cout << "Yes";
  } else if (S[3] == S[1] && S[3] == S[2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define SIZE 100
using namespace std;
class Jihe{
	char ch[SIZE];
	int len;
public:
	Jihe(){
		len = 0;
	}
	void add(char ch){
		this->ch[len] = ch;
		len++;
	}
	bool is_inside(char ch){
		bool ret = false;
		for(int i=0; i<len; i++){
			if(this->ch[i] == ch){
				return true;
			}
		}
		return ret;
	}
};

int main(){
	Jihe j = Jihe();
	j.add('A');
	j.add('C');
	j.add('G');
	j.add('T');
	int max = 0;
	int cnt = 0;
	char in;
	do{
		scanf("%c",&in);
		if(j.is_inside(in)){
			cnt++;
			max = max>cnt?max:cnt;
		}else{
			cnt = 0;
		}
	}while(in != '\n' && in != ' ');
	cout<<max;
}

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

using namespace std;

int mns[10000];

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a % b);
}

struct rat{
    int a, b;

    rat(){
    }

    rat(int a, int b):a(a), b(b){
    }

};

rat operator+ (rat a, rat b){
    return rat(a.a+ b.a, a.b + b.b);
}

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    int n, ma, mb;
    cin >> n >> ma >> mb;
    for (int i = 0; i < 10000; i++){
        mns[i] = 100000000;
    }
    vector<pair<rat, int> > v1, v2;
    for (int i = 0; i < n / 2; i++){
        int a, b, c;
        cin >> a >> b >> c;
        v1.push_back({rat(a, b), c});
    }
    for (int i = n / 2; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        v2.push_back({rat(a, b), c});
    }
    int mn = 100000000;
    int n1 = v1.size();
    int n2 = v2.size();
    for (int mask = 1; mask < (1 << n1); mask++){
        rat sum = rat(0, 0);
        int w = 0;
        for (int i = 0; i < n1; i++){
            if (mask & (1 << i)){
                sum = sum + v1[i].first;
                w += v1[i].second;
            }
        }
        mns[sum.a * mb - sum.b * ma + 4000] = min(mns[sum.a * mb - sum.b * ma + 4000], w);
    }
    for (int mask = 0; mask < (1 << n2); mask++){
        rat sum = rat(0, 0);
        int w = 0;
        for (int i = 0; i < n2; i++){
            if (mask & (1 << i)){
                sum = sum + v2[i].first;
                w += v2[i].second;
            }
        }
        if (mask != 0 && sum.b * ma - sum.a * mb == 0){
            mn = min(mn, w);
        }
        mn = min(mn, w + mns[sum.b * ma - sum.a * mb + 4000]);
    }
    if (mn >= 100000000) cout << -1;
    else cout << mn;
    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);
		StringBuilder sb = new StringBuilder();
		int n = scan.nextInt();
		int[] ar = new int[n];
		for (int i = 0; i < n; i++) {
			int x = scan.nextInt();
			ar[i] = x;
		}
		System.out.print(ar[n-1]);
		for (int i = n - 2; i >= 0; i--) {
			System.out.print(" " + ar[i]);
		}
		System.out.println();
	}
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-10;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int a[maxn];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    int l;
    cin >> l;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int pos = -1;
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i + 1] >= l) {
            pos = i;
            break;
        }
    }
    if (pos == -1) {
        cout << "Impossible";
        return 0;
    }
    cout << "Possible\n";
    for (int i = 1; i < pos; ++i) {
        cout << i << "\n";
    }
    for (int i = n - 1; i >= pos; --i) {
        cout << i << "\n";
    }
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

long long int max(std::vector<long long int> v){
    int maxVal = 0;
    for(int i = 0; i < (long long int)v.size(); ++i) {
        if( v[i] > maxVal )
            maxVal = v[i];
    }
    return maxVal;
}

int main(){
    long long int n,m;
    vector< vector< long long int > > vs(4);
    vector< vector< long long int > > vs2(4);
    vector<long long int> ans;
    long long min=0;
    cin >> n;
    cin >> m;
    for(long long int i=0;i<n;i++){
        long long int a ,b;
        cin >> a >>b;
        if(i == 0)min = a;
        vs[a-min].push_back(b);
    }
    for(int i=0;i<4;i++){
        sort(vs[i].begin(), vs[i].end());
        reverse(vs[i].begin(), vs[i].end());
    }
    for(int i=0;i<4;i++){
        vs2[i].push_back(0);
        for(int j=0;j<vs[i].size();j++){
            vs2[i].push_back(vs[i][j]+vs2[i][j]);
        }
    }
    for(long long int i1=0;i1<=vs[0].size();i1++){
        for(long long int i2=0;i2<=vs[1].size();i2++){
            for(long long int i3=0;i3<=vs[2].size();i3++){
                //cout<<i1<<","<<i2<<","<<i3<<","<<(i1 * min) + (i2 * (1+min)) + (i3 * (2+min))<<endl;
                if((i1 * min) + (i2 * (1+min)) + (i3 * (2+min)) <= m){
                      long long int i4=floor((m-((i1 * min) + (i2 * (1+min)) + (i3 * (2+min))))/(min+3));
                      if(i4 > vs[3].size())i4 = vs[3].size();
                      else if(i4<0)i4 = 0;
                      ans.push_back(vs2[0][i1]+vs2[1][i2]+vs2[2][i3]+vs2[3][i4]);
                }
            }
        }
    }
    cout<<max(ans)<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s;
    int k;
    cin >> s >> k;
    int cnt = 0;
    int ans = 0;
    vector<int> hoge;
    cnt = 1;
    bool flag = true;
    int saisyo = 0;
    FOR(i,1,s.size() ){
        if(s[i] == s[i-1]) cnt ++;
        else{
            if(cnt == 1){
                cnt = 1;
                if(flag == true) saisyo = cnt;
                flag = false;
            }
            else{                
                if(flag == false) hoge.push_back(cnt);
                else saisyo = cnt;
                cnt = 1;
                flag = false;
            }
        }
    }
    if(flag){
        cout <<int(  k * s.size() ) / 2 << endl;
        return 0;
    }
    hoge.push_back(cnt);
    FOR(i,0,hoge.size() - 1){
        ans += hoge[i] / 2;
    }
    ans *= k;
    if(s[s.size() - 1] == s[0]){
        ans += int( (saisyo + hoge[hoge.size() - 1]) / 2) * (k - 1);
        ans += int(saisyo / 2);
        ans += hoge[hoge.size() - 1] / 2;
    }
    else{
        ans += int(saisyo / 2) * k;
        ans += int(hoge[hoge.size() - 1] / 2) * k;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   double h;
   double max=0;
   double min=1000000+5;
   while(cin>>h)
   {
     if(h>max) max=h;
     if(h<min) min=h;              
   }
   double range=max-min;
   printf("%.1lf\n",range);
   //while(1);
   return 0;
 }

Measured memory_bytes: 3192
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 5003

using namespace std;

const int mod = 1000000007;

struct edge{
	int to, nxt;
}e[N << 1];

int n, cnt;
int fir[N], f[N], g[N][N][2], sz[N], h[N][2];

void add(int ,int);
void init();
void dfs(int ,int);

int main(){
	scanf("%d", &n); init();
	for(int i = 2; i <= n; ++i){
		int u, v; scanf("%d%d", &u, &v);
		add(u, v); add(v, u);
	}
	dfs(1, 0); int ans = 0;
	for(int i = 2; i <= n; ++i)
		(ans += 1ll * (g[1][i][0] - g[1][i][1] + mod) * f[i] % mod) %= mod;
	cout << ans << endl;
	return 0;
}

void add(int u, int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt;
	return ;
}

void init(){
	f[0] = 1;
	for(int i = 2; i <= n; i += 2)
		f[i] = 1ll * f[i - 2] * (i - 1) % mod;
	return ; 
}

void dfs(int u, int fa){
	g[u][1][0] = 1; sz[u] = 1;
	for(int i = fir[u]; i; i = e[i].nxt){
		int v = e[i].to; if(v == fa) continue;
		dfs(v, u);
		for(int j = 1; j <= sz[u]; ++j)
			for(int k = 1; k <= sz[v]; ++k){
				(h[j + k][0] += 1ll * g[u][j][0] * g[v][k][0] % mod) %= mod;
				(h[j + k][0] += 1ll * g[u][j][1] * g[v][k][1] % mod) %= mod;
				(h[j][0] += 1ll * g[u][j][0] * g[v][k][1] % mod * f[k] % mod) %= mod;
				(h[j][0] += 1ll * g[u][j][1] * g[v][k][0] % mod * f[k] % mod) %= mod;
				(h[j + k][1] += 1ll * g[u][j][0] * g[v][k][1] % mod) %= mod;
				(h[j + k][1] += 1ll * g[u][j][1] * g[v][k][0] % mod) %= mod;
				(h[j][1] += 1ll * g[u][j][0] * g[v][k][0] % mod * f[k] % mod) %= mod;
				(h[j][1] += 1ll * g[u][j][1] * g[v][k][1] % mod * f[k] % mod) %= mod;
			}
		sz[u] += sz[v];
		for(int j = 1; j <= sz[u]; ++j)
			g[u][j][0] = h[j][0], g[u][j][1] = h[j][1], h[j][0] = h[j][1] = 0;
	}
	return ;
}

Measured memory_bytes: 195072
#include<bits/stdc++.h>
#include<math.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
    float l; cin>>l;
    float s = l/3;
    printf("%.12f",s*s*s);
    return 0;
}

Measured memory_bytes: 256
input = gets.split(" ").map{|item| item.to_i}
N = input[0]
L = input[1]

def taste(i)
  L+i-1
end

total_taste = 0
taste_array = []
for i in 0...N
  total_taste += taste(i+1)
  taste_array.push(taste(i+1))
end

if taste(1) >= 0
  p total_taste - taste(1)
elsif taste(N) <= 0
  p total_taste - taste(N)
else
  p total_taste
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll R[MAX], n;

    cin >> n;
    rep(i, n) cin >> R[i];

    ll maxv = -2000000000;
    ll minv = R[0];

    for (ll i = 1; i < n; ++i) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

}


Measured memory_bytes: 4708
import copy
import heapq
from collections import deque
N, K = list(map(int, input().split()))
V = list(map(int, input().split()))

ans = 0

for i in range(min(N, K) + 1):
    for j in range(min(N-i, K-i) + 1):
        s = V[:i] + V[N-j:]
        s.sort()
        m = 0
        for x in range(min(K - i - j, len(s))):
            if s[x] < 0:
                m += s[x]
            else:
                break

        ans = max(ans, sum(s) - m)

print(ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string X;cin >> X;
    int sc = 0;
    int ct = 0;

    rep(i,X.size()){
        if(X[i] == 'S'){
            sc++;
        }
        else if(X[i] == 'T'){
            if(sc >= 1){
                sc--;
                ct++;
            }
        }
    }

    ct = X.size() - (2*ct);
    cout << ct << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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


	double con = 0.0;
	int water = 0,sugar = 0;
	for(int w = 0; w <=10; w++){
		for(int x = 0; x <= 10; x++){
			for(int y = 0; y <= 100; y++){
				for(int z = 0; z <= 100; z++){
					int water_weight = a*w+b*x, sugar_weight = c*y+d*z;
					int total = 100*water_weight + sugar_weight;
					if(total <= f && sugar_weight <= water_weight*e){
						if(con < (double)sugar_weight/total){
							con = (double)sugar_weight/total;
							water = 100*water_weight;
							sugar = sugar_weight;
						}
					}
				}
			}
		}
	}
  if(con == 0) water = 100*a;

	cout << water+sugar << " " << sugar << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,M,dp[3001][3001][2];

void ad(int& a, int b) { a = (a+b)%MOD; }

void sim(int x) {
    F0R(j,N+1) F0R(k,2) {
        if (j) {
            int K = k|(j == 1);
            ad(dp[x][j][K],dp[x-1][j][k]);
            ad(dp[x][j-1][K],dp[x-1][j][k]);
        }
        if (N-j) {
            ad(dp[x][j+1][k],dp[x-1][j][k]);
            ad(dp[x][j][k],dp[x-1][j][k]);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    F0R(i,N+1) dp[0][i][i == 0] = 1;
    
    FOR(i,1,M+1) sim(i);
    int ans = 0;
    F0R(i,N+1) ad(ans,dp[M][i][1]);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return -*(int*)p + *(int*)q;
}
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);

int end(void){
return 0;
}

int main (void){

int a,b;
scanf("%d%d", &a,&b);

printf("%d\n",a*b);


end;
}



Measured memory_bytes: 1736
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int w, a, b;
    cin >> w >> a >> b;

    if(b > a+w)
        cout << b - (a + w) << endl;
    else if(a - w <= b && b <= a + w)
        cout << 0 << endl;
    else if(b+w < a)
        cout << a - (b + w);

    return 0;
}


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


int main() {
	int n ; 
	cin >> n ; 
	vector<int> a(n) ; 
	for(int i = 0 ; i <  n ; ++i) {
		cin >> a[i] ;
	}
	ll ans = 0 ; 
	int mx = 0 ; 
	for(int i = 0 ; i < n ; ++i) {
		mx = max(mx,a[i]) ; 
		ans += mx -a[i] ;
	}
	cout << ans ; 

	return 0 ; 
}

Measured memory_bytes: 3980
#include <iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)

using namespace std;



int main() {
    int n;cin>>n;
    vector<int>w(n);
    rep(i,n)cin>>w[i];
    int ans=99999;
    for (int i = 0; i < n-1; i++)
    {
        int s1=0, s2=0;
        for(int j = 0; j < i+1; j++)s1+=w[j];
        for(int j = i+1; j < n; j++)s2+=w[j];
        ans = min(ans,abs(s1-s2));
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3612
a, b = map(int, input().split())
if a > 0 and b > 0:
    ans = 'Positive'
elif a == 0 or b == 0:
    ans = 'Zero'
elif a < 0 and 0 < b:
    ans = 'Zero'
else:
    if (b - a) % 2 == 0:
        ans = 'Negative'
    else:
        ans = 'Positive'
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

void Check(int n, int *c5, int *c7){
  if(n == 5) (*c5)++;
  if(n == 7) (*c7)++;
}

int main(void){
  int A, B, C, c5, c7;
  scanf("%d %d %d", &A, &B, &C);
  c5 = c7 = 0;
  Check(A, &c5, &c7);
  Check(B, &c5, &c7);
  Check(C, &c5, &c7);
  if(c5 == 2 && c7 == 1) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	if(n%2 == 1) cout << 2 * n << endl;
	else cout << n << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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 pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    string S;
    cin >> S;
    int res = 0;
    for (int i = 0; i < S.size(); ++i) {
        for (int j = i+1; j <= S.size(); ++j) {
            bool ok = true;
            for (int k = i; k < j; ++k) {
                if (S[k] != 'A' && S[k] != 'G' && S[k] != 'C' && S[k] != 'T')
                    ok = false;
            }
            if (ok) chmax(res, j-i);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = gets.split.map &:to_i

min = 3000000000
0.step([x*2, y*2].max, 2) do |k|
  price = k * c + [x - k/2, 0].max * a + [y - k/2, 0].max * b
  min = [min, price].min
end

p min

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 500005
//---------------------

string s;
int a[MAXN],b[MAXN];

int main(){
	cin >> s;
	ZERO(a);ZERO(b);
	s = '_'+s;
	REP1(i,s.size()){
		if(s[i] == '<') a[i] = a[i-1]+1;
	}
	PER1(i,s.size()){
		if(s[i] == '>') b[i-1] = b[i]+1;
	}
	ll sum = 0;
	REP(i,s.size()) sum += max(a[i],b[i]);
	PRT(sum);
	return 0;
}









Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  int ans=1;
  for (int i=2;i<sqrt(X);i++){
    int x=i;
    while (x*i<=X){
      x*=i;
    }
    ans=max(ans,x);
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
using namespace std;
#define ll long long
#define MX 1e9
int main(){
 int x,y;
 cin>>x>>y;
 cout<<(x+y/2)<<endl;

 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k,n;
    cin >> k >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];
    sort(ary, ary+n);

    int dis[n];
    rep(i,n-1) dis[i] = ary[i+1] - ary[i];
    dis[n-1] = (k+ary[0]) - ary[n-1];
    sort(dis, dis+n);
    cout << k - dis[n-1] << endl;
    
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
char s[500010];
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=1;i<=n;i++) s[i]-='0';
    s[0]=0;
    int p=1,ans=0,flag=1,last=0,nxt;
    while(p<=n){
        //printf("p=%d\n",p);
        if(s[p]<s[p-1]){
            //printf("fake");
            //printf("last=%d p=%d\n",last,p);
			nxt=p;
            p=last+1;
            //printf("%d",s[p-1]-1);
            //for(int i=p;i<=n;i++) printf("9");
            s[p-1]=0;
            s[n]++;
            for(int i=n;i>=p;i--){
                if(s[i]<10) break;
                s[i]-=10;
                s[i-1]++;
            }
            //cout<<endl;
            ans++;
            flag=1;
            last=p;
			p=nxt;
            //for(int i=p;i<=n;i++) printf("%d",s[i]);cout<<endl;
            //puts("------------------");
        }else{
            //if(!flag) printf("%d",s[p-1]);
            flag=0;
            if(s[p]!=s[p-1]) last=p;
            p++;
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>


using namespace std;
using ll = long long int; 

int main(void){

    int n;
    cin>>n;
    vector<int> x(n);

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        x[i] = a;
    }

    ll ans = 100000000;

    for(int i=1;i<=100;i++){
        ll sum = 0;

        for(int j=0;j<n;j++) sum += (x[j]-i)*(x[j]-i);
        //cout<<sum<<endl;
        ans = min(sum, ans);
    }

    cout<<ans<<endl;
    return 0;

}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;


int main()
{
    int n;
    cin >> n;
    vector <ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll temp1 = 0, temp2 = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            temp1 += ((b[i] - a[i]) / 2);
        } else {
            temp2 += a[i] - b[i];
        }
    }
    if (temp1 >= temp2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
string S;

int main(){
	cin >> S;
	vector<bool> ok(S.size()+1);
	ok[0] = true;

	for(int i=0; i<=S.size(); i++){
		if(i >= 5 && ok[i-5] && S.substr(i-5, 5) == "dream"){
			ok[i] = true;
		}
		else if(i >= 7 && ok[i-7] && S.substr(i-7, 7) == "dreamer"){
			ok[i] = true;
		}
		else if(i >= 5 && ok[i-5] && S.substr(i-5, 5) == "erase"){
			ok[i] = true;
		}
		else if(i >= 6 && ok[i-6] && S.substr(i-6, 6) == "eraser"){
			ok[i] = true;
		}
	}

	// cout << S << endl;
	// for(int i=0; i<ok.size(); i++) cout << ok[i];
	// cout << endl;

	cout << (ok[S.size()] ? "YES" : "NO") << endl;
	return 0;
}


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

int main()
{
	int a, b, c;
	int k;
	cin >> a >> b >> c >> k;
	if (k <= a) {
		cout << k << endl;
	}
	else if (k <= (a + b)) {
		cout << a << endl;
	}
	else {
		cout << a - (k - (a + b));
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

int main()
{
	int N;
	std::vector<long> A;
	
	std::cin >> N;
	A.resize(N);
	for (auto& a : A) {
		std::cin >> a;
	}

	long x = 0;
	for (int i = 0; i < N; ++i) {
		x += A[i] * (i%2 == 0 ? 1 : -1);
	}
	std::cout << x;

	for (int i = 1; i < N; ++i) {
		x = -x;
		x += A[i-1] * 2;
		std::cout << " " << x;
	}
	std::cout << "\n";
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;
using PP = pair<int, pair<int, int> >;

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

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    REP( i, N ){
        string s, t;
        cin >> s >> t;
        int snum = 0, tnum = 0, sdigit = 1, tdigit = 1;
        REP( i, s.size() ){
            if( s[i] == 'm' ){
                snum += sdigit * 1000;
                sdigit = 1;
            }else if( s[i] == 'c' ){
                snum += sdigit * 100;
                sdigit = 1;
            }else if( s[i] == 'x' ){
                snum += sdigit * 10;
                sdigit = 1;
            }else if( s[i] == 'i' ){
                snum += sdigit;
                sdigit = 1;
            }else{
                sdigit = s[i] - '0';
            }
        }
        REP( i, t.size() ){
            if( t[i] == 'm' ){
                tnum += tdigit * 1000;
                tdigit = 1;
            }else if( t[i] == 'c' ){
                tnum += tdigit * 100;
                tdigit = 1;
            }else if( t[i] == 'x' ){
                tnum += tdigit * 10;
                tdigit = 1;
            }else if( t[i] == 'i' ){
                tnum += tdigit;
                tdigit = 1;
            }else{
                tdigit = t[i] - '0';
            }
        }

        int sum = snum + tnum;
        if( sum / 1000 > 1 ) cout << sum / 1000;
        if( sum / 1000 > 0 ) cout << 'm';
        sum -= sum / 1000 * 1000;
        if( sum / 100 > 1 ) cout << sum / 100;
        if( sum / 100 > 0 ) cout << 'c';
        sum -= sum / 100 * 100;
        if( sum / 10 > 1 ) cout << sum / 10;
        if( sum / 10 > 0 ) cout << 'x';
        sum -= sum / 10 * 10;
        if( sum > 1 ) cout << sum;
        if( sum > 0 ) cout << 'i';
        cout << endl;
    }
}



Measured memory_bytes: 3172
N=int(input())
B=[int(x) for x in input().split()]
M=0
for i in range(N):
    if i==0:
        M+=B[0]
    elif i==N-1:
        M+=B[i-1]
    else:
        M+=B[i-1] if B[i-1]<B[i] else B[i]
print(M)

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

#define MOD_1000000007 (1000000007LL)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)

using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::map;
using std::pair;
using std::priority_queue;
using std::set;
using std::string;
using std::vector;
typedef long long ll;

ll H, W;

void solve() {
  bool h_odd = H%2;
  bool w_odd = W%2;
  if(H==1 || W==1) {
    cout << 1 << endl;
    return;
  }
  if(h_odd&&w_odd) cout << H*W/2+1 << endl;
  else cout << H*W/2 << endl;
}

int main() {
  scanf("%lld %lld", &H, &W);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

vector<pair<ll,ll>> prime_factorize(ll N){
    vector<pair<ll,ll>> ret;
    for(ll a = 2; a * a <= N; a++){
        if(N % a != 0) continue;
        ll ex = 0;
        while(N % a == 0){
            ex++;
            N /= a;
        }
        ret.push_back({a, ex});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}

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

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

int main(){
    ll n;
    cin >> n;
    VL a(n);
    rep(i, 0, n) cin >> a[i];
    auto ini = prime_factorize(a[0]);
    bool pair_wise = true;
    set<ll> seen;
    rep(i, 1, n) {
        auto v = prime_factorize(a[i]);
        for(auto e : v) {
            if(pair_wise) {
                if(seen.count(e.first)) pair_wise = false;
                seen.insert(e.first);
            }
        }
        if(!pair_wise) break;
    }
    if(pair_wise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    ll cur = a[0];
    rep(i, 1, n) cur = gcd(cur, a[i]);
    if(cur == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}

Measured memory_bytes: 11168
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K,L;
template<int um> class UF {
	public:
	vector<int> par,rank,cnt;
	UF() {par=rank=vector<int>(um,0); cnt=vector<int>(um,1); for(int i=0;i<um;i++) par[i]=i;}
	void reinit() {int i; FOR(i,um) rank[i]=0,cnt[i]=1,par[i]=i;}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int count(int x) { return cnt[operator[](x)];}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		cnt[y]=cnt[x]=cnt[x]+cnt[y];
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};

UF<505050> uf1,uf2;
vector<int> V[505050];
int num[505050];
int ret[505050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>L;
	FOR(i,K) {
		cin>>x>>y;
		uf1(x-1,y-1);
	}
	FOR(i,L) {
		cin>>x>>y;
		uf2(x-1,y-1);
	}
	FOR(i,N) V[uf1[i]].push_back(i);
	FOR(i,N) if(V[i].size()) {
		FORR(r,V[i]) num[uf2[r]]++;
		FORR(r,V[i]) ret[r]=num[uf2[r]];
		FORR(r,V[i]) num[uf2[r]]--;
	}
	
	FOR(i,N) _P("%d%c",ret[i],(i==N-1)?'\n':' ');
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}
int main() {
	int n = ri();
	int f[n][10];
	FOR(i,n) FOR(j,10) f[i][j] = ri();
	int p[n][11];
	FOR(i,n) FOR(j,11) p[i][j] = ri();
	
	s64 res = -LINF;
	FOR(i,1<<10) {
		if (!i) continue;
		s64 cur = 0;
		FOR(k,n) {
			int cnt = 0;
			FOR(j,10) {
				if (!(i&(1<<j))) continue;
				if (f[k][j]) cnt++;
			}
			cur += p[k][cnt];
		}
		res = max(res, cur);
	}
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, cnt = 0;
  string s;
  cin >> n >> s;
  rep(i,n){
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3600