akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define DB	double
#define lf	else if
#define	I64	long long
#define Rd()	(rand() << 15 | rand())
#define For(i,a,b)	for(int i=a;i<=b;i++)
#define Rep(i,a,b)	for(int i=a;i>=b;i--)
	
#define fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

#define CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for (; CH < '0' || ch > '9';)	f= (ch == '-');
		for (; ch >= '0' && ch <= '9'; CH)	(x*= 10)+= ch - '0';
		return	f ? -x : x;
}

string	A, B;

int		main()	{
		cin >> A >> B;
		
		sort(A.begin(), A.end());
		sort(B.begin(), B.end());
		
		reverse(B.begin(), B.end());
		
		puts(A < B ? "Yes" : "No");
}



Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200005,maxx=1000000000-1;
const double Pi=acos(-1),tv=20-5*Pi,sv=20-10*Pi;
int x,y,xx,yy,n,F[maxn];bool rev;double ans;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
struct Couple
{
	int x,y;
	inline bool operator < (const Couple& b)const{return x<b.x||(x==b.x&&y<b.y);}
}A[maxn];
inline void Solve()
{
	static int que[maxn],til,ma,mq[maxn];
	sort(A+1,A+1+n);que[0]=-1;
	for(int i=1;i<=n;i++)
	{
		if(A[i].y>que[til]) que[++til]=A[i].y;
		else
		{
			int L=1,R=til,mid;
			while(L<=R)
			{
				mid=(L+R)>>1;
				que[mid]<A[i].y?L=mid+1:R=mid-1;
			}
			que[R+1]=A[i].y;
		}
		if(til==ma) mq[++mq[0]]=i;
		else if(til>ma){mq[mq[0]=1]=i;ma=til;}
	}
	ans=((double)yy-y+xx-x)*100-til*tv;
	if(til==xx-x+1||til==yy-y+1) ans+=tv-sv;
}
int main()
{
	x=read();y=read();xx=read();yy=read();
	if(x>xx){swap(x,xx);swap(y,yy);}
	if(y>yy){y=maxx-y;yy=maxx-yy;rev=true;}
	n=read();ans=1e100;
	for(int i=1;i<=n;i++)
	{
		A[i].x=read();A[i].y=read();
		if(rev) A[i].y=maxx-A[i].y;
		if(A[i].x<x||A[i].x>xx||A[i].y<y||A[i].y>yy){i--;n--;}
	}
	Solve();
	printf("%.12lf\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <cstdio>

using namespace std;

struct Node {
	int x, y, step;
};

int main() {
	int w, h;
	while ( cin >> w >> h, getchar(), w || h ) {
		w = w * 2 - 1, h = h * 2 - 1;
		int m[100][100] = {0};
		for (int y = 0; y < h; ++y) {
			string str; getline(cin, str);
			for (int x = 0; x < str.size(); ++x) {
				if ( str[x] == '1' ) m[y][x] = 1;
			}
		}
		for (int y = 1; y < h; y += 2) {
			for (int x = 1; x < w; x += 2) {
				m[y][x] = 1;
			}
		}
		/*
		for (int y = 0; y < h; ++y) {
			for (int x = 0; x < w; ++x) {
				cout << m[y][x];
			}
			cout << endl;
		}
		*/
		int ans = 0;
		bool gone[100][100] = {0};
		queue<Node> Q; Q.push( (Node){0, 0, 0} );
		while ( !Q.empty() ) {
			Node node = Q.front(); Q.pop();
			int x = node.x, y = node.y, step = node.step;
			if (x < 0 || x >= w || y < 0 || y >= h) continue;

			if (m[y][x]) continue;
			if (gone[y][x]) continue;
			gone[y][x] = true;

			if (x == w-1 && y == h-1) {
				ans = step/2 + 1;
				break;
			}

			Q.push( (Node){x+1, y, step+1} );
			Q.push( (Node){x-1, y, step+1} );
			Q.push( (Node){x, y+1, step+1} );
			Q.push( (Node){x, y-1, step+1} );
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
int N,M,Q,ans=0;
vector<int> a,b,c,d;
vector<int> A(11);
void DFS(int i){
    //A_iが定義されたら，Qについてのループ
    if(i == N){
        int sum = 0;
        REP(j,Q){
            if(A[b[j]] - A[a[j]] == c[j]) sum += d[j];
        }
        ans = max(ans,sum);
        return;
    }
    FOR(j,min(A[i],M),M+1){//for(int j=min(A[i],M);j <=M;j++){
        A[i+1] = j;
        DFS(i+1);
    }
}

int main(void){
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    REP(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    A[0] = 1;
    DFS(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    string s;
    cin>>s;
    long long n=0,ss=0,w=0,e=0;
    f(i,0,s.size()){
        if(s[i]=='N'){
            n++;
        }
        else if(s[i]=='S'){
            ss++;
        }
        else if(s[i]=='W'){
            w++;
        }
        else{
            e++;
        }
    }
    if(n>0&&ss>0&&w==0&&e==0){
        cout<<"Yes"<<endl;
    }
    else if(n==0&&ss==0&&w>0&&e>0){
        cout<<"Yes"<<endl;
    }
    else if(n>0&&ss>0&&w>0&&e>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3552
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;

int main(){
    ll x,k,d; cin >> x >> k >> d;
    ll ans;
    int m = 0;
    if(x < 0){
        m = 1;
        x = -x;
    }
    if(k < x/d) ans = x-d*k;
    else{
        ans = x%d;
        ll l = k-x/d;
        if(l%2==1) ans = ans-d;
    }
    if(m) ans = -ans;
    if(ans < 0) ans = -ans;
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll n; cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0)
            continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	int sum=0,sub=0;
	vector<string> vec(N);
	for(int i=0; i<N; i++){
		cin>>vec[i];
	}
	
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(vec[i]==vec[j]){
				sub++;
			}
		}
	}
	
	if(sub==N){
		sum++;
	}//条件1
	
	sub=0;
	for(int i=0; i<N-1; i++){
	    string t=vec[i];
	    string u=vec[i+1];
	    int k=t.size();
		if(t.at(k-1)==u.at(0)){
			sub++;
		}
	}
	if(sub==N-1){
		sum++;
	}
	
	
	if(sum==2){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b){
        for(int i = 0; i < b; i++){
            printf("%d", a);
        }
    }else{
        for(int i = 0; i < a; i++){
            printf("%d", b);
        }
        
    }
    puts("");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long llong;

static const int INF = 2147483647;

int main( void ) {
  llong n, a, left, right, diff, point, min=INF;

  cin >> n;
  vector<llong> A(n);
  vector<llong> S(n);
  
  for(int i=0;i<n;i++) {
    cin >> a;
    
    A.at(i) = a;
    if (i==0) S.at(i) = a;
    else S.at(i) = S.at(i-1) + a;
  }

  for(int i=0;i<n;i++) {
    left = S.at(i);
    right = S.at(n-1) - S.at(i);
    diff = left-right;
    if(diff<0) diff *= -1;
    if(min>diff) {
      min = diff;
      point = i;
    }
  }

  if(n==2&&(A.at(0)==A.at(1))) min=0;
  else if (n!=2&&point!=n-1&&A.at(point)==A.at(point+1)) min = A.at(point);
  else ;

  cout << min << endl;

  return ( 0 );
}


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

long long  maxprofit(vector<int> w,vector<int> v,int n,int c)
{
	vector<vector<long long> > dp(n+1,vector<long long>(c+1));

	for (int i = 0; i <=n; i++)
	{
		for (int j = 0; j <=c; j++)
		{
			if(i==0 || j==0) dp[i][j] = 0;
			else if(w[i-1]<=j) dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	
	return dp[n][c];
}

int main()
{
	
	int n,c;
	cin>>n>>c;
	vector<int> w(n),v(n);
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	
	cout<<maxprofit(w,v,n,c)<<endl;

 
}



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

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

int main(){
	ios::sync_with_stdio(0);
	int N,M;
	cin>>N>>M;
	map< pair<int,int> , string >m;
	vector< pair<int,int> >arr(M);
	vector< pair<int,int> >arr2(M);
	for(int i=0;i<M;i++){
	    cin>>arr[i].first>>arr[i].second;
	    arr2[i].first=arr[i].first;
	    arr2[i].second=arr[i].second;
	}
	sort(arr.begin(),arr.end(),cmp);    
// 	for(int i=0;i<M;i++)
// 	    cout<<arr[i].first<<" "<<arr[i].second<<"\n";
        int total=0;
        int city=arr[0].first;
    for(int i=0;i<M;i++){
        string f="";
        string s="";
        if(arr[i].first==city){
            ++total;
        s=to_string(total);
        f=to_string(city);
        int z=s.size();
        int y=f.size();
        z=6-z;
        y=6-y;
        int q;
        for(q=0;q<z;q++)
            s='0'+s;
        for(q=0;q<y;q++)
            f='0'+f;
        m[make_pair(arr[i].first,arr[i].second)]=f+s;    
        }
        else{
            city=arr[i].first;
            total=0;
            --i;
        }
    }
    for(int i=0;i<M;i++)
        cout<<m[make_pair(arr2[i].first,arr2[i].second)]<<"\n";
	return 0;
}

Measured memory_bytes: 14080
n = int(input())
a, b = map(int, input().split())
plist = list(map(int, input().split()))
q = [0] * 3
for p in plist:
  if (p <= a):
    q[0] += 1
  elif ((p > a) & (p <= b)):
    q[1] += 1
  else:
    q[2] += 1
print(min(q))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#define re register
#define ll long long
using namespace std;
ll n,a[3005],s;
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		s+=a[i];
	}
	s-=n;
	cout<<s<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cmath>

using namespace std;

int main() {
	int d, a; double rad = 0; double x = 0, y = 0;
	while (true) {
		scanf("%d,%d", &d, &a);
		if (d == 0 && a == 0)break;
		y += d*cos(rad*M_PI/180);
		x += d*sin(rad*M_PI/180);
		rad =rad+a;
	}
	cout <<int(x) << endl <<int(y) << endl;
}

Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>
#include<set>
#define x first
#define y second
using namespace std;
typedef long long LL;
const int N = 2e5;
pair<LL,LL> a[N];
LL AABB(set<pair<LL,int>>& xs, set<pair<LL,int>>& ys)
{
	return ((*(--xs.end())).first-(*xs.begin()).first)*((*(--ys.end())).first-(*ys.begin()).first);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n; cin >> n;
	set<pair<LL,int>> xs, ys;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i].x >> a[i].y;
		if(!(a[i].x >= a[i].y))
			swap(a[i].x,a[i].y);
	}
	sort(a,a+n);
	for(int i = 0; i < n; i++)
	{
		xs.insert({a[i].x,i});
		ys.insert({a[i].y,i});
	}
	
	LL ans = AABB(xs,ys);
	for(int i = n-1; i >= 0; i--)
	{
		xs.erase({a[i].x,i});
		ys.erase({a[i].y,i});
		xs.insert({a[i].y,i});
		ys.insert({a[i].x,i});
		ans = min(ans,AABB(xs,ys));
	}
	cout<<ans<<endl;

	cout<<flush;
	return 0;
}

Measured memory_bytes: 28416
// 解き直し.
// https://atcoder.jp/contests/abc156/tasks/abc156_f
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL d[5050], dMod[5050];

int main(){
    
    // 1. 入力情報.
    int k, q;
    scanf("%d %d", &k, &q);
    rep(i, k) scanf("%lld", &d[i]);
    
    // 2. クエリに回答(解説通り).
    rep(i, q){
        LL n, x, m, s = 0, t = 0;
        scanf("%lld %lld %lld", &n, &x, &m);
        
        // 2-1. d の 要素 を m で 割った余りで置き換える.
        rep(j, k) dMod[j] = d[j] % m;
        
        // 2-2. (a[i] mod m) == (a[i + 1] mod m) となる場合.
        rep(j, k){
            // if(dMod[j] % k == 0){ // 誤答となるっぽい.
            if(dMod[j] == 0){
                LL q = (n - 1) / k;
                LL r = (n - 1 - j) - q * k;
                s += (q + (r > 0));
            }
        }
        
        // 2-3. (a[i] mod m) > (a[i + 1] mod m) となる場合.
        // a[n - 1] を m で 割った商 から a[0] を m で 割った商 を 引く.
        // ex.
        // k = 5, n = 12
        // i = 0 1 2 3 4 5 6 7 8 9 10 11 (= n - 1)
        // a[0]  = x
        // a[1]  = x + 1 * d[0]
        // a[2]  = x + 1 * d[0] + 1 * d[1]
        // a[3]  = x + 1 * d[0] + 1 * d[1] + 1 * d[2]
        // a[4]  = x + 1 * d[0] + 1 * d[1] + 1 * d[2] + 1 * d[3]
        // a[5]  = x + 1 * d[0] + 1 * d[1] + 1 * d[2] + 1 * d[3] + 1 * d[4]
        // a[6]  = x + 2 * d[0] + 1 * d[1] + 1 * d[2] + 1 * d[3] + 1 * d[4]
        // a[7]  = x + 2 * d[0] + 2 * d[1] + 1 * d[2] + 1 * d[3] + 1 * d[4]
        // a[8]  = x + 2 * d[0] + 2 * d[1] + 2 * d[2] + 1 * d[3] + 1 * d[4]
        // a[9]  = x + 2 * d[0] + 2 * d[1] + 2 * d[2] + 2 * d[3] + 1 * d[4]
        // a[10] = x + 2 * d[0] + 2 * d[1] + 2 * d[2] + 2 * d[3] + 2 * d[4]
        // a[11] = x + 3 * d[0] + 2 * d[1] + 2 * d[2] + 2 * d[3] + 2 * d[4]
        t = x;
        rep(j, k){
            LL q = (n - 1) / k;
            LL r = (n - 1 - j) - q * k;
            LL u = (q + (r > 0)) * dMod[j];
            t += u;
        }
        // printf("s=%lld t=%lld n=%lld\n", s, t, n);
        t /= m;       // (a[n - 1] / m) を 計算.
        t -= (x / m); // (a[0] / m) を マイナス.
        
        // 2-4. (n - 1) から, 前項までの結果をマイナス.
        LL ans = (n - 1) - (s + t);
        printf("%lld\n", ans);
    }
    return 0;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

set<int> G[200010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].insert(b);
        G[b].insert(a);
    }
    rep(i, 1, n - 1){
        if(G[0].count(i) && G[n - 1].count(i)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 28416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  string r,l;
  cin >> r;
  int n;
  cin >> n;
  
  rep(i,n){
    int ty;
    cin >> ty;
    if (ty == 1) swap(l,r);
    else {
      int f;
      char c;
      cin >> f >> c;
      if(f==1) l += c;
      else r += c;
    }
  }
  
  reverse(l.begin(), l.end());
  cout << l << r << endl;
  
  }

Measured memory_bytes: 960
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val vs = Array.fill(n)(sc.nextInt)
  val cs = Array.fill(n)(sc.nextInt)
  println(vs.zip(cs).collect{case (v, c) if v > c => v -c}.sum)
}

Measured memory_bytes: 25928
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  co(min(a, b) + min(c, d));
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  	int N, a = 0;
  	cin >> N;
 	for(int i = N; i > 0; i /= 10){
      	a += i % 10;
    }
  	if(N % a == 0){
      	cout << "Yes";
    }else{
      	cout << "No";
    }
  	return 0;
}

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

using namespace std;


int main(){
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(), t.end());

    if(s < t){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import datetime

lst = input().split()

h1 = int(lst[0])
m1 = int(lst[1])
h2 = int(lst[2])
m2 = int(lst[3])
k = int(lst[4])

d = (60 * h2 + m2) - (60 * h1 + m1)

print(int(d - k))

Measured memory_bytes: 9336
#include <bits/stdc++.h>
#define rep(i,s,e) for(int i = s; i < e; i++)
#define test(t) int t; cin >> t; while(t--) 
#define iterate(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef set<int> si;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll N,W;
  N = W = 0;
  cin >> N >> W;
  ll w[N],v[N];
  rep(i,0,N) {
    cin >> w[i] >> v[i];
  }
  ll arr[N+1][W+1];
  rep(i,0,N+1) {
    rep(j,0,W+1) {
      arr[i][j] = 0;
    }
  }
  rep(i,1,W+1) {
    rep(j,1,N+1) {
      ll ifincl = i - w[j-1];
      arr[j][i] = max(arr[j-1][i],arr[j][i-1]);
      if(ifincl < 0) continue;
      arr[j][i] = max(arr[j][i],arr[j-1][ifincl] + v[j-1]);
    }
  }
  cout << arr[N][W] << endl;
  return 0;
}


Measured memory_bytes: 79232
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

zero_cnt = a.count { |v| v.zero? }
negative_cnt = a.count { |v| v < 0 }
abs_sum = a.map(&:abs).inject(&:+)
if zero_cnt > 0 || negative_cnt % 2 == 0
  puts abs_sum
else
  min_abs = a.map(&:abs).min
  puts abs_sum - min_abs * 2
end


Measured memory_bytes: 11268
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s,a;
	cin >> s;
	for (int i=0;i<s.length();i++) {
		if (s[i]=='0') a+='0';
		else if  (s[i]=='1') a+='1';
		else {
        	if (a.length()!=0) a.pop_back();
        }
	}
	cout << a;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int L, R;
	cin >> L >> R;

	if (R-L+1 >= 2019) {
		cout << 0 << endl;
	}
	else {
		int ans = 2019;
		for (int i = L; i < R;i++) {
			for (int j = i + 1; j <= R;j++) {
				ans = min(ans, (int)((long long)i * j % 2019));
			}
		}
		cout << ans << endl;
	}




	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
cts = [tuple(map(int, input().split())) for _ in range(n)]

c_ans = float('inf')
for ct in cts:
    if ct[1] <= t:
        c_ans = min(c_ans, ct[0])
if c_ans == float('inf'):
    print('TLE')
else:
    print(c_ans)


Measured memory_bytes: 9180
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int k;
    cin >> k;

    ll seq = 0;
    REP(i, (int)1e7) {
        seq = (seq*10+7)%k;
        if (seq == 0) {
            cout << i+1 << endl;
            return 0;
        }
    } 

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3636
import sys

N = int(sys.stdin.readline())

def main():
    print(0)
    sys.stdout.flush()
    r = sys.stdin.readline().strip()
    if r == 'Vacant':
        return
    if r == 'Male':
        t = ['Male', 'Female']
    else:
        t = ['Female', 'Male']
    left = 1
    right = N - 1

    while True:
        pos = (left + right) // 2
        print(pos)
        sys.stdout.flush()
        r = sys.stdin.readline().strip()
        if r == 'Vacant':
            return
        if t[pos % 2] == r:
            left = pos + 1
        else:
            right = pos - 1

main()

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

int main() {
  int X, A;
  cin >> X >> A;
  if(X < A) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int a = in();
    int b = in();
    if (b * 2 > a){
        print(0);
    }
    else{
        print(a - b * 2);
    }

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string c;int i;
    cin>>c;
    for(i=0;c[i]!='C';i++)
    if(i==c.size()){
        cout<<"No"<<endl;
        return 0;
    };
    for(;c[i]!='F';i++)
    if(i==c.size()){
        cout<<"No"<<endl;
        return 0;
    };
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

vector <ll> pos;
vector <ll> neg;
int cntZero = 0;

ll badCase(int k) {
    ll ans = 1;
    if (cntZero) {
        ans = 0;
    }
    else {
        vector <ll> vall;
        rep(i, 0, SZ(pos)) vall.push_back(pos[i]);
        rep(i, 0, SZ(neg)) vall.push_back(-neg[i]);
        sort(all(vall));
        rep(i, 0, k) ans = ans * vall[i] % mod;
        ans = -ans;
    }
    return (ans + (ans < 0 ? mod: 0));
}

ll goodCase(int k) {
    ll ans = 1;
    sort(all(pos));
    sort(all(neg));
    reverse(all(neg));

    while (k) {
        if (k == 1) {
            k--;
            ans = ans * pos.back() % mod;
            pos.pop_back();
        }
        else {
            k -= 2;
            int sp = SZ(pos);
            int sn = SZ(neg);
            if (sp >= 2 && sn >= 2) {
                if (pos[sp - 1] * pos[sp - 2] > neg[sn - 1] * neg[sn - 2]) {
                    ans = ans * pos[sp - 1] % mod * pos[sp - 2] % mod;
                    pos.pop_back();
                    pos.pop_back();
                }
                else {
                    ans = ans * neg[sn - 1] % mod * neg[sn - 2] % mod;
                    neg.pop_back();
                    neg.pop_back();
                }
            }
            else if (sp >= 2) {
                ans = ans * pos[sp - 1] % mod * pos[sp - 2] % mod;
                pos.pop_back();
                pos.pop_back();
            }
            else {
                ans = ans * neg[sn - 1] % mod * neg[sn - 2] % mod;
                neg.pop_back();
                neg.pop_back();
            }
        }
    }
    return (ans + (ans < 0 ? mod : 0));
}

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

    int n, k;
    cin >> n >> k;
    
    rep(i, 0, n) {
        int num;
        cin >> num;
        if (num > 0) {
            pos.push_back(num);
        }
        else if (num == 0) {
            cntZero++;
        }
        else {
            neg.push_back(num);
        }
    }

    if (k % 2 == 0) {
        if (SZ(pos) / 2 * 2 + SZ(neg) / 2 * 2 >= k) {
            cout << goodCase(k) << endl;
        }
        else {
            cout << badCase(k) << endl;
        }
    }
    else {
        if (SZ(pos) + SZ(neg) / 2 * 2 >= k && SZ(pos)) {
            cout << goodCase(k) << endl;
        }
        else {
            cout << badCase(k) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll h, w;
  cin >> h >> w;
  if(h%3==0 || w%3==0) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = LLONG_MAX;
  ll a = w/3 -10;
  ll b = h/2 -10;
  rep(i,20)rep(j,20) {
    ll c = a+i;
    ll d = b+j;
    if(c<=0 || d<=0) continue;
    if(c>=w || d>=h) continue;
    ll s1 = c*h;
    ll s2 = (w-c)*d;
    ll s3 = h*w - s1 - s2;
    if(s1<=0 || s2<=0 || s3<=0) continue;
    ll smax = max(s1,max(s2,s3));
    ll smin = min(s1,min(s2,s3));
    ans = min(ans,smax-smin);
  }
  ll o = h/3 -100;
  ll p = w/2 -100;
  rep(i,200)rep(j,200) {
    ll q = o+i;
    ll r = p+j;
    if(q<=0 || r<=0) continue;
    if(q>=h || r>=w) continue;
    ll s1 = q*w;
    ll s2 = (h-q)*r;
    ll s3 = h*w - s1 - s2;
    if(s1<=0 || s2<=0 || s3<=0) continue;
    ll smax = max(s1,max(s2,s3));
    ll smin = min(s1,min(s2,s3));
    ans = min(ans,smax-smin);
  }
  ans = min(ans,h);
  ans = min(ans,w);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(n); ++i)
#define REP(i, d, n) for(long long i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main() {

int d,t,s; cin>>d>>t>>s;
  if(t*s>=d){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;

    

  
}


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

using ll = long long;

int n;
std::vector<ll> vec;
std::vector<ll> ans;

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        ll a;
        std::cin >> a;
        vec.push_back(a);
    }
    for (int i = 1; i < n; i++) {
        vec[i] += vec[i-1];
    }
    for (int i = 0; i < n-1; i++) {
        ans.push_back(std::abs(vec[i] - (vec[n-1] - vec[i])));
    }
    std::cout << *std::min_element(ans.begin(), ans.end()) << std::endl;
}


Measured memory_bytes: 4848
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val t = Array<Int>(n + 1, { 0 })
    val x = Array<Int>(n + 1, { 0 })
    val y = Array<Int>(n + 1, { 0 })
    for (i in (1..n)) {
        t[i] = scanner.nextInt()
        x[i] = scanner.nextInt()
        y[i] = scanner.nextInt()
    }

    for (i in (1..n)) {
        val d = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1])
        val td = t[i] - t[i - 1]
        if (d % 2 != td % 2 || td < d) {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 108552
#include "bits/stdc++.h"
using namespace std;
using ll = int64_t; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }



int main() {
	int n, h, w;
	cin >> n >> h >> w;
	int cnt = 0;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		cnt += (a >= h && b >= w);
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
   int N; cin >> N;
   vector<int> a(N);
   rep(i,N) cin >> a[i];
   int ans = INF;
   repr(i,-100,101){
       int now = 0;
       rep(j,N){
           now += abs(i-a[j]) * abs(i-a[j]);
       }
       ans = min(ans,now);
   }
   cout << ans << endl;
}


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

using namespace std;
#define         MAX         1000000
#define         ll          long long
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)

long long int cnt;

int main() {

    int n;
    string s;
    cin>>n>>s;
    int r=0,g=0,b=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }

    cnt = (ll)r*g*b;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int k = j+(j-i);
            if(k>=n) break;
            if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]) cnt--;
        }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> n >> x;
	vector<int> data(n);
	
	int en = 0;
	
	rep(i, 0, n) {
		
		cin >> data[i];
		en += data[i];
	}

	int ans = n;

	int cnt = x - en;

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

	ans += cnt / data[0];

	cout << ans << endl;
	


}
	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
		int y = sc.nextInt();

		boolean ans = false;
		long a = 1;
		if(y>x) {
			int yy = y;
			y = x;
			x = yy;
		}
		if((double)x/y>2.0) {

		}else {

			if((y-(x-y))%3!=0) {

			}else {
				ans = true;
				int s = (2*y-x)/3;
				int t = x-y;
				int[] divided = new int[s];
				int[] divide  = new int[s];
				for(int i=0;i<s;i++) {
					divided[i]=s+t+1+i;
					divide[i]=i+1;
				}

				for(int i =0;i<s;i++) {
					a = (a*divided[i])%1000000007;
				}
				long b = 1;
				for(int i =0;i<s;i++) {
					b = (b*divide[i])%1000000007;
				}
				long c =1;
				for(int i =0;i<100000;i++) {
					c = (c*b)%1000000007;
				}
				for(int i =0;i<10000;i++) {
					a = (a*c)%1000000007;
				}

				for(int i =0;i<5;i++) {
					a = (a*b)%1000000007;
				}
			}
		}
		if(ans) {
			System.out.println(a);
		}else {
			System.out.println(0);
		}
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


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

