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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll x,y;cin>>x>>y;
  ans(abs(x-y)<=1,"Brown","Alice");
  return 0;
}

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

using namespace std;

int map[4][4];
int tnt ,ans;

int main()
{
	for(int i = 1 ; i <= 3 ; i++){
		for(int j = 1 ; j <= 3 ;j++ ){
			cin >> map[i][j];
			tnt += map[i][j];
		}
	}
	ans = map[1][1] + map[2][2] + map[3][3];
	ans *= 3;
	if(ans != tnt )cout << "No" << endl;
	else cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string cname[9];
	int count[9],income[9];
	for(int i=0,am,pm;i<9;++i){
		cin>>cname[i]>>am>>pm;
		count[i]=am+pm;
		income[i]=am*200+pm*300;
	}
	for(int i=0;i<9;++i)cout<<cname[i]<<" "<<count[i]<<" "<<income[i]<<"\n";
	return 0;
}

Measured memory_bytes: 0
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        n: usize
    }
    let m = 1000000007;
    let mut ac = vec![1;n+1];
    if n == 1 {
        println!("1");
        return;
    }
    ac[1] = 1;
    let mut b = 0;
    let mut sumb = 0;
    for i in 2..n+1 {
        b = (sumb + ac[i-2]) % m;
        sumb = (sumb + b) % m;
        ac[i] = (pow_m(2,i-1,m) + m - b) % m;
    }
    let mut ans = 0;
    for i in 0..n {
        if i < n - 2 {
            ans += ac[i] * (n-i-2) % m * (n-1) % m;
        }
        if i < n - 1 {
            ans += ac[i] * (i + 1) % m * n % m;
        } else {
            ans += ac[i] * (n - 1) % m;
        }
        ans %= m;
    }
    ans = (ans + ac[n]) % m;
    println!("{}",ans);
}

fn pow_m(n: usize, mut p: usize, m: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % m;
            p /= 2;
        } else {
            ret = ret * r % m;
            p -= 1;
        }
    }
    ret
}


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

namespace APC2019_B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			input = Console.ReadLine().Split(' ');
			List<int> buttomList = new List<int>();
			List<int> middleList = new List<int>();
			List<int> topList = new List<int>();
			for (int i = 0; i < n; i++)
			{
				int number = int.Parse(input[i]);
				if(number <= a) buttomList.Add(number);
				else if(a + 1 <= number && number <= b) middleList.Add(number);
				else topList.Add(number);
			}

			int count;
			if (buttomList.Count < middleList.Count)
			{
				if (buttomList.Count < topList.Count) count = buttomList.Count;
				else count = topList.Count;
			}
			else
			{
				if (middleList.Count < topList.Count) count = middleList.Count;
				else count = topList.Count;
			}
			
			Console.WriteLine(count);
		}
	}
}


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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5;
int t[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n,c,k;
	cin>>n>>c>>k;
	rep(i,1,n)scanf("%d",t+i);
	sort(t+1,t+n+1);
	int ans=0;
	for(int i=1;i<=n;)
	{
		int j=i;
		while(j<=n&&j<i+c&&t[j]<=t[i]+k)++j;
		++ans;
		i=j;
	}
	cout<<ans;
}

Measured memory_bytes: 640
def median(arr)
  n = arr.size
  n.odd? ? arr[n/2] : (arr[n/2 - 1] + arr[n/2])/2.0
end

n = gets.to_i
args = readlines(chomp: true)
ab = args.map{|arr| arr.split(" ").map(&:to_i)}.transpose

result = []

if n.odd?
  ab.each do |range|
    result << median(range.sort)
  end
  result = result[-1] - result[0] + 1
else
  ab.each do |range|
    result << median(range.sort)
  end
  result = (result[-1] - result[0]) * 2 + 1
end

p result.to_i


