akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll n, m, x;
    cin >> n >> m >> x;
    vll c(n);
    vvll a(n, vll(m));
    REP(i, n) {
        cin >> c[i];
        REP(j, m) {
            cin >> a[i][j];
        }
    }
    ll res = 1e18;
    REP(bit, 1LL << n) {
        ll mem = 0;
        vll vvv(m);
        REP(i, n) {
            if ((bit >> i) & 1) {
                mem += c[i];
                REP(j, m) vvv[j] += a[i][j];
            }
        }
        ll ng = 0;
        REP(j, m) {
            if (vvv[j] < x) ng = 1;
        }
        if (ng == 0) chmin(res, mem);
    }
    if (res == 1e18) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys

inputs = [int(row.split()[0]) for row in sys.stdin.readlines()]

max_distance = inputs[-1]
antenna_list = inputs[:-1]

antenna_list = sorted(antenna_list)    

if (antenna_list[-1] - antenna_list[0]) <= max_distance:
    print("Yay!")
else:
    print(":(")


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

int dp[110][10010];
int v[110],w[110];

int main(){
    int N,W;
    cin>>N>>W;
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[N][W]<<endl;
    return 0;
}


Measured memory_bytes: 7012
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

h_max = [0 for _ in range(n)]
for a, b in ab:
    h_max[a-1] = max(h_max[a-1], h[b-1])
    h_max[b-1] = max(h_max[b-1], h[a-1])

cnt = 0
for i in range(n):
    if h[i] > h_max[i]:
        cnt += 1
print(cnt)


Measured memory_bytes: 31896
#include<iostream>
#include<map>
#include<utility>
using namespace std;

int min(int a,int b){
    return ((a>b)? b:a);
}

int max(int a,int b){
    return ((a>b)? a:b);
}

int main(){
    int N;
    int red[101][2],blue[101][2];
    int count=0;


    cin >> N;
    for(int i=0;i<N;i++){
        cin >> red[i][0] >> red[i][1]; 
    }
    for(int i=0;i<N;i++){
        cin >> blue[i][0] >> blue[i][1];
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(min(blue[i][0],blue[i][1])>min(blue[j][0],blue[j][1])){
                int temp1=blue[i][0];
                int temp2=blue[i][1];
                blue[i][0]=blue[j][0];
                blue[i][1]=blue[j][1];
                blue[j][0]=temp1;
                blue[j][1]=temp2;
            }
        }
    }

    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(max(red[i][0],red[i][1])<max(red[j][0],red[j][1])){
                int temp1=red[i][0];
                int temp2=red[i][1];
                red[i][0]=red[j][0];
                red[i][1]=red[j][1];
                red[j][0]=temp1;
                red[j][1]=temp2;
            }
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if((blue[i][0]>red[j][0])&&(blue[i][1]>red[j][1])){
                count++;
                red[j][0]=5000;
                red[j][1]=5000;
                break;
            }
        }
    }

    cout << count << "\n";
    /*
    for(int i=0;i<N;i++){
        cout << blue[i][0] << " " << blue[i][1] << "\n";
    }

    for(int i=0;i<N;i++){
        cout << red[i][0] << " " << red[i][1] << "\n";
    }
    */


    return 0;
}

Measured memory_bytes: 256
//#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
// using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl X(N), Y(N);
  vl X2(N), Y2(N);
  REP(i, N) cin >> X[i] >> Y[i];
  REP(i, N) {
    X2[i] = X[i] - Y[i];
    Y2[i] = X[i] + Y[i];
  }
  sort(ALL(X2));
  sort(ALL(Y2));
  cout << max(abs(X2[0] - X2[N - 1]), abs(Y2[0] - Y2[N - 1])) << endl;

  return 0;
}


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

using namespace std;

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
int arr[mxn];
ll n, m, k;

void solve(){
   cout << min(n % k, -(n % k - k)) << endl;
}

