akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n);
    vector<int> pena(n);

    rep(i, m) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "AC") {
            ac[p] = true;
        } else {
            if (!ac[p]) pena[p]++;
        }
    }

    int x = 0, y = 0;
    rep(i, n) {
        if (ac[i]) {
            x++;
            y += pena[i];
        }
    }
    cout << x << " " << y << endl;
}


Measured memory_bytes: 640
def B_Addition_and_Multiplication(N, K):
    if N==1:
        return 2
    multiply = 0  # 掛け算する回数
    add = 0  # 足し算する回数
    tmp = 1
    while tmp < K:
        tmp *= 2
        multiply += 1
    add = N - multiply

    ans = pow(2, multiply) + K * add
    return ans
  
N = int(input())
K = int(input())
print(B_Addition_and_Multiplication(N, K))

Measured memory_bytes: 3060
def max(a,b):
    if a>b:
        return a
    else:
        return b
def min(a,b):
    if a>b:
        return b
    else:
        return a
a0,a1,b0,b1 = map(int,input().split())
if a1<b0 or b1<a0:
    print(0)
else:
    print(min(a1,b1)-max(a0,b0))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ar              array
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("ip1.txt", "r", stdin);
	freopen("op1.txt", "w", stdout);
#endif
}
bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b);
int gcd(int a, int b) ;
int prime(int n);
int power(int x, int y);
int lcm(int a, int b);
bool compare(pii p1, pii p2)
{
	return p1.ff < p2.ff;
}
int32_t main()
{
	k_007();
	int n;
	cin >> n;
	vi v;
	for (int i = 1; i * i <= n; i++)
	{
		if (i * i == n && n % i == 0)
		{
			v.pb(i);
			continue;
		}
		if (n % i == 0)
		{
			v.pb(i);
			v.pb(n / i);
		}
	}

	sort(v.begin(), v.end());
	int ans = inf;
	for (int i = 0; i <= (v.size() - 1) / 2; i++)
	{
		ans = min(ans, v[i] - 1 + v[v.size() - 1 - i] - 1);
	}

	cout << ans << endl;
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, W,i,j,weight,value;
    cin>>n>>W;
    long long int dp[n+1][W+1]={0};
    for(j=0;j<=W;++j)
        dp[0][j] = 0;
    for(i=1;i<=n;++i){
        cin>>weight>>value;
        for(j=0;j<=W;++j){
            if(weight>j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight]+value);
        }
    }
    cout<<dp[n][W]<<endl;
    
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  for (ll i = 0; i < N; i++) {
    cin >> p[i];
  }

  vector<double> E(1001);
  for (ll i = 1; i <= 1000; i++) {\
    double exp = 0.0;
    for (ll j = 1; j <= i; j++) {
      double tmp = (double)j;
      double tmp_i = (double)i;
      exp += (tmp * (1.0/tmp_i));
    }
    E[i] = exp;
  }

  // for (ll i = 0; i < 10; i++) {
  //   cout << i << ":" << E[i] << endl;
  // }

  vector<double> s(N + 1, 0.0);
  s[0] = 0.0;
  for (ll i = 0; i < N; i++) {
    s[i + 1] = s[i] + E[p[i]];
    // cout << s[i + 1] << endl;
  }

  double ans = 0.0;
  for (ll i = 0; i <= N - K; i++) {
    double tmp = s[i + K] - s[i];

    // cout << i << " ~ " << i + K - 1 << endl;

    // cout << "tmp: " << tmp << endl;
    ans = max(ans, tmp);
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a, b;
string s;

int main() {
	cin >> a >> b >> s;
	
	bool f = true;
	if(s[a] != '-') { f = false; } else { s[a] = '0'; }
	inc(i, a + b + 1) {
		if(! inII(s[i], '0', '9')) { f = false; }
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for(int i = 1; i <= m; i++) a[i-1] = i;
    for(int i = 1; i <= m; i++) b[i-1] = m+m-i+1;
    if(n%2 == 0){
        for(int i = 0; i < m/2; i++)    b[i]++;
    }
    for(int i = 0; i < m; i++)  cout << a[i] << " " << b[i] << endl;
    return 0;
}

Measured memory_bytes: 3964
function f(inp) {
    inp = inp.split("\n");
    var N = +inp[0];
    for (var i = 0, H = inp[1].split(" "); i < H.length;) {
        H[i] = +H[i++];
    }
    var lf = H[0];
    for (var i = 1; i < N; i++) {
        if (lf < H[i]) {
            H[i]--;
        }
        else if (lf > H[i]) {
            console.log("No");
            return;
        }
        lf = H[i];
    }
    console.log("Yes");
}
f(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
	int N;
	while( cin >> N ){
		int T[ 101 ] = {0};
		int M;
		int P[ 101 ] = {0};
		int X[ 101 ] = {0};
		int sum = 0;
		for( int i = 1; i <= N; ++i ){
			cin >> T[ i ];
			sum += T[ i ];
		}
		cin >> M;
		for( int i = 1; i <= M; ++i ){
			cin >> P[ i ] >> X[ i ];
		}
		for( int i = 1; i <= M; ++i ){
			cout << sum - T[ P[ i ] ] + X[ i ] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

const int kN = 100;

struct P{
    int x, y;
};

void swap(char m[kN][kN], P b, P a){
    char temp = m[b.x][b.y];
    m[b.x][b.y] = m[a.x][a.y];
    m[a.x][a.y] = temp;
}

int main(){
    string s;
    while(cin >> s, s[0] != '#'){
        char m[kN][kN];
        rep(i,kN) rep(j,kN) m[i][j] = '\0';

        P b, a;
        cin >> b.x >> b.y >> a.x >> a.y;
        b.x--; b.y--; a.x--; a.y--;

        vector<string> v;
        string temp;

        s+='/';
        rep(i,s.size()){
            if(s[i] == '/'){
                v.emplace_back(temp);
                temp = "";
            }else{
                temp += s[i];
            }
        }

        rep(i,v.size()){
            int p = 0;
            rep(j,v[i].size()){
                if(v[i][j] == 'b'){
                    m[i][p] = 'b';
                    p++;
                }
                else{
                    for(int k = 0; k < v[i][j] - '0'; k++){
                        m[i][p] = '.';
                        p++;
                    }
                }
            }
        }
        /*
        for(int i = 0; m[i][0] != '\0'; i++){
            for(int j = 0; m[i][j] != '\0'; j++){
                cout << m[i][j];
            }
            cout << endl;
        }
        */
        swap(m, b, a);
        /*
        for(int i = 0; m[i][0] != '\0'; i++){
            for(int j = 0; m[i][j] != '\0'; j++){
                cout << m[i][j];
            }
            cout << endl;
        }
        */

        for(int i = 0; m[i][0] != '\0'; i++){
            if(i) cout << '/';
            int cnt = 0;
            for(int j = 0; m[i][j] != '\0'; j++){
                if(m[i][j] =='b'){
                    if(cnt) cout << cnt;
                    cnt = 0;
                    cout << 'b';
                }else if(m[i][j] == '.'){
                    cnt++;
                }
            }
            if(cnt) cout << cnt;
        }
        cout << endl;
    }
}

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

#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef long double ld;

int t[100005],x[100005],y[100005];
int main()
{
  fst();
  int i,n,xc,yc,tc;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>t[i]>>x[i]>>y[i];
  }
  xc=0,yc=0,tc=0;
  for(i=0;i<n;i++)
  {
    if(abs(x[i]-xc)+abs(y[i]-yc)<=(t[i]-tc) && (abs(x[i]-xc)+abs(y[i]-yc))%2==(t[i]-tc)%2)
      tc=t[i],xc=x[i],yc=y[i];
    else
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using lli = long long int;

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    cout << ((B - 1) % (A - 1) == 0 ? (B - 1) / (A - 1) : (B - 1) / (A - 1) + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d;
  cin>>d;
  d-=22;
  d=3-d;
  cout<<"Christmas ";
  rep(i,d)cout<<"Eve ";

  return 0;

}


Measured memory_bytes: 256
A, B, C, K = map(int, input().split())

sum = 0

if K - A > 0:
    sum += A
    K -= A
    if K - B > 0:
        K -= B
        if K - C > 0:
            sum = sum - C
        else:
            sum = sum - K
    else:
        pass
else:
    sum += K

print(sum)

Measured memory_bytes: 9188
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
bool Q;
#define INF LLONG_MAX
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const {
        return Q ? p < o.p : k < o.k;
    }
};
struct LineContainer : multiset<Line> {
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b){
        return a / b - ((a ^ b) < 0 && a % b);
    }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        if(empty()) return INF;
        Q = 1; auto l = *lower_bound({0,0,x}); Q = 0;
        return l.k * x + l.m;
    }
};

void solve()
{
	LineContainer a;
	ll n,c;
	cin>>n>>c;
	v64 arr(n+1);
	for (int i=1; i<=n; i++)
		cin>>arr[i];
	v64 dp(n+1,0);
	dp[1]=0;
	// cout<<c<<endl;
	a.add(arr[1],-c-dp[1]-arr[1]*arr[1]);
	for (int i=1; i<=n; i++)
	{
		dp[i]=-(a.query(2*arr[i])-arr[i]*arr[i]);
		a.add(arr[i],-c-dp[i]-arr[i]*arr[i]);		
	}
	cout<<dp[n]<<endl;
}
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    // LineContainer a;
    // // a.add(5,1);
    // a.add(4,1);
    // cout<<a.query(3)<<endl;
    while (t--)
    {
        solve();
    }
    return 0;   
} 

Measured memory_bytes: 15872
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std; 

int main(){
    int n;
    scanf("%d",&n);
    
    int i, r, maxv, minv;
    maxv = INT_MIN;
    minv = INT_MAX;
    for(i = 0; i < n; i++)
    {
        scanf("%d", &r);
        if(i != 0){
            maxv = max(maxv, r - minv);
        }
        minv = min(minv, r);
    }
    
    printf("%d\n", maxv);
    
    return 0;
    
}


Measured memory_bytes: 2736
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define swap(a, b) { bool t = a; a = b; b = t; }

int
main(int argc, char **argv)
{
	bool a = true;
	bool b = false;
	bool c = false;

	char l, r;
	while (scanf("%c,%c\n", &l, &r) != EOF)
	{
		if ((l == 'A' && r == 'B') || (l == 'B' && r == 'A'))
			{ swap(a, b); }

		else if ((l == 'A' && r == 'C') || (l == 'C' && r == 'A'))
			{ swap(a, c); }

		else if ((l == 'B' && r == 'C') || (l == 'C' && r == 'B'))
			{ swap(b, c); }
	}

	if (a)
		printf("A\n");
	else if (b)
		printf("B\n");
	else if (c)
		printf("C\n");
	return 0;
}

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

using namespace std;

typedef long long int 	ll;
typedef pair<int,int>   ii;
typedef vector< ii >   vii;
typedef vector<int>     vi;
typedef vector< vi >   vvi;

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<ll(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_io;
    int n,a[mm];
    cin>>n;
    forn(i,n)
        cin>>a[i];
    int f=0,t=0;
    forn(i,n)
        if(a[i]%4==0) f++;
        else if(a[i]%2==0) t++;
    if((f>=n/2)||(2*f+t)>=n) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder S = new StringBuilder(sc.next());
        int opt = 0;
        boolean check = true;
        for(int i=0;i<S.length();i++){
         if(S.charAt(i)!=S.charAt(S.length()-i-1)){
             check = false;
             break;
         }
        }
        if(check)opt++;
        int num = (S.length()-1)/2;
        StringBuilder s = new StringBuilder(S.substring(0,num));
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                check = false;
                break;
            }
        }
        if(check)opt++;
        num = (S.length()+3)/2;
        s = new StringBuilder(S.substring(num-1));
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=s.charAt(s.length()-i-1)){
                check = false;
                break;
            }
        }
        if(check)opt++;
        if(opt==3) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

