akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int> sum(n + 1, 0);
	rep(i, 0, n) {
		sum[i + 1] = sum[i] + (s[i] == '#' ? 1 : 0);
	}
	int ans = 2e9;
	rep(i,0 , n + 1) {
		int w = sum[i];
		int b = n-i-(sum[n] - sum[i]);
		ans = min(ans, w + b);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a,b,c,buf;
	cin >> a;
	cin >> b;
	cin >> c;
	buf = a;
	a = b;
	b = buf;
	buf = a;
	a = c;
	c = buf;
	cout << a << " " << b << " " << c << " " <<endl;	
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
numlist=[]

if k>b-a:
    k=b-a+1

for i in range(k):
    numlist.append(a+i)
    numlist.append(b-i)
numlist=sorted(list(set(numlist)))
for item in numlist:
    print(item)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll LINF = LLONG_MAX;
// const ll MOD = 1e9+7;
const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int K;
    string S;
    cin >> K >> S;

    // resolve
    if (S.size() <=K) {
        cout << S << endl;
    } else {
        for (int i=0; i<K; i++) {
            cout << S[i];
        }
        cout << "..." << endl;
    }

    // output

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define priority_queue pque;
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  P a[n];
  int A;
  rep(i, n) {
    cin >> A;
    a[i] = (P(A, i + 1));
  }
  sort(a, a + n);
  rep(i, n) cout << a[i].second << " ";
  return 0;
}


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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<pair<ll, ll>> vp(n);
  for (int i = 0; i < n; ++i) {
    cin >> vp[i].first >> vp[i].second;
  }

  pair<ll, ll> cur{vp[0].first, vp[0].second};
  for (auto &p : vp) {
    ll l = 1, r = pow(10, 18) / max(p.first, p.second);
    while (l < r) {
      ll mid = (l + r) / 2;
      ll fst = p.first * mid, snd = p.second * mid;
      if (cur.first > fst || cur.second > snd) {
        l = mid + 1;
      } else {
        r = mid;
      }
    }

    cur.first = r * p.first;
    cur.second = r * p.second;
  }

  cout << cur.first + cur.second << '\n';
}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>

using namespace std;
using ll = long long;

ll number_generator(ll number, ll digits) {
	string result = "";

	while(digits--)
		result += (char)(48 + number);

	return atoll(result.c_str());
}