void read(){
    cin >> n >> k;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    //init();
    while(T--) read(), solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		 InputStreamReader in = new InputStreamReader(System.in);
		 BufferedReader read = new BufferedReader(in);

		 String line = read.readLine();
		 String [] spli = line.split(" ");
		 double x1 = Double.parseDouble(spli[0]);
		 double y1 = Double.parseDouble(spli[1]);
		 double x2 = Double.parseDouble(spli[2]);
		 double y2 = Double.parseDouble(spli[3]);
		 double root;

		 root = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
		 System.out.println(Math.sqrt(root));
	}
}



Measured memory_bytes: 24272
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(void)
{
  float t, x;
  cin >> t >> x;
  t += 0.0;
  x += 0.0;
  cout << (float)t / x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
        return 0;
    }
    REP(i,a.size()){
        if(a[i]==b[i]){
            continue;
        }
        if(a[i]>b[i]){
            cout<<"GREATER"<<endl;
            return 0;
        }else if(a[i]<b[i]){
            cout<<"LESS"<<endl;
            return 0;
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_169_Multiplication1
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            Console.WriteLine(inputLongArray[0] * inputLongArray[1]);

            //string result = "";

            //Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28192
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
using namespace std;
int head[200005],n,cnt,d[200005];
struct Edge{
	int v,nx;
}e[400005];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch^48);ch=getchar();}
    return ret*ff;
}
inline void add(int x,int y){
	e[++cnt].v=y;
	e[cnt].nx=head[x];
	head[x]=cnt;
}
void dfs(int now,int fa){
	for(int i=head[now];i;i=e[i].nx){
		int v=e[i].v;
		if(v==fa) continue;
		d[v]=d[now]+1;
		dfs(v,now);
	}
}
signed main(){
	n=read();
	for(int i=1;i<n;i++){
		int x=read(),y=read();
		add(x,y);
		add(y,x);
	}
	d[1]=1;
	dfs(1,0);
	int mx=0;
	for(int i=1;i<=n;i++)
		if(d[i]>d[mx])
			mx=i;
	d[mx]=1;
	dfs(mx,0);
	mx=0;
	for(int i=1;i<=n;i++)
		if(d[i]>mx)
			mx=d[i];
	puts(mx%3==2?"Second":"First");
    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; i++)
#define inf 2e9
using namespace std;

int main(int argc, char **argv){
    int a,p;
    cin>>a>>p;
    p += a*3;
    cout<<p/2<<endl;
    return 0;
    
}

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

class Plogram
{
    static void Main()
    {

        int num = int.Parse(Console.ReadLine());

        var list = new List<int>();

        for (int i = 0; i < num; i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }

        Console.WriteLine(list.Sum() - list.Max() / 2);

    }
}


Measured memory_bytes: 13268
from math import sqrt

N,D,*f = map(int, open(0).read().split())
XY = [f[i*2:i*2+2] for i in range(N)]
ans = 0
for i in range(N):
    if sqrt(pow(XY[i][0],2)+pow(XY[i][1],2)) <= D:
        ans += 1
print(ans)

Measured memory_bytes: 55124
Ai = list(map(int, input().split()))

a_list = []
a_list.append(abs(Ai[0] - Ai[1]) + abs(Ai[1] - Ai[2]))
a_list.append(abs(Ai[0] - Ai[2]) + abs(Ai[2] - Ai[1]))
a_list.append(abs(Ai[1] - Ai[0]) + abs(Ai[0] - Ai[2]))
a_list.append(abs(Ai[1] - Ai[2]) + abs(Ai[2] - Ai[0]))
a_list.append(abs(Ai[2] - Ai[1]) + abs(Ai[1] - Ai[0]))
a_list.append(abs(Ai[2] - Ai[0]) + abs(Ai[0] - Ai[1]))