string S;
int idx;

const string D[] = {"dream", "erase", "eraser", "dreamer"};

bool takeNext() {
	int add = -1;
	FOR (i, 4) {
		bool found = true;
		FOR (j, D[i].sz)
			if (idx + j >= S.sz || S[idx + j] != D[i][j])
				found = false;
		if (found) {
			if (i == 3 && (idx + 7 == S.sz || S[idx + 7] != 'a'))
				add = i;
			else if (i < 3)
				add = i;
		}
	}
	if (add == -1)
		return false;
	idx += D[add].sz;
	return true;
}

int main() {
	cin >> S;
	idx = 0;
	while (idx < S.sz) {
		if (!takeNext())
			break;
	}
	if (idx == S.sz)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
use std::io;
use std::io::prelude::*;

fn main() {
    let line = io::stdin().lock().lines().skip(1).next().unwrap().unwrap();
    let cnt = line
        .split(' ')
        .step_by(2)
        .filter(|x| x.parse::<u8>().unwrap() & 1 == 1)
        .count();
    println!("{}", cnt);
}


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

int main(){
    int N, s, ans = 0, flag = 0;
    cin>>N;
    for(int i = 0; i < N; i ++){
        cin>>s;
        ans += s;
        if(s % 10 != 0){
            if(flag == 0)flag = s;
            else if(flag > s)flag = s;
        }
    }
    if(ans % 10 == 0)ans -= flag;

    if(ans % 10 == 0)cout<<'0';
    else cout<<ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
// import java.io.*;

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

        int num_query = sc.nextInt();

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < num_query; i++) {
            int query_type = sc.nextInt();
            int key;
            switch (query_type) {
                case 0:
                    key = sc.nextInt();
                    list.add(key);
                    break;
                case 1:
                    key = sc.nextInt();
                    System.out.println(list.get(key));
                    break;
                case 2:
                    list.remove(list.size()-1);
                    break;
                default:
                    return;
            }
        }

        // System.out.println();
        
        sc.close();
    }
}



