akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

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

    int n,m;
    cin >> n >> m;

    vector<P> al;
    for(int i=0; i<n; i++) {
        ll a; cin >> a;
        al.push_back(P(a,1));
    }

    for(int i=0; i<m; i++) {
        ll b,c; cin >> b >> c;
        al.push_back(P(c,b));
    }

    sort(al.begin(), al.end());
    reverse(al.begin(), al.end());
    ll curr_cnt = 0;
    ll ans = 0;
    for( auto num_cnt : al ){
        ll num = num_cnt.first;
        ll cnt = num_cnt.second;
        if (cnt + curr_cnt <= n){
            ans += num*cnt;
            curr_cnt += cnt;
        }
        else{
            ll rem = n - curr_cnt;
            ans += rem*num;
            break;
        }
    }
    cout << ans << endl;

}

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

using namespace std;



// Complete the cipher function below.


int main()
{
    
    int n;

    int k,m,l;
    string o,e,p;
    cin>>o>>e;;

    n=o.size();
    k=e.size();
    l=0,m=0;
    p="";
    for(int i=1;i<=n+k;i++)
    {
        if(i%2==0)
        {
            p=p+e.at(m);
            m++;
        }
        else
        {
            p=p+o.at(l);
            l++;
        }
        
    }
    
    
    cout<<p;
    




   
    return 0;
}



Measured memory_bytes: 256
<?php
$N = trim(fgets(STDIN));
//list($m2,$d2) =  explode(" ",trim(fgets(STDIN)));
//$A =  explode(" ",trim(fgets(STDIN)));
$s = ceil($N / 1.08);
$ss = floor($s*1.08);

if ($N != $ss) {
  printf(":(\n");
  exit;
}
printf("%d\n",$s);


Measured memory_bytes: 4856
#include <iostream>

using namespace std;

int m[101];