print(min(a_list))




Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[100000];
signed main(){
	int i,j;
	cin>>a;
	for(i=0;i<a;i++)
		cin>>p[i];
	int u=p[0];
	int ans=1;
	int f=true,g=true;
	for(i=0;i<a;i++){
		if(u>p[i])
			g=false;
		if(u<p[i])
			f=false;
		if(!f&&!g){
			f=true;
			g=true;
			ans++;
		}
		u=p[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    double n, m, d;
    cin >> n >> m >> d;
    if (d == 0) {
        print(setprecision(20) << (m-1) / n);
    } else {
        print(setprecision(20) << (m-1) * 2 * (n-d) / n / n);
    }
    return 0;
}

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

#define INF 1e15

int V, E, L;

bool warshall_floid(ll d[400][400]) {
    for (int i = 0; i < V; i++) {
        d[i][i] = 0;
    }
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (d[i][k] != INF && d[k][j] != INF) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for (int i = 0; i < V; i++) {
        if (d[i][i] < 0) return 1;
    }
    return 0;
}

int main() {
    ll d0[400][400], d1[400][400];
    fill(d0[0], d0[400], INF);
    fill(d1[0], d1[400], INF);
    cin >> V >> E >> L;
    for (int i = 0; i < E; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        d0[a][b] = d0[b][a] = c;
    }
    warshall_floid(d0);
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (d0[i][j] <= L) d1[i][j] = 1;
        }
    }
    warshall_floid(d1);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        if (d1[s][t] == INF)
            cout << -1 << endl;
        else
            cout << d1[s][t] - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
#include<math.h>

int main(void) {
    int h, w;

    while(1) {
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> Pi;
typedef unsigned long long ULL;
int gcd(int a,int b){if (b == 0) return a; return gcd(b , a%b);}
int lcm(int a, int b){ return a/gcd(a,b)*b;}
inline int read(){
    int f = 1, x = 0;char ch = getchar();
    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}
    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}
int main(){
   // freopen("/Users/chutong/data.txt", "r", stdin);
    int n = read();
    double sum = 0;
    for (int i=1; i<=n; i++) {
        double x; string u;
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else{
            sum += x*380000;
        }
    }
    printf("%.6f\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(b <= c || d <= a) cout << 0 << endl;
    else cout << min(b,d) - max(a,c) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

string s;
cin >> s;

bool good = false;

if(s[0] == s[1] && s[1] == s[2]) good = true;
if(s[1] == s[2] && s[2] == s[3]) good = true;

if(good) cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF ll(1e18)+1
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(ALL(a));
    ll l = -INF;
    ll r  = INF;
    while(l + 1 < r){
        ll x = (l + r) / 2;
        bool ok = [&] {
            ll tot = 0;
            for (int i = 0; i < n; i++)
            {
                if(a[i]>=0)
                {
                    int l = -1, r = n;
                    while(l+1<r)
                    {
                        int c = (l + r) / 2;
                        if (a[c] * a[i] < x)
                            l = c;
                        else
                            r = c;
                    }
                    tot += r;
                }
                else
                {
                    int l = -1, r = n;
                    while(l+1<r)
                    {
                        int c = (l + r) / 2;                   
                        if (a[c] * a[i] < x)
                            r = c;
                        else
                            l = c;
                    }
                    tot += n - r;
                }
                if(a[i]*a[i]<x)
                    tot--;
            }
            tot /= 2;
            return tot < k;
        }();
        if(ok)
            l = x;
        else
            r = x;
    }
    cout << l << endl;

    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   unordered_map<string,long int> umap;
    umap["SUN"] = 0, umap["MON"] = 1, umap["TUE"] = 2, umap["WED"] = 3, umap["THU"] = 4, umap["FRI"] = 5,umap["SAT"] = 6;  

  string s;
  cin>>s;

  cout<<7-umap[s];

   return 0;
}

Measured memory_bytes: 256
def int_to_list(bit, n):
    l = []
    for i in range(n):
     if bit & (1 << i):
         l.append(i)
    return l

def solve():
    N = int(input())
    A = [[] for _ in range(N)]
    for i in range(N):
        B = int(input())
        for _ in range(B):
            x, y = list(map(int, input().split()))
            A[i].append((x-1, y))

    ans = 0
    for i in range(1 << N):
        f = True
        # 正直者のリスト
        partial = int_to_list(i, N)
        for p in partial:
            for (a, b) in A[p]:
                if b == 1:
                    if not a in partial:
                        f = False
                else:
                    if a in partial:
                        f = False
        if f:
            ans = max(ans, len(partial))

    return ans

print(solve())

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

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

int main() {
    vector<string> c(3);
    rep(i,3) {
        cin >> c.at(i);
        cout << c.at(i).at(i);
    }
    cout << endl;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;


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

	vector<int> coins;
	FOR(i, 1, 18) {
	    coins.emplace_back(i * i);
	}

	V<LL> dp(400, 0);
	dp[0] = 1;
	FOR(i, 0, coins.size()) {
	    FOR(j, 0, 400) {
	        if (dp[j] != 0) {
	            if (j + coins[i] < dp.size()) {
                    dp[j + coins[i]] += dp[j];
                }
	        }
	    }
	}

	while (true) {
	    int N;
	    cin >> N;

	    if (N == 0) {
	        break;
	    }

	    print(dp[N]);
	}

	return 0;
}


Measured memory_bytes: 3132
import math

n = int(input())
x = list(map(int,input().split()))


for p in range(min(x), max(x)+1):
    hp = 0
    for j in range(n):
        hp += (x[j] - p)**2
    if p == min(x):
        hpmin = hp
    elif hp < hpmin:
        hpmin = hp

print(hpmin)


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

int main() {
  long long x=0;
  cin>>x;
  int count=0;
  long long num=100;
    while(num<x){
        num+=num/100;
        count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3636
N, P = gets.chomp.split(" ").map(&:to_i)
S = gets.chomp.chars

ans = 0
if [2, 5].include?(P) then
  (0...N).each{|i|
    ans += (i+1) if S[i].to_i % P == 0
  }
else
  cnt = Hash.new(0)
  k, wk = [1, 0]
  (N-1).downto(0){|i|
    wk = (S[i].to_i * k + wk) % P
    cnt[wk] += 1
    k = (k * 10) % P
  }
  cnt.each{|k, v|
    ans += ((v * (v-1)) / 2)
    ans += v if k == 0
  }
end

puts ans


Measured memory_bytes: 13436
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	s := nextMega()
	col := []int{0, 1}
	cnt := []int{0, 0}
	for i := range s {
		for j := 0; j < 2; j++ {
			if col[j] != int(s[i]-'0') {
				cnt[j]++
			}
		}
		col[0], col[1] = col[1], col[0]
	}

	puts(min(cnt[0], cnt[1]))
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}


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

int main(){
  int N; cin >> N;
  int A[200000]={};
  long long count[200010]={};
  for(int i=0; i<N; i++){
    cin >> A[i];
    count[A[i]]++;
  }
  
  long long combsum=0;
  for(int i=1; i<=N; i++) combsum+=count[i]*(count[i]-1)/2;
  
  for(int k=0; k<N; k++){
    long long Ak=A[k];
    cout << combsum-count[Ak]*(count[Ak]-1)/2
      +(count[Ak]-1)*(count[Ak]-2)/2 << endl;
  }
}

Measured memory_bytes: 4992
n,m=map(int,input().split())
k=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))

ans=0
baai=2**n

for i in range(baai):
  sta=str(bin(i)[2:].zfill(n))
  #print(sta)
  temp=0
  for t,j in enumerate(k): #各k列に対し
    wa=0
    for x in j[1:]:
      wa+=int(sta[x-1])
    if wa%2==p[t]: #電球の点灯判定
      #print("おｋ")
      temp+=1
  if temp==m:
    ans+=1
print(ans)

Measured memory_bytes: 3064
house = {1:[[0 for i in range(10)] for j in range(3)], 2:[[0 for i in range(10)] for j in range(3)],
         3:[[0 for i in range(10)] for j in range(3)], 4:[[0 for i in range(10)] for j in range(3)]}
n = int(input())
for i in range(n):
    building, floor, room, people_numbers = [int(j) for j in input().split()]
    house[building][floor - 1][room - 1] += people_numbers

partition = "#"*20
for i in range(4):
    for j in range(3):
        tmp_list = [str(tmp) for tmp in house[i + 1][j]]
        print(" {}".format(" ".join(tmp_list)))
        if j == 2 and i != 3: print(partition)

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

using namespace std;

int main()
{ 
	const string day[7] = {  "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday" };
	const int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

	int month, date;

	while (cin >> month >> date, month)
	{
		int sum = 0;
		for (int i = 1; i < month; ++i)
			sum += days[i - 1];

		sum += date;
		cout << day[sum % 7] << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
#define MAX_SIZE 101
#define UNKNOWN_ID -1
#define UNREACHABLE -1

typedef enum { UNEXPLORED, VISITED, COMPLETED } state_t;
typedef struct { int first, last, arr[MAX_SIZE]; } queue_t;

static void enqueue(queue_t *q, int n) {
  if (q->first == q->last) return;
  q->arr[q->last - 1] = n;
  q->last++;
  if (q->last == MAX_SIZE) q->last = 0;
}

static int dequeue(queue_t *q) {
  int n;
  if (q->first == q->last - 1) return UNKNOWN_ID;
  n = q->arr[q->first];
  q->arr[q->first] = UNKNOWN_ID;
  q->first++;
  if (q->first == MAX_SIZE) q->first = 0;
  return n;
}

static void bfs(int g[MAX_SIZE][MAX_SIZE], int size, state_t *s, queue_t *q, int *d) {
  int n, j;

  n = dequeue(q);
  if (n == UNKNOWN_ID) return;
  s[n] = COMPLETED;
  for (j = 1; j <= size; ++j) {
    if (g[n][j] == 0) continue;
    if (s[j] != UNEXPLORED) continue;
    s[j] = VISITED;
    d[j] = d[n] + 1;
    enqueue(q, j);
  }
  bfs(g, size, s, q, d);
}

int main(int argc, char **argv) {
  int n, i, j, k, l, m, g[MAX_SIZE][MAX_SIZE], d[MAX_SIZE];
  state_t s[MAX_SIZE];
  queue_t q;

  q.first = 0;
  q.last = 1;
  for (i = 0; i < MAX_SIZE; ++i) {
    d[i] = 0;
    q.arr[i] = UNKNOWN_ID;
    s[i] = UNEXPLORED;
    for (j = 0; j < MAX_SIZE; ++j) g[i][j] = 0;
  }

  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d %d", &k, &l);
    for (j = 0; j < l; ++j) {
      scanf("%d", &m);
      ++g[k][m];
    }
  }

  enqueue(&q, 1);
  bfs(g, n, s, &q, d);
  for (i = 1; i <= n; ++i) printf("%d %d\n", i, s[i] == UNEXPLORED ? UNREACHABLE : d[i]);
}


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

int main() {
  int n; cin >> n;
  vector<long long int> a(n,0),b(n,0); for(int i = 0;i < n;i++) { cin >> a[i]; }
  for(int i = 1;i < n;i++) { b[i] = a[i] - a[i-1]; }

  long long int ans=1;
  int flag = 0;

  for(int i = 1;i < n;i++) {
    if(flag == 0 && b[i] != 0) {
      if(b[i] < 0) { flag = -1; }
      else if(b[i] > 0) { flag = 1; }
    } else {
      if(flag*b[i] < 0) {
        if(flag > 0) { flag = 0; }
        else if(flag < 0) { flag = 0; }
        ans++;
      }
    }
  }

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

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

const int DIM = 2010;

int i,j,k,n,sum, v[DIM], *p;

int main(){
    long count = 0 ; 
    cin >> n;
    for (i = 1; i <= n; ++i) {
        cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    for (i = 1; i<= n - 2; i++){
        for (j = i + 1; j <= n-1 ; j++){
            sum = v[i] + v [j]; 
            /* for(k = j + 1 ; k <= n; k++){
                if (v[k] < sum){
                    count ++;
                }
            } */
            p =  upper_bound(v+j+1, v + n + 1, sum - 1); 
            k = (p - v ) - j -1;   
            // cout << i<< " " <<  j << " " << (p - v ) << " " << k << "\n"; 
            count += k; 
        }
    }
    cout << count << "\n";
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int H,W;



int main()
{
	cin>>H>>W;
  int D,Q;
  cin>>D;
  map<int,pair<int,int> >A;

  REP(i,0,H){
    REP(j,0,W){
      int a;
      cin>>a;
      A[a]=make_pair(i,j);
    }
  }
  cin>>Q;

  int ans[H*W+1];

  REP(i,0,D){
    ans[i]=0;
  }

  REP(i,D,H*W+1){
    auto p=A[i];
    auto pm=A[i-D];
    ans[i]=ans[i-D]+abs(p.first-pm.first)+abs(p.second-pm.second);
  }
  int an[Q];

  REP(i,0,Q){
    int l,r;
    cin>>l>>r;
    an[i]=ans[r]-ans[l];
  }

  REP(i,0,Q){
    cout<<an[i]<<endl;
  }



  return 0;
}

Measured memory_bytes: 8576
rect (h:w:_) 
    | h < 3 || w < 3 = replicate h s
    | otherwise = [s] ++ (replicate (h-2) $ ['#'] ++ replicate (w-2) '.' ++ ['#']) ++ [s]
    where s = replicate w '#'

main = interact $ unlines . map (unlines . rect . map read . words) . takeWhile (/="0 0") . lines


Measured memory_bytes: 4548
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, q = MI()
    S = input()
    ats = [0]
    cnt = 0
    for i in range(n-1):
        j = i + 2
        s = S[i:j]
        # print(s)
        if s == 'AC':
            cnt += 1
        ats.append(cnt)
    # print(ats)
    for _ in range(q):
        l, r = MI1()
        # print(S[l:r+1])
        print(ats[r] - ats[l])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 6124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	ll n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) cin >> s.at(i);

	sort(s.begin(), s.end());
	ll ans = s.size();
	rep(i, n - 1) {
		if (s.at(i) == s.at(i + 1)) ans--;
	}


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



Measured memory_bytes: 9596
#include <stdio.h>

static void
sort(int* h, int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (h[j] > h[j-1]) {
				int tmp = h[j];
				h[j] = h[j-1];
				h[j-1] = tmp;
			}
		}
	}
}

int
main(void)
{
	char line[80];
	int a[5];

	if (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d %d %d %d %d",
		    &(a[0]), &(a[1]), &(a[2]), &(a[3]), &(a[4])) == 5) {
			sort(a, 5);
			
			printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]);
		}
	}

	return 0;
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
#define FILEIN freopen("input.txt", "r", stdin)

