akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		string s;
		cin >> s;

		static string let[] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
		string res;
		char button = '0';
		int n = 0;
		for (int i = 0; i < s.size(); ++i)
		{
			if (s[i] == '0')
			{
				if (button != '0')
				{
					string& t = let[button - '0'];
					res += t[(n - 1) % t.size()];
				}

				n = 0;
			}
			else
				++n;

			button = s[i];
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
/**
 *	author:		Yoseph Weissman
 *	created:	17.06.2020 09:53:33
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	int sum = a1+a2+a3;
	if (sum >= 22)
		cout << "bust\n";
	else
		cout << "win\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h(vector<int> &height, vector<int> &dp, int num){
	int n = height.size();
	int tempsum = INT_MAX - 1000;
	int minsum = 0;
	if(n == 1)
	return 0;
	else if(n == 2)
	return abs(height[1]-height[0]);
	//else if(n == 3)
	//return min(abs(height[2] - height[1]) + dp[1], abs(height[2] - height[0]) + dp[0]);
	else
	dp[0] = 0;
	dp[1] = abs(height[1] - height[0]);
	//dp[2] = min(abs(height[2] - height[1]) + dp[1], abs(height[2] - height[0]) + dp[0]);
	for(int k = 2; k < n; k++){
		tempsum = INT_MAX - 10000;
		if(k < num){
		    for(int l = 0; l < k; l++){
                        minsum = abs(height[k] - height[k-l-1]) + dp[k-l-1];
                       // printf("Minsum in first loop for k less num is %d %d\n", k, minsum);
		        if(tempsum>=minsum)
		        tempsum = minsum;
		        else
		        tempsum = tempsum;}
		   // printf("Minsum in first loop for k less num is %d %d\n", k, minsum);
		    dp[k] = tempsum;}
		    //printf("Minsum in first loop for k less num is %d %d\n", k, minsum);}
		else{
		for(int j = 0; j < num; j++){
                   minsum = abs(height[k] - height[k-j-1]) + dp[k-j-1];
		  // printf("Minsum in second loop is %d\n",minsum); 
		   if(tempsum >= minsum)
		   tempsum = minsum;
		   else if(minsum > tempsum)
		   tempsum = tempsum;	   

		}
	//	printf("Minsum in second loop for k geq num is %d  %d\n", k, minsum);
		dp[k] = tempsum;}
		
	}
       //cout << dp[n-1] << endl;
       return dp[n-1];

}


int main(){

	int n,no;
        cin >> n >> no; 
	vector<int> height(n);
        for(int i = 0; i< n; i++)
		cin >> height[i];
	vector<int> height_dp(n,-1);
	int val = h(height, height_dp, no);
        cout << val << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    c[n - 1] = 1;
    for (int i = n - 2; i >= 0; i--) {
        if (a[i] < a[i + 1]) {
            c[i] = c[i + 1] + 1;
        } else {
            c[i] = 1;
        }
    }
    set<int> st;
    int res = 1;
    for (int i = 0; i < k; i++) {
        st.insert(a[i]);
    }
    int co = (c[0] >= k);
    for (int i = 1; i <= n - k; i++) {
        int f1 = ((*st.begin()) == a[i - 1]);
        st.erase(a[i - 1]);
        st.insert(a[i + k - 1]);
        auto it = st.end();
        --it;
        int f2 = ((*it) == a[i + k - 1]);
        if (f1 && f2) {
            co += (c[i] >= k);
            continue;
        }
        if (co > 0 && c[i] >= k) {
            continue;
        }
        co += (c[i] >= k);
        res++;
    }
    cout << res << endl;
}

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

using namespace std;

const int N = 1e2 + 8;
int n , w , h , c[N][N] , k , a[N * N];

int main()
{
	cin >> h >> w >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i];
	for(int i = 0 ; i < h ; i++)
	{
		if(i % 2)
		{
			for(int j = 0 ; j < w ; j++)
			{
				if(a[k])
					c[i][j] = k , a[k]--;
				else
					k++ , j--;
			}
		}
		else
		{
			for(int j = w - 1 ; j >= 0 ; j--)
			{
				if(a[k])
					c[i][j] = k , a[k]--;
				else
					k++ , j++;
			}
		}
	}
	for(int i = 0 ; i < h ; i++)
	{
		for(int j = 0 ; j < w ; j++)
			cout << c[i][j] + 1 << " ";
		cout << endl;
	}
}

Measured memory_bytes: 384
N = int(input())
lstA = list(map(int,input().split()))
lstB = list(map(int,input().split()))
lstC = list(map(int,input().split()))

plusC = 0
for i in range(len(lstA)-1):
    if (lstA[i] == N ):
        continue
    elif ( lstA[i] + 1 == lstA[i+1]):
        plusC += lstC[lstA[i]-1]
        #minusC = lstC[lstA[N-1]-1]

print (sum(lstB) + plusC )



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
const ll ex = -100000;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/

ll n,k,s;
std::vector<ll> ans;
int main(){
  cin >> n >> k >> s;
  ans.resize(n);
  for (size_t i = 0; i <= k-1; i++) {
    ans[i] = s;
  }
  for (size_t i = k; i < n; i++) {
    ans[i] = (s != 1000000000 ? s+1 : 1);
  }
  for (size_t i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer a=nil->next;
  while(1){
    if(a==nil) return NULL;
    else if(a->key==key) return a;
    a=a->next;
  }
  return NULL;
 
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  t->next->prev=t->prev;
  t->prev->next=t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer a=nil->prev;
  if(a==nil) return;
  deleteNode(a);
}

void delete(int key){
  /* your code */
  NodePointer a;
  a=listSearch(key);
  if(a==NULL){
    return;
  }
  a->prev->next=a->next;
  a->next->prev=a->prev;
  free(a);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /*your code*/
  x->next=nil->next;
  x->prev=nil;
  nil->next=x;
  x->next->prev=x;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  string X;
  cin>>X;
  
  stack<char> S;
  
  for(int i=0; i<X.size(); ++i){
    if(X.at(i)=='S') S.push('S');
    else{
      if(S.empty()) S.push('T');
      else if(S.top()=='S') S.pop();
      else S.push('T');
    }
  }
  
  cout<<S.size()<<endl;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, m;
  cin >> n >> m;
  if (m % n == 0) {
    cout << m / n << endl;
    return;
  }
  vector<int> dv;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      dv.push_back(i);
      if (i * i != m) {
        dv.push_back(m / i);
      }
    }
  }
  sort(dv.begin(), dv.end(), greater<int>());
  dump(dv);
  int ans = 0;
  rep(i, dv.size()) {
    if (m / n >= dv[i]) {
      ans = dv[i];
      break;
    }
  }
  dump(ans);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;