int main() {
  int N, K;
  cin >> N >> K;

  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      m[a]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (!m[i]) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
import collections
# Your code her
a = int(input())
b = [int(s) for s in input().split()]
b = sorted(b)
mod = int(1000000)
d = {}
e = collections.Counter(b)
X = int(0)
ans = int(0)

for i in range(a):
    if d.get(b[i]) == None:
        if e.get(b[i]) != 1:
            d[b[i]] = 1
        X = b[i]
        while X <= (mod-b[i]):
            X += b[i]
            d[X] = 1
        X = 0
    else:
        pass

for i in range(a):
    if d.get(b[i]) == None:
        ans += 1

print(ans)

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

#define int long long

auto main() -> signed {
    string s;
    cin >> s;
    int memo[1000] = {0};
    for(int i=0; i<s.size(); ++i) memo[s[i]]++;
    for(int i=0; i<1000; ++i)
        if(memo[i]>=2) {
            cout << "no" << endl;
            return 0;
        }
    cout << "yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll k,a,b;
	cin>>k>>a>>b;
	ll f=0;
	if(a%k==0 || b%k==0)
	f=1;
	ll p=a/k;
	p=(p+1)*k;
	if(p>=a && p<=b)
	f=1;
	if(f)
	cout<<"OK";
	else
	cout<<"NG";
	
	
}

Measured memory_bytes: 3596
class UnionFind
  def initialize(n)
    @parent = Array.new(n, -1)
  end

  def root(x) # xの根の番号を返す
    return x if @parent[x] < 0
    @parent[x] = root(@parent[x])
    return @parent[x]
  end

  def size(x) # xの属するグループのサイズを調べる
    return -@parent[root(x)]
  end

  def merge(x, y)
    x, y = root(x), root(y)
    return false if x == y
    # 大きい方(x)に小さい方(y)をくっつけたい
    x, y = y, x if size(x) < size(y)
    @parent[x] += @parent[y]
    @parent[y] = x
    return true
  end
end

N,M=gets.split.map(&:to_i)
a,b = Array.new(M), Array.new(M)
bridge = []
M.times do
  bridge << gets.split.map(&:to_i)
end

ans = Array.new(M)
ans[M-1]=N*(N-1)/2
uf = UnionFind.new(N)

i = 1
bridge.reverse_each do |a,b|
  id = M-1-i
  break if id < 0
  if uf.root(a-1) == uf.root(b-1)
    ans[id] = ans[id+1]
  else
    ans[id] = ans[id+1] - uf.size(a-1)*uf.size(b-1)
  end
  uf.merge(a-1,b-1)
  i += 1
end
puts ans

Measured memory_bytes: 13820
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;
int h, w,k;
char s[301][301];
	int  a[301][301];
	void dfs(int x, int y) {
		if (a[x][y] == 0)return;
		int nx[2];
		nx[0] = x - 1;
		nx[1] = x + 1;
		for (int i = 0; i < 2; i++) {
			if (nx[i] >= 0 && nx[i] < h && a[nx[i]][y] == 0) {
				a[nx[i]][y] = a[x][y];
				dfs(nx[i], y);
			}
		}
	}

int main() {
	
	
	cin >> h >> w >> k;
	
	rep(h) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	vi c(h+10,0);
	rep(h) {
		int cnta = 0;
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#')c[i]++;
		}
	}
	
	memset(a, 0, sizeof(a));
	int ans = 1;
	for (int i = 0; i < h; i++) {
		int cnt = 0;
		if (c[i]==0)continue;
		for (int j = 0; j < w; j++) {
			
			if (s[i][j] == '#' && cnt!=0) {
				ans++; cnt++;
				a[i][j] = ans;
				
			}
			else if (s[i][j] == '#' && cnt == 0) {
				a[i][j] = ans;
				cnt++;
			}
			else {
				a[i][j] = ans;
			}
		}
		ans++;
		
	}
	for (int i = 0; i < h; i++) {
		
		for (int j = 0; j < w; j++) {

			dfs(i, j);

			
		}
		

	}
	for (int i = 0; i < h; i++) {

		for (int j = 0; j < w; j++) {

			cout << a[i][j] << " ";


		}

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.14159265358979323846
#define Endl endl
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int lps = n/(a+b);
	int ans = 0;
	ans += lps * a;
	int amari  = n % (a+b);
	ans += min( amari, a );
	cout<<ans<<Endl;
	return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();
        int d = sc.NextInt();

        int answer = (a - c) * (b - d);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
import numpy as np
N = input()
h = input().split()
h = np.array(h).astype(int)
arr = np.zeros(len(h))

k = 0
def water(arr,h):
    # waterをかける場所がない
    if len(arr) == 0:
        return
    # waterをかける
    #print("water")
    global k
    k = k + 1
    arr = arr + 1
    # 水が足りている花があるかチェック
    # 目標の高さ == 現在の高さ　のインデックスを見つける
    ind = []
    i = 0
    for ea,eh in zip(arr,h):
        if ea == eh:
            ind.append(i)
        i = i + 1
    #print(h,"ind : ",ind)
    # インデックスを基準に分ける
    # それぞれについてwaterをかける
    index = 0
    for target in ind:
        water(arr[index:target],h[index:target])
        index = target+1
    water(arr[index:],h[index:])
# 水が足りている花があるかチェック
# 目標の高さ == 現在の高さ　のインデックスを見つける
ind = []
i = 0
for ea,eh in zip(arr,h):
    if ea == eh:
        ind.append(i)
    i = i + 1
#print(h,"ind : ",ind)
# インデックスを基準に分ける
# それぞれについてwaterをかける
index = 0
for target in ind:
    water(arr[index:target],h[index:target])
    index = target+1
water(arr[index:],h[index:])
print(k)

Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e5+7 ;
string s ;
int par[N] ;
int rnk[N] ;
bool cnt[N] ;
void init(){
	for(int i = 0 ; i < N ; i++){
		par[i] = i ;
		rnk[i] = 0 ;
	}
}

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

void unite(int x ,int y){
	x = fnd(x) ;
	y = fnd(y) ;
	if(x != y){
		if(rnk[x] > rnk[y])
			swap(x,y) ;
			par[x] = y ;
		//	siz[y] += siz[x] ; 
			if(rnk[x] == rnk[y])
				rnk[y]++ ;
	}
}


int main(){fast ;
	int n,m ;
	cin >> n >> m ;
	init() ;	
	for(int i = 0 ; i < m ; i++){
		int x ,y , z ;
		cin >> x >> y >> z ;
		unite(x,y) ;
	}
	int ans = 0 ;
	for(int i= 1 ; i <= n ; i++){
		cnt[par[fnd(i)]] = 1 ;
	}
	for(int i = 1 ; i <= n ; i++){
		if(cnt[i])
			ans++ ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 1152
n=int(input())
a=list(map(int,input().split()))
ans=[]
def ap(num1):
    ans.append(num1)
if n%2==0:
    num=n-1
    for i in range(n//2):
        ap(a[num])
        num-=2
    num=0
    for i in range(n//2):
        ap(a[num])
        num+=2
else:
    num=n-1
    for i in range(n//2+1):
        ap(a[num])
        num-=2
    num=1
    for i in range(n//2):
        ap(a[num])
        num+=2
print(*ans)


Measured memory_bytes: 30980
N, A, B = map(int, input().split())

if (A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    if A > B:
        print(min(B - 1, N - A) + 1 + (A - B - 1) // 2)
    else:
        print(min(A - 1, N - B) + 1 + (B - A - 1) // 2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
using namespace std;
// using namespace atcoder;
int N;
ll A[303];

void Main()
{
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	rep(i,N) cin>>A[i];
	ll xo=0;
	for(i=2;i<N;i++) xo^=A[i];
	
	vector<int> cand;
	rep(i,1<<20) if(i<A[0]) {
		ll v=(A[0]-i)^(A[1]+i)^xo;
		if((v&((1<<20)-1))==0) cand.push_back(i);
	}
	
	ll mi=1LL<<50;
	for(auto c : cand) {
		for(ll a=c;a<min(mi,A[0]);a+=1<<20) {
			ll v=(A[0]-a)^(A[1]+a)^xo;
			if(v==0) mi=min(mi,a);
		}
	}
	
	if(mi==1LL<<50) mi=-1;
	cout<<mi<<endl;
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	int n, ans = 0;
	cin >> n;
	vector<int>a(n);
	set<int>st;
	bool can = false;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] == 2)can = true;
	}
	if (can) {
		int i = 0;
		while (true) {
			if (a[i] != 2) {
				ans++;
				if (st.count(a[i]) == 0) {
					st.insert(a[i]);
					i = a[i] - 1;
				}
				else {
					cout << -1 << endl;
					return 0;
				}
			}
			else {
				ans++;
				break;
			}
		}
		cout << ans << endl;
		return 0;
	}
	else {
		cout << -1 << endl;
		return 0;
	}
}

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

int main(){
	int a, b;
	cin>> a >> b;
	
	if(a<b){
		cout << "a < b" <<endl;
	}
	if(a>b){
		cout << "a > b" <<endl;
	}
	if(a==b){
		cout << "a == b" <<endl;
	}
	
	return 0;
}

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

int main() {
    int p, q, r;
    int x, y , z;
    int ans;

    cin >> p >> q >> r;

    x = p + q;
    y = q + r;
    z = r + p;

    if (x < y) { ans = x; }
    else { ans = y; }
    if (z < ans) { ans = z; }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def search(n,d,t):
    b = 0
    e = n-1
    r = 0
    while True:
        if b > e:
            return r
        else:
            r += 1
            i = (b+e)//2
            if t == d[i]:
                return r
            elif t < d[i]:
                e = i - 1
            else:
                b = i + 1
while True:
    n = int(input())
    if n == 0:
        break
    d = [int(input()) for i in range(n)]
    t = int(input())

    m = search(n,d,t)
    print(m)

Measured memory_bytes: 7664
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
constexpr long long int MOD = 1000000007LL;

struct Point {
	int x, y;
	int manhattan_distance(const Point other) const {
		return std::abs(x - other.x) + std::abs(y - other.y);
	}
};
int main() {
	int n; std::cin >> n;
	std::vector<Point> points(n);
	for (auto& p : points) std::cin >> p.x >> p.y;
	std::sort(points.begin(), points.end(), [](const Point& a, const Point& b) {return a.y - a.x < b.y - b.x; });
	int max = points.front().manhattan_distance(points.back());
	std::sort(points.begin(), points.end(), [](const Point& a, const Point& b) {return a.y + a.x < b.y + b.x; });
	std::cout << std::max(max, points.front().manhattan_distance(points.back())) << '\n';
}

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

int main() {
    long long int L, R;
    cin >> L >> R;

    if (R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }

    int min = 9999;
    long long int tmp;
    for (long long int i = L; i < R; i++) {
        for (long long int j = i + 1; j <= R; j++) {
            tmp = i * j;
            tmp %= 2019;
            if (min > tmp) {
                min = tmp;
            }
        }
    }
    cout << min << endl;

    return 0;
}


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

int main() {
    using namespace std;
    unsigned long N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    unsigned long ans{0};
    if(10 % P) {
        vector<unsigned long> m(P);
        reverse(S.begin(), S.end());
        unsigned long rlhs{0}, x{1};
        m[0] = 1;
        for(const auto& c : S)++m[(rlhs += (c - 48) * ((x *= 10) %= P)) %= P];
        for(const auto &i : m)ans += i * (i - 1) / 2;
    }else for(unsigned long i{0}; i < N; ++i)ans += !((S[i] - 48) % P) * (i + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main(void) {
    int n, key, i;
    char com[15];

    init();
    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s %d", com, &key);
        
        if (com[0] == 'i') insert(key);
        else if (strlen(com) > 6) {
            if (com[6] == 'F') deleteFirst();
            else deleteLast();
        }
        else deleteKey(key);
    }

    printList();

    return 0;
}

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

int32_t main()
{
    int n,W;
    cin>>n>>W;
    
    int dp[n+1][W+1];
    
    int val[n],wt[n];
    
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
        
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
        
    for(int i=0;i<=W;i++)
        dp[0][i]=0;
    
    for(int i=1;i<=n;i++)
        for(int j=1;j<=W;j++)
            dp[i][j]=-1;
        
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j-wt[i-1]>=0)
                dp[i][j]=max(dp[i-1][j-wt[i-1]]+val[i-1],dp[i-1][j]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 82556
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        long n = in.nextLong();

        List<Character> chars = new ArrayList<>();
        while (n > 0) {
            n--;
            chars.add((char) ('a' + (n % 26)));
            n /= 26;
        }
        Collections.reverse(chars);
        String ans = chars.stream().map(String::valueOf).collect(Collectors.joining());
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 31444
#include <cstdio>
using namespace std;
int n, h, w, ans;
inline int read() {
   int x = 0, f = 1;
   char ch = getchar();
   while (ch < '0' || ch > '9'){if (ch == '-')f = -1; ch = getchar();}
   while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
   return x * f;
}
int main() {
    n = read(); h = read(); w = read();
    for (int i = 1; i <= n; ++i) {
        int x = read(), y = read();
        ans += (int)(x >= h) * (int)(y >= w);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)

def comb(x):
    return x * (x - 1) // 2

base = 0
for aa in c.keys():
    x = c[aa]
    base += comb(x)

for aa in a:
    ans = base - comb(c[aa]) + comb(c[aa] - 1)
    print(ans)

Measured memory_bytes: 25716
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

#define INF 1<<15

int main(){
	int n,m;
	int s,t,d;
	int e[15][15];
	int dp[1<<15][15];
	
	scanf("%d %d",&n,&m);
	for(int i=0;i<15;i++) fill_n(e[i],15,INF);
	for(int i=0;i<m;i++){
		scanf("%d %d %d",&s,&t,&d);
		e[s][t]=d;
	}
	
	for(int i=0;i<(1<<n);i++) fill_n(dp[i],n,INF);
	dp[(1<<n)-1][0]=0;
	
	for(int i=(1<<n)-2;i>=0;i--){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(!(i>>k&1))
				dp[i][j]=min(dp[i][j],dp[i|1<<k][k]+e[j][k]);
			}
		}
	}
	printf("%d\n",(dp[0][0]==INF ? -1 : dp[0][0]));
}


Measured memory_bytes: 5152
#include<iostream>
#include <stdio.h>
#include<string>
using namespace std;
int a[3][200], b[3][200], n, i;

int main() {

	    cin >> n;

	    for (int l = 0; l<n; l++) {

		    for (i = 0; i<3; i++) {

			    cin >> a[i][l];
		}
	}

	    for (int s = 0; s<3; s++) {

		    for (int r = 0; r<n; r++) {

		    for (int j = 0; j<r; j++) {

	

		    if (a[s][r] == a[s][j]) 
			{ b[s][r] = -1; b[s][j] = -1; }

					}


				}

			for (int p = 0; p<n; p++) {

				a[s][p] = a[s][p] * (b[s][p] + 1);

			}
		}

	    for (int q = 0; q<n; q++) {

	    cout << a[0][q] + a[1][q] + a[2][q] << endl;
	}

		return 0;

	
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
// const bool debug=true;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(void) {
    ll n,m;
    cin>>n>>m;
    priority_queue<ll,vector<ll>,greater<ll> > que;
    vector<pair<ll,ll> > bc;
    rep(i,n){
        ll tmp;
        cin>>tmp;
        que.push(tmp);
    }
    rep(i,m){
        ll tmpb,tmpc;
        cin>>tmpb>>tmpc;
        bc.push_back(make_pair(tmpc,tmpb));
    }
    sort(bc.begin(),bc.end(),greater<pair<ll,ll> >());
    int cur=0;
    bool flg=true;
    while(flg){
        rep(i,bc[cur].second){
            ll top = que.top();
            if(top>=bc[cur].first){
                flg=false;
                break;
            }
            que.pop();
            que.push(bc[cur].first);
        }
        if(cur==m-1)break;
        cur++;
    }
    ll res=0;
    while(!que.empty()){
        res+=que.top();
        que.pop();
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

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

    double s = x / a;
    double rad;
    if (s >= a * b / 2) {
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    }
    else {
        double w = s * 2 / b;
        rad = atan2(b, w);
    }
    double PI = acos(-1);
    double deg = rad / (2 * PI) * 360;

    printf("%.10f", deg);
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int n,k,c;
string ss;
int dp[2][200005]={};
int dp1[2][200005]={};
int32_t main() 
{
    IOS;
    cin>>n>>k>>c>>ss;
    set<int>s,s1;
    for(int i=0;i<n;i++)
    {
        if(ss[i]=='o')
        {
            s.insert(i);
            i+=c;
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(ss[i]=='o')
        {
            s1.insert(i);
            i-=c;
        }
    }
    if(s.size()>k)
        return 0;
    for(auto i:s)
        if(s1.find(i)!=s1.end())
            print(i+1);
}   


Measured memory_bytes: 22240
let rec f() =
  let a = Scanf.scanf "%s\n" (fun s -> s) in 
  let n = String.length a in
  let as_ = Array.make n '0' in
  if a <> "0" then
    begin
      for i = 0 to (n-1) do
        as_.(i) <- a.[i]
      done;
      Array.map int_of_char as_
      |> Array.map (fun x -> x - 48)
      |> Array.fold_left (+) 0 
      |> Printf.printf "%d\n";
      f()
    end ;;
f();;


Measured memory_bytes: 2480
import sys
input=sys.stdin.readline
import collections

H,W = map(int, input().split())

maze = [] # マス目
for _ in range(H):
    maze.append(input().strip())
move = {(1,0), (0,1), (-1,0), (0,-1)} # 動きのパターン

Inf = 10**9
def bfs():
    d = [[Inf]*W for _ in range(H)] # スタートからの最短経路の距離
    d[0][0] = 0

    q = collections.deque()
    q.append((0,0))
    while q:
        p = q.popleft() # 幅優先
        if p == (H-1, W-1):
            break # 幅優先なので、見つかった時点で最短経路
        for dh, dw in move:
            nh, nw = p[0] + dh, p[1] + dw # 次のマス
            if 0 <= nw and nw < W and 0 <= nh and nh < H: # 迷路の中か
                if maze[nh][nw] == "." and d[nh][nw] == Inf: # 移動可能で、かつ未訪問か
                    d[nh][nw] = d[p[0]][p[1]] + 1 # 幅優先なので確定して良い
                    q.append((nh, nw)) # 次のキューに入れる
    return d[H-1][W-1]

def main():
    d = bfs()
    if d == Inf:
        print(-1)
    else:
        x = 0
        for s in maze:
            x += s.count("#")
        print(W*H - x - (d+1))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.L;
		string s=t.ToString();
		int n=s.Length;
		long ans=0;
		var dp=new long[n+1,2,2,10,10,10];
		dp[0,0,0,0,0,0]=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
					for(int l=0;l<10;l++){
						for(int m=0;m<10;m++){
							for(int o=0;o<10;o++){
								int lm=j==0?s[i]-'0':9;
								if(dp[i,j,k,l,m,o]==0){continue;}
								for(int d=0;d<=lm;d++){dp[i+1,(j==1||d<lm)?1:0,(k==1||(l==5&&m==1&&d==3))?1:0,m,o,d]+=dp[i,j,k,l,m,o];}
							}
						}
					}
				}
			}
		}
		for(int j=0;j<2;j++){
			for(int k=0;k<10;k++){
				for(int l=0;l<10;l++){
					for(int m=0;m<10;m++){ans+=dp[n,j,1,k,l,m];}
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int n,m,q;
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
  if(A.size()==n+1){
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans,now);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= m){
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
using System;

class A
{
	static void Main()
	{
		var s = Console.ReadLine();

		var ft = new[] { false, true };
		Func<bool, string> a = b => b ? "A" : "";
		foreach (var b1 in ft)
			foreach (var b2 in ft)
				foreach (var b3 in ft)
					foreach (var b4 in ft)
						if ($"{a(b1)}KIH{a(b2)}B{a(b3)}R{a(b4)}" == s) { Console.WriteLine("YES"); return; }
		Console.WriteLine("NO");
	}
}


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c, d, x, y;

int main() {
	cin >> a >> b >> c >> d;
	x = a+b, y = c+d;
	if (x>y) cout << "Left" << ln;
	else if (x<y) cout << "Right" << ln;
	else cout << "Balanced" << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    string s;cin>>s;
    int n=s.size();
    ll jst[n+1],ovr[n+1];
    rep(i,n+1){
        jst[i]=LINF;
        ovr[i]=LINF;
    }
    reverse(ALL(s));
    s.push_back('0');
    jst[0]=s[0]-'0';
    ovr[0]=10-(s[0]-'0');
    for(int i=1;i<=n;i++){
        jst[i]=min(ovr[i-1]+(1+(s[i]=='9'?1:(s[i]-'0')))%10,jst[i-1]+(s[i]-'0'));
        ovr[i]=min(ovr[i-1]+10-(s[i]-'0')-1,jst[i-1]+10-(s[i]-'0'));
    }
    // rep(i,n+1)cout<<jst[i]<<" ";cout<<endl;
    // rep(i,n+1)cout<<ovr[i]<<" ";cout<<endl;
    cout<<jst[n]<<endl;
    return 0;
}


Measured memory_bytes: 17052
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

template <int MaxN = 100000, long long mod = 1000000007LL>
class Modlib {
    long long _fact[MaxN + 1];
    long long _fact_inv[MaxN + 1];

public:
    // x^n
    long long pow(long long x, long long n) const {
        long long ret = 1LL;
        long long t = x % mod;
        while (n > 0) {
            if (n & 1LL) {
                ret *= t;
                ret %= mod;
            }
            t *= t;
            t %= mod;
            n >>= 1;
        }
        return ret;
    }
    // xの逆元
    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long inv(long long a) const {
        long long b = mod, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        u %= mod;
        if (u < 0)
            u += mod;
        return u;
    }
    // n!
    long long fact(long long n) const {
        return _fact[n];
    }
    // nPk
    long long perm(long long n, long long k) const {
        return fact(n) * _fact_inv[n - k] % mod;
    }
    // nCk
    long long comb(long long n, long long k) const {
        return perm(n, k) * _fact_inv[k] % mod;
    }

    Modlib() : _fact{} {
        _fact[0] = _fact[1] = 1LL;
        _fact_inv[0] = _fact_inv[1] = inv(1LL);
        for (int i = 2; i <= MaxN; ++i) {
            _fact[i] = _fact[i - 1] * i % mod;
            _fact_inv[i] = inv(_fact[i]);
        }
    }
};

constexpr ll mod = 998244353LL;
const Modlib<300000, mod> modlib;

int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for (ll i = 0; i <= n; ++i) {
        ll j = k - a * i;
        if (j % b != 0)
            continue;
        j /= b;
        if (!(0 <= j && j <= n))
            continue;
        ans += modlib.comb(n, i) * modlib.comb(n, j) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner SC = new Scanner(System.in);
int N = SC.nextInt();
int H [] = new int[N + 1];
for(int i = 1; i <= N; i++) {
    H[i] = SC.nextInt();
}
int counter = 0;
for(int i = 1; i <= N; i++) {
	boolean cso = true;
	for(int j = 1; j < i; j++) {
		if(H[j] > H[i]) {
			cso = false;
		}
	}
	if(cso) {
		counter++;
	}
}
System.out.println(counter);
	}

}


Measured memory_bytes: 35820
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  int n,k; cin >> n >> k;
  vector<int> v(n);
  rep(i,n){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int ans=0;
  rep(i,k){
    ans+=v[i];
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long lsum[][] = new long[n][n]; // local sum:部分和
		for ( int c = 0; c < n; c++ ) {
			lsum[c][c] = in.nextInt();
			for ( int r = 0; r < c; r++ ) {
				lsum[r][c] = lsum[r][c - 1] + lsum[c][c];
			}
		}

		long cost[][] = new long[n][n]; // 累積コスト
		for ( int p = 1; p < n; p++ ) {
			for ( int r = 0, c = p; c < n; r++, c++ ) {
				Long min = Long.MAX_VALUE;
				for ( int i = r; i <= c - 1; i++ ) {
					min = Math.min(min, cost[r][i] + cost[i + 1][c]);
				}
				cost[r][c] = min + lsum[r][c];
			}
		}

		System.out.println(cost[0][n - 1]);
		in.close();
	}
}

Measured memory_bytes: 95188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
using namespace std;

typedef long long int ll;
typedef long double ld;



int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("tst.txt", "r", stdin);
	#endif	
}
const int N=1e5+5,MAX=3e7,MOD=1e9+7;


int n,ans;
map<char,int>occ;
int main()
{	
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	scanf("%d",&n);
	std::vector<int> a(n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);


	for(int i=1;i<n-1;i++){
		vector<int>v;

		v.pb(a[i-1]);v.pb(a[i]);v.pb(a[i+1]);
		sort(all(v));
		if(v[1]==a[i])ans++;
	}
	printf("%d\n",ans );
	
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}
impl<T: Iterator> IteratorExt for T {}

fn main() {
    let s = read!(String).into_bytes();
    let mut ans = 0;
    for c in &s {
        ans += c - 48;
        ans %= 9;
    }
    if ans % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2284
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n,x;cin>>n>>x;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll right,left;
  ll ansr=0;
  ll ansl=0;
  right=a[0];
  if(a[0]>x){
    ansr=a[0]-x;
    right=x;
  }
  left=a[n-1];
  if(a[n-1]>x){
    ansl=a[n-1]-x;
    left=x;
  }
  rep1(i,n-1){
    if(right+a[i]>x){
      ansr+=right+a[i]-x;
      right=x-right;
    }
    else{
      right=a[i];
    }
    if(left+a[n-1-i]>x){
      ansl+=left+a[n-1-i]-x;
      left=x-left;
    }
    else{
      left=a[n-1-i];
    }
  }
  ll ans=ansr;
  if(ansr>ansl)ans=ansl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
/*
asnasncsja
asncansca
ascnasncaks
sacnjsc
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
struct edge {
	int to;
	int w;
};
vector<edge> vec[MAXN];
int f[MAXN];
void dfs(int v,int fa) {
	for (int i = 0; i < vec[v].size(); ++i) {
		edge& t = vec[v][i];
		if (t.to == fa) continue;
		if (t.w & 1) f[t.to] = f[v] ^ 1;
		else f[t.to] = f[v];
		dfs(t.to,v);
	}
}
int main() {
	int n, u, v, w;
	cin >> n;
	for (int i = 0; i < n - 1; ++i) scanf("%d%d%d", &u, &v, &w), vec[u].push_back(edge{ v,w }), vec[v].push_back(edge{ u,w });
	f[1] = 1;
	dfs(1,0);
	for (int i = 1; i <= n; ++i) printf("%d\n", f[i]);
	return 0;
}

Measured memory_bytes: 9216
void main()
{
    long n, a, b;
    rdVals(n, a, b);

    long cnt;
    foreach (i; 0 .. n)
    {
        long t = rdElem;
        if (t < a || b <= t) ++cnt;
    }

    cnt.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>

using namespace std;

class P3 {
public:
	double x, y, z;
	P3(double x=0, double y=0, double z=0) : x(x), y(y), z(z) {}
	P3(const P3& p) : x(p.x), y(p.y), z(p.z) {}
	P3 operator + (const P3 &p) const { return P3(x+p.x, y+p.y, z+p.z); }
	P3 operator - (const P3 &p) const { return P3(x-p.x, y-p.y, z-p.z); }
	P3 operator * (double p) const { return P3(x*p, y*p, z*p); }
	void scale(double s){ x *= s, y *= s, z *= s; }
	double dot(const P3& p) const { return x*p.x + y*p.y + z*p.z; }
	double squaredLength() const { return x*x + y*y + z*z; }
	double length() const { return sqrt(squaredLength()); }
	double normalize(){ double L = length(); if(L>0) scale(1.0/L); return L; }
};

int main(){
	int N;
	while(cin >> N && N){
		P3 pos(0, 0, 0), dir;
		cin >> dir.x >> dir.y >> dir.z;
		dir.normalize();
		vector< pair<P3, double> > vp(N);
		for(int i=0;i<N;i++){
			cin >> vp[i].first.x >> vp[i].first.y >> vp[i].first.z >> vp[i].second;
		}
		while(true){
			bool end = true;
			double nearest = 1e12;
			P3 npos, ndir;
			for(int i=0;i<N;i++){
				P3 p(vp[i].first - pos);
				double l = dir.dot(p);
				p = p - dir*l;
				double dist = p.length();
				if(dist > vp[i].second - 1e-8) continue;
				double sub = sqrt(vp[i].second*vp[i].second - dist*dist);
				if(l-sub > 0 && nearest > l-sub){
					nearest = l-sub;
					npos = pos + dir*(l-sub);
					P3 ref(npos-vp[i].first);
					ref.normalize();
					ndir = dir - ref*dir.dot(ref)*2.0;
					end = false;
				}
			}
			if(end) break;
			pos = npos;
			dir = ndir;
		}
		printf("%.8lf %.8lf %.8lf\n", pos.x, pos.y, pos.z);
	}
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	std::string s, t; std::cin >> s >> t;
	std::cout << t << s << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int num;
	scanf("%d", &num);
	int test;
	for (int i = 1 ; i <= 9 ; i++){
		for (int j = 1 ; j <= 9 ; j++){
			if(i * j ==num){
				test++;
				}
			}
		}
	if (test != 0){
		printf("Yes");
	}else {
		printf("No");
	}
    return 0;
}

Measured memory_bytes: 1724