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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    ll x[1006],y[1006];
    ll r[1006] = {};
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    cin >> N;
    x[N+1] = x[1];
    y[N+1] = y[1];
    Rep(i,N){
        cin >> x[i+1] >> y[i+1] >> r[i+1];
    }

    N+=2;
    double dist[1005][1005] = {};
    double distance = 0;

    Rep(i,N){
        Rep(j,N){
            distance = 1.0 * (x[i] - x[j]) * (x[i] - x[j]) + 1.0 * (y[i] - y[j]) * (y[i] - y[j]);
            distance = sqrt( distance ) - r[i] - r[j];
            distance = max( distance, 0.0 );
            dist[i][j] = distance;
            //printf ("%.12lf %d %d\n", dist[i][j] ,  i , j);
        }
    }

    using Pll = pair< double , int >;


    priority_queue<Pll, vector<Pll>, greater<Pll> > dij;
    dij.push( Pll(0.0,0) );
    double cost[1005] = {};
    fill( cost+1, cost+N, INF*INF );

    Pll tmp;
    int v;
    while( !dij.empty() ){
        tmp = dij.top();
        dij.pop();
        v = tmp.second;
        if( cost[v] < tmp.first ) continue;
        Rep( i,N ){
            if( cost[i] > cost[v] + dist[v][i] ){
                cost[i] = cost[v] + dist[v][i];
                dij.push( Pll( cost[i],i ) );
            }
        }

    }
    printf ("%.9lf\n", cost[N-1]);




    return 0;
}