int main()
{
  fastio();

ll int T=1;
//cin>>T;
while(T--)
{
  ll int a,b,c,n,m,k,ans,cnt;
  ans=0;cnt=0;
  cin>>a>>b>>c;

  if(  (a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a) )
      cout<<"Yes"<<endl;
  else
      cout<<"No"<<endl;
}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

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

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

int h, n;

int main() {
    cin >> h >> n;
    REP (i, n) {
        int a;
        cin >> a;
        h -= a;
    }
    if (h > 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define istream ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define uint unsigned int
#define mod 1000000007
#define vec vector<int>
#define twod vector<vector<int>>
#define mp make_pair
#define pbc push_back
#define all(a) a.begin(),a.end()
#define debug1(x)                cout<<#x<<"="<<x<<endl;
#define debug2(x,y)              cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define debug3(x,y,z)            cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define debug4(x,y,z,w)          cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define debugarray(arr,j,n)      for(int i=j;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";};

int32_t main()
{
     int n;
     cin>>n;
     twod grid(n, vec (3,0));
     for(int i=0;i<n;i++){
          int t1,t2,t3;
          cin>>t1>>t2>>t3;
          grid[i][0] = t1;
          grid[i][1] = t2;
          grid[i][2] = t3;
     }
     for(int i=1;i<n;i++){
          grid[i][0] += max(grid[i-1][1],grid[i-1][2]);
          grid[i][1] += max(grid[i-1][0],grid[i-1][2]);
          grid[i][2] += max(grid[i-1][0],grid[i-1][1]);
     }
     cout<<*max_element(grid[n-1].begin(), grid[n-1].end());
     return 0;
}


Measured memory_bytes: 8732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M, S, T;
    cin >> N >> M >> S >> T;
    S--, T--;
    vector<vector<pii>> g(N);
    REP(i, M) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--;
        g[a].push_back({b, d});
        g[b].push_back({a, d});
        g[a].push_back({c, d});
        g[c].push_back({a, d});
        g[b].push_back({c, d});
        g[c].push_back({b, d});
    }
    heap<pii> hp;
    vector<int> dist(N, INF);
    dist[S] = 0;
    hp.push({0, S});
    while (!hp.empty()) {
        int v = hp.top().second; hp.pop();
        FORE(e, g[v]) {
            int w = e.first;
            int c = e.second;
            if (chmin(dist[w], dist[v] + c)) {
                hp.push({dist[w], w});
            }
        }
    }
    cout << dist[T] << endl;
    return 0;
}




Measured memory_bytes: 23624
// AtCoder150 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>
#include <ctype.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

int main(void)
{
    int i,j,n;
    long long int h;
    long long int cnt = 0;
    long long int plus = 1;


    scanf("%lld", &h);
    while(h > 0){
        h = h / 2;
        cnt += plus;
        plus *= 2;
    }

    printf("%lld", cnt);

    return 0;

}


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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);

