akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    char crt = s[0];
    FOR(i,1,s.size()) {
        if (s[i] != crt) cnt++;
        crt = s[i];
    }
    print(cnt);
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    int r = 0;
    int rmax = 0;
    for (int i = 0; i < N - 1; i++) {
        // これを最大にしたい
        int a = min(A[i], A[N - 1] - A[i]);

        if (a > rmax) {
            rmax = a;
            r = A[i];
        }
    }

    cout << A[N - 1] << " " << r << endl;
}

Measured memory_bytes: 3748
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    X = input()
    # print(X)

    L = deque([])
    for now in X:
        if not L:
            L.append(now)
            continue

        if now == 'T':
            pre = L.pop()
            if pre == 'S':
                continue
            else:
                L.append(pre)
        L.append(now)

    print(len(L))


if __name__ == '__main__':
    solve()



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

int main(){
	int n;	cin>>n;
	bool flag=true;
	for(int i=0;i<n;i++){
		int a;	cin>>a;
		if(a%2==0){
			if(!(a%3==0||a%5==0)){
				flag=false;
				break;
			}
		}
	}
	if(flag)cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;

	return 0;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8');

const countDivisor = input => {
  const [a, b, c] = input.split(' ').map(Number);

  let count = 0;
  for (let i = a; i < b + 1; i++) {
    if (c % i === 0) {
      count++;
    }
  }

  console.log(count);
};

countDivisor(input);



Measured memory_bytes: 15164
import java.util.Scanner;

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

		int[] data = new int[ 10 ];

		for ( int i = 10; i-- > 0; data[ i ] = stdIn.nextInt() ) ;

		for ( int i = 0; i < 3; i++ ) {
			int max = i;
			for ( int j = 9; j > i; j-- )
				if ( data[ max ] < data[ j ] )
					max = j;

			int tmp = data[ i ];
			System.out.println( data[ i ] = data[ max ] );
			data[ max ] = tmp;
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  set<int> d;
  int tmp;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    d.insert(tmp);
  }
  cout << d.size() << endl;
}

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

char so[1000001];