Measured memory_bytes: 46940
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin >> w;
  vector<int> a(26);
  for (int i = 0; i < w.size(); i++){
    a[w[i] - 'a']++;
  }
  bool res = true;
  for (int i = 0; i < 26; i++){
    if (a[i]%2>0){
      res = false;
      break;
    }
  }
  if (res){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
  if a < b: a, b = b, a
  if b == 0:
    return a
  return gcd(b, a % b)

ans = A.pop()
while A:
  ans = gcd(ans, A.pop())
print (ans)

Measured memory_bytes: 15020
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int limit = 100010;

using edge = struct { int to; LL cost; };

vector<edge> tree[limit];
LL depth[limit];

void dfs(int v, int p, LL d) {
	depth[v] = d;

	for (auto &e : tree[v]) {
		if (e.to == p)continue;
		dfs(e.to, v, d + e.cost);
	}
}

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



	for (int i = 0; i < n-1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		
		tree[a].push_back({ b,c });
		tree[b].push_back({ a,c });

	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);

	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;

		x--; y--;

		cout << depth[x] + depth[y] << endl;
	}
}

Measured memory_bytes: 14336
hash = Hash.new(0)
min_a, max_v = Float::INFINITY, -Float::INFINITY

n, q = gets.chomp.split.map(&:to_i)

q.times do
  a, v = gets.chomp.split.map(&:to_i)
  hash[a] += v
  if v > 0
    if hash[a] > max_v
      max_v = hash[a]
      min_a = a
    elsif hash[a] == max_v
      min_a = [a, min_a].min
    end
  else
    if a == min_a
      order = hash.sort do |(k1, v1), (k2, v2)|
        if v1 == v2
          k1 <=> k2
        else
          v2 <=> v1
        end
      end
      min_a, max_v = order.first[0], order.first[1]
    end
  end

  puts [min_a, max_v].join(' ')
end

Measured memory_bytes: 15432
const TOP: u64 = 1_000_000_007;

pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

// use std::collections::BTreeMap;

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

	let n: usize = iter.read();
	let m: usize = iter.read();

	let mut map: Vec<bool> = vec![true; n + 1];

	for _ in 0..m {
		let c: usize = iter.read();
		map[c] = false;
	}

	let mut count: Vec<u64> = vec![0; n + 1];

	count[0] = 1;
	if map[1] {
		count[1] = 1;
	}

	if 1 < n {
		for c in 2..n + 1 {
			if map[c] {
				count[c] = (count[c - 2] + count[c - 1]) % TOP;
			}
		}
	}

	println!("{}", count[n]);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