int s_asorts(const void* a, const void* b);


int main(void) {
	int N, A[101],i,j,a=0,b=0;
	
	i_cin(N); 
	i_cins(N,A);
	qsort(A, N, sizeof(int), s_dsort);

	for(i=0;i<N;i+=2)
	{
		a += A[i];
		if ((i + 1) < N) b += A[i + 1];
	}
	i_cout(a -= b);

	return 0;
}
	
//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

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

int main() {
	int a,b,c,d,r,l;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	l = a + b;
	r = c + d;
	if(l>r)printf("%s","Left");
	else if(l<r)printf("%s","Right");
	else printf("%s","Balanced");
	// your code goes here
	return 0;
}

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

using namespace std;

    int g(int n){
        int p = 0;
        bool is_prime[n + 1];
        is_prime[0] = is_prime[1] = false;

        for(int i = 2 ; i <= n ; i++)
            is_prime[i] = true;

        for(int i = 2 ; i <= n ; i++){
            if(is_prime[i]){
                p++;
                for(int j = i * 2 ; j <= n ; j += i) // j = i * 2 like 2 started form 4 then add 2 each time j += i not j * 2
                    is_prime[j] = false;
            }
        }
    return p;
}

int main(){
    int n;

    while(cin >> n){
        cout << g(n) << endl;
    }

}


Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;
void solve(){
  int h, w, n; cin >> h >> w >> n;
  vector<int> a(n + 1);
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  vector<vector<int> > c(h, vector<int>(w));
  int cnt = 0, num = 1;
  for(int i = 0; i < h; i++){
    if(i % 2 == 0){
      for(int j = 0; j < w; j++){
        c[i][j] = num;
        cnt++;
        if(a[num] <= cnt){
          num++;
          cnt = 0;
        }
      }

    }
    else{
      for(int j = w - 1; j >= 0; j--){
        c[i][j] = num;
        cnt++;
        if(a[num] <= cnt){
          num++;
          cnt = 0;
        }
      }
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << c[i][j] << " ";
    }
    cout << endl;
  }
  return;
}