Measured memory_bytes: 13936
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int curr;
const int MAXN = 250;
int ans[MAXN];
int n;
deque<int> dq;
int check(int mid){
    cout<<"? ";
    for(int i=mid;i<=mid+n-1;i++){
        cout<<i<<" ";
    }
    cout<<endl;
    cout.flush();
    string s;
    cin>>s;
    if(s=="Red"){
        return 1;
    }else{
        return 2;
    }
}
int query(){
    cout<<"? ";
    for(int i=0;i<n;i++){
        cout<<dq[i]<<" ";
    }
    cout<<endl;
    cout.flush();
    string s;
    cin>>s;
    if(s=="Red"){
        return 1;
    }else{
        return 2;
    }
}
int l,r;
int res;
int checker,checker2;
int main(){

    cin>>n;
    for(int i=1;i<=n;i++){
        dq.push_back(i);
    }
    int l=2;
    int r= n+1;
    int checker =query();
    if(checker == 1){
        checker2 = 2;
    }else{
        checker2 = 1;
    }
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid)!=checker){
            res = mid;
            r= mid-1;
        }else{
            l=mid+1;
        }
    }
    ans[res+n-1] = checker2;
    ans[res-1] = checker;
    l = res;
    r = res+n-2;
    dq.clear();

    for(int i=l;i<=r;i++){
        dq.push_back(i);
    }
    for(int i=1;i<=l-2;i++){
        dq.push_back(i);
        ans[i] = query();
        dq.pop_back();
    }
    for(int i=r+2;i<=2*n;i++){
        dq.push_back(i);
        ans[i] = query();
        dq.pop_back();
    }
    dq.clear();
    int targetone = (n-1)/2;
    int targettwo = (n-1)/2;
    for(int i=1;i<=l-1;i++){
        if(ans[i] == 1 && targetone){
            targetone--;
            dq.push_back(i);
        }else if(ans[i] == 2 && targettwo){
            targettwo--;
            dq.push_back(i);
        }
    }
    for(int i=r+1;i<=2*n;i++){
        if(ans[i] == 1 && targetone){
            targetone--;
            dq.push_back(i);
        }else if(ans[i] == 2 && targettwo){
            targettwo--;
            dq.push_back(i);
        }
    }
    for(int i=l;i<=r;i++){
        dq.push_back(i);
        ans[i] = query();
        dq.pop_back();
    }
    cout<<"! ";
    for(int i=1;i<=2*n;i++){
        if(ans[i] == 1){
            cout<<"R";
        }else if(ans[i] == 2){
            cout<<"B";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 724
#include <iostream>
using namespace std;
#include <math.h>
#include <stdio.h>
#define PI 3.141592653589
int main(void){
        int a,b;
        double S,L,h,deg,C,c;
        cin>>a>>b>>deg;
        C=deg*PI/180;
        S=a*b*sin(C)/2;
        c = sqrt(a*a + b*b - 2*a*b*cos(C));
        L=a+b+c;
        h=b*sin(C);
        printf("%f\n%f\n%f\n",S,L,h);
        return 0;
}


Measured memory_bytes: 3332
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    
template<typename T>
T lcm(T a, T b){
    return a/gcd(a,b)*b;
}       

int main(){
    ll c=0,d=0,n,h,w,l,r,ans=0,ptr=0;
    string s,s1,s2;
    cin >> s >> n;
    for(int i=0;i<n;i++){
        if(s[i]=='1'){
            continue;
        }
        else{
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;

}


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

int main(){
    int h1, m1, h2, m2;
    cin >> h1 >> m1 >> h2 >> m2;
    int k;
    cin >> k;
    int time = h2*60+m2-h1*60-m1;
    cout << time - k << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int N, L;
	cin >> N >> L;
	vector<string>S(N);
	rep(i, N)cin >> S[i];
	sort(S.begin(), S.end());
	rep(i, N)cout << S[i];
}

Measured memory_bytes: 256
import heapq
import math

def calc(n):
    return n*(-1)

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    AA = list(map(calc, A)) 
    heapq.heapify(AA) 
    
    for i in range(M):
        tmp = heapq.heappop(AA)
        tmp = math.floor(-tmp / 2)*(-1)
        heapq.heappush(AA, tmp)
    
    print(sum(AA)*(-1))

main()

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
 vector<int>M(5);
 REP(i, 5) cin >> M.at(i);

 vector<int>MT(5);
 REP(i, 5){
     MT.at(i) = (M.at(i) + 9) / 10 * 10;
 }
int BT = INF;
REP(i, 5){
    int tmp = 0;
    REP(j, 5){
    if(i == j) tmp += M.at(j);
    else tmp += MT.at(j);
    }
     BT = min(BT, tmp);
}
print(BT);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//親の頂点p,今見てるのv
void dfs(vector<vector<ll>>& graph,ll v,ll p,ll x,vector<ll>& cnt){
    cnt[v]+=x;
    for(auto next:graph[v]){
        if(next==p)continue;
        dfs(graph,next,v,cnt[v],cnt);
    }
}
void solve(){
    ll n,q;
    cin >> n >> q;
    vector<vector<ll>> adj(n);
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
vector<ll> cnt(n,0);
for(ll i=0;i<q;i++){
    ll p,x;
    cin >> p >> x;
    p--;
    cnt[p]+=x;
}
dfs(adj,0,-1,0,cnt);
for(auto i:cnt){
    cout << i << " ";
}
cout << endl;
}

int main() {
solve();
}


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

using namespace std;

const int inf = 1000000000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  vector<int> x(n);

  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  sort(x.begin(), x.end());

  int ans = inf;
  for (int i = x[0]; i <= x[n - 1]; ++i) {
    int sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += pow(x[j] - i, 2);
    }
    ans = min(ans, sum);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
int main()
{
	int a[10];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0]==a[1]&&a[0]!=a[2])||(a[1]==a[2]&&a[0]!=a[2])){
		printf("Yes\n");
	}	
	else{
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int a,b;
      cin>>a>>b;
      cout<<a*b;
	}
	return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n + 1);
	int z = 0;
	rep(i, n) cin >> a[i], z += (!a[i]);
	a[n] = 0;
	z++;
	n++;
	vi cnt(15, 0);
	cnt[0]++;
	vi pos;
	rep(i, n){
		if(cnt[a[i]] < 2) cnt[a[i]]++, pos.pb(a[i]);
		else{
			cout << 0 << endl;
			return 0;
		}
	}
	sort(all(pos));
	if(pos.size() >= 26){
		cout << 0 << endl;
		return 0;
	}
	if(pos.size() >= 24){
		cout << 1 << endl;
		return 0;
	}
	int ans = 0;
	rep(i, (1 << (int)(pos.size() - z))){
		vi cnt1(25, 0);
		rep(j, pos.size()){
			if(pos[j]){
				if(i & (1 << (j - z))) cnt1[pos[j]]++;
				else cnt1[(24 - pos[j]) % 24]++;
			}
			else{
				cnt1[pos[j]]++;
			}
		}
		int lst = -1, frst = -1;
		int bst = 1e9;
		int f = 1;
		rep(j, 24){
			if(cnt1[j] > 1){
				bst = 0;
				break;
			}
			if(cnt1[j]){
				if(f) frst = j;
				if(lst != -1) bst = min(bst, min(j - lst, 24 - (j - lst)));	
				lst = j;
				f = 0;
			}
		}
		if(lst != -1 && frst != -1) bst = min(bst, min((24 - lst) + frst, 24 - ((24 - lst) + frst)));
		ans = max(ans, bst);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

ll keta(ll a);

int main(){
  ll n;
  cin >> n;
  ll ans = INF;
  for(ll i = 1;i <= sqrt(n);i++){
    if(n % i == 0){
      //cout << n/i << endl;
      //cout << keta(n/i) << endl;
      ans = min(keta(n/i),ans);
      //cout << ans << endl;
    }
  }
  cout << ans << endl;
}

ll keta(ll a){
  ll sum = 0;
  while(a > 0){
    a /= 10;
    sum++;
  }
  return sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
int main(int argc, char const *argv[])
{
	int k;
	vector<int> a(3);
	for (int i = 0; i < 3; ++i)
	{
		cin >> a[i];
	}
	cin >> k;
	while (a[1] <= a[0] && k)
	{
		a[1] <<= 1;
		k --;
	}
	while (a[2] <= a[1] && k)
	{
		a[2] <<= 1;
		k --;
	}
	if (a[0] < a[1] && a[1] < a[2])
		cout << "Yes" << '\n';
	else
		cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>

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

int main()
{
  int i,n;
  double v[1000];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%lf", &v[i]);
  }
  qsort(v, n, sizeof(double), comp);  
  for (i = 1; i < n; i++) {
    v[i]=(v[i-1]+v[i])/2.;
  }
  printf("%lf", v[n-1]);
  return 0;
}

Measured memory_bytes: 128
S = str(input())

count = 0
count_max = 0
for i in S:
    if i == 'A' or i == 'T' or i == 'C' or i == 'G':
        count += 1
    else:
        count_max = max(count, count_max)
        count = 0

count_max = max(count, count_max)
print(count_max)

Measured memory_bytes: 2940
#include<stdio.h>
int R=1,C=1,H[2000010],N[100010];
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,a[100010],i,j,d[100010],b[100010];
  long long s=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d %d",&a[R],&b[R]);
    hin(a[R]);
  }
  for(i=0;i<n;i++)d[i]=hout();
  //for(i=0;i<n;i++)printf("!%d %d\n",a[d[i]],b[d[i]]);
  R=C=1;
  for(i=1;i<=m;i++){
    while(a[d[j]]==i)hin(-b[d[j++]]);
    if(C-1)s-=N[hout()];
  }
  printf("%lld\n",s);
  return 0;
}
    


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	
	return 0;
}

