akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
long long int power(long long int a,long long int n,long long int m) ;
long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
//map<ll,ll>::iterator it ;

int main()
{ int n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o,temp;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1,s2 ;
  cin>>x>>y>>z>>n ;
  cnt=0 ;
  if(n<=x+y)
  {
      if(n>=x)
        cout<<x ;
      else cout<<n ;
      return 0;
  }
  cout<<x-(n-x-y) ;
  return 0; }


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

int main(){
    double PI = 3.14159265358979323846;
    double twoPI = 6.28318530718;
;
    
    int a,b;
    double h,m;
    cin >> a >> b >> h >> m ;

    double ha = h*(twoPI/12)+ m*(twoPI/720);
    double ma = m*(twoPI/60);

    double hm = 0;
    if( ha >= ma ){
        hm = ha-ma;
    }else if( ma > ha ){
        hm = ma-ha;
    }
    
    if( hm > PI ){
        hm = twoPI - hm;
    }else{
    }
    
    double c = 0;
    c = a*a + b*b - 2 * a * b * cos(hm) ;
    c = sqrt(c);
    
    cout << fixed << setprecision(15) << c << endl;
    
    return 0;
}

Measured memory_bytes: 4212
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"20"# => r#"15800"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    (n * 800 - (n / 15 * 200)).to_string()
}

Measured memory_bytes: 4352
from math import sqrt
def isPrime(n):
    if n == 2:
        return 1
    if n == 1 or n % 2 == 0:
        return 0
    for i in range(3,int(sqrt(n)) + 1):
        if n % i == 0:
            return 0
    return 1

from sys import stdin
print(sum([isPrime(int(n))for n in stdin]))

Measured memory_bytes: 7808
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;
const ll inf=1000000000000;

int main()
{
    int N, M;
    cin >> N >> M;
    vector< vector< ll > > vt(M, vector<ll> (3));//vt[i][0]からvt[i][1]に重みvt[i][2]の辺が伸びる。
    for(int i=0; i<M; i++){
        cin >> vt[i][0] >> vt[i][1] >> vt[i][2];
        vt[i][2]=-vt[i][2];
    }

    ll dist[N];
    for(int i=0; i<N; i++){
        dist[i]=inf;
    }
    dist[0]=0;
    
    for(int loop=0; loop<N-1; loop++){
        for(int i=0; i<M; i++){
            if(dist[vt[i][0]-1]==inf)continue;
            if(dist[vt[i][1]-1]>dist[vt[i][0]-1]+vt[i][2]){
                dist[vt[i][1]-1]=dist[vt[i][0]-1]+vt[i][2];
            }
        }
    }
    ll ans=dist[N-1];
    
    bool negative[N];
    for(int i=0; i<N; i++){
        negative[i]=false;
    }

    for(int loop=0; loop<N-1; loop++){
        for(int i=0; i<M; i++){
            if(dist[vt[i][0]-1]==inf) continue;
            if(dist[vt[i][1]-1]>dist[vt[i][0]-1]+vt[i][2]){
                dist[vt[i][1]-1]=dist[vt[i][0]-1]+vt[i][2];
                negative[vt[i][1]-1]=true;
            }

            if(negative[vt[i][0]-1]==true) negative[vt[i][1]-1]=true;
        }
    }
    if(negative[N-1])cout << "inf";
    else cout << -ans;

    return 0;
}

Measured memory_bytes: 888
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;

ll a[100005],dp[100005],n,k;