int main(){
  solve();
  return 0;
}


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

struct item {
	int v;
	int w;
	char t;
	long long int d;
	string s;
};

int main(){
	int n;
	cin >> n;
	vector< item > a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].v >> a[i].w >> a[i].t >> a[i].d >> a[i].s;
	}
	sort(a.begin(), a.end(), [](item a, item b) {
		return a.v != b.v ? a.v < b.v :
			a.w != b.w ? a.w < b.w :
			a.t != b.t ? a.t < b.t :
			a.d != b.d ? a.d < b.d :
			a.s < b.s;
	});
	for (int i = 0; i < n; i++) cout << a[i].v << " " << a[i].w << " " << a[i].t << " " << a[i].d << " " << a[i].s << endl;
	return 0;
}


Measured memory_bytes: 12204
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define   ull unsigned long long 
#define pb push_back
const int MAX=2e5+9;
const long long mod=1e9+7;
using namespace std;
vector<int>adj[MAX];
ll dp[MAX][10][13];
int main(){
	int n ;
	vector<int>v;
	int k;
	cin>>n>>k;
	for(int i=1;i<n;i++){
		v.push_back(k-i);
		v.push_back(k+i);
	}
	v.push_back(k);
	sort(v.begin(), v.end());
	for(int i=0;i<v.size();i++)
		cout<<v[i]<<" ";
}

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

int isfa(string);
int isfb(string);

int main(){
  int n,fa,fb;
  string str;
  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> str;
    if(str.size()>5){
      fa = isfa(str);
      fb = isfb(str);
    }else fa=fb=0;

    if(fa == 1)
       cout << "A" << endl;
    else if(fb == 1)
      cout << "B" << endl;
    else 
      cout << "NA" << endl;
  }
  return 0;
}

int isfa(string n){
  int pos,c1,c2;
  c1=c2=0;
  pos=n.size()-1;
  if(n[0]!='>')return 0;
  if(n[1]!='\'')return 0;
  if(n[pos]!='~')return 0;
  pos--;
  while(n[pos]=='='){
    c1++;
    pos--;
  }
  if(n[pos]!='#')return 0;
  pos--;
  while(n[pos]=='='){
    c2++;
    pos--;
  }
  if(c1!=c2)return 0;
  if(pos!=1)return 0;

  return 1;
}

int isfb(string n){
  int pos;
  pos = n.size()-1;
  if(n[pos]!='~'||n[pos-1]!='~')
    return 0;
  if(n[0]!='>'||n[1]!='^')return 0;
  pos -= 2;
  while(n[pos]=='='&&n[pos-1]=='Q')pos-=2;
  if(pos!=1)return 0;
  return 1;
}



  

Measured memory_bytes: 0
N = int(input())
ranges = []
for _ in range(N):
    x, l = map(int, input().split())
    ranges.append([x + l, x - l])
ranges.sort()

sx = ranges[0][0]
ans = 1
for i in range(N):
    if sx <= ranges[i][1]:
        ans += 1
        sx = ranges[i][0]
print(ans)


Measured memory_bytes: 58968
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
typedef pair<int,int> P;

int main(){
    int n; cin >> n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        int a,b; cin >> a >> b;
        v[i]=make_pair(b,a);
    }
    sort(v.begin(),v.end());
    int time = 0; bool flag=true;
    for(int i=0;i<n;i++){
        time+=v[i].second;
        if(time<=v[i].first){
            flag = true;
            continue;
        }else{
            flag = false;
            break;
        }
    }
    if(flag==true){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
}



    

Measured memory_bytes: 1792
N, M = map(int, input().split())
p = list(map(int, input().split()))


class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            return


G = unionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    G.unite(x, y)

ans = 0
for i in range(N):
    if G.same(p[i]-1, i):
        ans += 1

print(ans)