int main(){
	int n,i,j,count;
	memset(so,0,sizeof(so));
	so[1]=1;
	for(i=2;i<6;i++){
		for(j=2*i;j<=29;j+=i){
			so[j]=1;
		}
	}
	
	for(i=29;i<1000;i+=2){
		if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
		for(j=3*i;j<=1000000;j+=(2*i)){
			so[j]=1;
		}
	}

	while(0<=scanf("%d",&n)){
		if(n==0)break;
		count=0;
		for(i=2;i<29;i++){
			if(2*i>n)break;
			if(n-i==3 || n-i==5 || n-i==7 || n-i==11 || n-i==13 || n-i==17 || n-i==19 || n-i==23 || n-i==29){
				if(so[i]==0){
					++count;
					continue;
				}
			}
			j=i;
			i=n-i;
			if(i%2==0 ||i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		
		for(i=29;2*i<=n;i+=2){
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
			j=i;
			i=n-i;
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		printf("%d\n",count);

	}
	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e9)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)
 
const int mxn = 1*(1e5) + 5;
ll n, m;
 
void solve(){
	cin >> n >> m;
	ll ans=0;
	m *= m;
	for(int i=0; i<n; i++) {
		ll x, y;
		cin>>x>>y;
		if(x*x + y*y <= m) ans++;
	}
	cout<<ans;
}

int main(){
	fast;
	// #ifndef ONLINE_JUDGE 
 //   freopen("input.txt", "r", stdin); 
 //   freopen("output.txt", "w", stdout); 
 //   #endif 
   
	// tt
		solve();
		return 0;
}

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

using namespace std;

int main()
{
	int N , M;
	while(cin >> N >> M , N || M)
	{
		int a = 0 , b = 0 , c = 0 , d = 0;
		map<vector<int> , int>data;
		for(size_t i = 0; i < N; i++)
		{
			string S;
			cin >> S;
			int now = 0;
			while(now < S.size() && S[now] == '.')
			{
				now++;
				d++;
			}
			int memo = 1;
			for(size_t i = 1; i < 20; i++)
			{
				if(a%i == 0 && b%i == 0 && c%i == 0 && d%i == 0)
				{
					memo = i;
				}
			}
			vector<int>memo2 = { a / memo,b / memo,c / memo };
			data[memo2] = d / memo;

			d = 0;
			while(now < S.size())
			{
				switch(S[now])
				{
					case '(':a++; break;
					case ')':a--; break;
					case '{':b++; break;
					case '}':b--; break;
					case '[':c++; break;
					case ']':c--; break;
					default:
						break;
				}
				now++;
			}
		}/*
		cout << "!" << endl;
		for(auto x : data)
		{
			cout << x.first[0] << " " << x.first[1] << " " << x.first[2] << " " << " " << x.second << endl;
		}*/


		//vector<vector<vector<bool>>>candidate(20 , vector<vector<bool>>(20 , vector<bool>(20)));
		vector<vector<int>>xx;
		for(int i = 1; i <= 20; i++)
		{
			for(int j = 1; j <= 20; j++)
			{
				for(int k = 1; k <= 20; k++)
				{
					bool f = 1;
					for(auto x : data)
					{
						if(x.first[0] * i + x.first[1] * j + x.first[2] * k != x.second)
						{
							f = 0;
							break;
						}
					}
					//candidate[i-1][j-1][k-1]=f;
					if(f)xx.push_back(vector<int>{i - 1 , j - 1 , k - 1});
					//if(f)cout << i << " " << j << " " << k << "  " << f << endl;
				}
			}
		}
		/*
		for(auto x : xx)
		{
			for(auto y : x)
			{
				cout << y + 1 << " ";
			}
			cout << endl;
		}*/
		vector<set<int>>ans(M);
		for(size_t i = 0; i < M; i++)
		{
			string S;
			cin >> S;
			int now = 0;
			while(now < S.size() && S[now] == '.')
			{
				now++;
				d++;
			}
			for(auto x : xx)
			{
				ans[i].insert(( x[0] + 1 )*a + ( x[1] + 1 )*b + ( x[2] + 1 )*c);
			}

			d = 0;
			while(now < S.size())
			{
				switch(S[now])
				{
					case '(':a++; break;
					case ')':a--; break;
					case '{':b++; break;
					case '}':b--; break;
					case '[':c++; break;
					case ']':c--; break;
					default:
						break;
				}
				now++;
			}
		}
		for(size_t i = 0; i < M; i++)
		{
			if(ans[i].size() == 1)
			{
				for(auto x : ans[i])
				{
					cout << x;
				}
			} else
			{
				cout << -1;
			}
			if(i==M-1)
			{
				cout<<endl;
			} else
			{
				cout<<" ";
			}
		}
	}
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
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(x) push_back(x)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
// template <typename... Args>
// void dbg(Args... args) {
//     ((cout << args << " "), ...);
//     cout << endl;
// }

//--------------------------------------------------//
vector<pii> Va;
int main() {
    use_cio();
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        Va.push_back({a, b});
    }
    sort(all(Va));
    int prv = -1, cnt = 0, cc = 0;
    for (auto x : Va) {
        int cur = x.first, cut = x.second;
        if (cur == prv) continue;
        //cout << cc << " " << cur << " " << cut << endl;
        if (cc > cut)
            cc = cut;
        else if (cc <= cur) {
            cnt++;
            cc = cut;
        }
        prv = cur;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
#include<iostream>



int main(void){

	int n,i;
	double x[1000], y[1000], z[1000], a[1000],aa[1000],aaa,xa[1000],ya[1000],za[1000];

	a[0] = 3;
	
	double tmp;

	std::cin >> n;
	i = 0;

	for (i = 0; i < n; i++) {
		

		

		std::cin >> x[i];
		std::cin >> y[i];
		std::cin >> z[i];


		if(x[i] < y[i]){

			tmp = y[i];
			y[i] = x[i];
			x[i] = tmp;
			

		}
		if(y[i] < z[i]){

			tmp = z[i];
			z[i] = y[i];
			y[i] = tmp;
			

		}if(x[i] < y[i]){

			tmp = y[i];
			y[i] = x[i];
			x[i] = tmp;
			

		}
		if(y[i] < z[i]){

			tmp = z[i];
			z[i] = y[i];
			y[i] = tmp;
			

		}
		
		
		
		
		ya[i] = y[i] * y[i];
		xa[i] = x[i] * x[i];
		za[i] = z[i] * z[i];
		aaa = ya[i] + za[i];

		if (aaa == xa[i]) aa[i] = 1;
		else aa[i] = 0;	

		

		



	}

	

	for (i = 0; i < n; i++) {

		if(aa[i] == 0)printf("NO\n");
		if(aa[i] == 1)printf("YES\n");

		


	}



	return 0;





}

Measured memory_bytes: 1216
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            StringTokenizer st=new StringTokenizer(br.readLine());
            int h=Integer.parseInt(st.nextToken());
            int w=Integer.parseInt(st.nextToken());
            if(w==0&&h==0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    System.out.print("#");
                }System.out.println();
            }System.out.println();
        }
    }
}