ll ans(ll i){	
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	if(dp[i]!=-1)	return dp[i];
	ll sol=INT_MAX;
	for(ll j=1;j<=k;j++){
		if(i+j<n){
			sol=min(sol,abs(a[i]-a[i+j]) + ans(i+j));		
		}
	}
	return dp[i]=sol;
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	for(ll i=0;i<n;i++)
		cin >> a[i];
	cout << ans(0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

Measured memory_bytes: 12944
#include<bits/stdc++.h>
using namespace std;
bool ispalindrome(char s[])
{
    int flag=0;
    int l=strlen(s)-1;
    int h=0;

    while(l>=h)
    {
        if(s[h++] != s[l--])
        {
            return false;
        }
    }

    return true;
}

bool firsthalfpalindrome(char s[])
{
    int h=0;
    int l= ((strlen(s)-1)/2)-1;
  //  cout<<l<<endl;

    while(l>=h)
    {
        if(s[l--] != s[h++])
            return false;

            return true;
    }
}

bool lasthalfpalindrome(char s[])
{
    int h= ((strlen(s)+3)/2)-1;
   // cout<< h<<endl;
    int l=strlen(s)-1;
    while(l>=h)
    {
        if(s[l--]!= s[h++])
            return false;

            return true;
    }
}


int main()
{
    char s[100];
    scanf("%s",s);

    if(ispalindrome(s) && firsthalfpalindrome(s) &&  lasthalfpalindrome(s) )
        cout<< "Yes"<<endl;
    else
        cout<< "No"<<endl;

}


Measured memory_bytes: 256
n = input()
s = [int(i) for i in n]
v = 0
w = ''
for p in range(2):
  if p == 0:
    v = s[0] + s[1]
    w = n[0] + "+" + n[1]
  else:
    v = s[0] - s[1]
    w = n[0] + "-" + n[1]
  for q in range(2):
    if q == 0 and p == 0:
      v += +s[2]
      w += "+" + n[2]
    elif q == 1 and p == 0:
      v = s[0] + s[1] - s[2]
      w =  n[0] + "+" + n[1] + "-" + n[2]
    elif q == 0 and p == 1:
      v += +s[2]
      w += "+" + n[2]
    elif q == 1 and p == 1: 
      v = s[0] - s[1] - s[2]
      w =  n[0] + "-" + n[1] + "-" + n[2]
    for r in range(2):
      if r == 0:
        if v+s[3] == 7:
          print(w + "+" + n[3] + "=7")
          exit()
      else:
        if v-s[3] == 7:
          print(w + "-" + n[3] + "=7")
          exit()
       
        
    
    

 


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	l := make([]int, n)
	for i:=0; i<n; i++ {
		fmt.Scan(&l[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(l)))

	sum := 0
	for i:=1; i<n; i++ {
		sum += l[i]
	}

	if l[0] < sum {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}

}

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

#define int long long
#define max(a,b) max((signed)a,(signed)b)
#define mn(a,b) min((signed)a,(signed)b)

using namespace std;

vector<vector<int>> adj(100005);
int visited[100005]={0};
int dist[100005]={0};
int in_degree[100005]={0};

void dfs(int curr){
	visited[curr]=1;
	for(int i=0;i<adj[curr].size();i++){
		in_degree[adj[curr][i]]--;
		dist[adj[curr][i]] = max(dist[adj[curr][i]],dist[curr]+1);
		if(in_degree[adj[curr][i]]==0){
			dfs(adj[curr][i]);
		}
	}
}

signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		in_degree[b]++;
	}
	for(int j=0;j<n;j++){
		adj[0].push_back(j+1);
	}
	for(int i=1;i<=n;i++){
		if(!visited[i] && !in_degree[i]){
			dfs(i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dist[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 18088
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	cin >> N;
	int R = 0;
	int B = 0;
	string s;
	char r[2] = "R";

	cin >> s;

	for (int i = 0; i <= N - 1; i++) {
		if (s[i] == r[0]) {
			R++;
		}
		else {
			B++;
		}
	}

	if (R > B) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
// Original: https://atcoder.jp/contests/abc162/submissions/11852555
use proconio::input;

fn main() {
    input! {
        n :usize,
        av: [i64; n],
    };

    let ans = if n % 2 == 0 {
        let mut dp = (0_i64, 0_i64);
        for (i, &a) in av.iter().enumerate() {
            if i % 2 == 0 {
                dp.0 = dp.0 + a;
            } else {
                dp.1 = std::cmp::max(dp.0, dp.1 + a);
            }
        }
        dp.1
    } else {
        let mut dp = (0_i64, 0_i64, 0_i64);
        for (i, &a) in av.iter().enumerate() {
            if i % 2 == 0 {
                dp.0 = dp.0 + a;
                if i != 0 {
                    dp.2 = std::cmp::max(dp.1, dp.2 + a);
                }
            } else {
                dp.1 = std::cmp::max(dp.0, dp.1 + a);
            }
        }
        dp.2
    };
    println!("{}", ans);
}


Measured memory_bytes: 5644
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << X << endl
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;
inline string YesNo(bool cond) { return cond ? "Yes" : "No"; }
inline string YESNO(bool cond) { return cond ? "YES" : "NO"; }
template <class T>
string join(const vector<T>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}
//---------------------------------------------------------------------------

int main(void)
{
    ll A,B,C;
    cin >> A >> B >> C;
    print(YesNo(A+B>=C));
}


Measured memory_bytes: 256
N = int(input())
a = 0
b = 0
c = 0
for i in range(N):
    t,x,y = [int(x) for x in input().split()]
    kyori = abs(a-x)+abs(b-y)
    if t-c-kyori >= 0 and (t-c-kyori) % 2 == 0:
        a = x
        b = y
        c = t
        continue
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
            ++count;
    }
    int a = 0;
    for (int i = 0; i < count; i++)
    {
        if (s[i] == 'W')
            ++a;
    }
    cout << a << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <cstdio>
#include <float.h>
#include <ctype.h>
 using namespace std;
 int main(void) {
	 int a, b, c, d, total, min, sec;
	 scanf("%d %d %d %d", &a, &b, &c, &d);
	 total = a + b + c + d;
	 min = total / 60;
	 sec = total % 60;
	 printf("%d\n%d\n", min, sec);
	 return 0;
 }



Measured memory_bytes: 3232
#include<iostream>

#include<cmath>

#include<cstdio>

#include<cstring>

#include<algorithm>



using namespace std;



int main(){

	string a , b , c;

	int m;

	double d;

	cin>>a>>b;

	c = a + b;

	m = atoi(c.c_str());

	d = sqrt(m);

	if(fabs(d-int(d))<1e-8) cout<<"Yes"<<endl;

	else cout<<"No"<<endl;

	return 0;

	}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"

int main(int argc, char const *argv[]) {
  /* code */

  int N;
  std::cin >> N;

  int res = N;

  for (int i = 0; i < N+1; i++) {
    /* code */
    int t = N - i;
    int t2 = i;

    int cc = 0;
    while (t > 0) {
      /* code */
      cc += t % 6;
      t /= 6;
    }
    while (t2 > 0) {
      /* code */
      cc += t2 % 9;
      t2 /= 9;
    }

    if(res > cc) res = cc;

  }
  std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
t_sorted = [int(input()) for _ in range(N)]
t_sorted.sort()

car = 0
passenger = 0
target_t, limit = 0, 0
for i, t in enumerate(t_sorted):
    if target_t == 0:
        target_t = t
        limit = t + K
    passenger += 1
    if passenger == C:
        car += 1
        passenger = 0
        target_t = 0
        continue
    if i != N - 1:
        if t_sorted[i + 1] > limit:
            car += 1
            passenger = 0
            target_t = 0
            continue
if passenger > 0:
    car += 1

print(car)


Measured memory_bytes: 81200
n = int(input())
s = input()
cnt_r = 0
cnt_b = 0
for i in range(len(s)):
    if s[i] == 'R':
        cnt_r+=1
    elif s[i] == 'B':
        cnt_b +=1
if cnt_r > cnt_b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 400010;
const double EPS = 1e-9;


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

int a[MX];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

  	int k, n;
  	cin >> k >> n;
  	fi(0, n) {
  		cin >> a[i];
  		a[i + n] = a[i] + k;
  	}
  	int mn = INF;
  	fi(0, n) {
  		mine(mn, a[i + n - 1] - a[i]);
  	}
  	cout << mn << '\n';
}

Measured memory_bytes: 3456
#include<stdio.h>

int main()
{
	int N, M, i, j;
	int target[100], cnt[100], data[100][100];

	scanf("%d %d", &N, &M);

	for (i = 0; i < M; i++)
	{
		scanf("%d", &target[i]);
		--target[i];
	}

	for (i = 0; i < M; i++)
	{
		for (j = 0; j < N; j++)
		{
			scanf("%d", &data[i][j]);
			--data[i][j];
			cnt[j] = 0;
		}
	}

	for (j = 0; j < N; j++)
	{
		for (i = 0; i < M; i++)
		{
			if (data[i][j] == target[i])
			{
				++cnt[j];
			}
			else
			{
				++cnt[target[i]];
			}
		}
	}

	for (j = 0; j < N; j++)
	{
		printf("%d\n", cnt[j]);
	}
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long f(long long h){
   long long cnt = 0;
   if(h == 1) return 1;

   
   h = h/2;
   cnt = 1 + f(h)*2;
   return cnt;
}
int main(){
  long long h;
  cin >> h;
  
  cout << f(h) << 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;
using ll =long long;
using P =pair<int,int>;

int main(){
    
    int n,m;
    cin >> n >> m;
    vector <vector <int>> v(n+1),v2(n+1);
    vector <vector <int>> so;
    vector <vector <int>> ans(m,vector <int> (2));

    int p,y;
    rep(i,m){
        cin >> p >> y;
        v[p].push_back(i);
        v2[p].push_back(y);
        ans[i][0]=p;
    }

    int l;
    rep(i,n){
        l=v[i+1].size();
        so.resize(l);
        rep(j,l){
            so[j].resize(2);
        }
        rep(j,l){
            so[j][0]=v2[i+1][j];
            so[j][1]=v[i+1][j];
        }
        sort(so.begin(),so.end());
        rep(j,l){
            ans[so[j][1]][1]=j+1;
        }
    }
    string s1,s2,s;
    int l1,l2;
    rep(i,m){
        s1=to_string(ans[i][0]);
        s2=to_string(ans[i][1]);
        l1=6-s1.size();
        l2=6-s2.size();
        rep(j,l1){
            s1="0"+s1;
        }
        rep(j,l2){
            s2="0"+s2;
        }
        
        
        cout << s1+s2 << endl;
    }

    

    return 0;
}

Measured memory_bytes: 17956
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <queue>

using namespace std;
int main(){
    int prime[50001]={0};
    prime[0]=-1;
    prime[1]=-1;
    int now =2;
    while(now<=50000){
        if(prime[now]==-1){
            now++;
        }else{
            prime[now]=1;
            int del = now;
            while(1){
                del+=now;
                if(del>50000)break;
                prime[del]=-1;
            }
            now++;
        }
        
    }
    int x;
    while(cin>>x){
        if(x==0)break;
        int count=0;
        for(int i=2; i<=x/2; i++){
            if(prime[i]==1&&prime[x-i]==1)count++;
        }
        cout<<count<<endl;
    }

}

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

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

	int64_t N;
	cin >> N;
	string ans;
	--N;
	if (N == 0) {
		cout << "a" << endl;
		return 0;
	}
	while (N) {
		// cout << N << endl;
		ans.push_back('a' + ((N)%26));
		N /= 26;
		if (N == 1) {
			ans.push_back('a');
			break;
		}
		if (N>1) --N;
	}

	reverse(ans.begin(), ans.end());

	cout << ans << endl;
}

Measured memory_bytes: 3624
a, b, x = gets.split.map(&:to_i)
box = (a ** 2) * b
if box.fdiv(2) >= x
  result = Math.atan2(a * (b ** 2), 2 * x)
else
  result = Math.atan2(2 * (box-x), (a ** 3))
end

puts result * 180 / Math::PI

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

int a, b;
bool is_first = true;

int main() {
  while (1) {
    scanf("%d%d", &a, &b);
    if (a == 0 && b == 0) return 0;
    if (!is_first) puts("");
    is_first = false;

    bool found = false;
    for (int i=a; i<=b; i++) {
      if (i%400 == 0) {
        printf("%d\n", i);
        found = true;
      } else if (i%100 == 0);
      else if (i%4 == 0) {
        printf("%d\n", i);
        found = true;
      }
    }

    if (!found) puts("NA");
  }
}

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

using namespace std;

int main() {
    int n, k; cin >> n >> k;
    vector<int> nums;
    int a;
    for (int i = 0 ; i < n; ++i) {
        cin >> a;
        nums.push_back(a);
    }
    sort(nums.begin(), nums.end());

    int res = 0;
    for (int i = 0; i < k; ++i) {
        res += nums[i];
    }    
	cout << res << endl;
}


Measured memory_bytes: 3200
def dfs(depth,prev,sum):
	if depth == n:
		return sum == s
	ret = 0
	for i in range(prev + 1,10):
		ret += dfs(depth + 1,i,sum + i)
	return ret

while True:
	n,s = map(int,input().split())
	if n == 0:
		break
	print(dfs(0,-1,0))


Measured memory_bytes: 5600
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}


int main(){

    ll n;
    cin >> n;
    string s = "";

    while(n){
        n--;
        s += ((n%26) + 'a');
        n /= 26;
    }

    reverse(s.begin(), s.end());
    cout << s <<endl;
}





Measured memory_bytes: 3632
def main():
    n = int(input())
    a = [None]*n
    b = [None]*n
    for i in range(n):
        x = int(input())
        a[i] = x
        b[i] = x
    b.sort()
    dic = {}
    for i, v in enumerate(b):
        dic[v] = i
    cnt = 0
    for i in range(n):
        if i%2 != dic[a[i]]%2:
            cnt += 1
    print(cnt//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19880
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, m;
vector<pair<int, pair<string, string> > >rule;

int judge(string src, string dst){
  for(int i = n-1; i >= 0; i--){
    int p;
    for(p = 0; p < 8; p++){
      if(rule[i].S.F[p] != '?' && src[p] != rule[i].S.F[p]) break;
      if(rule[i].S.S[p] != '?' && dst[p] != rule[i].S.S[p]) break;
    }
    if(p == 8) return rule[i].F;
  }
  return 0;
}

int main(){
  while(scanf("%d%d", &n, &m) && n+m){
    rule.clear();
    string r, src, dst, mes;
    rep(i, n){
      cin >> r >> src >> dst;
      rule.PB(MP((r[0]=='p')?1:0, MP(src, dst))); // permit 1, deny 0
    }

    vector<pair<string, pair<string, string> > >res;
    rep(i, m){
      cin >> src >> dst >> mes;
      if(judge(src, dst)) res.PB(MP(src, MP(dst, mes)));
    }

    printf("%d\n", (int)res.size());
    rep(i, res.size()) cout << res[i].F << " " << res[i].S.F << " " << res[i].S.S << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    cout << 0 << endl;
    string status;
    cin >> status;
    bool zero_is_male;
    if (status == "Vacant" ) {
        return 0;
    } else if (status == "Male") {
        zero_is_male = true;
    } else {
        zero_is_male = false;
    }

    int left = 0, right = n;
    while (true) {
        int mid = (left + right) / 2;
        cout << mid << endl;
        string status;
        cin >> status;
        if (status == "Vacant") {
            return 0;
        } else if (status == "Male") {
            if ((zero_is_male == true and mid % 2 == 0)
                    or (zero_is_male == false and mid % 2 == 1)) {
                left = mid;
            } else {
                right = mid;
            }
        } else {
            if ((zero_is_male == true and mid % 2 == 1)
                    or (zero_is_male == false and mid % 2 == 0)) {
                left = mid;
            } else {
                right = mid;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    long double a,b,c;cin>>a>>b>>c;
    long double tmp = a + b + (long double)(2.0*sqrt(a)*sqrt(b) );
    if(tmp < c){
        cout << "Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

void Sort()
{
    int a[5];
    
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
        
    sort (a, a + 5, greater<int>()); //sorting from big int
        
    for(int i = 0; i < 4; i++)
    {
        cout<<a[i]<<" ";
    }
    
    cout<<a[4]<<endl;  //don't forget this part
    
    return;
}

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

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

int main(){
    int n;
    cin >> n;

    vector< vector<int> > p(n, vector<int>(n));
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < n ; ++j){
            cin >> p[i][j];
        }
    }

    vector< vector<int> > sum(n + 1, vector<int>(n + 1, 0));
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < n ; ++j){
            sum[i + 1][j + 1] = p[i][j];
        }
    }

    for(int i = 0 ; i <= n ; ++i){
        for(int j = 1 ; j <= n ; ++j){
            sum[i][j] += sum[i][j - 1];
        }
    }

    for(int j = 0 ; j <= n ; ++j){
        for(int i = 1 ; i <= n ; ++i){
            sum[i][j] += sum[i - 1][j];
        }
    }

    int ans = -(1 << 30);

    for(int i = 1 ; i <= n ; ++i){
        for(int j = 0 ; j <= n ; ++j){
            for(int k = 0 ; k < j ; ++k){
                ans = max(ans, sum[i][j] - sum[i][k] - sum[i - 1][j] + sum[i - 1][k]);
                ans = max(ans, sum[j][i] - sum[k][i] - sum[j][i - 1] + sum[k][i - 1]);
            }
        }
    }

    for(int d = 2 ; d <= n ; ++d){
        for(int u = 1 ; u < d ; ++u){
            int maxi = sum[d][1] - sum[d][0] - sum[u - 1][1] + sum[u - 1][0];
            for(int j = 2 ; j <= n ; ++j){
                ans = max(ans, maxi + sum[d][j] - sum[d][j - 1] - sum[u - 1][j] + sum[u - 1][j - 1]);
                maxi = max(maxi + p[d - 1][j - 1] + p[u - 1][j - 1], sum[d][j] - sum[d][j - 1] - sum[u - 1][j] + sum[u - 1][j - 1]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,y,d;
	cin>>n>>y;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=n-a;b++){
			d=a*10000+b*5000+(n-a-b)*1000;
			if(y==d){
				cout<<a<<" "<<b<<" "<<(n-a-b);
				return(0);
			}
		}
	}
	cout<<"-1"<<" "<<"-1"<<" "<<"-1"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{     int c=0;
      string s,t;
      cin>>s>>t;
      for (int i = 0 ; i < s.size() ; i++)
{
if (s[i] != t[i])
    {
    c++;

    }

}
  if (c>=1)
    {
        cout<<"No";
    }
    else{


        cout<<"Yes";
    }

    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	ll N; cin >> N;
	ll _N = N - 1;
	string res;
    while (true) {
		int tmp = _N % 26;
		res += (char)('a' + tmp);
        _N /= 26;
		--_N;
		if (_N < 0) break;
    }
	REP(i,res.size()) {
		cout << res[res.size() - i - 1];
	}
	cout << endl;
}

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


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, K; cin >> N >> K;
    vector<int> A(N + 1, 0); FOR(i, 1, N + 1) cin >> A[i];
    REP(i, K) {
        vector<int> tmp(N + 1, 0);
        FOR(i, 1, N + 1) {
            int d = A[i];
            int b = (i - d < 0) ? 0 : i - d;
            tmp[b]++;
            if (i + d + 1 <= N) {
                int e = i + d + 1;
                tmp[e]--;
            }
        }
        A[0] = tmp[0];
        if (A[0] == N) break;
        FOR(i, 1, N + 1) {
            A[i] = A[i - 1] + tmp[i];
        }
    }
    FOR(i, 1, N + 1) {
        cout << A[i] << " ";
    }
    cout << "\n";
}

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

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

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

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

    string s, t;
    cin >> s >> t;

    vector<int> s_table(26, -1);
    vector<int> t_table(26, -1);

    rep(i, s.size()) {
        int a = s[i] - 'a';
        int b = t[i] - 'a';

        if(s_table[b] != -1 || t_table[a] != -1) {
            if(s_table[b] != a || t_table[a] != b) {
                cout << "No" << endl;
                return 0;
            }
        }

        s_table[b] = a;
        t_table[a] = b;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(void) {
	int k;
	char s[200],n[k+1];
	scanf("%d %s",&k,s);
	int len = strlen(s);
	if(len <= k){
		printf("%s\n",s);
	}else{
		strncpy(n,s,k);
		printf("%s...\n",n);
	}
	return 0;
}


Measured memory_bytes: 1688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

struct UnionFind{
  vector<int> d;
  UnionFind(int n) : d(n, -1){}
  int find(int x){
    if(d.at(x) < 0) return x;
    return d.at(x) = find(d.at(x));
  }
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return false;
    if(d.at(x) > d.at(y)) swap(x, y);
    d.at(x) += d.at(y);
    d.at(y)= x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d.at(find(x)); }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  rep(i, n){
    cin >> p.at(i);
    p.at(i)--;
  }
  UnionFind uf(n);
  rep(i, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x, y);
  }

  int ans = 0;
  rep(i, n){
    if(uf.same(i, p.at(i))) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4024
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
		int n = scan.nextInt();

		long first = scan.nextLong();
		long max = first;
		long min = first;
		for(int i = 1; i < n; i++) {
			long a = scan.nextLong();
			if(max < a) {
				max = a;
			}else if(min > a) {
				min = a;
			}
		}

		System.out.println(max - min);
    }
}


Measured memory_bytes: 21844
A,B,C=map(int,input().split())
if A==B:
    if A!=C:
        print("Yes")
    else:
        print("No")
elif A==C:
    if A!=B:
        print("Yes")
    else:
        print("No")
elif B==C:
    if A!=B:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 5;
char a[105];
bool vis[12];
typedef long long LL;
int main(){
	int n;
	scanf("%d",&n);
		int ans = 1;
		for(int i = 1; i <= n; i++){
			scanf(" %c",&a[i]);
		}
		sort(a+1,a+1+n);
		for(int i = 1; i < n; i++){
			if(a[i] != a[i+1]) ans++;
		}
		if(ans == 3) printf("Three\n");
		else printf("Four\n");
	return 0;
}

Measured memory_bytes: 256
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)
  
a, b = map(int, input().split())

print(lcm(a, b))

Measured memory_bytes: 38724
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().rstrip()
print(abs(S.index('A')-(len(S)-(S[::-1].index('Z')+1)))+1)


Measured memory_bytes: 3516
#include<stdio.h>

int main(void)
{
	int H=1,W=1;
	
	for(;H!=0&&W!=0;){
		
		scanf("%d %d",&H,&W);
		
		for(int s=0;s<H;s++){
			
			for(int t=0;t<W;t++){
				
				if(s==0||s==H-1){
					
					printf("#");
					
				}
				else if(t==0||t==W-1){
					
					printf("#");
					
				}
				else printf(".");
			}
			printf("\n");
		}
		if(H!=0&&W!=0){
			
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll sum1 = 4*a*b;
  ll val = (c-a-b);
  ll sum2 = val*val;
  if (0 < val && sum1 < sum2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    str_n = input()
    n = int(str_n)
    len_n = len(str_n)
    if len_n % 2 == 0:
        if len_n == 6:
            print(90909)
        elif len_n == 4:
            print(909)
        else:
            print(9)
    else:
        if len_n == 5:
            print(909 + n - 10000 + 1)
        elif len_n == 3:
            print(9 + n - 100 + 1)
        else:
            print(n)

# nが奇数桁の場合
# 　より小さい桁の奇数桁の個数 + 今の桁で今の数までの個数
# nが偶数桁の場合
# 　より小さい桁の奇数桁の個数
# 1 9
# 3 900
# 5 90000


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n,x;
     cin >> n >> x;
     for(int i=0;i<=n;i++){
        if((i*2 + (n-i)*4)==x){cout << "Yes";return;}
     }
     cout << "No";
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3804
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  P = list(map(int,input().split()))
  
  #COMP = P[1:len(P)-1]
  #print(COMP)
  cnt = 0
  for i in range(1,len(P)-1):
    #print(P[i])
    if P[i-1] < P[i] < P[i+1] or P[i-1] > P[i] > P[i+1]:
      cnt += 1
  
  print(cnt)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost = 1) : from(from), to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
	friend ostream& operator<<(ostream& os, const Edge<T> &e) { return os << e.from << " " << e.to << " " << e.cost; }
};


int main() {

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

	int L;
	cin >> L;

	vector<Edge<int>> ans;
	ans.reserve(60);

	int vert = 0;
	for (int i = 20; i >= 1; i--) {
		if ((1 << i) & L) {
			vert = i;
			break;
		}
	}

	for (int i = 0; i < vert; i++) {
		ans.emplace_back(i + 1, i + 2, 0);
		ans.emplace_back(i + 1, i + 2, (1 << i));
	}

	int cost = (1 << vert);
	for (int i = vert - 1; i >= 0; i--) {
		if (L & (1 << i)) {
			ans.emplace_back(i + 1, vert + 1, cost);
			cost += (1 << i);
		}
	}

	cout << vert + 1 << " " << ans.size() << "\n";
	cout << ans << "\n";

	return 0;
}

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

int main(){
  int n,i;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(i=0;i<n;i++){
    cin >> s.at(i) >> t.at(i);
  }
  string x;
  cin >> x;
  
  int j=0,a=0;
  for(i=0;i<n;i++){
    a += t.at(i)*j;
    if(s.at(i)==x){
      j=1;
    }
  }
  
  cout << a << endl;
}

Measured memory_bytes: 3636
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:  
		break
	for h in range(H):
		str = ''
		for w in range(W):
			if h != 0 and h != (H - 1) and w != 0 and w != (W - 1):
				str += '.'
			else:
				str += '#'
		print(str)
	print()


Measured memory_bytes: 5612
using System;
using System.Collections.Generic;

namespace P0026_DroppingInk
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = new List<string[]>();

            while (true)
            {
                var line = Console.ReadLine();
                if (line == null) break;

                inputs.Add(line.Split(','));
            }
            
            int[,] map = new int[14,14];

            var drop = new List<int[,]>();

            drop.Add( new int[,] { 
                { 0, 0, 0, 0, 0 }, 
                { 0, 0, 1, 0, 0 }, 
                { 0, 1, 1, 1, 0 }, 
                { 0, 0, 1, 0, 0 },
                { 0, 0, 0, 0, 0 } });

            drop.Add( new int[,] { 
                { 0, 0, 0, 0, 0 }, 
                { 0, 1, 1, 1, 0 }, 
                { 0, 1, 1, 1, 0 }, 
                { 0, 1, 1, 1, 0 },
                { 0, 0, 0, 0, 0 } });

            drop.Add( new int[,] { 
                { 0, 0, 1, 0, 0 }, 
                { 0, 1, 1, 1, 0 }, 
                { 1, 1, 1, 1, 1 }, 
                { 0, 1, 1, 1, 0 },
                { 0, 0, 1, 0, 0 } });

            foreach (var input in inputs)
            {
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]);
                int size = int.Parse(input[2]);

                for(int yy = 0;yy < 5;yy++)
                {
                    for(int xx = 0;xx < 5;xx++)
                    {
                        map[x + xx, y + yy] += drop[size - 1][xx, yy];
                    }

                }

            }

            int zero = 0;
            int max = 0;

            for (int y = 2; y < 12; y++ ) 
            {
                for (int x = 2; x < 12; x++)
                {
                    if (map[x, y] == 0) zero += 1;
                    if (max < map[x, y]) max = map[x, y];
                }
            }

            Console.WriteLine(zero.ToString());
            Console.WriteLine(max.ToString());
        }
    }
}

Measured memory_bytes: 5856
n, x = map(int, input().split())
L = list(map(int, input().split()))

D = [0] * (n + 1)
for i in range(n):
    D[i + 1] = D[i] + L[i]

from bisect import bisect_left, bisect_right

idx = bisect_right(D, x)
print(len(D[:idx]))

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.ReadSplitL();
            long N = p[0];
            long A = p[1];
            long B = p[2];
            if (N == 1) { Console.WriteLine(A == B ? 1 : 0);return; }
            if (A > B) { Console.WriteLine(0);return; }
            Console.WriteLine((N - 1) * B + A - (N - 1) * A - B + 1);
            
            //Console.Out.Flush();
        }
        
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    public class Scanner
    {
        public int[] ReadSplit()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitL()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplitD()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
}


Measured memory_bytes: 13268