Measured memory_bytes: 140380
macro_rules! input {
    ($t : ty) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().parse().unwrap(); 
        buf.clear();
        tmp_var
    }};
    ($t : ty, $size : expr) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().split_whitespace()
            .map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp_var
    }};
}
fn main() {
    let n = input!(usize);
    let mut nums: Vec<usize> = input!(Vec<usize>, n);
    let mut count = 0;
    while nums.iter().filter(|&&a| a % 2 == 0 && a != 0).collect::<Vec<&usize>>().len() == n {
        for num in &mut nums.iter_mut() {
            *num /= 2; 
        }
        count += 1;
    }
    println!("{}", count);
}



Measured memory_bytes: 4352
//
// Created by Rea1 on 2020/2/22.
//
#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const int mod = 1e9 + 7;
ll qmi(ll m, ll k, ll p)
{
    ll res = 1 % p, t = m;
    while (k)
    {
        if (k&1) res = res * t % p;
        t = t * t % p;
        k >>= 1;
    }
    return res;
}
ll inv(ll x, ll p)
{
    return qmi(x, p - 2, p);
}
ll A[400020];
ll C(ll n, ll m, ll p)
{
    if(m > n)return 0;
    return A[n] * inv(A[m], mod) % mod * inv(A[n - m], mod) % mod;
}
ll Lucas(ll n, ll m, ll p)
{
    if(m == 0)return 1;
    return C(n % p, m % p, p) * Lucas(n / p, m / p, p) % p;
}