Measured memory_bytes: 30984
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    if (2 * K - 1 > N) {
        cout << -1 << endl;
        return 0;
    }
    ll ansa[N], ansb[N];
    REP(i, 0, (N + 1) / 2) {
        ansa[i * 2] = K + i;
    }
    REP(i, 0, N - (N + 1) / 2) {
        ansa[i * 2 + 1] = K + (N + 1) / 2 + i;
    }
    REP(i, 0, N / 2) {
        ansb[i * 2 + 1] = K + N + i; 
    }
    REP(i, 0, N - (N / 2)) {
        ansb[i * 2] = K + N + N / 2 + i;
    }
    REP(i, 0, N) {
        cout << ansa[i] << " " << ansb[i] << " " << K + 2 * N + i << endl;
    }
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int n,k,has,arr[200005];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>arr[i];
	int l=1,r=1000000000;
	while(l<=r)
	{
		int mid=(l+r)/2,now=k;
		for(int i=1;i<=n;i++)
		{
			if(arr[i]<=mid) continue;
			else 
			{
				now-=arr[i]/mid;
				if(now<0) break;
			}
		}
		//cout<<now<<" "<<mid<<endl;
		if(now<0) l=mid+1;
		else has=mid,r=mid-1;
	}
	cout<<has<<endl;
}

Measured memory_bytes: 4324
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N), F(N);
  ll i,s;
  s = 0;
  for(i=0;i<N;i++){
    cin >> A[i];
    s += A[i];
  }
  if(s<=K){
    cout << 0;
    return 0;
  }
  for(i=0;i<N;i++){
    cin >> F[i];
  }
  sort(A.begin(),A.end());
  sort(F.rbegin(),F.rend());
  ll ok = 1e16;
  ll ng = 0;
  ll mid;
  ll c;
  while(ok-ng > 1){
    mid = (ok + ng) / 2;
    c=0;
    for(i=0;i<N;i++){
      if(A[i]*F[i]>mid){
        c += A[i] - mid/F[i]; 
      }
    }
    if(c>K){
      ng = mid;
    }else{
      ok = mid;
    }
  }
  cout << ok;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int arr[maxn],n,L[maxn];
const int inf=0x3f3f3f3f;
int main()
{
    memset(L,inf,sizeof L);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        *lower_bound(L,L+n,arr[i])=arr[i];
    }
    cout<<lower_bound(L,L+n,inf)-L<<"\n";
}



Measured memory_bytes: 3884
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

char A[1000001];

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


	int N = getint();

	rep(i, N) {
		int a = getint();
		A[a] += A[a] + 1;
	}

	if (A[1]) {
		if (A[1] == 1) co(1);
		else co(0);
		return 0;
	}
	if (A[2]) {
		int kotae = (A[2] == 1);
		for (int i = 3; i <= 500000; i += 2) {
			if (A[i]) {
				kotae += (A[i] == 1);
				for (int j = i + i; j <= 1000000; j += i) {
					A[j] = 0;
				}
			}
		}
		for (int i = 500001; i <= 1000000; i += 2) kotae += (A[i] == 1);
		co(kotae);
		return 0;
	}

	int kotae = 0;
	for (int i = 2; i <= 500000; i++) {
		if (A[i]) {
			kotae += (A[i] == 1);
			for (int j = i + i; j <= 1000000; j += i) {
				A[j] = 0;
			}
		}
	}
	for (int i = 500001; i <= 1000000; i++) kotae += (A[i] == 1);
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 4760
#include<stdio.h>
 
