akhauriyash/Code-Regression huggingface dataset:
#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;
const ll mod=1000000007;
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

const int N=6010;
string dp[N];
int mark[N],op[N],sel[N];
string solve(string s) {
	int n=SZ(s)/2;
	rep(i,0,2*n) mark[i]=0;
	int r=0;
	rep(i,0,2*n) if (!mark[i]) {
		mark[i]=1;
		while (r<2*n&&(mark[r]||s[i]==s[r])) ++r;
		mark[r]=2;
		op[i]=r;
		op[r]=i;
	}
	dp[2*n]="";
	per(i,0,2*n) {
		dp[i]=dp[i+1];
		if (mark[i]!=1) continue;
		if (s[i]=='a') {
			dp[i]=max(dp[i],"ab"+dp[op[i]+1]);
			continue;
		}
		rep(j,0,2*n) sel[j]=0;
		sel[i]=1; sel[op[i]]=1;
		int mr=op[i];
		string tmp;
		for (int j=i;j<2*n;j++) {
			if (j<mr&&mark[j]==1&&s[j]=='b') {
				mr=op[j];
				sel[j]=sel[op[j]]=1;
			}
			if (sel[j]) tmp.pb(s[j]);
		}
		dp[i]=max(dp[i],tmp+dp[mr+1]);
		for (int j=2*n-1;j>=i;j--) if (mark[j]==1&&!sel[j]) {
			sel[j]=sel[op[j]]=1; break;
		}
		tmp.clear();
		for (int j=i;j<2*n;j++) if (sel[j]) tmp.pb(s[j]);
		dp[i]=max(dp[i],tmp);
	}
	return dp[0];
}
string bf(string s) {
	int n=SZ(s)/2;
	rep(i,0,2*n) mark[i]=0;
	int r=0;
	VI pos;
	rep(i,0,2*n) if (!mark[i]) {
		mark[i]=1;
		pos.pb(i);
		while (r<2*n&&(mark[r]||s[i]==s[r])) ++r;
		mark[r]=2;
		op[i]=r;
		op[r]=i;
	}
	string ans;
	rep(S,0,(1<<n)) {
		string tmp;
		rep(i,0,2*n) sel[i]=0;
		rep(i,0,n) if (S&(1<<i)) sel[pos[i]]=sel[op[pos[i]]]=1;
		rep(i,0,2*n) if (sel[i]) tmp.pb(s[i]);
		ans=max(ans,tmp);
	}
	return ans;
}