int main() {

	int digits=1, val;
	cin >> val;

	int number = val;

	while(number/10 != 0)
		number = number / 10, digits++;

	ll ans = number_generator(number, digits);

	while(ans < val) {
		ans = number_generator(++number, digits);
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

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



Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
    long long N, K;
    cin >> N >> K;
    long long A[N + 1];
    for(long long i = 1; i < N + 1; i++){
        cin >> A[i];
    }
    int vis[N + 1] = {0};
    long long pos = 1;
    long long end = 1;
    while(vis[pos] < 2){
        vis[pos]++;
        end = pos;
        pos = A[pos];
    }
    long long cnt1 = 0, cnt2 = 0;
    for(long long i = 1; i < N + 1; i++){
        if(vis[i] == 1){
            cnt1++;
        }
        else if(vis[i] == 2){
            cnt2++;
        }
    }
    if(K <= cnt1 + cnt2){
        long long ans = 1;
        for(long long i = 1; i <= K; i++){
            if(i == K){
                ans = A[ans];
                cout << ans << endl;
            }
            else{
                ans = A[ans];
            }
        }
    }
    else{
        long long y = (K - cnt1) % cnt2;
        long long ans = end;
        for(long long i = 1; i <= y + 1; i++){
            if(i == y + 1){
                ans = A[ans];
                cout << ans << endl;
            }
            else{
                ans = A[ans];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5976
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(M):
    L[i],R[i]=map(int,input().split())
a=L[0]
for i in range(M):
  if L[i]>a:
    a=L[i]
  else:
    a=a
b=R[0]
for i in range(M):
  if R[i]<b:
    b=R[i]
  else:
    b=b
if b-a<0:
  print("0")
else:
  print(b-a+1)

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

int main(){
	long long int a,b,c[100010],ans =0;
  
  cin >> a >> b;
  
  for(int i=0;i<a;i++)
    cin >> c[i];
  a -=b;
  ans++;
  while(a>0){
     a -= (b-1);
    
    ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0LL)
# define debug(x) cerr<< #x << " = " << x << endl
# define ddebug(x, y) cerr<< #x << " = " << x  << ", " << #y << " = " << y << endl
# define tdebug(x, y, z) cerr<< #x << " = " << x  << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
# define bin(x) cerr<< #x << " : " << bitset<4>(x) << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)
# define MP make_pair
# define uop(x, y) pii(min(x, y), max(x, y))

const int MAXN = 200 * 1000 + 10, MOD = 1000 * 1000 * 1000 + 7;
vector <int> v[MAXN];
int mn[MAXN], m1[MAXN], m2[MAXN], fact[MAXN];

int _pow(int a, int p)
{
	if (!p)
		return 1;
	return _pow(a * a % MOD, p / 2) * ((p & 1) ? a : 1) % MOD;
}

int rev(int a)
{
	return _pow(a, MOD - 2);
}

int choose(int k, int n)
{
	return fact[n] * rev(fact[k] * fact[n - k] % MOD) % MOD;
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	int n, x, y;
	cin >> n >> x >> y;

	memset(mn, 63, sizeof mn);
	for (int i = 0; i < n; i ++)
	{
		int c, w;
		cin >> c >> w;
		v[c].PB(w);
		smin(mn[c], w);
	}

	fact[0] = 1;
	for (int i = 1; i <= n + 5; i ++)
		fact[i] = fact[i - 1] * i % MOD;

	m1[0] = INT_MAX;
	for (int i = 1; i <= n; i ++)
		m1[i] = min(m1[i - 1], mn[i]);

	m2[n + 1] = INT_MAX;
	for (int i = n; i >= 1; i --)
		m2[i] = min(m2[i + 1], mn[i]);

	int ans = 1, sum = 0;
	for (int i = 1; i <= n; i ++)
	{
		if (mn[i] + min(m1[i - 1], m2[i + 1]) > y)
			continue;

		int cnt = 0;
		for (int a : v[i])
			cnt += ((a + mn[i] <= x) || (a + min(m1[i - 1], m2[i + 1]) <= y));
		sum += cnt;
		ans *= choose(cnt, sum);
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15744
import copy
import math
import string
import heapq
import bisect
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i]*= -1
heapq.heapify(A)

while M > 0:
    M -= 1
    a = heapq.heappop(A)
    heapq.heappush(A,math.ceil(a/2))
ans = 0
for i in range(N):
    ans += abs(heapq.heappop(A))
print(ans)


Measured memory_bytes: 108952
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define int long long
class segtree{
private:
    int n,sz;
    vector<pair<int,int>> node;
public:
    segtree(vector<pair<ll,ll> >& v) : sz((int)v.size()){
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n-1,MP(0,0));
        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i=n-2; i>=0; i--){
            node[i] = max(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k,pair<ll,ll> a){
    	k += n-1;
    	node[k] = a;
    	while(k>0){
            k = (k-1)/2;
            node[k] = max(node[2*k+1],node[2*k+2]);
    	}
    }
    pair<ll,ll> query(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0) r = n;
    	if(r <= a || b <= l){
            return MP(0,0);
    	}
    	if(a <= l && r <= b){
            return node[k];
    	}else{
            pair<ll,ll> vl = query(a,b,2*k+1,l,(l+r)/2);
            pair<ll,ll> vr = query(a,b,2*k+2,(l+r)/2,r);
            return max(vl,vr);
    	}
    }
    
};


signed main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<pair<ll,ll> > v(200000);
    segtree seg(v);
    rep(i,n){
        cin >> a[i];
        if(a[i]==0)continue;
        auto x = seg.query(0,a[i]);
        seg.update(a[i],MP(x.first+1,x.second+a[i]));
    }
    cout << seg.query(0,200000).second << endl;
    return 0;
}


Measured memory_bytes: 14972
import sys
input = sys.stdin.readline

n = int(input())
nums = [None] * n

for i in range(n):
    nums[i] = int(input())
sorted_nums = sorted(nums)

for num in nums:
    max_val = sorted_nums[n - 1]
    if num == max_val:
        max_val = sorted_nums[n - 2]
    print(max_val)


Measured memory_bytes: 14092
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b;
    cin >> a >> b;
    int d = 0;
    rep(i, b) {
        int c;
        cin >> c;
        d = max(d, c);
    }
    cout << max(0, d-(a-d)-1) << 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 eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

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





int main(){

    ll l, r;
    cin >> l >> r;

    ll ans = LINF;
    int cnta = 0, cntb = 0;
    for(ll i = l; i <= r; ++i){
        if(cnta >= 2019) break;
        for(ll j = i+1; j <= r; ++j){
            if(cntb >= 2019) break;
            ans = min(ans, (i%2019 * j%2019)%2019);
            ++cntb;
        }
        cntb = 0;
        ++cnta;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter

# print(c['str']) # strの個数を表示
# print(c.keys()) # キーを表示
# print(c.values()) # 値を表示
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *l = map(int, read().split())

# l.sort()
c = Counter(l)
h = []
for k, v in c.items():
    h.append([k, v])
h.sort()
# print(h)
ans = 0
for i in range(len(h) - 2):
    for j in range(i + 1, len(h) - 1):
        for k in range(j + 1, len(h)):
            if h[k][0] < h[j][0] + h[i][0]:
                ans += h[i][1] * h[j][1] * h[k][1]
print(ans)


Measured memory_bytes: 9464
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  int a = 0, N;
  ll y = 100;
  double x, z = 100;
  cin >> x;

  while (y < x) {
    z = y * 1.01;
    y = z;
    a++;
    if (y >= x) {
      cout << a <<endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3708
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

struct S {
  string s;
  size_t p;
  size_t idx;
  S(string _s, size_t _p, size_t _idx) : s(_s), p(_p), idx(_idx) {}
};

int main() {
  size_t N;
  cin >> N;

  vector<S> Ps;

  for (size_t i = 0; i < N; i++) {
    string s;
    size_t p;
    size_t idx = i + 1;
    cin >> s >> p;
    Ps.emplace_back(S(s, p, idx));
  }

  sort(Ps.begin(), Ps.end(), [](const S& a, const S& b) {
    return a.s < b.s;
  });


  size_t begin_i = 0;
  string current_s = Ps[0].s;
  for (size_t i = 1; i < N; i++) {
    if (current_s == Ps[i].s) {
      if (i == N-1) {
        sort(Ps.begin() + begin_i, Ps.end(), [](const S& a, const S& b) {
          return a.p > b.p;
        });
      }
    } else {
      sort(Ps.begin() + begin_i, Ps.begin() + i, [](const S& a, const S& b) {
        return a.p > b.p;
      });

      begin_i = i;
    }
    current_s = Ps[i].s;
  }


  for (const auto& s : Ps) {
    cout << s.idx << endl;
  }

  return 0;
}

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


int ASC(const void *a, const void *b) {
	return *(int *)b - *(int *)a;//降順
}


int main(void)
{
	char a[4];
	scanf("%s",a);
	if (a[0] == '7' || a[1] == '7' || a[2] == '7')
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> a(N), b(M);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < M; i++) cin >> b[i];
    vector<ll> sa(N+1);
    for (int i = 0; i < N; i++) sa[i+1] += a[i] + sa[i];
    for (int i = 1; i < M; i++) b[i] += b[i-1];
    b.push_back(LINF);
    ll ans = 0LL;
    for (ll i = 0; i <= N; i++) {
        ll d = K - sa[i];
        if (d >= 0LL) {
            ll ib = upper_bound(b.begin(), b.end(), d) - b.begin();
            ll tmp = i + ib;
            ans = max(ans, tmp);
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 9540
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
 
using namespace std;
typedef long long ll;


int main()
{
    ll X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N, M = [int(i) for i in input().split()]
Like = [[int(i) for i in input().split()] for j in range(N)]

like_dict = defaultdict(int)
for k, *a in Like:
    for e in a:
        like_dict[e] += 1
ans = 0
for e in like_dict.values():
    if e == N:
        ans += 1
print(ans)

Measured memory_bytes: 3436
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
ll n,m,k;

vector<ll> CS1;
vector<ll> CS2;
vector<ll> A;
vector<ll> B;
//vector<ll> P;
ll P[100000] = {0};
int main()
{

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

    ll a,b,c,d,e;
    ll c1,c2,c3,c4;

   cin >> n;
   for(c1 = 0; c1 < n; c1++){
        cin >> a;
        a--;
        P[c1] = a;
        A.push_back(c1+1);
        B.push_back(n-c1);
        CS1.push_back(0);
        CS2.push_back(0);
   }

   for(c1 = 0; c1 < n; c1++){
        a = P[c1];
      //  cout << a << "\n";
        if(a < n-1){
            CS1[a+1] += n-c1;
        }
        if(a != 0){
            CS2[0] += n-c1;
            CS2[a] -= n-c1;
        }
   }
   ll cs1 = 0;
   ll cs2 = 0;
   for(c1 = 1; c1 < n; c1++){
        CS1[c1] += CS1[c1-1];
        CS2[c1] += CS2[c1-1];
   }
   for(c1 = 0; c1 < n; c1++){
        A[c1] += CS1[c1];
        B[c1] += CS2[c1];
        //cout << CS1[c1] << " " << CS2[c1] << "\n";
   }
   for(c1 = 0; c1 < n; c1++){
        cout << A[c1] << " ";
   }
   cout << "\n";
    for(c1 = 0; c1 < n; c1++){
        cout << B[c1] << " ";
   }
   cout << "\n";

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  // or pb_ds;

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#ifndef DEBUG
// #define endl "\n"
#endif
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define FILE_INPUT                  \
  freopen("input.txt", "r", stdin); \
  freopen("output.txt", "w", stdout)

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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

template <typename T, typename B = null_type>
using oset =
    tree<T, B, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order / order_of_key

const ld eps = 1e-12;

/*-----------------END TEMPLATE-----------------*/

const int N = 2e5 + 50;
int a[N];
int n;

ll pardp[N][2];
ll impardp[N];

ll solvePar(int i, int lastPairLeft) {
  if (i >= n) return 0;
  if (pardp[i][lastPairLeft] != -1) return pardp[i][lastPairLeft];

  if (!lastPairLeft) {
    ll sum = a[i + 1];
    return pardp[i][lastPairLeft] = sum + solvePar(i + 2, 0);
  }

  ll left = a[i];
  left += solvePar(i + 2, 1);

  ll right = a[i + 1];
  right += solvePar(i + 2, 0);

  return pardp[i][lastPairLeft] = max(left, right);
}

ll solveImpar(int i) {
  if (i >= n) return 0;
  if (impardp[i] != -1) return impardp[i];

  // not pick
  ll notPick = solvePar(i + 1, 1);

  // pick
  ll pick = a[i];
  pick += solveImpar(i + 2);

  return impardp[i] = max(notPick, pick);
}

void solve() {
  cin >> n;
  rep(i, 0, n) cin >> a[i];

  memset(pardp, -1, sizeof pardp);
  memset(impardp, -1, sizeof impardp);

  if (n % 2 == 1) {
    cout << solveImpar(0) << endl;
  } else {
    cout << solvePar(0, 1) << endl;
  }
}

int(((((((((((((((main)))))))))))))))() {
  FASTIO;
  int n;
  // cin >> n;
  n = 1;
  int i = 1;
  while (n--) {
    solve();
  }
}

/*


00100
00

*/

Measured memory_bytes: 15340
import java.util.Scanner;

public class Main {
	//問題：タテナガ
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		System.out.println("");

		for(int i=0;i<h;i++){
			String s= sc.next();
			System.out.println(s);
			System.out.println(s);
		}
	}
	/*

入力する値↓

9 20
.....***....***.....
....*...*..*...*....
...*.....**.....*...
...*.....*......*...
....*.....*....*....
.....**..*...**.....
.......*..*.*.......
........**.*........
.........**.........


	 */
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  
  for (int i = 0; i < N; i++) cin >> card.at(i);
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int A = 0, B = 0;
  
  for (int i = 0; i < N; i += 2) A += card.at(i);
  for (int i = 1; i < N; i += 2) B += card.at(i);
  
  cout << A - B << endl;
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
const ll mod = 1e9+7;

struct Bitree {
	typedef ll btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};


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

	int n; ll k;
	cin >>n >>k;
	vector<ll> a(n+1);
	rep(i, n){
		ll wa; cin >> wa;
		a[i+1] = a[i] + wa - k;
	}
	Bitree bta(n);
	auto b=a;
	sort(all(b));
	b.erase(unique(all(b)), b.end());
	ll ans =0;
	rep(i,n+1){
		int ix = lower_bound(all(b), a[i]) - b.begin();
		ans += bta.sum(ix);
		bta.add(ix, 1);
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 4992
N,W = map(int,input().split())

w = []
v = []

for i in range(N):
    peso,valor = map(int,input().split())
    w.append(peso)
    v.append(valor)

V = sum(v)

dp = [[W+1] * (V + 1) for i in range(N+1)]
#DP[i][j] = menor peso para obter o i-th item com valor j

dp[0][0] = 0

for i in range(1,N+1):
    for j in range(V + 1):
        if v[i-1] <= j:
            dp[i][j] = min(dp[i-1][j], w[i-1] + dp[i-1][j- v[i-1]])

        else:
            dp[i][j] = dp[i-1][j]

resp = 0

for i in range(V + 1):
    if dp[-1][i] <= W:
        resp = max(i,resp)

print(resp)


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

using namespace std;

int main(){
    string s;
    cin>>s;
    int n = s.length();
    int count = 0;
    for (int i=0; i<n/2; i++){
        if (s[i]!=s[n-1-i]) count++;
    }
    cout<<count;
    return 0;
}

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

union{
  uint8_t *as_uint8;
  char *as_char;
} data;

union{
  uint8_t *as_uint8;
  char *as_char;
} ans;

int i,j,n;
uint8_t S=83,W=87,o=111,x=120;

int test(uint8_t x,uint8_t y){
  ans.as_uint8[0]=x;
  ans.as_uint8[1]=y;
  //  puts(data.as_char);
  for(i=0;i<n;i++){
    ans.as_uint8[i+2]=ans.as_uint8[i]^((ans.as_uint8[i+1]^data.as_uint8[i+1]^4)&4);
  }
  if(ans.as_uint8[n]-x|ans.as_uint8[n+1]-y)return 0;
    ans.as_uint8[n]=0;
    puts(ans.as_char);
    exit(0);  
}

int main(){
  scanf("%d\n",&n);
  data.as_char=malloc(sizeof(char)*(n+1));
  ans.as_char =malloc(sizeof(char)*(n+2));
  fgets(data.as_char,n+1,stdin);
  data.as_uint8[n]=data.as_uint8[0];
  //  printf("%c\n",*(char *)&x);
  test(S,S);
  test(S,W);
  test(W,S);
  test(W,W);
  
  puts("-1");
}

Measured memory_bytes: 512
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h=in.nextInt();
        int a=in.nextInt();
        int ans=h/a;
        if(h%a==0)
            System.out.println(ans);
        else{
            ans++;
            System.out.println(ans);
        }

    }
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	while(sc.hasNext()) {
	int b=sc.nextInt();
	int []a=new int[b];
	for(int i=0;i<b;i++) {
		a[i]=i+1;
	}
	int s=sc.nextInt();
	for(int i=0;i<s;i++) {
		   String str = sc.next();
		   String Str[] = str.split(",");
		   int p = 0,q = 0;
		   for(int l =0;l<Str.length;l++) {
			   p=Integer.parseInt(Str[0])-1;
			   q=Integer.parseInt(Str[1])-1;
			//   System.out.println(p);
			  // System.out.println(q);
		   }
			int temp;
			temp=a[p];
			a[p]=a[q];
			a[q]=temp;

	/*	for(int k=0;k<b;k++) {
			System.out.println(a[k]);
		}*/
	}
	for(int i=0;i<b;i++) {
		System.out.println(a[i]);
	}
}
}
}


Measured memory_bytes: 26312
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;
const int MOD=1e9+7;

const int MAX_N=1e3;

int N,A,B,C,D;

ll fact[MAX_N+1];
ll dp[MAX_N+1][MAX_N+1];

ll mod_pow(ll n,int m){
	ll res=1;
	while(m){
		if (m&1) res=res*n%MOD;
		m>>=1;
		n*=n;
		n%=MOD;
	}
	return res;
}

ll mod_inverse(ll n){
	return mod_pow(n,MOD-2);
}

ll comb(int n,int m){
	return fact[n]*mod_inverse(fact[m]*fact[n-m]%MOD)%MOD;
}

int main(){
	cin>>N>>A>>B>>C>>D;
	fact[0]=1;
	FOR(i,1,N+1){
		fact[i]=fact[i-1]*i%MOD;
	}
	REP(i,N+1) dp[0][i]=1;
	FOR(n,1,N+1){
		FOR(b,A,B+1){
			dp[n][b]=dp[n][b-1];
			for(int g=C;g<=D && n-b*g>=0;g++){
				dp[n][b]+=fact[n]*mod_inverse(mod_pow(fact[b],g)*fact[n-b*g]%MOD*fact[g]%MOD)%MOD*dp[n-b*g][b-1]%MOD;
				dp[n][b]%=MOD;
			}
		}
	}
	printf("%lld\n",dp[N][B]);
	return 0;
	}


Measured memory_bytes: 8064
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <queue>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

string s;

vector<int> a;

int main() {
    cin >> n >> s;

    bool no1 = true;
    for (int i = 1; i < n; i++) {
        int d = abs(s[i] - s[i-1]);
        a.PB(d);

        if (d == 1) {
            no1 = false;
        }
    }

    //PR0(a, n-1);

    if (no1) {
        for (auto& e : a) {
            e /= 2;
        }
    }

    int parity = 0;

    FORN(i, n-1) {
        if (((n-2-i) & i) == 0) {
            parity += a[i];
        }
    }

    if (parity % 2 == 0) {
        cout << 0 << "\n";
    }
    else if (no1) {
        cout << 2 << "\n";
    }
    else {
        cout << 1 << "\n";
    }
}


Measured memory_bytes: 7420
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var s = Console.ReadLine();
        Console.WriteLine(s.Length - Abs(s.Count(x => x == '0') - s.Count(x => x == '1')));
    }
}

Measured memory_bytes: 11616
#include<iostream>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
string b[1000];
int main() {
	string a;
	char s;
	while (cin >> a >> s&&s != 'X') {
		bool l = false;
		for (int i = 0; i < a.length(); i++) {
			if (a[i] == '_') {
				l = true;
				break;
			}
		}
		int sum = 0;
		string h = "";
		if (l) {
			a += "_";
			for (int i = 0; i < a.length(); i++) {
				if (a[i] == '_') {
					b[sum] = h;
					sum++;
					h = "";
				}
				else
					h += a[i];
			}
		}
		else {
			if (a[0] <= 'Z'&&a[0] >= 'A')
				a[0] = (char)(int)a[0] - (int)('A' - 'a');
			a += 'A';
			for (int i = 0; i < a.length(); i++) {
				if (a[i] <= 'Z'&&a[i] >= 'A') {
					b[sum] = h;
					sum++;
					h = "";
					h += (char)((int)a[i] - (int)('A' - 'a'));
				}
				else
					h += a[i];
			}
		}
		switch (s) {
		case 'D':
			for (int i = 0; i < sum; i++) {
				if (i == 0) cout << b[i];
				else cout << "_" << b[i];
			}
			break;
		case 'U':
			for (int i = 0; i < sum; i++) {
				b[i][0] += ('A' - 'a');
				cout << b[i];
			}
			break;
		case 'L':
			for (int i = 0; i < sum; i++) {
				if(i!=0) b[i][0] += ('A' - 'a');
				cout << b[i];
			}
		}
		cout << endl;
	}
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
map<ll, ll> memo;

ll mod_pow(ll base, ll index, ll mod) {
    if(index == 0) return 1LL;
    ll res = mod_pow((base * base) % mod, index / 2, mod);
    if(index & 1) (res *= base) %= mod;
    return res;
}

signed main() {
    cin >> N;
    REP(i, N) {
        LCIN(a);
        if(++memo[a] > 2) {
            cout << 0 << "\n";
            return 0;
        } else if(N % 2 && memo[0] > 1) {
            cout << 0 << "\n";
            return 0;
        }
    }
    cout << mod_pow(2, N / 2, MOD) << "\n";
    return 0;
}


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

struct Point {double x, y;};
struct Square {double left, right, top, bottom;};

bool include(const Square& s, const Point& p) {
  return s.left <= p.x && p.x <= s.right && s.bottom <= p.y && p.y <= s.top;
}

bool ok(const vector<Point>& point, double d) {
  Square A = {point.front().x, point.front().x + d, 0, 0};
  Square B = {point.back().x - d, point.back().x, 0, 0};
  double lowA = 1e9, highA = -1e9;
  double lowB = 1e9, highB = -1e9;
  for(const auto& p: point) {
    if(p.x <= A.right) {
      lowA = std::min(lowA, p.y);
      highA = std::max(highA, p.y);
    }
    if(B.left <= p.x) {
      lowB = std::min(lowB, p.y);
      highB = std::max(highB, p.y);
    }
  }
  A.top = highA;    A.bottom = highA - d;
  B.top = lowB + d; B.bottom = lowB;
  if(all_of(begin(point), end(point), [&](const Point& p){return include(A, p) || include(B, p);})) return true;
  A.top = lowA + d; A.bottom = lowA;
  B.top = highB;    B.bottom = highB - d;
  if(all_of(begin(point), end(point), [&](const Point& p){return include(A, p) || include(B, p);})) return true;
  return false;
}

int main() {
  int N;
  cin >> N;
  vector<Point> point(N);
  for(auto& p: point) cin >> p.x >> p.y;
  for(auto& p: point) p = {p.x / sqrt(2) - p.y / sqrt(2), p.x / sqrt(2) + p.y / sqrt(2)};
  sort(begin(point), end(point), [](const Point& lhs, const Point& rhs){return lhs.x < rhs.x;});
  double low = -1, high = 3e5;
  while(1.0 < high - low) {
    double middle = (low + high) / 2.0;
    ok(point, middle) ? (high = middle) : (low = middle);
  }
  cout << int(high * sqrt(2)) << endl;
}

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

int main () {
  int n, q, a, v;
  priority_queue<pair<int,int> > pq;
  
  cin >> n >> q;
  vector<int> x(n+1, 0);
  for(int i=0; i<q; i++) {
    cin >> a >> v;
    x[a] += v;
    pq.push(make_pair(x[a], -a));
    for(;;) {
      int b = -pq.top().second;
      int w = pq.top().first;
      if(x[b]==w) {
	cout << b << " " << w << endl;
	break;
      }
      pq.pop();
    }
  }
  
  return 0;
}

Measured memory_bytes: 6012
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;		
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b) 
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n;
	ll k;
	cin >> n >> k;
	
	int p = 0;
	ll tk = k;
	while (tk > 0)
		tk >>= 1, p++;
	int m = -1;
	vector<int> a(64);
	for (int i = 0; i < n; i++)
	{
		ll in;
		cin >> in;
		for (int j = 0; in > 0; in >>= 1, j++)
			if (in & 1)
			{
				a[j]++;
				if (j > m)
					m = j;
			}
	}

	ll r = 0;
	ll j = 1;
	for (int i = 0; i < (m > p ? m : p); i++)
		j <<= 1;
	ll now = 0;
	for (ll i = (m > p ? m : p); i >= 0; i--, j >>= 1)
	{
		if (now + j > k)
		{
			if (i <= m)
				r += j * a[i];
			continue;
		}

		if (n > a[i] * 2)
			now += j;
		r += j * (n > a[i] * 2 ? n - a[i] : a[i]);
	}

	printf("%lld", r);

	return 0;
}


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

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N,K;
    cin>>N>>K;
    vector<int> dk(K);
    unordered_set<int> dis;
    for(auto&& d:dk){
        cin>>d;
		dis.insert(d);
	}
    auto check_func=[&](int val){
        while(val > 0){
            if(dis.count(val%10)>0)return false;
            val /= 10;
        }
        return true;
    };
    while(!check_func(N)){ //全探索
		++N;
	}
    cout<<N<<endl;
    return 0;
}

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

int main(){
  string a;
  int s,t,u,ans;
  ans=0;
  s=0;
  t=0;
  cin>>a;
  u=a.size();
  for(int i=0;i<u;i++){
 if(a[i]=='S'){
      s++;
    }
    else {
      t++;
    }
    ans=max(ans,t-s);
    
  }
      cout<<ans*2<<endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll MOD = 1e9+7;
	
ll binPow(ll a, ll p){
	ll ans = 1;
	while(p){
		if(p&1)
			ans=(ans*a)%MOD;
		a = (a*a)%MOD;
		p>>=1;
	}
	return ans;
}

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

	ll n; cin >> n;
	vector<int> v(n);
	for(auto& p: v) cin >> p;

	if(n == 1){
		cout << 2*v[0] %MOD << '\n';
		return 0;
	}

	sort(all(v));

	ll multi = binPow(2, n-2);
	ll aux = 2;
	ll ans = 0;
	for(int i = n-1; i>=0; i--){
		ll add = multi*aux %MOD;
		add = add * v[i] %MOD;
		ans = (ans + add) % MOD;
		aux++;
	}

	multi = binPow(2, n);

	cout << ans*multi%MOD << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


signed main(){

	int A, B, C;
	cin >> A >> B >> C;

	// CはA+B+1まで食べられる
	int c = min(C, A + B + 1);
	cout << B + c << endl;

	return 0;
}


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

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


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

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
    string S; cin >> S;

    map<char,int> cnt;
    for (auto c : S) {
        ++cnt[c];
    }

    if (cnt.size() == 2) {
        bool flag = true;
        for (auto p : cnt) {
            if (p.second != 2) flag = false;
        }
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#ABC62
x, y = map(int, input().split())
if(x==2 or y==2):
    if(x==y):
        print("Yes")
    else:
        print("No")

elif((x==4 or x==6 or x==9 or x==11) or (y==4 or y==6 or y==9 or y==11)):
        if((x==4 or x==6 or x==9 or x==11) and (y==4 or y==6 or y==9 or y==11)):
            print("Yes")
        else:
            print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int n,k,q;cin >> n >> k >> q;
    vint A(q); REP(i,q) cin >> A[i];

    // ｎ人がＫポイントを持っており、q回クイズを行う
    // A[i]が正解した人の番号であり、A[i]以外の人は-1ポイント

    // 出力：最終的にポイントが１以上あればYes、なければNoとして配列Xを出力する
    vint Point(n);
    // REP(i,n) Point.at(i) = 0;
    Point.assign(0,n);

    REP(i,q){
        Point[A[i]-1]++;
    }

    REP(i,n){
        if(Point[i] + k - q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;

    bool judge = true;
    if ( s.at(0) != 'A' ) judge = false;
    if ( s.find('C') != s.rfind('C') || !( s.find('C') >=2 && s.find('C') <= s.size()-2) ){
        judge = false;
    }
    int cnt = 0;
    for ( int i = 0 ; i < s.size(); i++ ){
        if ( islower(s.at(i))) cnt++;
    }
    if (cnt != s.size()-2 ) judge = false;

    string ans;
    if( judge ) ans = "AC";
    else ans = "WA";

    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n = ri()
ls = rils(n)
ls = [(x - l + 0.5, x + l - 0.5) for x, l in ls]
ls.sort(key=lambda x: x[1])
pos = [r for _, r in ls]

dp = collections.defaultdict(int)
prev_r = None
for l, r in ls:
    i = bisect.bisect_left(pos, l)
    if i > 0:
        dp[r] = max(dp[r], dp[pos[i - 1]] + 1)
    else:
        dp[r] = max(dp[r], 1)
    if prev_r:
        dp[r] = max(dp[r], dp[prev_r])
    prev_r = r
print(max(dp.values()))

Measured memory_bytes: 39796
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll r[18];

int main(){
    ll N; cin>>N;
    if(N%2==1) cout<<0<<endl;
    else{
        ll ans=N/10;
        ll r=ans;
        while(r>0){
            r/=5;
            ans+=r;
        }
        cout<<ans<<endl;
    }


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    string a;
    cin>>a;
    int len=a.size();
    for(int i=0;i<len;i++)
    {
        if(a[i]==',')cout<<" ";
        else cout<<a[i];
    }

}






Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>

using namespace std;
int S[100010];
int main(void){
    int n,q,t,ans=0;

    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&S[i]);

    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&t);

        int Min=0,Max=n-1,center;

        for(int j=0;j<18;j++){
            center=(Max+Min)/2;
            if(t>S[center]){
                Min=center;
            }else{
                Max=center;
            }
        }
        if(S[Max]==t)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1596