int main(){
 
int a;
scanf("%d",&a);
 
if(a>=64){
printf("64\n");
}else if(a>=32){
printf("32\n");
}else if(a>=16){
printf("16\n");
}else if(a>=8){
printf("8\n");
}else if(a>=4){
printf("4\n");
}else if(a>=2){
printf("2\n");
}else{
printf("1\n");
}
 
 
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll n;
    cin>>n;
    VL arr(n);
    ll first=0;
    bool t=true;
    fr(i,0,n)
    {
        cin>>arr[i];
        if(t)
        {
            first+=arr[i];
        }
        else
        {
            first-=arr[i];
        }
        t=!t;
        arr[i]*=2;
    }
    cout<<first<<" ";
    fr(i,0,n-1)
    {
        cout<<arr[i]-first<<" ";
        first=arr[i]-first;
    }
    cout<<"\n";
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

int main(){
  string s; cin >> s;
  long long cnt = 0,ans = 0;
  
  for(int i = 0; i < s.size() - 1; ++i){
    if(s[i] == 'A') cnt++;
    else if(s[i] == 'B' && s[i+1] == 'C') {
      i++;
      ans += cnt;
    } else cnt = 0;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	long long int sum = 0;
	if(k>a)
	{
		sum += a;
		k -= a;
	}
	else
	{
		sum += k;
		cout << sum << endl;
		return 0;
	}
	if(k>b)
		k -= b;
	else
	{
		cout << sum;
		return 0;
	}
	sum -= k;
	cout << sum;

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <cstring>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <vector>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <cassert>

using namespace std;
using ll = long long;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define nl "\n"

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

	string s;
	cin >> s;
	string a, b;
	for(int i = 0; i < s.size(); i++) {
		if(i % 2 == 0) {
			a += '1';
			b += '0';
		} else {
			a += '0';
			b += '1';
		}
	}
	int cnt1 = 0, cnt2 = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != a[i]) {
			cnt1++;
		}
		if(s[i] != b[i]) {
			cnt2++;
		}
	}
	cout << min(cnt1, cnt2);
}

Measured memory_bytes: 720
import collections
S = list(input())
T = list(input())
S_c = sorted(collections.Counter(S).items(),key=lambda x:x[1])
T_c = sorted(collections.Counter(T).items(),key=lambda x:x[1])

if len(S_c) == len(T_c):
  for i in range(len(S_c)):
    if S_c[i][1] != T_c[i][1]:
      print('No')
      exit()
  else:
    print('Yes')
      
else:
  print('No')

Measured memory_bytes: 6960
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge {
    ll from;
    ll to;
    ll cost;
};

ll V, E, d[1010];
edge es[2010];


bool find_negative_loop() {
    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.from]!=INF&&d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (e.to== V - 1) {
                    return true;
                }
            }
        }
    }
    return false;
}
void shortest_path(ll s){
  rep(i,V)d[i]=INF;
  d[s]=0;
  rep(j,V){
    bool update=false;
    rep(i,E){
      edge e=es[i];
      if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        update=true;
      }
    }
    if(!update)break;
    return;
  }
}
int main(){
  cin>>V>>E;
  rep(i,E){
    ll f,t,c;
    cin>>f>>t>>c;
    es[i].from=f-1;
    es[i].to=t-1;
    es[i].cost=-c;
  }
  shortest_path(0);
  if(find_negative_loop()){
    cout<<"inf"<<endl;
    return 0;
  }
  cout<<-d[V-1]<<endl;
  
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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; }
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n), b(n);
	rep(i, n)cin >> a[i] >> b[i];
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		int x = (b[i] - (ans + a[i]) % b[i]) % b[i];
		ans += x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    count = 0

    if max(A, B) == 1:
        print 1
        return

    num_list = []
    for x in range(1, max(A, B) + 1):
        if A%x == 0 and B%x == 0:
            num_list.append(x)
    num_list.sort(reverse = True)
    print num_list[K - 1]

if __name__ == '__main__':
    main()


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