#define ll long long
#define endl "\n"

int main(){
	// FILEIN;
	int n; cin>>n;
	string s; cin>>s;
	int count = 0;
	for(int i = 0; i<n; i++){
		if(s[i] == 'A'){
			if(i+1<n && i+2<n){
				if(s[i+1] == 'B' && s[i+2] == 'C'){
					count++;
				}
			}
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	cout<<s.substr(0,4)<<' '<<s.substr(4,12)<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, L;
    cin >> N >> L;
    int s = 0;
    REP(i, N) {
        s += L + (i + 1) - 1;
    }
    int m = 2000000;
    int ans;
    REP(i, N) {
        int t = s - (L + (i + 1) - 1);
        if (m > abs(t - s)) {
            m = abs(t - s);
            ans = t;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h = I()
    k = h.bit_length()
    print((1<<k)-1)
    return

#Solve
if __name__ == "__main__":
    solve()


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    for(int i = 0; i < n; i++){
        if(s.at(i) != s.at(k-1)){
            s.at(i) = '*';
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
def intersect_list(lst1, lst2):
    arr = []
    lst = lst1.copy()
    for element in lst2:
        try:
            lst.remove(element)
        except ValueError:
            pass
        else:
            arr.append(element)
    return arr

n = int(input())
a0 = list(input())
for i in range(n-1):
    a  = list(input())
    a0 = intersect_list(a0, a)

print("".join(sorted(a0)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    string s;
    cin >> s;
    bool flag = false;
    if (s[0] == s[1] && s[0] != s[2] && s[2] == s[3]) flag = true;
    if (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) flag = true;
    if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2]) flag = true;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(float, input().split()))

dp = [[0 for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for j in range(n):
        dp[i+1][j+1] += dp[i][j]*p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

ans = 0
for i in range(n+1):
    if i > n-i:
        ans += dp[n][i]

print(ans)


Measured memory_bytes: 224188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio	
	int n;
	cin >> n;
	int a[n];
	int cnt = 0;
	for(int i=0; i<n; i++)cin >> a[i];
	for(int i=1; i<n-1; i++){
		if(a[i]<a[i+1] && a[i]>a[i-1]){
			cnt++;
		}else if(a[i]>a[i+1] && a[i]<a[i-1]){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}








Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;
using std::vector;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a / gcd(a , b)) * b;
}

int main(){

  int x; cin >> x;
  
  if(x == 7 or x == 5 or x == 3)
    pr("YES");
  else
    pr("NO");

  return 0;
}


Measured memory_bytes: 256
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (_, x) = scan!(usize, i64);
    let vs = scan!(i64;;);

    let mut n = vs[0];

    let mut ans = 0;
    for m in vs.iter().skip(1) {
        if n + m >= x {
            let diff = n + m - x;
            ans += diff;
            n = max(0, m - diff);
        } else {
            n = *m;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 8444
#include<cstdio>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
  int a[4],b[4];
  for(int i=0;i<4;i++) scanf("%d",&a[i]);
  for(int i=0;i<4;i++) scanf("%d",&b[i]);
  printf("%d\n",max(accumulate(a,a+4,0),accumulate(b,b+4,0)));
  return (0);
}

Measured memory_bytes: 2748
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    jj             " "
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e6+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

ll a[15][15];

int main() {ikarus_101

    ll n,m,i,j,k,x;

    vll v;
    for(i=1;i<=10000;i++) v.eb(sqr(i));

    cin>>n>>k;
    rep1(i,n) rep1(j,k) cin>>a[i][j];
    ll cnt = 0;
    rep1(i,n)
    {
        for(j=i+1;j<=n;j++)
        {
            ll dis = 0;
            for(ll pos = 1;pos <= k; pos++)
            {
                ll dif = a[i][pos] - a[j][pos];
                dis += sqr(dif);
            }
            if(binary_search(all(v),dis)) ++cnt;

        }
    }
    cout << cnt << nn;





    return 0;
}


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

int main(void){
    ll n;
    cin >> n;
    vector<ll>L(n);
    for(int i=0;i<n;i++){
        cin >> L[i];
    }
    ll sum_L = accumulate(L.begin(),L.end(),0);
    // cout << sum_L<<endl; 
    bool flag = true;
    for(int i=0;i<n;i++){
        ll tmp = sum_L - L[i];
        // cout << "L[i]" << tmp<<endl;
        if(tmp <= L[i]){
            flag = false;
        }
    }
    if(flag){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256