akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int a,b;
    int cnt=0;
    cin>>a>>b;
    while(b!=a-1){
        string s=to_string(b);
        if(s[0]==s[4] && s[1]==s[3])cnt++;
        b--;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,m,k,tot;
LL a[500005],b[500005],c[500005],d[500005];
LL vis[500005] = {0};
string s;
map <LL,LL> mp;

LL fa[500005];
LL getf(LL x){
	if(fa[x] == x) return x;
	return fa[x] = getf(fa[x]);
}
void unionn(LL x,LL y){
	x = getf(x); y = getf(y);
	if(x == y) return;
	tot --; fa[x] = y;
}

int main(){
	cin >> n;
	for(LL i = 1;i <= n;i ++){ cin >> a[i]; c[i] = a[i]; a[n + 1] ^= a[i]; }
	for(LL i = 1;i <= n;i ++){ cin >> b[i]; d[i] = b[i]; b[n + 1] ^= b[i]; }
	n ++; c[n] = a[n]; d[n] = b[n];
	sort(c + 1,c + 1 + n); sort(d + 1,d + 1 + n);
	for(LL i = 1;i <= n;i ++){
		if(c[i] != d[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	
	tot = 0;
	for(LL i = 1;i < n;i ++){
		if(a[i] != b[i]){
			if(mp.find(a[i]) == mp.end()) mp[a[i]] = ++ tot;
			if(mp.find(b[i]) == mp.end()) mp[b[i]] = ++ tot;
		}
	}
	if(mp.find(a[n]) == mp.end()) mp[a[n]] = ++ tot;
	if(mp.find(b[n]) == mp.end()) mp[b[n]] = ++ tot;
	for(LL i = 1;i <= n;i ++){
		a[i] = mp[a[i]];
		b[i] = mp[b[i]];
	}
	
//	for(LL i = 1;i <= n;i ++) cout << a[i] << (i == n ? '\n' : ' ');
//	for(LL i = 1;i <= n;i ++) cout << b[i] << (i == n ? '\n' : ' ');
	
	LL tmp = 0;
	for(LL i = 1;i <= tot;i ++) fa[i] = i;
	for(LL i = 1;i < n;i ++){
		if(a[i] != b[i]){
			tot ++; tmp = 1;
			unionn(a[i],b[i]);
			vis[a[i]] = 1; vis[b[i]] = 1;
		}
	}
	unionn(a[n],b[n]);
	tot --;
//	if(!tmp) tot = 0;
	cout << tot << endl;
	return 0;
}

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

#define SLAY ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(0);
#define LL long long
#define PII pair<int , int>
#define PLL pair<long long , long long>
#define INPUT freopen("/Users/amrfahmy/Documents/Problem solving/CF/CF/input.txt", "r", stdin);
using namespace std;
 
const LL MOD = 1000000007;
LL arr[1000000];
LL b[1000];
LL n,q,c,cnt,mx,m,temp,k;
string str;



bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){
    return (a.first < b.first);
}
int gcd(int a, int b) {
   if (b == 0)
      return a;
   return gcd(b, a % b);
}

int main()
{
    bool readfromfile=false; if(!readfromfile){SLAY} else{INPUT}
    
 

    cin>>n;
    for(int i = 0 ; i < n ; i++)cin>>arr[i];
   
    LL ans=0;
    LL last=0;
    for(int i = 0 ; i < n ; i ++){
        if(arr[i]==last+1){
            last++;
        }else{
            ans++;
        }
    }
    if(last==0)cout<<-1;
    else cout<<ans;
    return 0;
}
 



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N; cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >> a[i];
  
  vector<int> b(N);
  
  int now, sum, M = 0;
  for(int i=0; i<N; i++){
    now = N-i;
    sum = 0;
    for(int j=2; j*now<=N; j++){
      sum ^= b[j*now-1];
    }
    b[now-1] = sum^a[now-1];
    if(b[now-1] == 1) M++;
  }
  
  cout << M << endl;
  for(int i=0; i<N; i++){
    if(b[i] == 1) cout << i+1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, k, a[100100], dp[100100];

signed main() {
	cin >> n >> k;
	rep(i,n) cin >> a[i];
	reps(i,1,n) dp[i] = 1<<30;
	rep(i,n) reps(j,1,k+1) chmin(dp[i+j], dp[i] + abs(a[i]-a[i+j]));
	cout << dp[n-1] << endl;
}

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

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

struct Point{
  int t;
  int x;
  int y;
  int dif;
  int dif_t;

  Point(int t = 0, int x = 0, int y = 0,int dif = 0,int dif_t=0) {
        this->t = t;
        this->x = x;
        this->y = y;
        this->dif = dif;
        this->dif_t=dif_t;
  }
  bool operator<(const Point &p) const {
    return t < p.t;
  }
};

int main(){
  int n;cin>>n;
  vector<Point> points(n+1);
  rep(i,n){
    cin>>points[i+1].t>>points[i+1].x>>points[i+1].y;
    points[i+1].dif=abs(points[i+1].x-points[i].x)+abs(points[i+1].y-points[i].y);
    points[i+1].dif_t=points[i+1].t-points[i].t;
    if((points[i+1].dif%2!=points[i+1].dif_t%2)||points[i+1].dif>points[i+1].dif_t){
      cout<<"No"<<endl;
      return 0;
    }
  }cout<<"Yes"<<endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int VMAX=2600,EMAX=5010;
const ll INFLL = 1e+17;
int V,E;
ll p;
int a[5010],b[5010];
ll c[5010];
struct edge{
  int from,to;
  ll cost;
};
edge e[EMAX];
ll d[VMAX];
bool update;
bool bellmanford(int s){
  for(int i=0;i<V;i++) d[i]=INFLL;
  d[s]=0;
  for(int j=0;j<2*V;j++){
    update=false;
    for(int i=0;i<E;i++){
      int f=e[i].from,t=e[i].to;
      ll c=e[i].cost;
      if(d[f]!=INFLL&&d[t]>d[f]+c){
	d[t]=d[f]+c;
	update=true;
	if(j>=V-1&&t==V-1) return false;
      }
    }
    if(!update) break;
  }
  return true;
}
//負閉路の検出
bool find_negative_loop(){
  for(int i=0;i<V;i++) d[i]=0;
  for(int i=0;i<V;i++){
    for(int j=0;j<E;j++){
      int f=e[i].from,t=e[i].to;
      ll c=e[i].cost;
      if(d[t]>d[f]+c){
	d[t]=d[f]+c;
	if(i==V-1) return true;
      }
    }
  }
  return false;
}

int main()
{
  cin >> V >> E >> p;
  rep(i,E){
    cin >> a[i] >> b[i] >> c[i];
    e[i].from = --a[i];
    e[i].to = --b[i];
    e[i].cost = -c[i]+p;
  }
  if(!bellmanford(0)) cout << -1 << "\n";
  else{
    cout << max((ll)0,-d[V-1]) << "\n";
  }
  
  return 0;
}



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

int main()
{
	long long N;

	cin >> N;
	
	vector<long long> H;

	for (long long iN = 0; iN < N; iN++)
	{
		long long val;

		cin >> val;
		H.push_back(val);
	}

	long long max_down = 0;
	//for (long long iN = 0; iN < N; iN++)
	//{
	//	long long down = 0;

	//	for (long long iR = iN; iR < N - 1; iR++)
	//	{
	//		if (H[iR] >= H[iR + 1]) {
	//			down++;
	//		}
	//		else {
	//			break;
	//		}
	//	}

	//	max_down = std::max(down, max_down);
	//}

	long long now = 100000000001;
	long long up = 0;
	for (long long iN = N - 1; iN >= 0; iN--) {
		if (H[iN] >= now) {
			up++;
		}
		else {
			max_down = std::max(up, max_down);
			up = 0;
		}

		now = H[iN];
	}

	max_down = std::max(up, max_down);

	cout << max_down << endl;
}

//int main()
//{
//	int A, B;
//
//	cin >> A >> B;
//
//	long long socket = 1;
//	long long count = 0;
//
//	while (socket < B)
//	{
//		socket = socket - 1 + A;
//		count++;
//	}
//
//	cout << count << endl;
//}

//int main()
//{
//	string S, T;
//
//	cin >> S >> T;
//
//	int hit = 0;
//
//	for (long long iS = 0; iS < 3; iS++)
//	{
//		if (S[iS] == T[iS])
//		{
//			hit++;
//		}
//	}
//
//	cout << hit << endl;
//}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
int main() {
  char s[100001];
  scanf("%s", s);
  int n = strlen(s);
  int i, cnt_0 = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '0'){
      cnt_0 ++;
    }
  }
  int cnt_1 = n - cnt_0;
  int cnt = cnt_1 < cnt_0 ? cnt_1 : cnt_0;
  printf("%d\n", cnt << 1);
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i=0;i<n;i++)

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;
//#define PI 3.14159265359

ll calc(ll a, ll b, ll x) {
    return floor(a * x / b) - a * floor(x / b);
}

int main() {
    // input
    ll A, B, N;
    cin >> A >> B >> N;

    // process
//    ll x = N / 2;
//    if (x > B) {
//        x = x - (x % B) - 1;
//    }
//
//    while (1) {
//        ll left = 0, mid = 0, right = 0;
//
//        mid = calc(A, B, x);
//
//        ll left_x = 0, right_x = 0;
//        if (x - B >= 0) {
//            left_x = x - B;
//        } else {
//            left_x = 0;
//        }
//        if (x + B <= N) {
//            right_x = x + B;
//        } else {
//            right_x = N;
//        }
//
//        left = calc(A, B, left_x);
//        right = calc(A, B, right_x);
//
//        if (left <= mid && mid >= right) {
//            cout << mid;
//            break;
//        }
//
//        if (left > mid) {
//            x = left_x;
//        } else if (mid < right) {
//            x = right_x;
//        }
//    }
    ll ans = 0;
    ll i = 1;
    ll n = (B * i) - 1;
    if (n > N) {
        n = N;
    }
    ll a = 0;
    while (n <= N) {
        a = calc(A, B, n);
        if (ans < a) {
            ans = a;
        }
        if (ans == a) {
            break;
        }
        i++;
        n = n + (B * i);
        if (n >= N) {
            a = calc(A, B, N);
            if (ans < a) {
                ans = a;
            }
            break;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>

using namespace std;

#define NMAX 100000
#define SENTINEL 1000000001

int Partition(int A[],char B[],int p,int r){
    int x=A[r];
    int i=p-1;
    for(int j=p;j<=r-1;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
            swap(B[i],B[j]);
        }
    }
    swap(A[i+1],A[r]);
    swap(B[i+1],B[r]);
    return i+1;
}
 
void Quicksort(int A[],char B[],int p,int r){
    if(p<r){
        int q=Partition(A,B,p,r);
        Quicksort(A,B,p,q-1);
        Quicksort(A,B,q+1,r);
    }
    return;
}

void merge(int A[],char B[],int left,int mid,int right){
    int n1=mid-left;
    int n2=right-mid;
    int L[NMAX],R[NMAX];
	char LL[NMAX],RR[NMAX];

    for(int i=0;i<=n1-1;i++){
        L[i]=A[left+i];
		LL[i]=B[left+i];
    }
    for(int i=0;i<=n2-1;i++){
        R[i]=A[mid+i];
		RR[i]=B[mid+i];
    }
    L[n1]=SENTINEL;
    R[n2]=SENTINEL;
    int i=0,j=0;
    for(int k=left;k<=right-1;k++){
        if(L[i]<=R[j]){
            A[k]=L[i];
			B[k]=LL[i];
            i++;
        }
        else{
            A[k]=R[j];
			B[k]=RR[j];
            j++;
        }
    }
}
 
void merge_sort(int A[],char B[],int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        merge_sort(A,B,left,mid);
        merge_sort(A,B,mid,right);
        merge(A,B,left,mid,right);
    }
}

int main(void){
    std::ios_base::sync_with_stdio(false);
 
    int n,qA[NMAX],mA[NMAX];
    char qB[NMAX],mB[NMAX];

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>qB[i]>>qA[i];
		mA[i]=qA[i];
		mB[i]=qB[i];
    }

    Quicksort(qA,qB,0,n-1);
	merge_sort(mA,mB,0,n);

	bool f=true;
	for(int i=0;i<n;i++){
		if(qB[i]!=mB[i]){
			f=false;
			break;
		}
	}

	if(f) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    for(int i=0;i<n;i++){
        cout<<qB[i]<<" "<<qA[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<ll, ll> m;
  rep(i, 3) {
    ll x;
    cin >> x;
    m[x]++;
  }
  if (m.size() == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <string.h>
#include <math.h>
typedef long long ll;
#define INF			100000
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define SWAP
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int N,al,ar,m;

int main() {
	
	cin >> N;
	
	vector<int> a(N),b(N);
	
	REP(i,0,N) cin >> a[i],b[i]=a[i];

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

	m = N/2-1;
	al = b[m];
	ar = b[m+1];
	
	REP(i,0,N) 
		if (a[i]<=al) cout << ar << endl;
		else cout << al << endl;
	
	return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string A;
  while (cin >> A) {
    bool res = false;
    for (int i = 1; i < A.size(); i++) res |= A[i] == A[i - 1];
    cout << (res ? "Bad" : "Good") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1; j = 0
    A[0] = l = N
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

n = inp()
s = input()
res = 0
for i in range(n-1):
    a = z_algo(s[i:])
    ln = n-i
    for j,x in enumerate(a):
        tmp = min(j,x)
        res = max(res, tmp)
print(res)

Measured memory_bytes: 76120
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

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

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//素数pn
//n乗jou
//コンビネーションfactorial
//
int main(){
    int x,t;
    cin >> x >> t;
    cout << (x > t ? x - t : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
ll a, b, c, i, j, k, n, m, t, p, q, s;
struct node {
	ll x, y;
};
node arr[2505];
string s1,s2,s3;
int main() {
	cin >> n >> m;
	a = 0;
	a = n * (n - 1) / 2;
	a += (m * (m - 1) / 2);
	cout << a;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

const int N = 321;
const int P = 31;
const int m = 1e9+9;

char A[N][N];
long long p[2*N], h[2*N][2*N], v[2*N][2*N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf(" %c", A[i]+j);
      A[i][j] -= 'a'-1;
    }
  }
  p[0] = 1;
  for (int i = 1; i < 2*n; ++i)
    p[i] = (p[i-1] * P) % m;
  for (int i = 0; i < 2*n; ++i) {
    for (int j = 0; j < 2*n; ++j) {
      h[i][j+1] = (h[i][j] + A[i%n][j%n] * p[j]) % m;
      v[i][j+1] = (v[i][j] + A[j%n][i%n] * p[j]) % m;
    }
  }
  int ans = 0;
  for (int a = 0; a < n; ++a) {
    for (int b = 0; b < n; ++b) {
      for (int i = 0; i < n; ++i) {
	long long H = (h[i+a][b+n]-h[i+a][b]+m)%m,
	  V = (v[i+b][a+n]-v[i+b][a]+m)%m;
	if (a < b) {
	  V = V*p[b-a]%m;
	} else if (b < a) {
	  H = H*p[a-b]%m;
	}
	if (H != V) goto bad;
      }
      ++ans;
    bad:;
    }
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int k;
	bool ok = false;
	for (int i = 1; i * (i + 1) / 2 <= n; ++i) {
		if (i * (i + 1) / 2 == n) {
			ok = true;
			k = i;
			break;
		}
	}
	if (!ok) {
		cout << "No" << endl;
		return 0;
	}
	vector<vector<int>> ans(k + 1);
	int now = 1;
	rep(i, k + 1) {
		for (int j = i + 1; j < k + 1; ++j) {
			ans[i].push_back(now);
			ans[j].push_back(now++);
		}
	}
	cout << "Yes" << endl;
	cout << k + 1 << endl;
	rep(i, k + 1) {
		cout << ans[i].size() << endl;
		for (int c : ans[i]) cout << c << (c == ans[i].back() ? "\n" : " ");
	}
 	return 0;
}


Measured memory_bytes: 2304
s = input()
mod = 10 ** 9 + 7
dp = [[0 for _ in range(13)] for __ in range(len(s) + 1)]
dp[0][0] = 1
for i, si in enumerate(s):
    if si == '?':
        for n in range(10):
            for j in range(13):
                dp[i+1][(n + j * 10) % 13] += dp[i][j]
    else:
        for j in range(13):
                dp[i+1][(int(si) + j * 10) % 13] += dp[i][j]
    for k in range(13):
      dp[i+1][k] = dp[i+1][k] % mod
print(dp[len(s)][5])


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

void North(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[1];
    nums[1]=nums[5];
    nums[5]=nums[4];
    nums[4]=nums[6];
}
void East(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[3];
    nums[3]=nums[5];
    nums[5]=nums[2];
    nums[2]=nums[6];
}
void South(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[4];
    nums[4]=nums[5];
    nums[5]=nums[1];
    nums[1]=nums[6];
}
void West(int *nums){
    nums[6]=nums[0];
    nums[0]=nums[2];
    nums[2]=nums[5];
    nums[5]=nums[3];
    nums[3]=nums[6];
}
int main(void){
    int nums[7];
    string line;
    for(int i=0;i<6;i++){
        cin>>nums[i];
    }
    nums[6]=0;
    cin>>line;
    for(int i=0;i<line.size();i++){
        if(line[i]=='N')North(nums);
        else if(line[i]=='E')East(nums);
        else if(line[i]=='S')South(nums);
        else West(nums);
    }
    cout<<nums[0]<<endl;;
    return 0;
}


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

#define MAX_N 50

int N;
int L[MAX_N+1];

int dpMin[MAX_N][MAX_N+1];
int dpMax[MAX_N][MAX_N+1];

void dp(int cut, int begin){
	if(dpMin[cut][begin]) return;
	if(cut == 0){
		dpMin[cut][begin] = L[N] - L[begin];
		dpMax[cut][begin] = L[N] - L[begin];
	}else{
		int bestMin = -99999999;
		int bestMax = +99999999;
		for(int pos=begin+1; pos+cut<=N; ++pos){
			const int left = L[pos]-L[begin];
			dp(cut-1, pos);
			if( bestMax - bestMin > max(dpMax[cut-1][pos], left) - min(dpMin[cut-1][pos], left) ){
				bestMax = max(dpMax[cut-1][pos], left);
				bestMin = min(dpMin[cut-1][pos], left);
			}
		}
		dpMin[cut][begin] = bestMin;
		dpMax[cut][begin] = bestMax;
	}
	//printf("dp[%2d][%2d]={%4d,%4d}\n",cut,begin,dpMin[cut][begin],dpMax[cut][begin]);
}

int main(){
	cin >> N;
	
	for(int i=1; i<=N; ++i){
		cin >> L[i];
		L[i] += L[i-1];
	}
	
	int best = 1<<29;
	for(int n=1; n<N; ++n){
		dp(n,0);
		best = min(best, dpMax[n][0] - dpMin[n][0]);
	}
	
	cout << best << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;

using namespace std;
int n;
int a[100100];
ll l = 2, r = 2;
void solve(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	

	for(int i = n - 1; i >= 0; i--){
		ll x =(r/a[i]) * a[i] + a[i] - 1;
		ll y = ((l + a[i] - 1)/a[i]) * a[i];
		//cout << l << " "<<r << endl;
		//cout << x << " "<< y << endl;
		if(x < y){
			cout<<-1<<endl;
			return;
		}
		l = y;
		r = x;
	}
	cout << l  << " " << r << endl;
}


int main () {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}



Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

double n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;


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

  cin>>n;
  if((int)n%2)pri1((double)(n/2+0.5)/n);
  else pri1(0.5);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long
int inf = 100000;

int main(){
  int N, ma, mb;
  cin>>N>>ma>>mb;
  int a[N], b[N], c[N];
  REP(i, N) cin>>a[i]>>b[i]>>c[i];
  int dp[N+1][401][401];
  REP(i, N+1)REP(j,401)REP(k, 401){
    dp[i][j][k]=inf;
  }
  dp[0][0][0]=0;

  REP(i, N)REP(j, 401)REP(k, 401){
    if(j-a[i]>-1 && k-b[i]>-1) dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
    else dp[i+1][j][k] = dp[i][j][k];
  }
  int ans=inf;
  for(int i=ma, j=mb; i<401&&j<401; i+=ma, j+=mb){
      ans = min(ans, dp[N][i][j]);
  }
  //cout<<ans<<endl;

  //REP(j,6){REP(k, 14){
  //  cout<<dp[N][j][k]<<" ";
  //}cout<<endl;}

  if(ans==inf) cout<<-1<<endl;
  else cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 25984
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 


#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main() {

    int x;
  cin>>x;
    cout<<(x^1)<<Endl;

    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 100010
int n, m, a[MAXN], b[MAXN], c[MAXN];
long long tmp;
int lc0[MAXN], lc1[MAXN], rc0[MAXN], rc1[MAXN], ls[MAXN], rs[MAXN];
void solve(int l, int r) {
	if (l == r) return tmp += c[l], void();
	int mid = (l + r) >> 1;
	solve(l, mid);
	solve(mid + 1, r);
	int cl0 = 0, cl1 = 0, cr0 = 0, cr1 = 0;
	for (int i = mid; i >= l; i--) {
		ls[mid - i + 1] = ls[mid - i] + c[i];
		if ((mid - i + 1) & 1) {
			lc1[++cl1] = ls[mid - i + 1] - (mid - i + 1) / 2;
		} else {
			lc0[++cl0] = ls[mid - i + 1] - (mid - i + 1) / 2;
		}
	}
	for (int i = mid + 1; i <= r; i++) {
		rs[i - mid] = rs[i - mid - 1] + c[i];
		if ((i - mid) & 1) {
			rc1[++cr1] = rs[i - mid] - (i - mid) / 2;
		} else {
			rc0[++cr0] = rs[i - mid] - (i - mid) / 2;
		}
	}
	std::sort(lc0 + 1, lc0 + cl0 + 1);
	std::sort(rc0 + 1, rc0 + cr0 + 1);
	std::sort(lc1 + 1, lc1 + cl1 + 1);
	std::sort(rc1 + 1, rc1 + cr1 + 1);
	int cur = cr0;
	for (int i = 1; i <= cl0; i++) {
		while (cur && lc0[i] + rc0[cur] >= 1) cur--;
		tmp += cr0 - cur;
	}
	cur = cr0;
	for (int i = 1; i <= cl1; i++) {
		while (cur && lc1[i] + rc0[cur] >= 1) cur--;
		tmp += cr0 - cur;
	}
	cur = cr1;
	for (int i = 1; i <= cl0; i++) {
		while (cur && lc0[i] + rc1[cur] >= 1) cur--;
		tmp += cr1 - cur;
	}
	cur = cr1;
	for (int i = 1; i <= cl1; i++) {
		while (cur && lc1[i] + rc1[cur] >= 2) cur--;
		tmp += cr1 - cur;
	}
}
inline bool judge(int v) {
	for (int i = 1; i <= n; i++) c[i] = a[i] <= v;
	// fprintf(stderr, "JUDGE %d\n", v);
	// for (int i = 1; i <= n; i++) fprintf(stderr, "%d ", c[i]);
	// fprintf(stderr, "\n");
	tmp = 0;
	solve(1, n);
	// fprintf(stderr, "RETURN %lld\n", tmp);
	return tmp >= 1LL * n * (n + 1) / 4 + 1;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	memcpy(b, a, sizeof(b));
	std::sort(b + 1, b + n + 1);
	int l = 1, r = n, ans = 0;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (judge(b[mid]))
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	printf("%d\n", b[ans]);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    rep(i, n)cin >> a[i] >> b[i];
    vector<vector<int>> dp1(n+1, vector<int>(t+1, 0));
    vector<vector<int>> dp2(n+1, vector<int>(t+1, 0));
    //dp[i][j] := 最初の注文からi分後にj番目の料理を食べたときの満足度の最大値
    //左右からKnapSackする
    rep(i, n){
        rep(j, t+1){
            if(j >= a[i]) dp1[i+1][j] = max(dp1[i][j-a[i]] + b[i], dp1[i][j]);
            else dp1[i+1][j] = dp1[i][j];
        }
    }
    reverse(all(a)); reverse(all(b));
    rep(i, n){
        rep(j, t+1){
            if(j >= a[i]) dp2[i+1][j] = max(dp2[i][j-a[i]] + b[i], dp2[i][j]);
            else dp2[i+1][j] = dp2[i][j];
        }
    }
    reverse(all(dp2));
    reverse(all(a)); reverse(all(b));
    int ans = 0;
    rep(i, n){
        rep(j, t){
            ans = max(ans, dp1[i][j] + dp2[i+1][t-j-1] + b[i]);
        }
    }
    cout << ans << endl;
}

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

int main()
{
	long long int a, b, c,k,sum=0;

	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);

	if (k <= a)
	{
		sum = k;
		k = 0;
	}
	else
	{
		k=k - a;
		sum = a;
	}
	if (k > b)
	{
		k = k - b;
		sum += (k * (-1));
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+10;
const int maxm = 200000+10;
const int mod = 1e9+7;
const double eps = 1e-9;
int a[maxn],n,A,B;
bool check(int x){
    ll res=0;
    for (int i=0;i<n;i++){
        if (a[i]>1ll*x*B){
            res+=(a[i]-x*B+A-1)/A;
        }
    }
    return res<=x;
}
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>A>>B;
    A-=B;
    for (int i=0;i<n;i++) cin>>a[i];
    int L=0,R=1e9,ans;
    while (L<=R){
        int mid=L+(R-L)/2;
        if (check(mid)){
            ans=mid;
            R=mid-1;
        } else {
            L=mid+1;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    if m % 2 == 1 {
        println!("-1");
        return;
    }
    let mut graph = vec![vec![]; n];
    for i in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push((b, i));
        graph[b].push((a, i));
    }

    let mut edge_used = vec![false; m];
    let mut vis = vec![false; n];
    vis[0] = true;
    let mut answer = vec![None; m];
    dfs(0, &mut vis, &graph, &mut edge_used, &mut answer);
    for e in answer.into_iter() {
        let (from, to) = e.unwrap();
        println!("{} {}", from + 1, to + 1);
    }
}

fn dfs(
    v: usize,
    vis: &mut Vec<bool>,
    graph: &Vec<Vec<(usize, usize)>>,
    edge_used: &mut Vec<bool>,
    answer: &mut Vec<Option<(usize, usize)>>,
) {
    for &(next, id) in graph[v].iter() {
        if vis[next] {
            continue;
        }
        vis[next] = true;
        edge_used[id] = true;
        dfs(next, vis, graph, edge_used, answer);
    }

    let mut forward = 0;
    for &(next, id) in graph[v].iter() {
        match answer[id] {
            None => {
                if !edge_used[id] {
                    answer[id] = Some((v, next));
                    forward += 1;
                }
            }
            Some((from, _)) => {
                if from == v {
                    forward += 1;
                }
            }
        }
    }

    if v != 0 {
        let e = graph[v]
            .iter()
            .filter(|&&(_, id)| answer[id].is_none())
            .map(|&(next, id)| (id, v, next))
            .collect::<Vec<_>>();
        assert_eq!(e.len(), 1);
        let (id, v, next) = e[0];
        if forward % 2 == 0 {
            answer[id] = Some((next, v));
        } else {
            answer[id] = Some((v, next));
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 40060
import heapq
N, M = list(map(int,input().split()))
h = []
for i in input().split():
  heapq.heappush(h,-int(i))
for i in range(M):
  x = -heapq.heappop(h)
  x //=2
  heapq.heappush(h,-x)
print(-sum(h))

Measured memory_bytes: 14180
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

struct point_t {
  int y, x;
};

vector<point_t> solve_half(int n, int d) {
  int r = d % 4;
  vector<point_t> result;
  if (r == 2 || r == 3 || d == 0) {
    for (int y = 0; y < n; ++y)
      for (int x = 0; x < n; x += 2)
        result.push_back({y, x});
  } else if (r == 1) {
    for (int y = 0; y < n; ++y)
      for (int x = y % 2; x < n; x += 2)
        result.push_back({y, x});
  } else {
    for (const point_t &p : solve_half((n + 1) / 2, d / 4))
      for (int dy = 0; dy <= 1; ++dy)
        for (int dx = 0; dx <= 1; ++dx) {
          int y2 = 2 * p.y + dy, x2 = 2 * p.x + dx;
          if (max(y2, x2) < n)
            result.push_back({y2, x2});
        }
  }
  assert((int)result.size() >= (n * n + 1) / 2);
  result.resize((n * n + 1) / 2);
  return result;
}

vector<point_t> solve_quarter(int n, int d1, int d2) {
  int r1 = d1 % 4, r2 = d2 % 4;
  if (r1 > r2) return solve_quarter(n, d2, d1);

  vector<point_t> result;
  if (r1 >= 1 || (d1 == 0 && d2 == 0)) {
    for (int y = 0; y < n; y += 2)
      for (int x = 0; x < n; x += 2)
        result.push_back({y, x});
  } else if (r2 == 3) {
    return solve_quarter(n, d1, d1);
  } else if (r2 == 2) {
    for (point_t p : solve_half((n + 1) / 2, d1 / 4)) {
      result.push_back({2 * p.y, 2 * p.x});
      if (2 * p.y + 1 < n)
        result.push_back({2 * p.y + 1, 2 * p.x});
    }
  } else if (r2 == 1) {
    for (point_t p : solve_half((n + 1) / 2, d1 / 4)) {
      result.push_back({2 * p.y, 2 * p.x});
      if (2 * max(p.y, p.x) + 1 < n)
        result.push_back({2 * p.y + 1, 2 * p.x + 1});
    }
  } else {
    for (point_t p : solve_quarter((n + 1) / 2, d1 / 4, d2 / 4))
      for (int dy = 0; dy <= 1; ++dy)
        for (int dx = 0; dx <= 1; ++dx) {
          int y2 = 2 * p.y + dy, x2 = 2 * p.x + dx;
          if (max(y2, x2) < n)
            result.push_back({y2, x2});
        }
  }
  assert((int)result.size() >= (n * n + 3) / 4);
  result.resize((n * n + 3) / 4);
  return result;
}

int main() {
  int n, d1, d2;
  scanf("%d %d %d", &n, &d1, &d2);
  n *= 2;
  for (const point_t &p : solve_quarter(n, d1, d2)) {
    printf("%d %d\n", p.y, p.x);
  }
  return 0;
}


Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

#include <x86intrin.h>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

/*
  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

    cout << max(max(dp[n-3][0], dp[n-2][1]), dp[n-1][2]) << endl;
  }
*/

  vector<ll> even(n/2+16);
  vector<ll> odd(n/2+16);
  for (int i = 0; i < n; i += 2) even[i/2] = a[i];
  for (int i = 1; i < n; i += 2) odd[i/2] = a[i];

  vector<vector<ll> > dp(3, vector<ll>(n/2+16, (ll) -1e18));
  dp[0][0] = even[0];
  for (int i = 0; i < n/2; i++) {
    dp[0][i+1] = dp[0][i] + even[i+1];
  }
  dp[1][0] = odd[0];
  for (int i = 0; i < n/2; i++) {
    dp[1][i+1] = max(dp[0][i], dp[1][i]) + odd[i+1];
  }
  dp[2][0] = even[1];
  for (int i = 0; i < n/2; i++) {
    dp[2][i+1] = max(max(dp[0][i], dp[1][i]), dp[2][i]) + even[i+2];
  }
/*
  for (auto &x: dp) {
    for (auto &y: x) cerr << y << " ";
    cerr << endl;
  }
*/
  ll ans;
  if (n % 2 == 0) ans = max(dp[0][n/2-1], dp[1][n/2-1]);
  else ans = max(max(dp[0][n/2-1], dp[1][n/2-1]), dp[2][n/2-1]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
int abs(int a,int b)
{
	if(a>b)
	{
		return a-b;
	}
	else
	{
		return  b-a;
	}
}
int main()
{
int n;
cin>>n;
int arr[n],arr1[n];
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}
arr1[0]=0;
arr1[1]=abs(arr[1],arr[0]);
for(int i=2;i<n;i++)
{
	int a=abs(arr[i-2],arr[i])+arr1[i-2];
	int b=abs(arr[i-1],arr[i])+arr1[i-1];
	arr1[i]=min(a,b);
}
// for(int i=0;i<n;i++)
// {
// 	cout<<arr1[i]<<" ";
// }
// cout<<endl;
cout<<arr1[n-1]<<endl;











	return 0;
}

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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll M,D; cin>>M>>D;
	ll ans=0;
	f(d,22,D){
		ll d1 = d%10;
		ll d10 = (d/10);

		if(d1>=2 and d1*d10 <=M and d1*d10>=1)  ans++;
	}
	cout<<ans;

	return 0;
}

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

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

	vector<int> a(3);
	for (auto& i : a)
		cin >> i;
	sort(a.rbegin(), a.rend());

	int ans = a[0] * 10;
	ans += a[1];
	ans += a[2];

	cout << ans << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
vector<int> adj[N];
int mod = 1000000007;
long long dp[N][2];


int solve(int i , int j){
	dp[i][0] = 1;
	dp[i][1] = 1;
	for(auto w : adj[i]){
		if(w == j) continue;
		solve(w,i);
		dp[i][0] *= (dp[w][0] + dp[w][1])%mod;
		dp[i][0] %= mod;
		dp[i][1] *= dp[w][0];
		dp[i][1] %= mod;
	}
}


int32_t main(){
	scanf("%d" , &n);
	for(int i = 1 ; i < n ; i ++){
		int x,y;
		scanf("%d%d" , &x , &y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	solve(1,1);
	printf("%lld\n" , (dp[1][0] + dp[1][1])%mod);
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_M=1e5,MAX_Q=1e5,MAX_D=10;

int N,M,Q,v[MAX_Q],d[MAX_Q],c[MAX_Q];
vector<int> G[MAX_N];
bool flg[MAX_N][MAX_D+1];
int col[MAX_N];
void dfs(int v,int d,int c){
	flg[v][d]=true;
	if (d==0){
		if (!col[v]){
			col[v]=c;
		}
	}else{
		if (!flg[v][d-1]){
			dfs(v,d-1,c);
		}
		for(auto e:G[v]){
			if (!flg[e][d-1]){
				dfs(e,d-1,c);
			}
		}
	}
}

int main(){
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	cin>>Q;
	memset(flg,false,sizeof(flg));
	REP(i,Q){
		cin>>v[i]>>d[i]>>c[i];
		v[i]--;
	}
	REP(i,Q){
		if (!flg[v[Q-1-i]][d[Q-1-i]]){
			dfs(v[Q-1-i],d[Q-1-i],c[Q-1-i]);
		}
	}
	REP(i,N){
		cout<<col[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 9080
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<char> c(n);
    cin >> c;

    int ans = 0;
    int l = 0, r = n - 1;
    while (l < n && c[l] == 'R') l++;
    while (0 <= r && c[r] == 'W') r--;

    while (l < r) {
        ans++;
        l++;
        r--;
        while (l < n && c[l] == 'R') l++;
        while (0 <= r && c[r] == 'W') r--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616