void init() {
    A[0] = A[1] = 1;
    for (int i = 2; i <= 400000; i++) {
        A[i] = A[i - 1] * i % mod;
    }
}
int main() {
    int n,k;
    scanf("%d%d", &n, &k);
    init();
    ll ans = 0;
    if (k >= n) {
        ans = C(n * 2 - 1, n - 1, mod);
    } else {
        if (k == 1) {
            ans = n * (n - 1) % mod;
        } else {
            for (int i = 0; i <= k; i++) {
               ans = (ans + C(n, i, mod) * C(n - 1, n - i - 1, mod) % mod) % mod;
            }
        }
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	Loop(i, N) cin >> A[i];
	int ret = 0;
	Loop(i, N) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				int pass = A[j];
				A[j] = A[j - 1];
				A[j - 1] = pass;
				ret++;
			}
		}
	}
	cout << A[0];
	for (int i = 1; i < N; i++) cout << " " << A[i];
	cout << endl << ret << endl;
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    typedef pair<ll, ll> pa;
    vector<pa> vp;
    int n;
    vector<ll> a;
    cin >> n;
    for(int i = 0, x; i < n; i++) {
        cin >> x;
        a.push_back(x);
    }
    n = a.size();
    sort(a.begin(), a.end());
    ll final_s = 0;
    if(a[0] < 0 && a[n-1] > 0) {
        int pos = 0;
        for(int i = 0; i < n; i++) {
            if(a[i] >= 0) {
                pos = i;
                break;
            }
        }
        for(int i = pos; i < n-1; i++) {
            vp.emplace_back(a[0], a[i]);
            a[0] -= a[i];
        }
        for(int i = 0; i < pos; i++) {
            vp.emplace_back(a[n-1], a[i]);
            a[n-1] -= a[i];
        }
        final_s = a[n-1];
    } else if(a[0] >= 0) {
        for(int i = 1; i < n-1; i++) {
            vp.emplace_back(a[0], a[i]);
            a[0] -= a[i];
        }
        vp.emplace_back(a[n-1], a[0]);
        final_s = a[n-1] - a[0];
    } else {
        for(int i = n-2; i >= 0; i--) {
            vp.emplace_back(a[n-1], a[i]);
            a[n-1] -= a[i];
        }
        final_s = a[n-1];
    }
    cout << final_s << '\n';
    for(int i = 0; i < n-1; i++) {
        cout << vp[i].first << " " << vp[i].second << '\n';
    }
    return 0;
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int n, a[200005], b[200005];

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

    reverse(b, b + n);

    int l = 0, r = n - 1;
    while (l < n && a[l] != b[l]) l++;
    while (r >= 0 && a[r] != b[r]) r--;

    int i, j;
    for (i = l, j = 0; i <= r && j < n; j++) {
        if (a[j] != b[i] && b[j] != b[i]) {
            swap(b[j], b[i]);
            i++;
        }
    }

    if (l > r || i == r + 1) {
        cout << "Yes\n";
        for (int i = 0; i < n; i++) {
            cout << b[i] << " \n"[i == n - 1];
        }
    }
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 5132
#include <iostream>
#define ll long long
using namespace std;