Measured memory_bytes: 3652
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
ans = "Yes"
for i in range(1, h - 1):
    for j in range(1, w - 1):
        if s[i][j] == "#" and s[i-1][j] == "." and s[i][j-1] == "." and s[i+1][j] == "." and s[i][j+1] == ".":
            ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
ll n,a,b;

int main()
{
	cin >> n >> a >> b;
	if((b-a)&1)
	    cout << (b-a-1)/2+min(n-b,a-1)+1 << endl;
	else
	    cout << (b-a)/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
ll mod=1e9+7;
     
ll ceil1(ll n,ll k){
    if(n%k) return n/k+1;
    return n/k;
}
     
ll pow1(ll n,ll k){
        ll ans=1;
        while(k!=0){
            if(k%2) ans=(ans*n)%mod;
            n=(n*n)%mod;
            k=k/2;
        }
        return ans;
}

bool ispal(string s){
    ll i=0;
    ll j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j]) return false;
        i++;
        j--;
    }
    return true;
}

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

ll fact(ll n){
    if(n==1 || n==0) return 1;
    else return (n*fact(n-1))%mod;
}

bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

void solve(){
	ll x;
	cin>>x;
	vector<ll> a;
	for(ll i=-150;i<=150;i++){
		a.push_back(i*i*i*i*i);
	}
	ll ansa,ansb;
	for(ll i=0;i<a.size();i++){
		for(ll j=0;j<a.size();j++){
			if((a[i]-a[j])==x){
				ansa=a[i];
				ansb=a[j];
			}
		}
	}
	ll ta,tb;
	for(ll i=-150;i<=150;i++){
		if(i*i*i*i*i==ansa) ta=i;
	}
	for(ll i=-150;i<=150;i++){
		if(i*i*i*i*i==ansb) tb=i;
	}
	cout<<ta<<" "<<tb<<endl;
	return;
}
	