Measured memory_bytes: 13812
inf=10**8
a,b,c,d,e,f=map(int,input().split())
a,b=100*a,100*b
DP=[inf]*(f+max(a,b)+1)
DP[a],DP[b]=0,0

for i in range(f+1):
    if DP[i]!=inf:
        DP[i+a]=DP[i]
        DP[i+b]=DP[i]
        for j in c,d:
            if 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
                DP[i+j]=max(DP[i],DP[i]+j)

ans,index=0,[a,0]
for i in range(f+1):
    if DP[i]!=inf:
        if ans<100*DP[i]/i:
            ans=100*DP[i]/i
            index=[i,DP[i]]

print(*index)

Measured memory_bytes: 40304
#include <stdio.h>
#include <stdlib.h>
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)
#define QSIZE 300010
int que[QSIZE + 5];
int qsize;

void max_heapify(int i)
{
	int l, r, max;
	int qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l] > que[i]) 
	{
		max = l;
	}
	else{
		max = i;
	}
	if (r < qsize && que[r] > que[max]) max = r;
	if (max != i) 
	{
		qt = que[i];
		que[i] = que[max];
		que[max] = qt;
		max_heapify(max);
	}
}

void deq()
{
	que[0] = que[--qsize];
	max_heapify(0);
}

void enq(int c)
{
	int i, max;
	int qt;

	i = qsize++;
	que[i] = c;
	while (i > 0 && que[max = PARENT(i)] < que[i]) 
	{
		qt = que[i]; 
		que[i] = que[max];
		que[max] = qt;
		i = max;
	}
}

int c[300010];
int top[300010], sz[300010]; int N;

int main()
{
	int i, k, M;
	unsigned ans;

    scanf("%d", &N);//乗り場
	k = 0;
	for (i = 0; i < N; i++) 
	{
	    scanf("%d", &M);//人数
		sz[i] = M;
		top[i] = k;//先頭
		while (M--) scanf("%d", &c[k++]);//M人分人を並べる
	}
	
	ans = 0;//最大値
	qsize = 0;
	for (i = N - 1; i >= 0; i--) {
		M = sz[i];//その乗り場の人数を再格納
		k = top[i];//その乗り場の先頭を再格納
		while (M--) enq(c[k++]);//キュー配列cにM人分格納
		ans += (unsigned)que[0];
		deq();
	}
	printf("%u\n", ans);
	return (0);
}




Measured memory_bytes: 5204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] array = new int[N + 1];
		array = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

		int result = array[0];

		for (int i = 1; i < N - 1; i++) {
			result += Math.min(array[i], array[i - 1]);
		}

		result += array[N - 2];

		System.out.println(result);
	}

}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string n; cin >> n;
	for(int i{}; i < n.size(); i++)
	{
		if(n[i] == '7')
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

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

int main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    char f = S.front();
    char b = S.back();
    int x;
    if (f == b) {
        int count=0;
        for (int i=1; i<S.size(); i++){
            if (S[i-1] != S[i]) count++;
        }
        count/=2;
        if (count >= M) {
            x = (count-M)*2+1;
        }
        else x = 1;
    }
    else/* if (f=='R')*/ {
        int count=0;
        for (int i=1; i<S.size(); i++){
            if (S[i-1] != S[i]) count++;
        }
        count = (count+1)/2;
        if (count-M > 0) {
            x = (count-M)*2;
        }else x = 1;
    }
    /*
    else if (f == 'L') {
        int count=0;
        for (int i=1; i<S.size(); i++){
            if (S[i-1] != S[i]) count++;
        }
        count = (count-1)/2;
        if (count-M > 0) {
            x = (count-M)*2+2;
        }else x = 1;
    }
    */
    cout << S.size()-x << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());

            if (N % 2 == 0) {
                Console.WriteLine((double)1 / 2);
            } else {
                Console.WriteLine(((double)1 / 2) + ((double)1 / (2 * N)));
            }

        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(void){
  int N,i,j;
  cin>>N;
  cin>>i>>j;
   for(i=0; i<25; i++){
       for(j=0; j<14; j++){
          if(N== 4*i + 7*j){
             cout<<"Yes"<<endl;
             return 0;
   }
   }
   }
   cout<<"No"<<endl;
       
   
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

void insertionSort(vector<int> a,int n){

    rep(i,n){
        cout << a[i];
        if(i < n - 1){
            cout << " ";
        }
    }
    cout << endl;

    for(int i = 1; i < n; i++){
        int v = a[i];

        int j = i - 1;
        
        while(j >= 0 && v < a[j]){
            a[j+1] = a[j];
            j--;
        }

        a[j+1] = v;

        rep(i,n){
            cout << a[i];
            if(i < n - 1){
                 cout << " ";
            }           
        }
        cout << endl;
    }


}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    insertionSort(a,n);


}