int main() {
	scanf("%*d");
	string s;
	cin>>s;
	cout<<solve(s)<<endl;
/*
	while (1) {
		int n=rand()%10+1;
		string s;
		rep(j,0,n) s.pb('a'),s.pb('b');
		random_shuffle(all(s));
		cout<<s<<endl;
		assert(solve(s)==bf(s));
	}*/
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    string S;   cin>>S;
    for(int bit=0;bit<(1<<3);bit++){
        int s=S[0]-'0';
        for(int i=0;i<3;i++){
            if(bit&(1<<i)){
                s+=S[i+1]-'0';
            }
            else{
                s-=S[i+1]-'0';
            }
        }
        if(s==7){
            cout<<S[0];
            for(int i=0;i<3;i++){
                if(bit&(1<<i)){
                    cout<<'+';
                }
                else{
                    cout<<'-';
                }
                cout<<S[i+1];
            }
            cout<<"=7";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val (a, b, k) = readLine()!!.trim().split(' ').map(String::toInt)
    println(solve(a, b, k))
}
fun solve(a: Int, b: Int, k: Int): Int {
    val aDigits = (10000000000L + a).toString().drop(1).map{it - '0'}.toIntArray()
    val bDigits = (10000000000L + b).toString().drop(1).map{it - '0'}.toIntArray()
    val memo = Array(2){Array(k + 1){Array(aDigits.size){null as Int?}}}
    fun sub(digit: Int, restK: Int, borrow: Int = 0): Int {
        if (digit < 0) return 0
        if (memo[borrow][restK][digit] != null) return memo[borrow][restK][digit]!!
        val d = aDigits[digit] - bDigits[digit] - borrow
        var max = sub(digit - 1, restK, if (d < 0) 1 else 0) * 10 + (10 + d) % 10
        if (restK > 0) {
            val s = sub(digit - 1, restK - 1, 0) * 10 + (10 + d) % 10
            if (max < s) max = s
        }
        memo[borrow][restK][digit] = max
        return max
    }
    return sub(aDigits.lastIndex, k)
}


Measured memory_bytes: 32176
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

int n, L, Q;
const int maxn = 1e5 + 5;
int x[maxn];
int st[maxn][20];

void init(){
    for(int i = 1;i <= n;i++){
        int l = i, r = n;
        while(l < r){
            int mid = (l + r + 1) / 2;
            if(x[mid] - x[i] <= L){
                l = mid;
            }else{
                r = mid - 1;
            } 
        }
        st[i][0] = l;
    }
    for(int len = 1;len < 20;len++){
        int j = (1 << len);
        for(int i = 1;i <= n;i++){
            st[i][len] = st[st[i][len - 1]][len - 1];
        }
    }
}

int query(int a, int b){
    int ans = 0;
    for(int i = 19;i >= 0;i--){
        if(st[a][i] < b){
            ans += (1 << i);
            a = st[a][i];
        }
    }
    return ans + 1;
}

int main(){
    //freopen("in/subtask1_01.txt", "r", stdin);
    cin >> n;
    for(int i = 1;i <= n;i++){
        scanf("%d", &x[i]);
    }
    cin >> L;
    x[n + 1] = x[n] + 1;
    init();
    cin >> Q;
    for(int i = 1;i <= Q;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        if(a > b)
            swap(a, b);
        printf("%d\n", query(a, b));
    } 
    return 0;
}


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

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

    if(a > b)
        swap(a, b);

    vector<int> ans;

    ans.insert(ans.begin(),b,a);

    for(int i = 0; i <ans.size(); i++)
        cout<< ans[i];
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    int a[q];
    for(int i = 0; i < q; i++) cin >> a[i];

    int points[n];
    for(int i = 0; i < n; i++) points[i] = k;

    int t = 0;
    for(int i = 0; i < q; i++) {
        points[a[i]-1]++;
        t++;
    }

    for(int j = 0; j < n; j++) {
        if(points[j] <= t) {
            cout << "No" << endl;
        }else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
 {
	
	
	    int n;
	    cin>>n;
	    int a[n][3];
	    for(int i=0; i<n; i++){
	    	cin>>a[i][0]>>a[i][1]>>a[i][2];
		}
		
		long long int dp[n][3];
		for(int i=0; i<3; i++){
			dp[0][i] = a[0][i];
		}
		
		if(n>1){
			for(int i=1; i<n; i++){
				dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
				dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
				dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][0]);
			}
		}
		int long long m=-1;
	    for(int i=0; i<3; i++){
	    	m = max(m,dp[n-1][i]);
		}
		cout<<m<<endl;
	
	return 0;
}

Measured memory_bytes: 3712
n=int(input())
if 1<=n and n<=9:
    print(n)
else:
    import queue
    q=queue.Queue()
    for i in range(1,10):
        q.put(i)
    count=9
    while count<n:
        t=q.get()
        if t%10==0:
            q.put(10*t)
            q.put(10*t+1)
            count+=2
        elif t%10==9:
            q.put(10*t+8)
            q.put(10*t+9)
            count+=2
        else:
            q.put(10*t+t%10-1)
            q.put(10*t+t%10)
            q.put(10*t+t%10+1)
            count+=3
    if count-n==0:
        if t%10!=9:
            print(10*t+t%10+1)
        else:
            print(10*t+9)
    elif count-n==1:
        if t%10!=9:
            print(10*t+t%10)
        else:
            print(10*t+8)
    else:
        print(10*t+t%10-1)
        

Measured memory_bytes: 54228
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <chrono>
#include <queue>
#include <string>
#include <cassert>
#include <bitset>
#include <stack> 
#include <unordered_set>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef vector <ll> vll;

struct Line {
	ll k;
	ll b;

	Line(ll k, ll b) {
		this->k = k;
		this->b = b;
	}
	ll getValue(ll val) {
		return k * val + b;
	}

};

int n;
ll c;
ll arr[200000];
ll dp[200000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d %lld", &n, &c);
	for (int i = 0; i < n; i++) {
		scanf("%lld", arr + i);
	}
	dp[0] = 0;
	vector <Line> lines;
	Line tmp(-2 * arr[0], arr[0] * arr[0]);
	lines.push_back(tmp);
	int start = 0;
	for (int i = 1; i < n; i++) {
		while (start < lines.size() - 1) {
			if (lines[start].getValue(arr[i]) >= lines[start + 1].getValue(arr[i])) start++;
			else break;
		}
		dp[i] = lines[start].getValue(arr[i]) + c + arr[i] * arr[i];

		Line z(-2 * arr[i], arr[i] * arr[i] + dp[i]);
		while (start < lines.size() - 1) {
			pair <ll, ll> f, s;
			Line x = lines.end()[-2];
			Line y = lines.end()[-1];
			f.first = x.b - y.b;
			f.second = y.k - x.k;
			
			s.first = y.b - z.b;
			s.second = z.k - y.k;

			if (f.first * s.second >= s.first * f.second) {
				lines.pop_back();
			} else break;
		}
		lines.push_back(z);
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 9200
n, m = map(int, input().split(" "))

s = dict()

for i in range(0, m):
    a, b = map(int, input().split(" "))

    if a not in s.keys():
        s[a] = list()

    s[a].append(b)

    if b not in s.keys():
        s[b] = list()

    s[b].append(a)

ans = False
for k in s[1]:
    g = s[k]
    if n in g:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 50928
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int a;
  while(cin>>a){
    cin>>s;
  	int x=0,ans=0;
    for(int i=0;i<a;i++){
      if(s[i]=='I') x++;
      else x--;
      ans=max(ans,x);	
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
//  cout << N <<endl;
  vector<int> a(N);
  for(int i=0; i<N; ++i) {
    cin >> a.at(i);
//    cout << a.at(i) << endl;
  }

/*  for(int i=0; i<N; ++i) {
    cout << a.at(i) << ' ';
  }*/
  
  sort(a.begin(), a.end());
  
/*  cout <<endl;
  for(int i=0; i<N; ++i) {
    cout << a.at(i) << ' ';
  }*/

  int A=0, B=0;
  for(int i=0; i<N; ++i) {
    if (i%2 == 0) {
      A += a.at(N-i-1);
    } else {
      B += a.at(N-i-1);
    }
  }
  
  int result = A - B;
  
  cout << result <<endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
using namespace std;
#define NEL -1

struct tree{
    int p,l,r;
};

tree a[100005];
int d[100005];

int re(int u,int p){
    d[u]=p;
    if(a[u].r>=0) re(a[u].r,p);
    if(a[u].l>=0) re(a[u].l,p+1);
}

void print(int n){
    for(int i=0;i<n;i++){
        printf("node %d:",i);
        printf(" parent = %d, ",a[i].p);
        printf("depth = %d, ",d[i]);
        if(a[i].p==NEL) printf("root, ");
        else{
            if(a[i].l==NEL) printf("leaf, ");
            else printf("internal node, ");
        }
        printf("[");
        int c=a[i].l;
        while(c>=0){
            if(c==a[i].l)
                printf("%d",c);
            else
                printf(", %d",c);
            c=a[c].r;
        }
        printf("]");
        printf("\n");
    }
}

int main(){
    int n,id,k,m,c;
    int l;
    scanf("%d",&n);
    for(int i=0;i<n;i++) { a[i].p=NEL; a[i].l=NEL; a[i].r=NEL; }
    for(int i=0;i<n;i++){
        scanf("%d%d",&id,&k);
        for(int j=0;j<k;j++){
            scanf("%d",&m);
            a[m].p=id;
            if(!j) a[id].l=m;
            else a[l].r=m;
            l=m;
            }
    }
    for(int i=0;i<n;i++){
        if(a[i].p==NEL){
            c=i;
            break;
        }
    }
    re(c,0);
    print(n);
    return 0;
}

Measured memory_bytes: 7328
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int n;

		int max=0;
		int sum=0;
		int ans;
		int []p= {0,0,0,0,0,0,0,0,0,0};
		n=sc.nextInt();
		
		for(int i=0;i<n;i++) {
			p[i]=sc.nextInt();
			
			if(max<p[i]) {
				max=p[i];
			}
			sum+=p[i];
		}
		ans=sum-max+(max/2);
		System.out.println(ans);		
	}

}


Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
using namespace std;
 
int main(){
    int n=0, m=1;
    int a[101], b[101], x=0, y=0;
    int p,q;
     
    while(1){
     
    cin >> n >> m;
    x=0;
    y=0;
    p=-1;
    q=-1;
     
     
    if(0== n + m) break;
     
    for(int i=0;i<n;i++){
        cin >> a[i];
        x+=a[i];
    }
    for(int j=0;j<m;j++){
        cin >> b[j];
        y+=b[j];
    }
     
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if((a[i]-b[j])*2==(x-y)){
                if(p==-1){
                    p = a[i];
                    q = b[j];
                }else if(p+q>a[i]+b[j]){
                    p = a[i];
                    q = b[j];
                }
            }
        }
    }
     
    if(p==-1) cout << p << endl;
    else cout << p << " " << q << endl;
    }
     
    return 0;
}

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

int main (){
	int A,B;cin>>A>>B;
	if(A%3==0||B%3==0||(A+B)%3==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
    return 0;
}

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

int main(){
    ll h, n; cin >> h >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

// Eratosthenesの篩
vector<int> primeno(1000100, -1);
void Eratosthenes(int n) {
    primeno.at(0) = 0;
    primeno.at(1) = 1;
    int limit = n+1;
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i) == -1) {
            primeno.at(i) = i;
            for(int j = 0; i*(j+2) < n+1; ++j) {
                if(primeno[i*(j+2)] == -1) {
                    primeno[i*(j+2)] = i;
                }
            }
        }
    }
}