using namespace std;

int main(void) {
  int n,q,l,r;
  cin >> n >> q;
  string s;
  cin >> s;

  int ans[100000] = {0};
  for (int i = 0;i < n - 1;i++)
  {
    if (s[i] == 'A' && s[i + 1] == 'C')
    {
      ans[i + 1] = ans[i] + 1;
    }
    else
    {
      ans[i + 1] = ans[i];
    }
  }

  for (int i = 0; i < q;i++)
  {
    cin >> l >> r;
    l--;r--;
    cout << ans[r] - ans[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
int x ; string s;
cin >> x; cin >> s;
string s1; string s2;
bool ans = false;
if ( x % 2 == 0) {
    s1 = s.substr(0, x/2); s2 = s.substr(x/2, x/2);
    ans = s1 == s2 ;
}
string res = ans ? "Yes" : "No" ;
cout << res;
// return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  string s ;
  cin >> n >> s ;
  int cnt = 0 ;
  REP(i,n-2){
    if(s.substr(i,3)=="ABC"){
      cnt++ ;
    }
  }cout << cnt <<endl ;
      
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200010


int main(void) {
	long long dp[N];
	long long h[N];
	long long n;
	scanf("%lld", &n);
	f(i, n)scanf("%lld", &h[i]);
	f(i, n)dp[i] = MOD;
	dp[0] = 0;
	f(i, n - 1) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	printf("%lld\n", dp[n - 1]);
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define pb(a) push_back(a)
#define mp make_pair
#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int n = 0;
	cin >> n;
	int ct = 0;
	vector<int> nums(n);
	REP(i, n)
	{
		cin >> nums[i];
	}

	REP(i, n - 2)
	{
		int a = nums[i];
		int b = nums[i + 1];
		int c = nums[i + 2];
		if (nums[i] < nums[i + 1] &&  nums[i + 1] < nums[i + 2])
		{
			ct++;
		}
		else if (nums[i] > nums[i + 1] && nums[i + 1] > nums[i + 2])
		{
			ct++;
		}
	}
	
	COUT(ct);

	return 0;
}

Measured memory_bytes: 256
while true do

  n = $stdin.gets.to_i
  break if n == 0

  t = {}
  
  l = $stdin.gets.split(/\s*/)

  m = 0
  l.each do |e|
    if t[e] then
      t[e] += 1
    else
      t[e] =  1
    end

    m += 1

    s = t.sort { |a, b| b[1] <=> a[1] }
    if (s.size == 1) and (s[0][1] > (n-m)) then
      break
    elsif (s.size > 1) and ((s[0][1] - s[1][1]) > (n-m)) then
      break
    end
  end

  s = t.sort { |a, b| b[1] <=> a[1] }

  if s.size == 1 then
    printf("%s %d\n", s[0][0], m )
  elsif s[0][1] > s[1][1] then
    printf("%s %d\n", s[0][0], m )
  else
    printf("TIE\n")
  end

end



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

int main(){
    int a,b,c;
    string A,B,C;
    cin>>A>>B>>C;
    a = A.length() - 1;
    b = B.length() - 1;
    c = C.length() - 1;

    if(A[a]==B[0] && B[b]==C[0]){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
int main() {
  int N;
  string S;
  int K;
  cin>>N >> S >> K;
 
  for(int i = 0; i <N; i++ ) {
    if(S.at(i)!=S.at(K-1)){
  S.at(i)='*';
   }
  }
cout << S<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>a(N);
  for (int i = 0; i < N; i ++) cin >> a[i];
  int ans = 0;
  vector<bool>b(1000000001, false);
  for (int i = 0; i < N; i ++) {
    if (b[a[i]]) {
      ans --;
      b[a[i]] = false;
    }
    else {
      ans ++;
      b[a[i]] = true;
    }
  }
  cout << ans << endl;
}
  




Measured memory_bytes: 122752
S = str(input())
cont = 0
ans = 0
for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        cont += 1
        if ans < cont:
            ans = cont
    else:
        if ans < cont:
            ans = cont
        cont = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll n, k;
    cin >> n >> k;
    if(k-1 <= (n-1)/2){
        set<ll> st;
        for(ll i = 0; i < n*2; i++){
            st.insert(k+i);
        }
        for(ll i = k+n*3-1, x=k+n*2-1; i >= k+n*2; i-=2, x--){
            ll y = i-x;
            cout << x << " " << y << " " << i << endl;
            st.erase(x);
            st.erase(y);
        }
        for(ll i = k+n*3-2; i >= k+n*2; i-=2){
            ll x = *--st.end();
            st.erase(x);
            ll y = *--st.upper_bound(i-x);
            cout << x << " " << y << " " << i << endl;
            st.erase(y);
        }
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N+1);
  for(int i=0;i<N+1;i++){
    cin>>A.at(i);
  }
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  int64_t ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)<B.at(i)&&A.at(i)+A.at(i+1)>=B.at(i)){
      ans+=B.at(i);
      A.at(i+1)=A.at(i+1)-B.at(i)+A.at(i);
    }
    else if(A.at(i)<B.at(i)&&A.at(i)+A.at(i+1)<B.at(i)){
      ans+=A.at(i)+A.at(i+1);
      A.at(i+1)=0;
    }
    else if(A.at(i)==B.at(i)){
      ans+=A.at(i);
    }
    else if(A.at(i)>B.at(i)){
      ans+=B.at(i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3984
A, B, K= map(int, input().split())
 
if A >= K:
  ans_t = A - K
  ans_a = B
elif B >= ( K - A):
  ans_t = 0
  ans_a = B - ( K - A)
else:
  ans_t = 0
  ans_a = 0
 
print( '{} {}'.format( ans_t, ans_a))

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;

ll i,j,k;


int main(){
   ll N,K;
   cin>>N>>K;
   V d(K);
   vector<V> A(K,V());
   rep(i,K){
       cin>>d[i];
       
       rep(j,d[i]){
          ll q;
          cin>>q;
          A[i].push_back(q);
       }
   }
   set<ll> snuke;
   
   rep(i,K){
       rep(j,d[i]){
           snuke.insert(A[i][j]);
       }
   }
   cout<<N-snuke.size()<<endl;
}


Measured memory_bytes: 3688
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int n, a, b;
    cin >> n;
    if(n == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> a >> b;
        cout << a + b << endl;
    }
}


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

long long int modpow(long long int A , long long int N){
  long long int ans = 1 , B = N ;
  while(B >= 1){
    if(B % 2 == 1) ans = (ans * A) % 1000000007 ;
    A = (A * A) % 1000000007 ;
    B /= 2 ;
  }  
  return ans ;
}  

long long int modinv(long long int a, long long int mod){
  long long int ans = 1 , n = mod - 2 ;
  while(n > 0){
    if(n & 1) ans = (ans * a) % mod ;
    a = (a * a) % mod ;
    n = n >> 1 ;
  }  
  return ans ;
}  

long long int ansgudge(long long int a){
  if(a >=1000000007) return ansgudge(a - 1000000007);
  else if(a < 0) return ansgudge(a + 1000000007);
  else return a;
}

int main(){
  long long int N, A, B, ans = 0, seki = 1 ;
  cin >> N >> A >> B;
  long long int NCA = 1, NCB = 1 ;
  ans = modpow(2, N) ;
  for(long long int i=0;i<A;i++){
    NCA = (NCA * (N-i)) % 1000000007 ;
    NCA = (NCA * modinv(i+1,1000000007)) % 1000000007 ;
  }  
  ans = ans - NCA ; 
  for(long long int i=0;i<B;i++){
    NCB = (NCB * (N-i)) % 1000000007 ;
    NCB = (NCB * modinv(i+1,1000000007)) % 1000000007 ;
  }  
  ans = ans - NCB ; 
  ans = ansgudge(ans) - 1 ;
  
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <math.h>  /* M_PI */
using namespace std;

int main() {
    int a, b;
    char op;

    cin >> a >> op >> b;
    while(op!='?'){
    switch(op)
    {
        case '+':
        cout << a+b << endl;
        break;

        case '-':
        cout << a-b << endl;
        break;

        case '*':
        cout << a*b << endl;
        break;

        case '/':
        cout << a/b << endl;
        break;
    }
    cin >> a >> op >> b;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

int main() {
  ll n, t;
  cin >> n >> t;
  vector<ll> a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }

  vector<vector<ll>> dpl(n + 1, vector<ll>(t, -1));
  dpl[0][0] = 0;
  REP(i, n) {
    REP(j, t) if (dpl[i][j] != -1) {
      chmax(dpl[i + 1][j], dpl[i][j]);
      if (j + a[i] < t) chmax(dpl[i + 1][j + a[i]], dpl[i][j] + b[i]);
    }
  }
  REP(i, n + 1) REP(j, t - 1) { chmax(dpl[i][j + 1], dpl[i][j]); }

  vector<vector<ll>> dpr(n + 1, vector<ll>(t, -1));
  dpr[0][0] = 0;
  REP(i, n) {
    REP(j, t) if (dpr[i][j] != -1) {
      chmax(dpr[i + 1][j], dpr[i][j]);
      if (j + a[n - 1 - i] < t)
        chmax(dpr[i + 1][j + a[n - 1 - i]], dpr[i][j] + b[n - 1 - i]);
    }
  }
  REP(i, n + 1) REP(j, t - 1) { chmax(dpr[i][j + 1], dpr[i][j]); }

  ll ans = 0;
  FOR(i, 1, n + 1) {
    REP(j, t) {
      ll x = dpl[i - 1][j] + dpr[n - i][t - 1 - j] + b[i - 1];
      chmax(ans, x);
    }
  }
  cout << ans << endl;
}


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

int main ()
{
	int w,h,n;
	int s,l,r,t,b;
	int x,y,a;
	int i;

	scanf("%d %d %d", &w, &h, &n);

	l = 0;
	r = w;
	b = 0;
	t = h;

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &x, &y, &a);
		switch(a) {
		case 1:
			if (l < x)
				l = x;
			break;
		case 2:
			if (r > x)
				r = x;
			break;
		case 3:
			if (b < y)
				b = y;
			break;
		case 4:
			if (t > y)
				t = y;
			break;
		}
	}

	if (r > l && t > b) {
		s = (r - l) * (t - b);
		printf("%d\n", s);
	} else {
		printf("0\n");
	}

	return 0;
}


Measured memory_bytes: 128