int main()
{
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		ans += 2 * min(abs(t), abs(t - k));
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
K, S = map(int, input().split())
wariate = 0

for x in range(0, K + 1):
    if S - x <= K:
        wariate += max(S - x + 1, 0)
    else:
        wariate += max(0, 2 * K - (S - x) + 1)

print(wariate)

Measured memory_bytes: 3064
n = int(input())
for i in range(n):
    no = 0
    np = 0
    tm = 0
    while(True):
        s = input()
        if s == "HIT":
            tm += 1
            if tm >= 4:
                np += 1
                tm = 3
        if s == "HOMERUN":
            np += tm +1
            tm = 0
        if s == "OUT":
            no += 1
        if no >= 3:
            print(np)
            break


Measured memory_bytes: 5588
/**
 * Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define psb push_back
template<class T> T read() { T x; cin >> x; return x; }
typedef long long ll;
#define wyzi() read<int>()

const int maxN = 1000001;

int a[maxN], b[maxN], c[maxN];

int main() {
  vector<int> ans;
  fore(i, 1, 9) fore(j, 1, 9) ans.psb(i * j);
  puts((find(ans.begin(), ans.end(), wyzi()) != ans.end()) ? "Yes" : "No");
}


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

int main(){
  int a[3];
  for (int i = 0; i <3; i++){
    cin >> a[i];
  }
  int m,n;
  m=max(a[0], max(a[1],a[2]));
  n=min(a[0], min(a[1],a[2]));
        
   cout << m-n << endl;     
        
        
  return 0; 
}

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

const int MaxN = 100050;

char c[MaxN];
int ans, p, g, N;

int main()
{
	scanf("%s",c);
	N = strlen(c);
	for(int i = 0; i < N; ++ i)
		if(c[i] == 'g')
		{
			if(p + 1 <= g)	++ ans, ++ p;
			else ++ g;
		}
		else
		{
			if(p + 1 <= g) ++ p;
			else ++ g, -- ans;
		}
	cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
ll negmd(ll a,ll n){
	return (n+(a%n))%n;
}
ll modexp(ll x,ll n,ll m)
{
	if(n == 0) return 1;
	else if(n & 1)
	{
		return ((x % m) * modexp(x,n - 1,m))%m;
	}
	else
	{
		ll y = modexp(x,n/2,m);
		return (y * y)%m;
	}
	
}
void Compute(ll n)
{
	KAKA
	string s;
	cin>>s;
	ll popc = 0;
	ll a = 0,b = 0,c = 0;
	popc = count(s.begin(),s.end(),'1');
	ll rem1 = popc,rem2 = popc - 1,rem3 = popc + 1;
	pragi(0,n)
	{
		if(s[i] == '1'){
		if(rem1) a = ((a % rem1) + (modexp(2,n - i - 1,rem1)))%rem1;
		if(rem2) b = ((b % rem2) + (modexp(2,n - i - 1,rem2)))%rem2;
		if(rem3) c = ((c % rem3) + (modexp(2,n - i - 1,rem3)))%rem3;}
	}
	//cout<<a<<" "<<b<<" "<<c<<"\n";
	pragi(0,n)
	{
		//ith bit is inverted
		
		ll num = 0;
		ll steps = 0;
		if(s[i] == '0')
		{
			num = (c + modexp(2,n - i - 1,rem3))%rem3;
			steps++;
		}
		else if((s[i] == '1') and (popc > 1))
		{
			num = (b - modexp(2,n - i - 1,rem2));
			if(num >= 0) num %= rem2;
			else num = negmd(num,rem2);
			steps++;
		}
		else if((s[i] == '1') and (popc == 1))
		{
			cout<<0<<"\n";
			continue;
		}
		//ll steps = 1;
		//cout<<num<<"\n";
		while(num > 0)
		{
          ll pc = __builtin_popcountll(num);
          num %= pc;
		  steps++;
		}
		cout<<steps<<"\n";
	}
}
int main()
{
	KAKA
	ll n;
	cin>>n;
	Compute(n);
}

Measured memory_bytes: 3784
#AGC047-A Integer Product
"""
小数または整数が与えられるので、その積が整数となるペアの個数を求めよ。

まず入力に10**9をかけることで、
問題を「その積が10**18の倍数となるペアの個数を求めよ」
とする。
その場合、とりあえず10**18を素因数分解すると2**18と5**18なので、
片方が因数分解済みであるとした時に、
dp[i][j] : 2**iかつ5**jの個数
として、もう片方を2**aかつ5**bであると考えた時に、
2**(i+a)>=18かつ5**(j+b)>=18となるならば、それは条件を満たす
と考えられる。

よってこの個数を数えることで問題が解けた。
"""
import sys
from decimal import Decimal
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())

dp = [[0]*100 for _ in range(100)]

ans = 0

for i in range(n):
    s = readline().rstrip().decode('utf-8')
    res = int(Decimal(s)*(10**9))
    t,f = 0,0
    while True:
        if res%2==0:
            res //= 2
            t += 1
        else:
            break
    while True:
        if res%5==0:
            res //= 5
            f += 1
        else:
            break
    #i+t>=18かつj+f>=18であるような場所からカウント
    for i in range(18-t,45):
        for j in range(18-f,20):
            ans += dp[i][j]
    dp[t][f] += 1

print(ans)

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, K;
	cin >> N >> K;

	ll tmp = N / K;

	ll ans1 = N - tmp * K;
	ll ans2 = abs(N - (tmp+1) * K);

	cout << min(ans1, ans2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int i,n,a[100010],j;
    long long ans;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    ans += a[0]-1;
    j = 2;
    for(i=1;i<n;i++){
        ans += (a[i]-1)/j;
        if(a[i]==j){
            j++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for(int i=A; i<=min(B,A+K-1); ++i){
        cout << i << endl;
    }
    for (int i = max(B - K + 1, A + K); i<=B; ++i){
        cout << i << endl;
    }

        return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

struct Edge {
    int to;
    int color;
};

vector<pair<int, int>> input;
vector<vector<struct Edge>> edges;

void solve(int cur, int prev, int prev_color, const int color_kinds, const int N) {
    int color = 1;
    for (auto &edge : edges[cur]) {
        if (edge.to == prev) continue;
        if (color == prev_color) color++;
        assert(color <= color_kinds);
        edge.color = color;
        solve(edge.to, cur, color, color_kinds, N);
        color++;
    }
}

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

    edges.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back({b, -1});
        edges[b].push_back({a, -1});
        input.push_back({a, b});
    }

    int required_colors = 0;
    for (int i = 0; i < N; i++) {
        chmax(required_colors, (int) edges[i].size());
    }
    cout << required_colors << endl;

    solve(0, -1, -1, required_colors, N);

    map<pair<int, int>, int> ans;
    for (int i = 0; i < (int) edges.size(); i++) {
        for (int j = 0; j < (int) edges[i].size(); j++) {
            ans[{i, edges[i][j].to}] = edges[i][j].color;
        }
    }

    for (auto &p : input) {
        cout << ans[p] << endl;
    }

    return 0;
}


Measured memory_bytes: 19828
using System;

class Program
{
  static void Main(string[] args)
  {
    string S = Console.ReadLine();

    int posA = 0;
    while (S[posA] != 'A') ++posA;

    int posZ = S.Length - 1;
    while (S[posZ] != 'Z') --posZ;

    Console.WriteLine(posZ - posA + 1);
  }
}


Measured memory_bytes: 13180
n = gets.to_i
kura = (1..n).map{gets.split.map &:to_i}

route = {}
(0..n-1).each {|i| route[[1 << i, i]] = [i] }

cost = Array.new(2**n).map{[Float::INFINITY] * n}
(0..n-1).each {|i| cost[1 << i][i] = 0 }

weight = Array.new(2 ** n, 0)
(0..n-1).each {|i| weight[1 << i] = kura[i][2] * 20}

(1..2**n-1).each do |x|
	ones = (0..n-1).select{|i| x[i] == 1}
	zeros = (0..n-1).to_a - ones
	v = 2000.0 / (70 + weight[x])
	ones.each do |i|
		key1 = [x, i]
		c0 = cost[x][i]
		d0 = kura[i][1]
		w = weight[x]
		zeros.each do |j|
			y = x | (1 << j)
			weight[y] = w + kura[j][2] * 20
			c = c0 + (kura[j][1] - d0).abs / v
			key2 = [y, j]
			if c < cost[y][j]
				cost[y][j] = c 
				route[key2] = route[key1] + [j]
			end
		end
	end
end

puts route[[2**n-1, (0..n-1).min_by{|i| cost[2**n-1][i]}]].map{|i| kura[i][0]} * ' '

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

using namespace std;

int main()
{
    int N,a = 0;
    long A,O[100];
    vector<long> v;
    cin >> N;

    while (cin >> A)
    {
        O[a] = A;
        v.push_back(O[a]);
        a++;
    }

    sort(v.begin(),v.end());

    cout << v[v.size() - 1 ] -v[0];

}

Measured memory_bytes: 3592
x = list(map(int, input().split()))
insts = input()
for inst in insts:
    if inst == 'N':
        x = [x[1], x[5], x[2], x[3], x[0], x[4]]
    elif inst == 'E':
        x = [x[3], x[1], x[0], x[5], x[4], x[2]]
    elif inst == 'S':
        x = [x[4], x[0], x[2], x[3], x[5], x[1]]
    elif inst == 'W':
        x = [x[2], x[1], x[5], x[0], x[4], x[3]]
print(x[0])

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

using namespace std;

int main(int argc, char *argv[]) {
    int a, b, k;
    cin >> a >> b >> k;

    int l = 0;
    vector<int> arr;
    for (int i = 1; i <= max(a, b); i++) {
        if (a % i == 0 && b % i == 0) {
            arr.push_back(i);
        }
    }

    sort(arr.begin(), arr.end(), greater<int>());

    int ans = 0;
    for (int j = 0; j < arr.size(); j++) {
        if (j + 1 == k) {
            ans = arr[j];
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define i64 long long
#define inf 1000000000000000000
using namespace std;
i64 ara[100009];


i64 n;
i64 f(i64 mid)
{
    for(i64 i=0; i<n; i++)
    {
        mid= (mid/ara[i])*ara[i];
        //printf("%d / %lld *%d\n",mid,ara[i],ara[i]);

    }

    return mid;

}


int main()

{


    scanf("%lld",&n);
    for(i64 i=0; i<n; i++)
        scanf("%lld",&ara[i]);




    i64 lo=1,hi=1000000000000000000,cnt=0,mid,res1,res2;


    while(cnt++<70)
    {
        mid=(lo+hi)/2;

        if(f(mid)>=2)
            hi=mid;
        else lo=mid;

    }

    if(f(mid)<2) mid++;


    if(f(mid)!=2)
    {
        res1=-1;
    }
    else res1=mid;


    lo=1,hi=1000000000000000000,cnt=0,mid=0;


    while(cnt++<70)
    {
        mid=(lo+hi)/2;

        if(f(mid)>2)
            hi=mid;
        else lo=mid;

    }

    if(f(mid)<2) mid++;

    if(f(mid)!=2)
    {
        res2=-1;
    }
    else
        res2=mid;


    if(res1==-1 || res2==-1)
        printf("-1\n");
    else
        printf("%lld %lld\n",res1,res2);


}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

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

bool prime_check(ll p){
    for(ll i=2; i<=sqrt(p); i++){
        if(p%i == 0){
            return false;
        }
    }
    return true;
}

int main()
{
    ll P;
    cin >> P;
    
    while(1){
        if(prime_check(P)){
            cout << P << endl;
            break;
        }
        else{
            P++;
        }
    }
    return 0;
}

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

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 7028
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0
for i in 0...n do
  if a[i] >= b[i]
    count += b[i]
    a[i] -= b[i]
  else
    count += a[i]
    bb = b[i] - a[i]
    a[i] = 0
    if a[i + 1] >= bb
      count += bb
      a[i + 1] -= bb
    else
      count += a[i + 1]
      a[i + 1] = 0
    end
  end
end
puts count


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

template<typename t>void chkmin(t&a,t b){if(a>b)a=b;}

typedef long long ll;
const int maxn=1e5+10;
int n,t,e,x[maxn],endd=0;
ll dp[maxn],val=1e18;

int main(){
	cin>>n>>e>>t;
	for(int i=1;i<=n;++i){
		dp[i]=1e18;
		cin>>x[i];
		while(endd<i&&2*(x[i]-x[endd+1])>=t)
			chkmin(val,dp[endd]-2*x[endd+1]),++endd;
		chkmin(dp[i],val+2*x[i]);
		if(endd<i)
			chkmin(dp[i],dp[endd]+t);
	}
	printf("%lld\n",dp[n]+e);
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int get(int n,int k){
	if(n<k)return 0;
	if(n%k==0)return n/k;
	int o=n%k-1,s=n/k+1;
	return get(n-(o/s+1)*s,k);
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int qwq=gi(),XOR=0;
	while(qwq--){
		int n=gi(),k=gi();
		XOR^=get(n,k);
	}
	puts(XOR?"Takahashi":"Aoki");
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void) {
    int p, q, r, min=300;
    scanf("%d%d%d", &p, &q, &r);
    if(p+q<=min)
        min=(p+q);
    if(p+r<=min)
        min=(p+r);
    if(q+r<=min)
        min=(q+r);
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int q = 0;
    cin>>q;
    int *T = new int[q+1];
    for(int j=0;j<q;j++)
        cin>>T[j];

    int n = 0;
    cin>>n;
    int *S = new int[n];
    for(int i=0;i<n;i++)
        cin>>S[i];

    int num = 0;
    for(int i = 0;i<n;i++)
    {
        T[q+1] = S[i];
        int j = 0;
        while(S[i] != T[j])
            j++;
        if(j != q+1 )
            num++;
    }
    cout<<num<<endl;
    return 0;
}



Measured memory_bytes: 3136
//
// Created by yuu on 2019-08-18.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>

using namespace std;


int main(void){
    int a;
    cin>>a;
    string s;
    cin>>s;
    
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 764
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            //System.Threading.Thread.Sleep(3000);
        }

        public void Solve(ConsoleInput cin)
        {
            int N = cin.ReadInt;
            int x = cin.ReadInt;
            int[] list = cin.ReadIntArray(N);

            int sum = list.Sum();
            int cnt = N + ((x - sum) / list.Min());

            Console.WriteLine(cnt);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,K,R,S,P;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  vector<char> A(K,'a');
  int k=0;
  for(int i=0;i<N;i++){
    if(A[i%K]!=T[i]){
      A[i%K]=T[i];
      if(T[i]=='r')
        k+=P;
      else if(T[i]=='s')
        k+=R;
      else
        k+=S;
    }else
      A[i%K]='a';
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    x -= a;

    cout << x - x / b * b << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N,M;
int num[5001];
int dp[5001][5001];
bool flag;
int ans;
int l, r,current;

int main() {
	cin >> N >> M;
	l = 0;
	r = N+1;
	for (int i = 1; i <= N; i++)cin >> num[i];

	stable_sort(num, num + N + 1);
//	for (int i = 0; i <= N; i++)cout << num[i] << endl;

	while(r-1!=l){
		current = (r + l + 1) / 2;
		for (int j = 1; j <= N; j++) {
			for (int k = 0; k <= N; k++) {
				dp[j][k] = 0;
			}
		}
		dp[0][0] = 1;
		for (int j = 1; j <= N; j++) {
			for (int k = 0; k < M; k++) {
				dp[j][k] = dp[j - 1][k];
			}
			if(j!=current) {
				for (int k = num[j]; k < M; k++) {
					dp[j][k] += dp[j - 1][k - num[j]];
					if (dp[j][k])dp[j][k] = 1;
				}
			}
		}
		flag = true;
		for (int j = max(0, M - num[current]); j < M; j++) {
			if (dp[N][j])flag = false;
		}
		if (flag)l=current;
		else r = current;
	//	cout << l << " " << r << endl;
	}
	cout << l << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        auto ss = s;
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                ss[j][k] = s[(i + j) % n][k];
            }
        }
        bool ok = true;
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                ok &= ss[j][k] == ss[k][j];
            }
        }
        cnt += ok;
    }
    cout << cnt * n << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

char arr[6][6];
int n, m, k;
int check(int row, int col)
{
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (arr[i][j] == '#' and ((1 << i)&row) && ((1 << j)&col))
			{
				cnt++;
			}
		}
	}
	return (cnt == k);
}

void solve()
{
	cin >> n >> m >> k;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> arr[i][j];

	int ans = 0;
	for (int i = 0; i < (1 << n); i++)
	{
		for (int j = 0; j < (1 << m); j++)
		{
			ans += check(i, j);
		}
	}
	cout << ans;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }



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

  ll N;
  std::cin >> N;

  ll ans = 0;
  ll n = N;
  while (n > 0) {
    if (n % 10 == 2) {
      ans++;
    }
    n /= 10;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256