ll n;

int main() {
    cin >> n;
    vector<ll> avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> avec[i];
    sort(avec.begin(), avec.end(), greater<ll>());
    ll amax = 1000005;
    Eratosthenes(amax+1);
    vector<int> cnt(amax+1, 0);
    vector< set<int> > prime(n);

    for(int i = 0; i < n; ++i) {
        ll now = avec[i];
        while(1) {
            if(now == 1) break;
            prime[i].insert(primeno[now]);
            now /= primeno[now];
        }
    }

    /*for(int i = 0; i <= avec[0]; ++i) {
        cout << i << " p " << primeno[i] << endl;
    }*/

    /*for(int i = 0; i < n; ++i) {
        for(auto x : prime[i]) {
            cout << x << " ";
        }
        cout << endl;
    }*/

    for(int i = 0; i < n; ++i) {
        for(auto x : prime[i]) {
            cnt[x]++;
        }
    }

    /*for(int i = 0; i <= avec[0]; ++i) {
        cout << i << " cnt " << cnt[i] << endl;
    }*/

    int ch = 0;
    if(n == 2) {
        for(int i = 0; i <= amax; ++i) {
            if(cnt[i] == n) {
                ch = 2;
                break;
            }
        }
        cout << "ok" << endl;
        return 0;
    }else {
        for(int i = 0; i <= amax; ++i) {
            if(cnt[i] == n) {
                ch = 2;
                break;
            }else if(cnt[i] >= 2) {
                ch = 1;
            }
        }
    }

    if(ch == 0) cout << "pairwise coprime" << endl;
    else if(ch == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 302556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first1
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define set             set<string>  //insert()
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{

    int radius;
    double PI=3.14,area,ci;


    cin>>radius;




    ci = 2 * PI * radius;
    cout<<ci<<endl;

    return 0;
}


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

signed main()
{
  int A, B, C, D;
  
  while(cin >> A >> B >> C >> D, A || B || C || D) {
    cout << max(0, (B * C - A + D - 1) / D) << endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

	ll ans = (B*(N - 1) + A) - (A*(N - 1) + B) + 1;
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	P := make([]int, n)
	for i := range P {
		P[i] = readInt()
	}

	var ans int
	for i := 1; i+1 < n; i++ {
		if (P[i-1] < P[i] && P[i] < P[i+1]) ||
			(P[i+1] < P[i] && P[i] < P[i-1]) {
			ans++
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
def main():
    S = input()
    T = input()
    lst = [""] * (ord("z") - ord("a") + 1)
    flg = True
    for s, t in zip(S, T):
        # 同アルファベット、違アルファベット変換チェック
        if lst[ord(s) - ord("a")] and lst[ord(s) - ord("a")] != t:
            flg = False
            break
        lst[ord(s) - ord("a")] = t
    lst = [i for i in lst if i != ""]
    # 変換先の重複チェック
    if len(lst) != len(set(lst)):
        flg = False
    print("Yes" if flg else "No")
    return


main()


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  ll n,m,d;
  cin>>n>>m>>d;
  ll tmp = d;
  if(d==0) tmp = n;
  else if(2*d >= n) tmp = n;
  else tmp += d + (n-2*d)*2;
  //cout << tmp << endl;
  double ans = tmp/double(n*n)*(m-1);
  cout << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
    int h,n;
    cin >>h>> n;
  	vector<int> a(n);
    for (int i = 0; i < n; i++)
         cin >> a[i];
  	int total=0;
  for(int x:a)
    total+=x;
  if(total>=h)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}


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

      int main(){
         int n;
         string s,t,u;
         cin >> s >> t >> u;
         cout << s[0] << t[1] << u[2] << endl;
   

         
         return 0;
         
      }



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

int main() {
    int n;
    cin >> n;
    vector<long long> ma(3), mb(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> ma.at(i);
    }
    for (int i = 0; i < 3; i++)
    {
        cin >> mb.at(i);
    }
    
    vector<long long> dp(n + 1);
    for (int i = 0; i <= n; i++)
    {
        dp.at(i) = i;
    }
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (i - ma.at(j) >= 0) dp.at(i) = max(dp.at(i), dp.at(i - ma.at(j)) + mb.at(j));
        }
    }
    
    vector<long long> dp2(dp.at(n) + 1);
    for (int i = 0; i < (int)dp2.size(); i++)
    {
        dp2.at(i) = i;
    }
    
    for (int i = 1; i < (int)dp2.size(); i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if (i - mb.at(j) >= 0) dp2.at(i) = max(dp2.at(i), dp2.at(i - mb.at(j)) + ma.at(j));
        }
    }
    
    cout << dp2.at((int)dp2.size() - 1) << endl;
}

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

int hd[26];
int nxt[111111][32];
char S[111111];
char T[111111];

long long ans=0;
int main(){
	scanf("%s %s",S+1,T+1);
	int lens=strlen(S+1);
	int lent=strlen(T+1);
	for(int i=lens;i>0;i--){
		//cerr<<"QAQQ_____++++"<<S[i]<<endl;
		for(int j=0;j<26;j++){
			nxt[i][j]=hd[j];
		}
		hd[S[i]-'a']=i;
//		cerr<<"------->"<<i<<endl;
//		for(int j=0;j<26;j++){
//			cerr<<(char)(j+'a')<<":"<<nxt[i][j]<<"  ";
//		}cerr<<endl;

	}
	
	
//	for(int i=0;i<26;i++){
//		cerr<<(char)(i+'a')<<"::\t\t"<<hd[i]<<endl;
//	}
//	
//	for(int i=0;i<lens;i++){
//		for(int j=0;j<26;j++){
//			cerr<<"\t"<<nxt[i][j];
//		}cerr<<endl;
//	}
	
	int idxs=hd[T[1]-'a'];
	if(idxs==0){
		printf("-1");
		return 0;
	}
	ans++;
	for(int i=2;i<=lent;i++){
		//cerr<<i-1<<"("<<T[i-1]<<")"<<"::\t"<<idxs<<"("<<S[idxs]<<")"<<"\t ans::"<<ans<<"\t idex::"<<idxs<<endl;
		if(nxt[idxs][T[i]-'a']){
			idxs=nxt[idxs][T[i]-'a'];
		}else{
			//cerr<<"QAQQQQ"<<endl;
			idxs=hd[T[i]-'a'];
			if(idxs==0){
				printf("-1");
				return 0;
			}
			ans++;
		}
	}
	//cerr<<lent-1<<"("<<T[lent-1]<<")"<<"::\t"<<idxs<<"("<<S[idxs]<<")"<<"\t ans::"<<ans<<"\t idex::"<<idxs<<endl;
	//cerr<<ans<<"  "<<lens<<"  "<<idxs<<endl;
	printf("%lld",(ans-1)*lens+idxs);
	
	return 0;
} 

//1 2 3 3 3 4 5 6
//s e n t e n c e

Measured memory_bytes: 12928
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_1(): 
    text = (['Sunny', 'Cloudy'], ['Cloudy', 'Rainy'],['Rainy','Sunny'])
    s = SI()
    for i in text:
        if s == i[0]:
            print(i[1])

def main_2(): 
    s = SI()
    for num, i in enumerate(s):
        if num % 2 == 1: # even
            if not (i in 'LUD'):
                print('No')
                return
        else:
            if not (i in 'RUD'):
                print('No')
                return
    print('Yes')

def main():
    N, K, Q = LI()
    A = [0] * (N+1)
    for _ in range(Q):
        n = II()
        A[n] += 1

    for i in range(N):
        if K - Q + A[i+1] <= 0:
            print('No')
        else:
            print('Yes')

main()

Measured memory_bytes: 47068
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct mod_int {
  static int Prime;
  int v_;
  mod_int(int x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
int mod_int::Prime = 2;

// fact
template<typename INT, int MAXN_>
struct factorial {
  INT fact[MAXN_+1], ifact[MAXN_+1];
  void init(int N) {
    fact[0] = fact[1] = INT(1);
    for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
    ifact[N] = fact[N].inv();
    for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
  }
  INT comb(int n, int k) {
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int const PMAX = 2999;
int P;
mod_int b[PMAX];
factorial<mod_int, PMAX> F;

int main() {
  std::cin >> P;
  mod_int::Prime = P;
  F.init(P-1);
  for(int i = 0; i < P; ++i) {
    int a; std::cin >> a;
    if(a == 0) continue;
    // calc 1 -(x-i)^(P-1)  = 1 - sum x^k(-i)^(P-1-k) comb(P-1,k)
    b[0] += 1;
    if(i == 0) { b[P-1] -= 1; continue; }
    mod_int mi_inv = mod_int(-i).inv(), c(1);
    for(int k = 0; k < P; ++k) {
      b[k] -= c*F.comb(P-1, k);
      c *= mi_inv;
    }
  }
  for(int i = 0; i < P-1; ++i) std::cout << b[i].v_ << " ";
  fin(b[P-1].v_);
  return 0;
}




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

int main()
{
ll k ;
cin >> k ;
ll t=7,cnt=1;;
while(1){
  t%=k;
  if(t==0)break;
  t=t*10+7;
  cnt++;
  if(cnt>10000000){cnt=-1;break;}
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 3628
#include<cstdio>

int main(){
	int f[50000] = {1,1};
	for(int i = 2; i < 25000; i++){
		f[i * 2] = 1;
	}
	for(int i = 3; i <= 224; i += 2){
		for(int j = 3; j * i < 50000; j += 2){
			f[i*j] = 1;
		}
	}

	int n;
	scanf("%d", &n);
	while(n){
		int count = 0;
		for(int i = n; i * 2 >= n; i--){
			if(!f[i] && !f[n-i]){
				count++;
			}
		}
		printf("%d\n", count);
		scanf("%d", &n);
	}

}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
int main() {
	int k = 0, x = 0;
	std::cin >> k >> x;
	for (int i = -1000000; i <= 1000000; i++) {
		if (std::abs(x - i) <= k - 1) {
			std::cout << i << std::endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  string s;cin>>s;
  if(s=="Sunny") pr("Cloudy");
  else if(s=="Cloudy") pr("Rainy");
  else pr("Sunny");
  return 0;
}


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

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e5+5;
const int MOD=1e9+7;
const int MAAX=1e18;
const long double EPS=1e-6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2);
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a * a % MOD;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //scanf("%lld",&tc);
    while(tc--)
    {
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a,a+3);
        cout<<((a[0]<a[1]&&a[1]==a[2])||(a[0]==a[1]&&a[1]<a[2])?"Yes\n":"No\n");
    }
    ///matensa4 tegarab el sample w te7ot el freopen w te3mel SCANF
    RETURN;
}


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

using namespace std;
const long long mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int f[26] = {0};
    for (char c: s) f[c - 'a']++;
    long long ans = 1;
    for (int i = 0; i < 26; i++)
        ans *= (1 + f[i]), ans %= mod;
    ans += mod - 1;
    ans %= mod;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <cstdio>
#include <math.h>
using namespace std;

long int isqrt(long int x);

int MAX_N = 1000;

int main(){
  long int N=0;
  /* read input */
  scanf("%ld", &N);
  long int s = isqrt(2*N);
  if(2*N == s*(s+1)){
    printf("Yes\n");
    
    int n = 1;
    int sets[MAX_N][MAX_N];
    for(long int i = 0; i < s; i++){
      for(long int j = i; j < s; j++){
        sets[i][j] = n;
        sets[j+1][i] = n;
        n++;
      }
    }
    printf("%ld\n", s+1);
    for(int i = 0; i < s+1; i++){
      printf("%ld ", s);
      for(int j = 0; j < s-1; j++){
        printf("%d ", sets[i][j]);
      }printf("%d\n", sets[i][s-1]);
    }
  }
  else printf("No");
  return 0;
}

long int isqrt(long int x){
  long int ans = 1;
  while(ans*ans < x){
    ans++;
  }
  return ans-1;
}


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


int x, y, s;

int main(){
  while(true){
    cin >> x;
    cin >> y;
    cin >> s;
    if (x == 0 && y == 0 && s == 0)break;

    int bef, aft, max;
    max = 0;
  
    for (int i = 1; i<=s; ++i){
      for (int j = 1; j<=s; ++j){
	bef = i * (100 + x) / 100 + j * (100 + x) / 100;
	if (bef == s){
	  aft = i * (100 + y) / 100 + j * (100 + y) / 100;
	  if(aft >= max){
	    max = aft;
	    //cout << "ijmax" << i << " " << j << " " << max << endl;
	  }
	}
      }
    }
    cout << max << endl;
  }
}

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

n, m = map(int, input().split())
l = ["" for _ in range(m)]
r = ["" for _ in range(m)]

for i in range(m):
    l[i], r[i] = map(int, input().split())
#print(l, r)

L = 1
R = n

for i in range(m):
    L = max(L, l[i])
    R = min(R, r[i])
    #print(L, R)

print(len(list(range(L, R+1))))


Measured memory_bytes: 60004
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            double r = double.Parse(Console.ReadLine());

            double R = 2 * System.Math.PI * r;
            double R2 = System.Math.PI * System.Math.Pow(r, 2);

            Console.WriteLine("{0} {1}", R2.ToString("f5"), R.ToString("f5"));
        }
    }
}


Measured memory_bytes: 18012
if __name__ == '__main__':
    n, y = map(int, input().split())
    for i in range(0, n+1):
        for j in range(0, n+1-i):
            k = n - (i + j)
            sum_price = 10000*i + 5000*j + 1000*k
            if n == i + j + k and sum_price == y:
                print(i, j, k)
                exit()
    print(-1, -1, -1)


Measured memory_bytes: 3060
s=input()
fs=int(s[:2])
ls=int(s[2:])
if 1<=fs<=12 and 1<=ls<=12:
    print('AMBIGUOUS')
elif 1<=fs<=12:
    print('MMYY')
elif 1<=ls<=12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
	int n,m;
	cin>>n>>m;
	vector<int>vec(n);
	for(int i=0;i<m;i++) {
		int a,b;
		cin>>a>>b;
		for(int j=0;j<n;j++) {
			if(a==(j+1)||b==(j+1)) {
				vec[j]++;
			}
		}
	}
	for(int i=0;i<n;i++) {
		cout<<vec[i]<<endl;
	}
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, K;
	
	cin >> N >> K;

	ll x[N], y[N];

	vector<ll> xa, ya;

	rep(i, N)
	{
		cin >> x[i] >> y[i];
		xa.pb(x[i]);
		ya.pb(y[i]);
	}

	//cout << "N = " << N  << endl;
	sort(xa.begin(), xa.end());
	sort(ya.begin(), ya.end());

	//cout << "xa=" << xa.size() << endl;
	//cout << "ya=" << ya.size() << endl;

	ll ans = 1LL * (xa[N-1] - xa[0]) *	(ya[N-1] - ya[0]);
	//cout << "ans = " << ans << endl;
	rep(xi, N)
	{
		for(int xj = xi+1; xj < N; xj++)
		{
			rep(yi, N)
			{
				for(int yj = yi +1; yj < N; yj++)
				{
					int num = 0;
					ll lx = xa[xi], rx = xa[xj];
					ll by = ya[yi], uy = ya[yj];

					rep(i, N)
					{
						if ((lx <= x[i]) && (x[i] <= rx) && (by <= y[i]) && (uy >= y[i]))
						{
							num++;
						}
					}

					if (num >= K)
					{
						ans = min(ans, 1LL * (rx - lx) * (uy-by));
					}
				}
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
Tree_List=list(map(int,input().split()))
ct =0
for i in range(n):
    while Tree_List[i] != 0:
        k = i + 1
        while k < n and Tree_List[k] != 0: 
            k+=1
        Tree_List[i:k]=map(lambda x:x-1,Tree_List[i:k])
        ct += 1
        
print(ct)


Measured memory_bytes: 3060
# include <stdio.h>
# include <string.h>
# include <algorithm>

using namespace std;

char s[1010];
char t[1010];

int main() {
  int l1, l2;
  scanf ("%s%s", s, t);
  l1 = strlen(s);
  l2 = strlen(t);
  int ans = 1010;
  for (int i = 0; i + l2 <= l1; i++) {
    int ts = 0;
    for (int j = i; j < i + l2; j++) {
      ts += s[j] != t[j - i];
    }
    ans = min(ans, ts);
  }
  printf("%d\n", ans);
}

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

typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  vector<ll> x(m);
  for(i=0;i<m;i++)cin >> x[i];
  sort(x.begin(),x.end());
  vector<ll> v(m-1);
  ll ret = 0ll;
  for(i=0;i<m-1;i++){
    ret += x[i+1] - x[i];
    v[i] = x[i+1] - x[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(i=0;i<min(n-1,m-1);i++)ret-=v[i];
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kishore
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextLine();
            if (s.length() >= 2) {
                for (int i = 0; i < s.length() - 1; i++) {
                    if (s.charAt(i) == s.charAt(i + 1)) {
                        out.println((i + 1) + " " + (i + 2));
                        return;
                    }
                    if (i + 2 < s.length() && s.charAt(i) == s.charAt(i + 2)) {
                        out.println((i + 1) + " " + (i + 3));
                        return;
                    }
                }

            }
            out.println("-1 -1");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}



Measured memory_bytes: 24532
#include <iostream>
#include <limits.h>

using namespace std;

int main()
{
  int N;

  cin >> N;

  int H=0;
  int count = 0;
  
  for (int ii=0; ii<N; ++ii) {
    int h;
    cin >> h;
    if (h >= H) {
      H = h;
      ++count;
    }
  }
  
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        FastScanner sc = new FastScanner(Console.OpenStandardInput());
        int N, M;
        N = sc.nextInt();
        M = sc.nextInt();
        int[] A = sc.intArray(M);
        int accum = A.Sum();
        Console.WriteLine(N < accum ? -1 : N - accum);
        return;
    }
}

// FastScanner start
public class FastScanner
{
    public readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public FastScanner(Stream stream)
    {
        str = stream;
    }
    private T[] enumerate<T>(int n, Func<T> f)
    {
        var a = new T[n];
        for (int i = 0; i < n; ++i) a[i] = f();
        return a;
    }
    public char nextChar()
    {
        byte b = 0;
        do
        {
            b = read();
        }
        while ((b < 33 || 126 < b) && !isEof);
        return (char)b;
    }
    public int nextInt()
    {
        return (isEof) ? int.MinValue : (int)nextLong();
    }
    public long nextLong()
    {
        if (isEof)
        {
            return long.MinValue;
        }
        long ret = 0;
        byte b = 0;
        var ng = false;
        do
        {
            b = read();
        }
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = read();
        }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
            {
                return ng ? -ret : ret;
            }
            else ret = ret * 10 + b - '0';
        }
    }
    public int[] intArray(int n)
    {
        return enumerate(n, nextInt);
    }
    public long[] longArray(int n)
    {
        return enumerate(n, nextLong);
    }
    public char[] charArray(int n)
    {
        return enumerate(n, nextChar);
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = nextChar(); b >= 33 && b <= 126; b = (char)read())
        {
            sb.Append(b);
        }
        return sb.ToString();
    }
    private byte read()
    {
        if (isEof)
        {
            return 0;
        }
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
}
// FastScanner end

Measured memory_bytes: 27756
S=input()
N=len(S)
flag=0
for i in range(N//2):
  if S[i]==S[N-i-1]:
    continue
  else:
    flag=1
s1=S[0:(N-1)//2]
s1l=len(s1)

s2=S[(N+3)//2-1:N]
s2l=len(s2)

if flag!=1:
  for i in range(s1l//2):
    if s1[i]==s1[s1l-i-1]:
      continue
    else:
      flag=1
      break

if flag!=1:
  for i in range(s2l//2):
    if s2[i]==s2[s2l-i-1]:
      continue
    else:
      flag=1
      break

if flag==0:
  print("Yes")

else:
  print("No")














Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ?????????????????°??????????????????
    // ?????°?????§?????????????????????
    double r;
    cin >> r;
    // ??????????????°???10?????§????????????
    cout << fixed << setprecision(10);
    // ??¢???????±???????????????????
    cout << r * r * pi << " " << 2 * pi * r << endl;
    // ???????????§
}

Measured memory_bytes: 3244
#include <cstdio>
#include <algorithm>
using namespace std;

int a[10+5];

int main() {
	int n;
	scanf("%d", &n);
	int sum = 0;
	int maxn = -1;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		maxn = max(a[i], maxn);
	}
	if (sum > 2 * maxn) 
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String st = scan.next();
	int w = Integer.parseInt(st);
	st = scan.next();
	int h = Integer.parseInt(st);
	st = scan.next();
	int x = Integer.parseInt(st);
	st = scan.next();
	int y = Integer.parseInt(st);
	st = scan.next();
	int r = Integer.parseInt(st);
	
	if((x - r) < 0 || (y - r) < 0 || (x + r) > w || (y + r) > h) 
	    {
		System.out.println("No");
	    }
	else System.out.println("Yes");
    }
}



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

ll N, W, w[101], v[101], dp[101][100001];
ll solve(int i, int j) {
	if (dp[i][j] != -1) return dp[i][j];
	if (i == N) return dp[i][j] = 0;
	if (w[i] > j) return dp[i][j] = solve(i + 1, j);
	return dp[i][j] = max(solve(i + 1, j), solve(i + 1, j - w[i]) + v[i]);
}
int main() {
	cin >> N >> W;
	rep(i, N) cin >> w[i] >> v[i];
	memset(dp, -1, sizeof(dp));
	cout << solve(0, W) << endl;
	return 0;
}

Measured memory_bytes: 79104
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        string a, b, c;
        cin >> a >> b >> c;
        if (a.back() == b[0] && b.back() == c[0]) cout << "YES" << endl;
        else cout << "NO" << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int N;

int calc(int x, int y, int z)
{
    int result = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + x * z;
    return result;
}

int main(void)
{
    cin >> N;

    vector<int> a(N, 0);

    for (int x = 1; x < 100; x++)
    {
        for (int y = 1; y < 100; y++)
        {
            for (int z = 1; z < 100; z++)
            {
                int n = calc(x, y, z);
                if (calc(x, y, z) > N)
                {
                    break;
                }
                else
                {
                    a[n - 1]++;
                }
            }
        }
    }

    rep(i, N)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 3496
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<ll> b(n+1);
	b[0] = 0;
	for(int i = 1; i <= n; i++){
		b[i] = a[i-1] + b[i-1];
		b[i] %= m;
	}
	map<ll,int> x;
	for(int i = 0; i <= n; i++){
		x[b[i]]++;
	}
	ll ans = 0;
	for(auto itr = x.begin(); itr != x.end() ; ++itr){
		ll z = itr->second;
		z--;
		//cout << itr->first << "   " <<  itr->second << endl;
		ans += z*(z+1)/2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760