int main(){    
      ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
      ll q=1;
      //cin>>q;
      while(q--){
        solve();
      }
      return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H, A;

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

  cin >> H >> A;
  int cnt = 0;
  while(H>0) {
    H-=A;
    cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
fn main() {
   println!("{}",
            gets().trim().chars()
            .map(|c| c.to_digit(10).unwrap())
            .fold(0, |sum,a| sum + a))
}

fn gets() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}



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

using namespace std;

int main(){
    long long N, M;
    cin >> N >> M;

    vector<bool> good_tenbou(N);
    vector<long long> height(N);
    vector<vector<int> > G(N);

    for(int i=0; i<N; ++i){
        good_tenbou[i] = 0;
    }
    
    for(int i=0; i<N; ++i){
        cin >> height[i];
    }

    for(int i=0; i<M; ++i){
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        G[from].push_back(to);
        G[to].push_back(from);
    }

    for(int i=0; i<N; ++i){
        bool flag = true;
        if(G[i].size() >0){
            for( auto j: G[i]){
                if( i != j){
                    int test = height[i];
                    int test2 = height[j];
                    if( height[i] <= height[j] ){
                        flag = false;
                        break;
                    }
                }
            }
        }else{
            good_tenbou[i] = true;
        }

        if(flag){
            good_tenbou[i] = true;
        }
   
    }

    int ans=0;
    for(int i=0; i<N; ++i){
        if(good_tenbou[i] == true){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef complex<double> pt;
typedef pair<pt,pt> L;
typedef vector<P> poly;
const double EPS = 1e-9;
#define x real()
#define y imag()
bool eq(double a,double b){
  return (-EPS < a-b && a-b < EPS);
}
double dot(pt a,pt b){
	return (conj(a)*b).x;
}
double cross(pt a,pt b){
	return (conj(a)*b).y;
}
int ccw(pt a,pt b,pt c){
	b -= a; c -= a;
	if(cross(b,c) > EPS) return 1; // counter clockwise
	if(cross(b,c) < -EPS) return -1; // clockwise
	if(dot(b,c) < -EPS) return 2; //c-a-b
	if(norm(b) < norm(c)) return -2; //a-b-c
	return 0; //a-c-b
}
pt crossPoint(pt a,pt b,pt c,pt d){
	double A = cross(b-a,d-c);
	double B = cross(b-a,b-c);
	if( fabs(A) < EPS && fabs(B) < EPS ) return c;
	else if(fabs(A) >= EPS ) return c+B/A*(d-c);
	else pt(1e9,1e9);
}
vector<pt> convex_cut(vector<pt> G, pair<pt,pt>l){
  vector<pt> ans;
  for(int i=0;i<(int)G.size();i++){
    pt A = G[i];
    pt B = G[(i+1)%G.size()];
    if(ccw(l.fi,l.sc,A) != -1) ans.pb(A);
    if(ccw(l.fi,l.sc,A) * ccw(l.fi,l.sc,B) < 0)
      ans.pb(crossPoint(A,B,l.fi,l.sc));
  }
  return ans;
}
int n;
pt p[105];
int main(){
	while(1){
		cin >> n; if(!n) return 0;
		for(int i=0;i<n;i++){
			double xx,yy; scanf("%lf%lf",&xx,&yy);
			p[i] = pt(xx,yy);
		}
		double lb = 0.0,ub = 10000.0;
		rep(WWW,100){
			double mid = (lb+ub)/2;
			vector<pt>vec; rep(i,n) vec.pb(p[i]);
			rep(j,n){
				pt A = p[j],B = p[(j+1)%n];
				pt C = A-B;
				C *= pt(0.0,-1.0); //cout << C << endl;
				C *= mid / abs(C);
				A += C; B += C;
			//	cout << A << " " << B << endl;
				vec = convex_cut(vec,mp(A,B));
				//rep(i,vec.size()) cout << vec[i] << endl;
			}
			//cout << vec.size() << endl;
			if(vec.size() <= 2) ub = mid;
			else lb = mid;
		}
		printf("%.12f\n",lb);
	}
}

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

using namespace std;

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

    int N, T;
    cin >> N >> T;

    int min_cost = 1001;
    for (int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if (t <= T){
            if (c < min_cost) min_cost = c;
        }
    }

    if (min_cost == 1001) cout << "TLE";
    else cout << min_cost;

    return 0;
}



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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

int n, r, g, b, ans;

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

	cin >> r >> g >> b >> n;

	for(int i = 0; i <= n; ++i)
	{
		for(int j = 0; j <= n; ++j)
		{
			int zos = n - r * i - g * j;

			if(zos >= 0 && zos % b == 0)
				++ans;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import copy
import sys

S = list(input())
T = list(input())

A = copy.deepcopy(S)
B = A.pop()
A.insert(0, B)

b = False

if S == T:
    print('Yes')
    b = True
    
while A != S:
    if A == T:
        print('Yes')
        b = True
    B = A.pop()
    A.insert(0, B)

if not b:
    print('No')

Measured memory_bytes: 3444
s = input()

word = "keyence"

for i in range(len(word)):
    a = s.find(word[:i])
    b = s.rfind(word[i:])
    if((a == 0 and b == 0) or (a == 0 and b == len(s)-len(word[i:]))):
        print("YES")
        exit()

print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define ld          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

const int N = 1e4+4;
vl g[N];
ll n;
ll c[N], x[N];
bool vis[N];

void solve()
{
       cin>>n;
       rep(i,0,n-1)
       {
              ll a,b;
              cin>>a>>b;
              g[a].pb(b);
              g[b].pb(a);
       }
       rep(i,1,n+1) cin>>c[i];
       sort(c+1, c+n+1);
       ll ans=0;
       rep(i,1,n) ans+=c[i];
       queue<ll>q;
       ll ind=n;
       q.push(1);
       while(!q.empty())
       {
              ll f=q.front();
              q.pop();
              vis[f]=1;
              x[f]=c[ind];
              ind--;
              for(ll d:g[f])
                     if(!vis[d]) q.push(d);
       }
       cout<<ans<<endl;
       rep(i,1,n+1) cout<<x[i]<<" ";
}

int main()
{
       speed_up;
       //pre();
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main(){
  int r,c;
  cin>>r>>c;
  // インプット
  int S[r][c];
  for(int i=0;i<r;i++){
    for(int v=0;v<c;v++){
      cin>>S[i][v];
    }
  }
  int sumr[r],sumc[c];
  // 初期化ここから
  for(int i=0;i<r;i++){
    sumr[i]=0;
  }
  for(int i=0;i<c;i++){
    sumc[i]=0;
  }
// 合計のインプット
  for(int i=0;i<r;i++){
    for(int v=0;v<c;v++){
      sumr[i]+=S[i][v];
    }
  }
  for(int v=0;v<c;v++){
    for(int i=0;i<r;i++){
      sumc[v]+=S[i][v];
    }
  }//問題はこの上
  int sum=0;
  for(int i=0;i<r;i++){
    sum+=sumr[i];
  }
  for(int i=0;i<r;i++){
    for(int v=0;v<c;v++){
      if(v==c-1){
        cout<<S[i][v]<<" "<<sumr[i]<<endl;
      }else{
        cout<<S[i][v]<<" ";
      }
    }
  }
  for(int v=0;v<c;v++){
    if(v==c-1){
      cout<<sumc[v]<<" "<<sum<<endl;
    }else{
      cout<<sumc[v]<<" ";
    }
  }
}



Measured memory_bytes: 3088
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,max;
    scanf("%d%d",&a,&b);
    max=a+b;
    if(max<a-b)max=a-b;
    if(max<a*b)max=a*b;
    printf("%d\n",max);
    return 0;
    
}


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

int main()
{

	ios::sync_with_stdio(0);
	cin.tie(0);

	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b;
	

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

void shit(){
    string s,t;
    int max_=-1;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        int temp=0;
        int ii=i;
        //cout<<ii<<" sa"<<endl;
        for(int j=0;j<t.size();j++)
        {
            //cout<<j<<endl;
            if(ii<s.size()&&s[ii]==t[j])
            {
                //cout<<ii<<" "<<j<<" ";
                //cout<<temp<<endl;
                temp++;
                ii++;
            }
            else
            {
                if(temp>max_&&j-temp<=ii-temp&&t.size()-j<=s.size()-ii)
                {
                    max_=temp;
                }
                temp=0;
            }
        }
        if(temp>max_&&t.size()-temp<=ii-temp&&0<=s.size()-ii)
        {
            max_=temp;
        }
    }
    cout<<t.size()-max_;
}

void slove(){
    string s,t;
    int max_=-1;
    cin>>s>>t;
   for(int i=0;i<=s.size()-t.size();i++)
   {
       int temp=0;
       int ii=i;
       for(int j=0;j<t.size();j++)
       {
           if(s[ii]==t[j])
           {
               temp++;
           }
           ii++;
       }
       if(temp>max_)
       {
           max_=temp;
       }
   }
   cout<<t.size()-max_;
}

int main() {
    int _=1;
//    cin>>_;
    while (_--){
        slove();
    }
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <set>
#include <map>
#include <cmath>
#include <list>
using namespace std;



int main(){
	int N;
	while(cin >> N && N){
		list< pair< pair<int,int> , int> > se;
		for(int i = 0 ; i < N ; i++){
			string s;
			cin >> s;
			if( s == "D" ){
				int v;
				cin >> v;
				for( list< pair< pair<int,int> , int> >:: iterator it = se.begin(); it != se.end() ;){
					if( it->second == v ){
						it = se.erase(it);
					}else{
						++it;
					}
				}
			}else if( s == "W" ){
				int l,sec;
				cin >> l >> sec;
				int prev = 0;
				for( list< pair< pair<int,int> , int> >:: iterator it = se.begin(); it != se.end() ;){
					if( sec == 0 ) break;
					int width = it->first.first - prev;
					int use = min(sec,width);
					int tmp = it->first.second;
					if( use != 0 ) {
						sec -= use;
						se.insert(it,make_pair(make_pair(prev,prev+use),l));	
					}
					it++;
					prev = tmp;
				}
				if( sec != 0 ){
					se.push_back(make_pair(make_pair(prev,prev+sec),l));
				}
			}else{
				int pos;
				cin >> pos;
				int flag = 0;
				for( list< pair< pair<int,int> , int> >:: iterator it = se.begin(); it != se.end() ;++it){
					if( it->first.first <= pos && pos < it->first.second ){
						cout << it->second << endl;
						flag = 1;
						break;
					}
				}
				if( !flag ){
					cout << -1 << endl;
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1364
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Polygon
            int n = int.Parse(Console.ReadLine());
            var lines = ReadLine();

            //辺の長さが長い順にソート
            lines = lines.OrderByDescending(x => x).ToList();

            int longest = lines[0];
            int sum = lines.Skip(1).Sum();

            if (longest < sum)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> d1(N), d2(N);
    for (int i = 0; i < N; i++) {
        cin >> d1.at(i) >> d2.at(i);
    }

    int temp = 0;
    bool result = false;

    for (int i = 0; i < N; i++) {
        if (d1.at(i) == d2.at(i)) {
            temp++;
            if (temp == 3) {
                result = true;
            }
        } else {
            temp = 0;
        }
    }

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

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

int main() {
    int n,r;
    cin >> n;
    r = n%10;
    if (r==2 || r==4 || r==5 || r==7 || r==9 ){
        cout << "hon" << endl;
    }
    else if (r==3){
        cout << "bon" << endl;
    }
    else{
        cout << "pon" << endl;
    }
    return 0;   
}

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

#define ll long long
#define ld long double

using namespace std;

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    string s;
    cin >> s;
    ll ans = 0;
    ll len = 0;
    for(auto i : s) {
        if(i == 'S') {
            ans = max(ans, len);
            len = 0;
        }
        else {
            len++;
        }
    }
    cout << max(ans, len);
}


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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define base 402653189
#define mod 998244353
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 200005

int n,m;
int x;
int c[15];
int a[15][15];
int ans=INT_MAX;

bool check(int mask){
    int tmp[15];
    mem(tmp,0);
    for(int i=0;i<n;i++){
        if(mask&(1<<i)){
            for(int j=0;j<m;j++) tmp[j]+=a[i][j];
        }
    }
    for(int i=0;i<m;i++) if(tmp[i]<x) return false;
    return true;
}


int main(){
	optimize();
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int res=0;
    for(int i=0;i<(1<<n);i++){
        if(check(i)){
            int tot=0;
            for(int j=0;j<n;j++) if(i&(1<<j)) tot+=c[j];
            ans=min(ans,tot);
        }
    }
    if(ans!=INT_MAX) cout<<ans<<endl;
    else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 3656
X = input()
st = 0
s = 0
t = 0
for x in X:
    if x == "S":
        st += min(s, t)
        if t > 0:
            s -= min(s, t)
            t = 0
        s += 1
    elif x == "T" and s > 0:
        t += 1
st += min(s, t)
print(len(X) - 2 * st)

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll x, ans = 0;
  cin >> x;
  for (ll i = 100; i < x; ans++) {
    i += i / 100;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3660
from functools import lru_cache
from itertools import groupby

@lru_cache(maxsize=None)
def comb(n, r):
    if r == 1:
        return n
    if n < r:
        return 0
    return comb(n-1, r-1) + comb(n-1, r)

for n in range(10**5):
    comb(n, 2)

N = int(input())
S = tuple(sorted(tuple(sorted(input())) for _ in range(N)))

print(sum(comb(len(tuple(g)), 2) for _, g in groupby(S)))

Measured memory_bytes: 72748
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	fact_memo[n] = (ans + mod) % mod;
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, j;
int a[100000], l[100000], r[100000];
int ans = 0;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	l[0] = a[0];
	r[n - 1] = a[n - 1];
	rep(i, n - 1) {
		l[i + 1] = gcd(l[i], a[i + 1]);
		j = n - 2 - i;
		r[j] = gcd(r[j + 1], a[j]);
	}
	rep(i, n) {
		if (i == 0) {
			ans = r[i + 1];
		}
		else if (i == n - 1) {
			ans = max(ans, l[i - 1]);
		}
		else {
			ans = max(ans, gcd(l[i - 1], r[i + 1]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
#define     mod            (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
#define     sz(x)           (int)(x).size()
#define     grid            vector<vector<int> >
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
  //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif



string a, b;

int n, m;




int main()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  IOS;


  cin >> a >> b;

  n = sz(a), m = sz(b);

  grid dp(n + 1, std::vector<int>(m + 1, 0));

  for (int i = 1; i <= n; i++)
  {
    for (int j = 1; j <= m; j++)
    {
      if (a[i - 1] == b[j - 1])
      {
        dp[i][j] = 1 + dp[i - 1][j - 1];
        continue;
      }

      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);

    }
  }

  string ans;

  while (n && m)
  {
    if (a[n - 1] == b[m - 1])
    {
      ans = a[n - 1] + ans;
      n--, m--;
      continue;
    }

    if (dp[n - 1][m] > dp[n][m - 1])
      n--;
    else
      m--;
  }

  cout << ans << endl;


}

Measured memory_bytes: 38988
a=int(input())
b=list(map(int,input().split()))
ans=0
for i in range(1,a-1):
    if (b[i-1]<b[i] and b[i]<b[i+1]) or (b[i-1]>b[i] and b[i]>b[i+1]):
        ans+=1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ps(m);
  REP(i, m) {
    cin >> ps[i].first >> ps[i].second, ps[i].second--;
  }
  sort(begin(ps), end(ps));
  vector<int> l(n), r(n);
  REP(i, n) l[i] = r[i] = i;
  REP(i, m) {
    int x, y;
    tie(x, y) = ps[i];
    l[y] = min(l[y], l[y + 1]);
    r[y] = max(r[y], r[y + 1]);
    l[y + 1] = min(l[y], l[y + 1]);
    r[y + 1] = max(r[y], r[y + 1]);
  }
  REP(i, n) {
    cout << r[i] - l[i] + 1 << ((i == n - 1) ? '\n' : ' '); 
  }
}




Measured memory_bytes: 5204
from functools import lru_cache

n = int(input())
action = []
for i in range(n):
    action.append(list(map(int,input().split())))

@lru_cache(maxsize=None)
def dp(i, a):
    if i == 0:
        return action[0][a]
    else:
        return max(dp(i-1, (a+1)%3), dp(i-1, (a+2)%3)) + action[i][a]

import sys
sys.setrecursionlimit(1000000)
print(max([dp(n-1,a) for a in range(3)]))


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


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

    if(A==1 && B==2) _PR(3);
    else if(A==2 && B==1) _PR(3);
    else if(A==1 && B==3) _PR(2);
    else if(A==3 && B==1) _PR(2);
    else if(A==2 && B==3) _PR(1);
    else if(A==3 && B==2) _PR(1);


    return 0;
}

/*



*/

Measured memory_bytes: 256
<?php
$n = (int)fgets(STDIN);
$a = explode(' ', fgets(STDIN));
for ($i = 0; $i < $n; $i++) {
	$a[$i] = (int)$a[$i];
}

$p = [];
foreach ($a as $item) {
	$p[$item] = $p[$item] ?? 0;
	$p[$item - 1] = $p[$item - 1] ?? 0;
	$p[$item + 1] = $p[$item + 1] ?? 0;
	$p[$item]++;
	$p[$item - 1]++;
	$p[$item + 1]++;
}

echo max($p),"\n";


Measured memory_bytes: 19188
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long
int N;
ll S[1<<18];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	rep(i,1<<N) cin>>S[i];
	sort(S,S+(1<<N));
	multiset<int> T;
	rep(i,(1<<N)-1) T.insert(S[i]);
	
	vector<int> V;
	V.push_back(S[(1<<N)-1]);
	rep(i,N) {
		vector<int> W=V;
		
		for(auto v : V) {
			auto it=T.lower_bound(v);
			if(it==T.begin()) {cout << "No\n"; return;}
			it--;
			W.push_back(*it);
			T.erase(it);
		}
		
		sort(all(W));
		reverse(all(W));
		swap(V,W);
	}
	cout << "Yes\n";
	
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 14592
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
map<string,int> mp;
char l;

signed main(){
    io();

    in(n);
    rep(i,n){
        string s;in(s);
        if(i==0)l=s[0];
        if(mp[s] || s[0]!=l){
            no;
            return 0;
        }
        mp[s]++;
        l=s[s.size()-1];
    }
    yes;

    return 0;
}


Measured memory_bytes: 256
class Node
    attr_accessor :parent, :rank
    def initialize(n)
        @parent = n
        @rank = 0
    end
end

class UnionFindTree
    attr_accessor :nodes
    def initialize(n)
        @nodes = (0..n).to_a.map { |i| Node.new(i) }
    end
    def find(x)
        return x if @nodes[x].parent == x
        return @nodes[x].parent = find(@nodes[x].parent)
    end
    def unite(a, b)
        a = find(a)
        b = find(b)
        return if a == b
        if @nodes[a].rank < @nodes[b].rank
            @nodes[a].parent = b
        else
            @nodes[b].parent = a
            @nodes[b].rank += 1 if @nodes[a].rank == @nodes[b].rank
        end
    end
    def same?(a, b)
        find(a) == find(b)
    end
end
loop do
    n, q = gets.split.map(&:to_i)
    break if n == 0 && q == 0
    p = UnionFindTree.new(n)
    pp = Array.new(n+1,-1)
    pp[1] = 1
    m = Array.new(n+1,0)
    m[1] = 1
    (n-1).times do |i|
        temp = gets.to_i
        pp[i+2] = temp
    end
    qs = q.times.map{gets.split}.map{|t, k| [t,k.to_i]}
    qs.each do |qr|
        if qr[0] == "M"
            m[qr[1]] += 1
        end
    end
    1.upto(n) do |i|
        p.unite(pp[i], i) if m[i] == 0
    end
    ans = 0
    qs.reverse.each do |qr|
        case qr[0]
        when "M"
            m[qr[1]] -= 1
            p.unite(pp[qr[1]], qr[1]) if m[qr[1]] == 0
        when "Q"
            ans += p.find(qr[1])
        end
    end
    puts ans
end

Measured memory_bytes: 92116
import math

s = input()
n = len(s)
n2 = math.ceil(n/2)
result = 'Yes'

for i in range(n2):
    if s[i] != s[n-1-i]:
        result = 'No'

th = s[math.ceil(((n+3)/2)-1):n]
# print(th)
th_s = len(th)
th_n = math.ceil(th_s/2)
# print(th_s)
# print(th_n)

for i in range(th_n):
    if s[i] != s[th_s-1-i]:
        result = 'No'


print(result)




Measured memory_bytes: 3060