int main() {
   ll a[10000000];
   a[10000000]={0};
   a[2]=1;
   for(ll i=3;i<=10000000;i+=2)
    a[i]=1;
    for(ll i=3;i<=10000000;i+=2)
    {
        if(a[i])
        {
            for(ll j=i*i;j<=10000000;j+=2*i)
            a[j]=0;
        }
    }
    ll x;
    cin>>x;
    
    for(ll i=x;i<=10000000;i++)
    {
        if(a[i])
        {
            cout<<i;
            break;
        }
    }
   
	return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // code:
    int n,m; cin>>n>>m;cout<<n*m<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;

  reps(i, 1, 10) reps(j, 1, 10) if(i*j == N) {cout << "Yes" << endl; return 0;}

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
mo=10**9+7

n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a,b))

l.sort(key=lambda x: x[1])
t=0
k=0
for i in range(n):
    a,b=l[i]
    t+=a
    if t>b:
        k=1
        break
    
#a=[int(i) for i in input().split()]
#a=[l+i-1 for i in range(1,n+1)]


ans=['Yes','No']
print(ans[k])


Measured memory_bytes: 75096
from collections import Counter
from itertools import accumulate

def bisect(ng, ok, judge):
    while abs(ng-ok) > 1:
        m = (ng+ok)//2
        if judge(m):
            ok = m
        else:
            ng = m
    return ok

N = int(input())
A = Counter(Counter(map(int,input().split())).values())
m = max(A.keys())
nA = list(accumulate(A[c] for c in range(m+1)))
wA = list(accumulate(A[c]*c for c in range(m+1)))

A = [wA[i]+(nA[-1]-nA[i])*i for i in range(m+1)]
for k in range(1,N+1):
    print(bisect(N+1, 0, lambda x: x*k <= A[min(x,m)]))