Measured memory_bytes: 3164
"""別解
解説動画でやってること。

考察問題。

ランレングス法みたいな考え方をする。

LグループとRグループに分けて考える。

LグループとRグループの境目を選択して操作をすると、基本的に幸福な人の数を＋２できる

ただし、端っこの境目を選んだときのみ、＋１になる。


・入力例２を考える

## 初期状態
 L R R L R L R R L R L L R
   .         .         .     幸福な人：3人


## LグループとRグループの境目を選択して、操作をする

 L R R L R L R R L R L L R
  |___|

 L L L L R L R R L R L L R
   . . .     .         .     幸福な人：5人

## LグループとRグループの境目を選択して、操作をする

 L L L L R L R R L R L L R
        |_|

 L L L L L L R R L R L L R
   . . . . . .         .     幸福な人：7人

## LグループとRグループの境目を選択して、操作をする

 L L L L L L R R L R L L R
            |___|

 L L L L L L L L L R L L R
   . . . . . . . .     .     幸福な人：9人

## LグループとRグループの境目を選択して、操作をする

 L L L L L L L L L R L L R
                  |_|

 L L L L L L L L L L L L R
   . . . . . . . . . . .     幸福な人：11人

## LグループとRグループの境目を選択して、操作をする

 L L L L L L L L L L L L R
                        |_|

 L L L L L L L L L L L L L
   . . . . . . . . . . . .   幸福な人：12人


この考察からすると、初期状態の幸福な人の数を score とすると、

・K回操作して、初期状態の幸福な人に加えて 2*K 人を幸福にすることができたパターン = score + 2*K
・K回以下の操作で、すべての人を L(R) にすることができたパターン = N-1

のどちらかなので、最終的な幸福な人の数 ans は、

ans = min(score+2*K, N-1)

となる。

初期状態の幸福な人の数 score をO(N)で数えればよいだけなので、計算量はO(N)

"""
def solve2():
    N, K = list(map(int, input().split()))
    S = input()

    ans = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            ans += 1

    ans = min(ans + 2*K, N-1)
    print(ans)