signed main(){

	lli a,b,x;
	cin>>a>>b>>x;

	lli maxV = a*a*b;

	cout<<setprecision(21);
	double rad = atan((a*b*b)/(2.0*x));
	if(DEBUG)cout<<"tan="<<(a*b*b)/(2.0*x)<<endl;
	if(DEBUG)cout<<"rad="<<rad<<endl;

	double deg = (((rad)/2.0/PI)*360);

	double rad2 = atan(2.0*(maxV-x)/(a*a*a));
	double deg2 = (((rad2)/2.0/PI)*360);

	if(maxV>=2*x){
		cout<<deg<<endl;
	}
	else{
		cout<<deg2<<endl;
	}

	return 0;
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

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

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>=b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n; cin>>n;
map<ll,ll>mp;
ll ans = 0;
rep(i,0,n)
{
    ll x; cin>>x;
    ans+=x;
    mp[x]++;
}

ll q; cin>>q;
while(q--)
{
    ll x,y; cin>>x>>y;
    ll cnt = 0;
    if(mp.find(x)!=mp.end())cnt = mp[x];
    mp[x] = 0;
    mp[y] += cnt;
    ans-=x*cnt;
    ans+=y*cnt;
    cout<<ans<<endl;
}
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 9560
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <stack>

using namespace std;

int main() {

  string op;
  stack<int> st;  
  int sec,fir;

  while(cin >> op){
    if(op=="+"||op=="-"||op=="*"){
      fir = st.top();
      st.pop();
      sec = st.top();
      st.pop();
      if(op=="+") st.push(fir+sec);
      if(op=="-") st.push(sec-fir);
      if(op=="*") st.push(fir*sec);
    }
    else st.push(atoi(op.c_str()));
  }
  cout << st.top() << endl;
  
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
  int root(int x) {
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main() {
  ll n,m;
  cin >> n >> m;
  UnionFind tree(n);
  vi A,B;
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    A.push_back(a);
    B.push_back(b);
  }
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  ll ans = n*(n-1)/2;
  vl L(m,0);
  rep(i,m){
    L[m-i-1] = ans;
    if(tree.same(A[i],B[i]))continue;
    ll sa = tree.size(A[i]);
    ll sb = tree.size(B[i]);
    ans-=(sa*sb);
    tree.unite(A[i],B[i]);
  }
  rep(i,m)cout<<L[i]<<endl;
  return 0;
}

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

int main(void){
    vector<int> num_of_alphabet(26,0);
    string input_line;
    while(getline(cin,input_line)){
        for(int i=0;i<input_line.size();i++){
            if(isalpha(input_line[i]))
                num_of_alphabet[(tolower(input_line[i]) - 'a')]++;
        }
    }

    for(char i='a';i<='z';i++){
        cout << i << " : " << num_of_alphabet[int(i-'a')] << endl;
    }
}


Measured memory_bytes: 3192
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    a = '#.'
    b = '#'
    c = '.#'
    d = '.'

    def bw(n):
        if n % 2 == 0:
            print((n//2)*a)
        else:
            print((n//2)*a + b)

    def wb(n):
        if n % 2 == 0:
            print((n//2)*c)
        else:
            print((n//2)*c + d)

    for i in range(1,H + 1):
        if i % 2 == 0:
            wb(W)
        else:
            bw(W)
    print()

Measured memory_bytes: 7604
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int n;
vector<vector<int>> g;
vector<string> vs;
void dfs(int cur, int p) {
	for (int i = 0; i < p; i++)cout << ".";
	cout << vs[cur] << "\n";
	for (int i = 0; i < g[cur].size(); i++) {
		dfs(g[cur][i], p + 1);
	}
}
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		scanf("%d", &n);
		g.resize(n);
		vs.resize(n);
		for (int i = 0; i < n; i++) {
			int p; scanf("%d", &p);
			cin >> vs[i];
			if (p != 0) {
				p--;
				g[p].push_back(i);
			}
		}
		dfs(0, 0);
	}
	return 0;

}



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

int main() {
	int a,i;
	for (i = 1; i <= 5; ++i)
	{
		cin >> a;
		if (a == 0)
			break;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std; 
int main() {
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin>>a[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
    }
    cout<<dp[n - 1];
    return 0; 
}

Measured memory_bytes: 1024
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=1e2+1,KMAX=1e5+1,AUCUN=0,PREMIER=1,SECOND=2;
int winner[3][KMAX],n,k,a[NMAX];

int other(int player){
	if(player==PREMIER) return SECOND;
	if(player==SECOND) return PREMIER;
	return AUCUN;
}

int simuler(int tas,int player){ //renvoie le gagnant
	//cout << tas << ' ' << player << endl;
	if(winner[player][tas]!=AUCUN){
		return winner[player][tas];
	}
	bool gagnant=false;
	for(int i=0;i<n;i++){
		if(tas-a[i]>=0 && simuler(tas-a[i],other(player))==player){
			gagnant=true;
		}
	}
	if(gagnant) winner[player][tas]=player;
	else winner[player][tas]=other(player);
	return winner[player][tas];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k;
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	int joueur=simuler(k,PREMIER);
	
	if(joueur==PREMIER) cout << "First\n";
	else cout << "Second\n";
	
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    ll prev = 0;
    REP(i,N){
       ll h;
       cin >> h;
       if( h > prev ){
           prev = h-1;
       }else if( h == prev ){
           prev = h;
       }else{
           cout << "No" << endl;
           return 0;
       }
    }
     cout << "Yes" << endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict
t = int(input())
def chmin(a,b):
  a = min(a,b)
def calc(x):
  ret = d*x
  if dc[x] < 10**36:
    return dc[x]
  if x:
    ret = min(ret,calc(x//2)+a+d*(x%2))
  if x%2 and x > 1:
    ret = min(ret,calc(x//2+1)+a+d)
  if x:
    ret = min(ret,calc(x//3)+b+d*(x%3))
  if x%3 and x > 1:
    ret = min(ret,calc(x//3+1)+b+d*(3-x%3))
  if x:
    ret = min(ret,calc(x//5)+c+d*(x%5))
  if x%5 and x > 1:
    ret = min(ret,calc(x//5+1)+c+(5-x%5)*d)
  dc[x] = ret
  return ret
for _ in range(t):
  n,a,b,c,d = map(int,input().split())
  ans = n*d
  dc = defaultdict(lambda:10**36)
  if n == 1:
    print(ans)
  else:
    dc[0] = 0
    dc[1] = d
    print(min(ans,calc(n)))

Measured memory_bytes: 91068
Public Class Compiler
    Shared Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Dim input As String() = Console.ReadLine().split(" ")
        Dim ls(0 To n - 1) As Integer
        Dim lMax As Integer = 0
        Dim lSum As Integer = 0
        For i As Integer = 0 To n - 1
            ls(i) = Integer.Parse(input(i))
            If ls(i) > lMax Then lMax = ls(i)
            lSum += ls(i)
        Next
        Dim output As String = "No"
        If lMax < lSum - lMax Then output = "Yes"
        Console.WriteLine(output)
    End Sub
End Class


Measured memory_bytes: 13140
A,B,C = (input() for i in range(3))
count_A=1
count_B=0
count_C=0
arr = A[0]
for i in range(len(A)+len(B)+len(C)):
    if arr=='a':
        if count_A==len(A):
            print('A')
            break
        arr = A[count_A]
        count_A+=1
    elif arr=='b':
        if count_B==len(B):
            print('B')
            break
        arr = B[count_B]
        count_B+=1
    else:
        if count_C==len(C):
            print('C')
            break
        arr = C[count_C]
        count_C+=1

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

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    map <string,int> m;
    map <string,int> :: iterator it;
    multimap <int,string> x;
    multimap <int,string> :: iterator xt;
    set <string> st;
    set <string> :: iterator si;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        it = m.find(s);
        if(it == m.end())
        {
            m.insert(make_pair(s,1));
        }
        else
        {
            m[s]++;
        }
    }
    for(it = m.begin(); it != m.end(); it++)
    {
        x.insert(make_pair(it -> second, it -> first));
    }
    xt = x.end();
    xt--;
    int maxi = xt -> first;
    for(xt = x.begin(); xt != x.end(); xt++)
    {
        if(xt -> first == maxi)
        {
            st.insert(xt -> second);
        }
    }
    for(si = st.begin(); si != st.end(); si++)
    {
        cout << *si << "\n";
    }
}


Measured memory_bytes: 50548
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c; cin >> a >> b >> c; a-=c;
    out(a/(b+c));

    return 0;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")



X, A = list(map(int, sys.stdin.readline().split()))
if X < A:

    print(0)
else:
    print(10)


Measured memory_bytes: 23320
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,k,s=I()
an = [s]*k+[s+1 if s!=10**9 else 1]*(n-k)
print(*an)


Measured memory_bytes: 11912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main()
{
    ll n,m;
    cin>>n>>m;
    ll ans=min(n,m/2);
    n=n-ans;
    m=m-ans*2;
    ans+=(m/4);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
let () =
  let s = read_line () in
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left (fun l s ->
    max l @@
    if
      List.exists (function
        | 'A' | 'C' | 'G' | 'T' -> false | _ -> true) @@
      Array.to_list @@
      Array.init (String.length s) (String.get s)
    then min_int
    else String.length s)) min_int @@
  Array.init (String.length s + 1) @@ fun l ->
    Array.init (String.length s - l + 1) @@ fun i ->
      String.sub s i l


Measured memory_bytes: 384
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [x] <- readInts
  print $ solve x

solve :: Int -> Int
solve x = maximum (map (maxExp x) [1 .. maxRoot x])

maxRoot :: Int -> Int 
maxRoot = floor . sqrt . fromIntegral

maxExp :: Int -> Int -> Int
maxExp x r = if r == 1 then 1 else maxExpIter x r r
  where
    maxExpIter x r a =
      if next > x
        then a
        else maxExpIter x r next
      where next = r * a

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 380
#include <stdio.h>

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

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

int main(void)
{
    int a, b;

    while (scanf("%d %d", &a, &b) != EOF){
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }

    return (0);
}

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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 1; i < 10; i++) for(int j = 1; j < 10; j++) {
		if(i * j == n) {
			return printf("Yes\n"), 0;
		}
	}
	printf("No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
	ll a,b,s,t,u;
	cin>>a>>b;
	s=a+b;
	t=a*b;
	u=a-b;
	s=max(s,max(t,u));
	cout<<s;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  string c;
  cin >> c;
  ll cnt=0;
  rep(i, N){
    if(c[i]=='R')cnt++;
  }
  ll ans = 0;
  rep(i, cnt){
    if(c[i]=='W'){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll x,y;
  cin >> x >> y;
  if(y%2==1){
    cout << "No";
  }
  else if(x*2<=y&&y<=x*4){
    cout << "Yes";
  }
  else cout << "No";
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b;
    char op;
    cin >> a >> op >> b;
    cout << (op=='+'? a+b : a-b) << endl;
}

Measured memory_bytes: 256
/**
 * auther: moririn_cocoa
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define ll long long
#define pll pair<ll,ll>
#define pq priority_queue
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

int main(int argc, const char * argv[]) {
  
  int N;
  
  cin >> N;
  
  cout << N / 3 << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){
  ll N;
  cin >> N;
  ll A[N];
  vector<ll> ab;
  ll num_plus = 0;
  ll num_minus = 0;
  vector<ll> vec_plus;
  vector<ll> vec_minus;
  REP(i, 0, N){
    cin >> A[i];
    ab.push_back(abs(A[i]));
    if (A[i] > 0){
      vec_plus.push_back(A[i]);
      num_plus++;
    }
    else if (A[i] < 0){
      vec_minus.push_back(A[i]);
      num_minus++;
    }
  }

  ll sum = 0;
  if(num_minus%2 == 0){
    REP(i, 0, N){
      sum+=abs(A[i]);
    }
  }
  else{
    sort(ab.begin(), ab.end());
    REP(i, 0, N){
      sum+=abs(A[i]);
    }
    sum+=(ab[0]*-2);
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define MOD 1000000007
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef int64_t in;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;




int main(){
    ll n; cin >> n;
    ll p[n];
    ll cnt=0;
    rep(i,n){
        cin >> p[i];
    }
    rep(i,n-2){
        if(p[i] < p[i+1] && p[i+1] < p[i+2] || p[i+2] < p[i+1] && p[i+1] < p[i]) cnt++;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
import math

def main():

    _ = int(input())
    h = list(map(int, input().split()))

    ans = 0
    while True:
        m = max(h)
        if m == 0:
            print(ans)
            return
        else:
            b = False
            for i,x in enumerate(h):
                if x == m:
                    h[i] -= 1
                    b = True
                elif b:
                    break
            ans += 1

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#ifdef _WIN32
#include <vector>
#include<set>
#include<map>
#include<algorithm>
#include<stdio.h>
#include<iostream>
#else
#include <bits/stdc++.h>
#endif
using namespace std;


int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0){
		cout << (B - A) / 2 << endl;
	}
	else {
		cout << min((N + (N + 1) - B - A) / 2, (B - (1 - A)) / 2) << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int N; cin >> N;
    ll S=1;
    ll e=1000000000000000000;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    bool zero = find(A.begin(),A.end(),0) != A.end();
    if(zero) {
        cout << "0" << endl;
        return 0;
    }
    else {
        rep(i,N) {
            if (S<=e/A[i]) S *= A[i];
            else {
                cout << "-1" << endl;
                return 0;
            }
        }
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

int main(){
    string SS;
    cin >> SS;


    Int count = 0;
    if(SS.size() < 3){
        cout << 0 << endl;
        return 0;
    }

    string S=""; 
    for (int i = 0; i < SS.size()-1; i++)
    {
        if(SS[i] == 'B' and SS[i+1] == 'C'){
            S.append("D");
            i++;
        }else{
            S.push_back(SS[i]);
        }
    }
//    cout << S << endl;
    

    int a=0;
    int d=0;
    count = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == 'A'){
            a++;
        } else if(S[i] == 'D'){
            count += a; 
        }else{
            a=0;
            d=0;
        }
    }
    cout <<  count << endl;
    return 0;
}

Measured memory_bytes: 900
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int n; cin >> n;
	vector<Vi> G(n);
	Vi deg(n);

	rep(i, 1, n) {
		int a, b; cin >> a >> b;
		G[a-1].pb(b-1);
		G[b-1].pb(a-1);
		deg[a-1]++;
		deg[b-1]++;
	}

	Vi nums(n);
	each(k, nums) cin >> k;
	sort(all(nums));

	Vi ans(n);
	ll score = 0;
	int j = 0;

	queue<int> que;
	rep(i, 0, n) if (deg[i] == 1) que.push(i);

	while (!que.empty()) {
		int v = que.front();
		que.pop();
		ans[v] = nums[j];
		if (deg[v] == 1) {
			score += nums[j];
			each(e, G[v]) if (--deg[e] == 1) que.push(e);
		}
		j++;
	}

	cout << score << '\n';
	each(a, ans) cout << a << ' ';
	cout << '\n';
}


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

int main()
{
    long N;
    cin >> N;
    int digits[16];
    long remainder = N;
    int max_sum = 0;
    long divining = 1000000000000000;
    for(int i=15;i>=0;i--){
        digits[i] = remainder / divining;
        remainder = remainder % divining;
        divining /= 10;
        max_sum += digits[i];
    }
    // max digit-sum is (top digit num - 1) + 9 * (num of the rest digits)
    // unless each of the rest digits are 9.
    // 2799 -> max digit-sum is 28 for 1999.
    // 199 -> max digit-sum is 19 for 199.
    for(int i=15;i>=0;i--){
        if(digits[i] != 0){
            int tmp_sum = digits[i] - 1 + 9 * i;
            max_sum = max(max_sum, tmp_sum);
            cout << max_sum << endl;
            break;
        }
    }
    return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

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

            List<String> input = Arrays.asList(br.readLine().split(""));

            String result = "No";
            if (!input.get(0).equals(input.get(1))
                && input.get(2).equals(input.get(3))
                && input.get(4).equals(input.get(5))) {
                result = "Yes";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    int res = 0;

    for(int i = N - 1; i >= 0; --i) {
        int c = min(A[i + 1], B[i]);
        res += c;
        B[i] -= c;
        int d = min(B[i], A[i]);
        res += d;
        A[i] -= d;
//        cerr << c << "," << d << endl;
    }

    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N+1);
    for(int i = 0 ; i < N+1 ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;

int a[maxn];//各个同余系的个数

int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=1;i<=k;i++)
        {
            a[i]=n/k;
        }
        int r=n%k;
        for(int i=1;i<=r;i++) a[i]++;
        ll ans=0;

        ans+=(ll)a[k]*(ll)a[k]*(ll)a[k];
        if(k%2==0)
            ans+=(ll)a[k/2]*(ll)a[k/2]*(ll)a[k/2];
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1024