Measured memory_bytes: 120476
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b==15) cout << "+" << endl;
    else if(a*b==15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> H;
  rep(i, 1, N) {
    int h;
    cin >> h;
    H.push_back(h);
  }

  sort(ALL(H));
  reverse(ALL(H));

  ll ans = 0;
  rep(i, K, N - 1) { ans += H[i]; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            List<int> h = new List<int>();

            for (int i = 0; i < 10; i++)
                h.Add(cin.GetInt());

            h = h.OrderByDescending(x => x).ToList();

            for (int i = 0; i < 3; i++)
                Console.WriteLine(h[i]);
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

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

int main(){
    int x1,y1,x2,y2,x3,y3,x4,y4;cin>>x1>>y1>>x2>>y2;
    x3=x2+y1-y2;
    y3=y2+x2-x1;
    x4=x1+y1-y2;
    y4=y1+x2-x1;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 1000*1000+10;
bool besucht[bound];

void init(){
	for( int i = 0; i < bound; ++i ) besucht[i] = false;
}

int no(){
	cout << 0 << endl;
	return 0;
}

int main(){
	int n, m; cin >> n >> m;
	vector<int> a(n);
	vector<int> b(m);
	for( auto &k : a ){
		cin >> k;
		if( besucht[k] ) return no();
		besucht[k] = true;
	}
	init();
	for( auto &k : b ){
		cin >> k;
		if( besucht[k] ) return no();
		besucht[k] = true;
	}
	sort( a.begin(), a.end() );
	sort( b.begin(), b.end() );
	ll ans = 1;
	for( int k = 1; k <= n*m; ++k ){
		bool ares = binary_search( a.begin(), a.end(), k );
		bool bres = binary_search( b.begin(), b.end(), k );
		ll comb = 1;
		if( !bres ) comb *= (b.end() - lower_bound( b.begin(), b.end(), k ));
		if( !ares ) comb *= (a.end() - lower_bound( a.begin(), a.end(), k ));
		if( !ares && !bres ) comb -= n*m-k;
		ans *= comb;
		ans %= mod;
	}
	cout << ans << endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<long long, long long>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {
	
	vector<int>svec(100000, -1);
	vector<int>vec(100001,0);
	vec[3] = 1;

	//累積和を先に出しておく
	for (int i = 3; i <= 50000;i+=2) {
		if (svec[i] == -1) {
			svec[i] = 1;
			int max = sqrt(i);
			for (int j = 2; j <= max; ++j) {
				if (i % j == 0) svec[i] = 0;
			}
		}
		if (svec[i]==1) {
			if (svec[i*2-1] == -1) {
				svec[i*2-1] = 1;
				int max2 = sqrt(i * 2 - 1);
				for (int j = 2; j <= max2; ++j) {
					if ((i*2-1) % j == 0)svec[i * 2 - 1] = 0;
				}
			}
			if (svec[i * 2 - 1] == 1)vec[i*2-1]++;
		}
	}
	
	for (int i = 0; i < 100000;++i) {
		vec[i + 1] += vec[i];
	}

	long long Q;
	cin >> Q;

	for (int i = 0; i < Q;++i) {
		int l,r;
		cin >> l >> r;
		cout << vec[r] - vec[l-1] << endl;
	}
}


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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) {
    cin >> h.at(i);
  }
  vector<int> dp(n,1e9);
  dp.at(0)=0;
  for(int i=0;i<n-1;i++) {
    for(int j=i+1;j<min(i+k+1,n);j++) {
      dp.at(j)=min(dp.at(j),dp.at(i)+abs(h.at(j)-h.at(i)));
    }
  }
  cout << dp.at(n-1) << endl;
}

Measured memory_bytes: 1024
n = int(input())
bricks = [int(x) for x in input().split()]
if 1 not in bricks:
    ans = -1
else:
    counter = 1
    ans = 0
    for i in range(n):
        if bricks[i] == counter:
            counter += 1
        else:
            ans += 1
print(ans)

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

int main() {
    int N; cin >> N;
    int A;
    int ans = 10000000;
    int cnt;
    rep(i, N) {
        cnt = 0;
        cin >> A;
        while (A > 0) {
            if (A % 2 == 0) {
                cnt++;
                A /= 2;
            }
            else {
                break;
            }
        }
        if (cnt < ans) {
            ans = cnt;
        }
    }
    cout << ans << endl;
}


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

typedef struct node{
	int key;
	struct node *parent,*left,*right;
}Node;

Node *root,*NIL;

void insert(int k);
void inOrder(Node *x);
void preOrder(Node *x);

int main(){
	int i,n,x;	scanf("%d",&n);
	char com[10];

	for(i=0;i<n;i++){
		scanf("%s",com);
		if(com[0]=='i'){
			scanf("%d",&x);
			insert(x);

		}else{
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}
	}

	return 0;
}

void insert(int k){
	Node *y=NIL, *x=root, *z;

	z=(Node*)malloc(sizeof(Node));

	z->key=k;	z->left=NIL;	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(k < x->key){
			x=x->left;
		}else{
			x=x->right;
		}
	}
	z->parent=y;

	if(y==NIL)root=z;
	else{
		if(k < y->key){
			y->left = z;
		}else{
			y->right=z;
		}
	}
}

void inOrder(Node* x){
	if(x==NIL)return;
	inOrder(x->left);
	printf(" %d",x->key);
	inOrder(x->right);
}
void preOrder(Node* x){
	if(x==NIL)return;
	printf(" %d",x->key);
	preOrder(x->left);
	preOrder(x->right);
}



Measured memory_bytes: 25164
#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
#define gg {puts("-1");return 0;}
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e5+10;
char s[MAXN];
int n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]=='0' || s[n]=='1')
		gg;
	for(rg int i=2;i<n;++i)
		if(s[i]!=s[n-i])
			gg;
	int rt=1;
	for(rg int i=1;i<n;++i)
		{
			printf("%d %d\n",rt,i+1);
			if(s[i]=='1')
				rt=i+1;
		}
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Measured memory_bytes: 1536
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.reverse()
B.reverse()