if __name__ == "__main__":
    solve2()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m;

    while (cin >> n >> m, n) {
        vector<string> winning_num(n);
        vector<int> hash(n);

        for (int i = 0; i < n; ++i) {
            string s;
            int m;

            cin >> s >> m;
            winning_num[i] = s;
            hash[i] = m;
        }

        int sum = 0;
        for (int i = 0; i < m; ++i) {
            string s;

            cin >> s;
            for (int j = 0; j < n; ++j) {
                bool flag = true;

                for (int k = 0; k < 8; ++k) {
                    if (winning_num[j][k] != '*' && winning_num[j][k] != s[k]) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    sum += hash[j];
                    break;
                }
            }
        }

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int f = sc.nextInt();
		int r = sc.nextInt();
		while(m != -1 || f != -1 || r != -1){
			if(m == -1 || f == -1){
				System.out.printf("F");
			} else if ((m=m+f)<30){
				System.out.printf("F");
			} else if (m<50){
				if(r >= 50) {
					System.out.printf("C");
				} else {
					System.out.printf("D");
				}
			} else if (m<65){
				System.out.printf("C");
			} else if (m<80){
				System.out.printf("B");
			} else {
				System.out.printf("A");
			}
			System.out.println();
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
		}
	}
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int c=0;
	for(int i=1;i<=n;i+=2){
		if(a[i]&1)
			c++;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3524
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long lint;
#define mo 924844033
const int N=2333;
int n,m;
lint fac[N];
int ne[N<<1],ep,ni[N<<1];
lint dp[N<<1][N][2];
lint ans;
queue<int>q;
int main()
{
	scanf("%d%d",&n,&m);
	fac[0]=1;for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mo;
	for(int i=1;i<=min(n,m);i++) q.push(i),q.push(i+n);
	int nw=q.front();q.pop();
	while(nw)
	{
		if((nw>n?nw-n:nw)+m<=n) ne[nw]=(nw>n?nw-n+m:nw+n+m),ni[nw]=1;
		else if(!q.empty()){ne[nw]=q.front();q.pop();}
		else ep=nw;
		nw=ne[nw];
	} 
	dp[1][0][0]=1;
	for(int i=1;ne[i];i=ne[i])
	{
		if(ni[i])
			for(int j=0;j<=n;j++)
			{
				(dp[ne[i]][j+1][1]+=dp[i][j][0])%=mo;
				(dp[ne[i]][j][0]+=dp[i][j][0]+dp[i][j][1])%=mo;
			}
		else for(int j=0;j<=n;j++) dp[ne[i]][j][0]=(dp[i][j][0]+dp[i][j][1])%mo;
	}
	for(int i=0;i<=n;i++)
		(ans+=((i&1)?-1ll:1ll)*((dp[ep][i][0]+dp[ep][i][1])%mo*fac[n-i]%mo)+mo)%=mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 147584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi Prime;
  vii P(4);
  P[1].push_back(2);
  Prime.push_back(3);
  Prime.push_back(5);
  REP(i,7,55555){
    bool flag=1;
    rep(j,0,Prime.size()){
      if(i%Prime[j]==0){
        flag=0;
        break;
      }
    }
    if(flag){
      P[i%5-1].push_back(i);
      Prime.push_back(i);
    }
  }
  rep(i,0,N) cout<<P[0][i]<<endl;
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    persons = [[input().split() for j in range(int(input()))] for i in range(n)]

    result = 0
    for i in range(1, 2 ** n):
        flg = True
        for j, answers in enumerate(persons):
            if (i >> j) & 1 == 1:
                for x, y in answers:
                    if not((i >> int(x) - 1) & 1 == int(y)):
                        flg = False
                        break

        if flg:
            result = max(result, bin(i)[2:].count("1"))

    print(result)


if __name__ == '__main__':
    main()




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

using namespace std;
typedef long long ll;
const ll p = 1e9 + 7;
const int N = 2e5 + 100;

ll fact[N],infact[N];
ll qpow(ll a,ll b)
{
    ll res = 1 % p;
    while(b)
    {
        if(b & 1)res = res * a % p;
        b >>= 1;
        a = a * a % p;
    }
    return res % p;
}
ll inv(ll m)
{
    return qpow(m,p-2) % p;
}
void init()
{
    fact[0] = 1,infact[0] = 1;
    for(int i = 1;i < N;i++)
    {
        fact[i] = (fact[i - 1] * i * 1ll) % p;
        infact[i] = inv(fact[i]) % p;
    }
}
ll C(ll m,ll n)
{
    if(m > n)return  0;
    return (fact[n] * infact[n - m] % p) * infact[m] % p;
}
int main()
{
    init();
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = 0;i <= min(k,n-1);i++)
    {
        ans = (ans +  C(i,n) * C(n - i - 1,n - 1) % p) % p;
    }
    cout << ans % p;
    
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long X = sc.nextLong();
		long sum = N + func(Math.min(N-X, X), Math.max(N-X, X));
		System.out.println(sum);
		sc.close();
	}

	private static long func(long a, long b) {
		if (a==0) return -b;
		return 2*a*(long)(b/a)+func(b%a, a);
	}
}


Measured memory_bytes: 9940
#include <iostream>

using namespace std;

int main(void){
    string sl, sr;
    int n; cin >> n;
    int l = 0, r = n-1;
    cout << l << endl; cin >> sl;
    if (sl == "Vacant") return 0;
    cout << r << endl; cin >> sr;
    if (sr == "Vacant") return 0;
    string stemp;
    while (stemp != "Vacant") {
        int m = (l + r) / 2;
        cout << m << endl;
        cin >> stemp;
        if ((sl == stemp && ((m-l) % 2 == 0)) || (sl != stemp && ((m-l) % 2 == 1))) {
            l = m; sl = stemp;
        }
        else {
            r = m; sr = stemp;
        }
    }
    return 0;
}
//simple is best


Measured memory_bytes: 852
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

s = p[:x] + q[:y] + r[:x+y]
s.sort(reverse=True)
print(sum(s[:x+y]))


Measured memory_bytes: 23200
#include <bits/stdc++.h>
using namespace std;
 
int n;
int ans = 0;
int X[100], Y[100];
 
int main(){
  	cin >> n;
  	for ( int i = 0; i < n; i++ ) cin >> X[i];
  	for ( int i = 0; i < n; i++ ) cin >> Y[i];
  	for ( int i = 0; i < n; i++ ){
    	if ( X[i] > Y[i] ) ans += X[i] - Y[i];
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

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

    sort(A.begin(), A.end());
    ll ans = A[0];
    for(int i = 1; i < N; i++) {
        ans = gcd(ans, A[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
<?php
$input = trim(fgets(STDIN));
$array = explode(" ", $input);
list($a, $b, $c, $d) = $array;

$s1 = $a * $b;
$s2 = $c * $d;

if ($s1 == $s2) {
  echo $s1 . "\n";
} else if ($s1 < $s2) {
  echo $s2 . "\n";
} else if ($s1 > $s2) {
  echo $s1 . "\n";
}


Measured memory_bytes: 4604
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    vector<ll> h(m), v;
    ll sum = 0;
    for (ll i = 0; i < m; i++)
    {
        cin >> h[i];
    }
    sort(ALL(h));
    for (ll i = 0; i < m - 1; i++)
    {
        v.push_back(h[i + 1] - h[i]);
        sum += v[i];
    }
    sort(ALL(v));

    ll t = min(n - 1, (ll)v.size());

    for (ll i = 0; i < t; i++)
    {
        sum -= v[m - 2 - i];
    }
    cout << sum << endl;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> vec;
	for (int i=0; i<n; i++){
		int x;
		cin>>x;
		vec.push_back(x);
	}
	int suma=0;
	for (int i=1; i<n-1; i++){
		if ((vec[i-1]>vec[i]&&vec[i]>vec[i+1])||(vec[i-1]<vec[i]&&vec[i]<vec[i+1]))
			suma++;
	}
	cout<<suma;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define For(i, begin, end) for(int i=begin;i<end;i++)
#define Rep(i, n) For(i,0,n)
#define Sort(v) sort(v.begin(),v.end())
using namespace std;

int main(){
  
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;

  return 0;
}

Measured memory_bytes: 256
def How_many_times_devide(n):
    count = 0
    while n %2 == 0:
        n/= 2
        count += 1

    return count

N = int(input())
num_max = 1
count_max = 0
for i in range(1,N+1):
    count = How_many_times_devide(i)
    if count_max < count:
        count_max = count
        num_max = i

print(num_max)

Measured memory_bytes: 3060