res = 0
for i in range(N):
    res += (B[i] - (A[i]+res)%B[i]) % B[i]

print(res)

Measured memory_bytes: 16820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1e9+7
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
const int MAXN = 2e5+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
int32_t main() {
    fio
    int n,x,t;
    cin >> n >> x >> t;
    cout << (n + x - 1)/x * t << endl;


}






Measured memory_bytes: 3676
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
 
 
 
int main(){
    int N;
    cin >> N;
    int B[N-1];
    rep(i,N-1) cin >> B[i];
    int ans = B[0] + B[N-2];
    for (int i = 0; i < N-2; i++)
    {
        ans += min(B[i],B[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(){

    int K, S;
    int x, y, z;
    int ans = 0;

    cin >> K >> S;

    for(x = 0; x <= K; ++x){
        for(y = 0; y <= K; ++y){
            z = S - x -y;
            if( 0 <= z && z <= K ){
                ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod (lint)1000000007
#pragma endregion

class UnionFind {
	vector<int> par;
public:
	UnionFind(int n) : par(n, -1) { }
	void init(int n) { par.assign(n, -1); }
	lint root(int x) {//根を出す
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}
	bool same(int x, int y) {//同じ集合なのかを調べる
		return root(x) == root(y);
	}
	bool unite(int x, int y) {//xの根とyの根をつなげる
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int n, q;

int main(void) {
	cin >> n >> q;
	UnionFind u(n);
	for (int i = 0; i < q; i++) {
		int a, b, c; cin >> a >> b >> c;
		if (a == 0) {
			u.unite(b, c);
		}
		else {
			if (u.same(b, c)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <stdio.h>
using namespace std;
int main ()
{
	int x;
	char a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}

	x=(int)a[0]+(int)a[1]+(int)a[2];
	if(x==294)
	cout<<"Yes";
	else 
	cout<<"No"	 ;
}

Measured memory_bytes: 256
//Bubble Sort
#include <iostream>
#include <algorithm>

using namespace std;

int bubbleSort(int A[], int n) {
    int count =0;
    for(int i=0; i<n-1; i++) {
        for(int j=n-1; j>i; j--) {
            if(A[j] < A[j-1]) {
                swap(A[j-1], A[j]);
                count++;
            }
        }
    }
    return count;
}

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

    int count = bubbleSort(A, n);

    for(int i=0; i<n-1; i++) cout << A[i] << " ";
    cout << A[n-1] << endl;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int MaxN = 1e5 + 10;
map <string, int> cnt;

char s[10], str[105][15];

int main() {
	int n, m;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%s", str[i]);
		cnt[str[i]]++;
	}
	scanf("%d", &m);
	while(m--) {
		scanf("%s", s);
		cnt[s]--;
	}
	int maxx = 0;
	for(int i = 1; i <= n; i++) maxx = max(maxx, cnt[str[i]]);
	if(maxx < 0) maxx = 0;
	printf("%d\n", maxx);
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll H, N;
  cin >> H >> N;
  vector<ll> pow(N), mp(N);
  rep(i, N) { cin >> pow[i] >> mp[i]; }
  vector<ll> ans(10001, 10000000000); // ans[hp] = mp;
  ans[0] = 0;
  for (ll hp = 1; hp < 10001; hp++) {
    rep(i, N) { chmin(ans[hp], mp[i] + ans[max((ll)0, hp - pow[i])]); }
  }
  cout << ans[H] << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		List<Integer> list = new ArrayList<Integer>();
		for (;;) {
			int num = scan.nextInt();
			if (num == 0) {
				break;
			}
			list.add(num);
		}

		int i = 1;
		for (Integer num : list) {
			System.out.printf("Case %d: %d\n", i++, num);
		}
		scan.close();

	}

}

Measured memory_bytes: 59616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
	fastio;
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 764