akhauriyash/Code-Regression huggingface dataset:
// AUTHOR - RUTVIK KOTHARI
// DAIICT , GANDHINAGAR

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

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e5 + 5;
const ll mod = 1e9 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

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

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}



int main()
{
    FIO;
    //pre();

    ll i,j;
    
    ll a,b,c;
    cin>>a>>b>>c;
    
    ll ans = max(c-a+b,0LL);
    
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x; cin >> x;
    for (;;) {
        if (is_prime(x)) {
            cout << x << endl;
            break;
        }
        ++x;
    }
    return 0;
}

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

#define F first
#define S second
#define ll long long
#define pb push_back
#define ld long double
#define int long long

using namespace std ; 

const int MAXN = 101 * 1001 , MOD = 1e9 + 7 ; 

int a[MAXN] , b[MAXN] ; 

int fact[MAXN] ; 

int n ; 

bool check(int x)
{
	int cur = 1 ; 
	for(int i = 0 ; i < x ; i ++ ) 
	{
		if(a[i]<cur)
			return cout << i << ' ' << a[i] << ' ' <<cur << endl, 0 ; 
		b[i] = min(a[i],cur) ; 
		cur = b[i] + 2  ; 
	}	
	return 1 ;
}

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ;
	fact[0] = 1 ;
	for(int i = 1 ; i < MAXN ; i ++ ) fact[i] = fact[i-1] * i % MOD ;
	cin >> n ;
	for(int i = 0 ; i < n ; i ++ ) cin >> a[i] ; 
	int ans = 1 , cur = 1 , cnt = 0  ;
	for(int i = 0 ; i < n ; i ++ ) 
	{
		cnt ++ ; 
		if(a[i]<cur)
		{
	//		cout << cnt << ' ' << i<< endl ; 
			ans *= cnt ; 
			cnt -- ;
			ans %= MOD ; 
		}
		else
		{
			cur += 2 ;
		//	cnt ++ ; 
		}
	}
	ans *= fact[cnt] ; 
	ans %= MOD ; 
	/*
	int l = 0 , r = n ; 
//	check(r) ; 
//	return 0 ; 
	while(r-l>1)
	{
		int mid = (r+l) / 2 ;
		if(check(mid))
			l = mid ;
		else
			r = mid ;
	}
	cout << check(n-1) << endl ; 
	cout << l << endl ;
	for(int i = 0 ; i < n ; i ++ )
		cout << fact[i+1] * fact[n-i] << endl ; 
	cout << fact[l+1] * fact[n-l] % MOD << endl ; ; 
	*/
	cout << ans << endl  ;
}

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

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

int main() {
    int n, m, X, Y; cin >> n >> m >> X >> Y;
    vector<int> x(n); rep(i, n) cin >> x[i]; x.push_back(X);
    vector<int> y(m); rep(i, m) cin >> y[i]; y.push_back(Y);
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    int xr = x[x.size()-1];
    int yl = y[0];
    cout << (xr<yl ? "No War" : "War") << endl;
    return 0;
}


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

int main() {
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;

    char turn = 'a';
    while(1) {
        // cout << "turn: " << turn << endl;
        // cout << Sa << "\t" << Sb << "\t" << Sc << endl;
        if(turn == 'a') {
            if(Sa.size() == 0) {
                cout << 'A' << endl;
                return 0;
            }
            turn = Sa[0];
            Sa = Sa.substr(1, Sa.size()-1);
        } else if(turn == 'b') {
            if(Sb.size() == 0) {
                cout << 'B' << endl;
                return 0;
            }
            turn = Sb[0];
            Sb = Sb.substr(1, Sb.size()-1);
        } else if(turn == 'c') {
            if(Sc.size() == 0) {
                cout << 'C' << endl;
                return 0;
            }
            turn = Sc[0];
            Sc = Sc.substr(1, Sc.size()-1);
        }
        
        // cout << Sa << "\t" << Sb << "\t" << Sc << endl;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef int HeapElementType;
typedef bool (*CompareFunc)(HeapElementType, HeapElementType);

typedef struct {
  HeapElementType* heap;
  unsigned int size;
  unsigned int maxSize;
  CompareFunc cmp;
} PriorityQueue;

void heapify(HeapElementType*, unsigned int, CompareFunc, unsigned int);
bool compare(HeapElementType, HeapElementType);

void insert(PriorityQueue*, HeapElementType);
HeapElementType extract(PriorityQueue*);

int main () {
  int k;
  char command[10];
  PriorityQueue pQueue;

  pQueue.maxSize = 1;
  pQueue.heap = (HeapElementType*)malloc(sizeof(HeapElementType)*(pQueue.maxSize + 1));
  pQueue.size = 0;
  pQueue.cmp  = compare;

  while (true) {
    scanf("%s", command);
    if (!strcmp(command, "insert")) {
      scanf("%d", &k);
      insert(&pQueue, k);
    } else if (!strcmp(command, "extract")) {
      k = extract(&pQueue);
      printf("%d\n", k);
    } else {
      break;
    }
  }
  
  return 0;
}

bool compare (HeapElementType x, HeapElementType y) {
  return x > y;
}

void heapify (HeapElementType* heap, unsigned int H, CompareFunc cmp, unsigned int i) {
  unsigned int left  = 2*i;
  unsigned int right = 2*i + 1;

  unsigned int target;
  if (left <= H && cmp(heap[left], heap[i])) {
    target = left;
  } else {
    target = i;
  }

  if (right <= H && cmp(heap[right], heap[target])) {
    target = right;
  }

  if (target != i) {
    HeapElementType t = heap[i];
    heap[i] = heap[target];
    heap[target] = t;
    heapify(heap, H, cmp, target);
  }
}

void insert (PriorityQueue* pQueue, HeapElementType key) {
  pQueue->size++;
  if (pQueue->size > pQueue->maxSize) {
    pQueue->maxSize <<= 2;
    pQueue->heap = (HeapElementType*)realloc(pQueue->heap, sizeof(HeapElementType)*(pQueue->maxSize + 1));
  }

  pQueue->heap[pQueue->size] = key;

  unsigned int target = pQueue->size;
  while (target >= 2) {
    unsigned int parent = target/2;
    if (pQueue->cmp(pQueue->heap[parent], pQueue->heap[target])) {
      break;
    } else {
      HeapElementType t = pQueue->heap[parent];
      pQueue->heap[parent] = pQueue->heap[target];
      pQueue->heap[target] = t;
      target = parent;
    }
  }
}

HeapElementType extract (PriorityQueue* pQueue) {
  int key = pQueue->heap[1];
  pQueue->heap[1] = pQueue->heap[pQueue->size];
  pQueue->size--;  
  heapify(pQueue->heap, pQueue->size, pQueue->cmp, 1);

  return key;
}



Measured memory_bytes: 5688
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	p := make([]int, n)
	for i := range p {
		p[i] = nextInt() - 1
	}

	ans := 0
	for i := 0; i < n; i++ {
		if p[i] == i {
			if i < n-1 {
				p[i], p[i+1] = p[i+1], p[i]
			}
			ans++
		}
	}
	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

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

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


Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	cin >> n;
	vector<LL>a(n);
	map<LL, LL>m;
	m[0] = 1;
	LL ans = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		ans += m[sum];
		m[sum]++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define fastt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define enl "\n"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define vvl vector<vector<ll>> 
#define vl vector<ll> 
#define vpll vector<pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(ll i = 0; i < n; ++i)
#define PI 3.14159265 
ll mod=1e9+7;

ll Sum(ll i){
    if(i==-1)return 0;
    return (i*(i+1)/2)%mod;
}
 int main(){
     fastt;
     ll i,j,k;
   ll n,m;
   cin>>n>>m;
   ll ans=0;
   for(k=m;k<=n+1;k++){
       i=Sum(k-1);
       j=Sum(n)-Sum(n-k);
       j++;
       ans+=j-i;
       ans%=mod;
   }
   cout<<(ans+mod)%mod<<enl;
 }


Measured memory_bytes: 3692
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

struct edge{
	int to,co,p;
};

vector<edge> vs[105];

int ds[105];
void bfs(int st){
	queue<mp> que;
	que.push(mp(0,st));
	memset(ds,-1,sizeof(ds));
	while(!que.empty()){
		mp pa=que.front();
		que.pop();
		int no=pa.sec,
			nd=pa.fir;
		if(ds[no]>=0)continue;
		ds[no]=nd;
		rep(i,vs[no].size()){
			int to=vs[no][i].to,
				ec=vs[no][i].co;
			if(ec<=0 || ds[to]>=0)continue;
			que.push(mp(nd+1,to));
		}
	}
}

int gone[105];
int dfs(int no,int gl,int f){
	gone[no]=1;
	if(no==gl)return f;
	rep(i,vs[no].size()){
		edge& e=vs[no][i];
		if(e.co<=0 || ds[e.to]<=ds[no])continue;
		int tf=dfs(e.to,gl,min(f,e.co));
		if(tf<=0)continue;
		e.co-=tf;
		vs[e.to][e.p].co+=tf;
		return tf;
	}
	return 0;
}

int dinic(int st,int gl){
	int res=0;
	for(;;){
		bfs(st);
		if(ds[gl]<0)break;
		for(;;){
			memset(gone,0,sizeof(gone));
			int f=dfs(st,gl,IINF);
			if(f<=0)break;
			res+=f;
		}
	}
	return res;
}
	
int n,m;
int main(void){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		edge e;
		e.to=b; e.co=c; e.p=vs[b].size();
		vs[a].push_back(e);
		e.to=a; e.co=0; e.p=vs[a].size()-1;
		vs[b].push_back(e);
	}
	printf("%d\n",dinic(0,n-1));
	return 0;
}

Measured memory_bytes: 1260
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        ss: [proconio::marker::Chars; h],
    }
    let mut group = vec![vec![None; w]; h];
    for i_origin in 0..h {
        for j_origin in 0..w {
            if ss[i_origin][j_origin] == '.' || group[i_origin][j_origin].is_some() {
                continue;
            }
            let mut deque = std::collections::VecDeque::new();
            deque.push_back((i_origin, j_origin));
            while let Some((i, j)) = deque.pop_front() {
                if group[i][j].is_some() {
                    continue;
                }
                group[i][j] = Some((i_origin, j_origin));
                let nexts = [
                    (i.wrapping_sub(1), j),
                    (i, j.wrapping_sub(1)),
                    (i + 1, j),
                    (i, j + 1),
                ];
                for &(i_next, j_next) in &nexts {
                    if i_next < h
                        && j_next < w
                        && group[i_next][j_next].is_none()
                        && ss[i][j] != ss[i_next][j_next]
                    {
                        deque.push_back((i_next, j_next));
                    }
                }
            }
        }
    }
    let mut nums = std::collections::HashMap::new();
    for (i, group) in group.iter().enumerate() {
        for (j, group) in group.iter().enumerate() {
            if let Some(group) = group {
                let e = nums.entry(group).or_insert([0, 0]);
                let idx = if ss[i][j] == '#' { 0 } else { 1 };
                (*e)[idx] += 1;
            }
        }
    }
    let ans = nums.values().map(|x| x[0] * x[1]).sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 15696
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pq = priority_queue<int>;
using q = queue<int>;
 
int main() {
  int n;
  cin >> n;
  int ans = 0;
 ans = n%10;

 if(ans == 3){
     cout << "bon" << endl;
 }else if(ans == 0 || ans == 1 || ans == 6 || ans == 8){
     cout << "pon" << endl;
 }else{
     cout << "hon" << endl;
 }
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9

int aa(int x) {
	int sum=0;
	for (;;) {
		if (x % 2 == 0) {
			sum++;
			x /= 2;
		}
		else break;
	}
	return sum;
}

int main() {
	ull n, a[10001],s=0;
	cin >> n;
	for (int i = 0;i < n;i++) cin >> a[i];
	for (int i = 0;i < n;i++) {
		s += aa(a[i]);
	}
	cout << s << endl;

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  
  long tmp;
  vector<long> a,b;
  for(int i=0;i<n+1;i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  for(int i=0;i<n;i++){
    cin >> tmp;
    b.push_back(tmp);
  }
  
  long yoryoku=0; //勇者が次の街で倒せる数
  long taoshita=0; //倒したモンスターの数
  long nokori=0; //その街の残りモンスター数
  
  for(int i=0;i<n;i++){
    nokori = a[i];//街iのモンスター数をセット
    taoshita += min(nokori,yoryoku);//勇者i-1の余力で倒せるだけ倒す
    nokori = nokori - min(nokori,yoryoku);//余力で倒した街iの残りモンスター数を残りにセット
    taoshita += min(nokori,b[i]);//勇者iで倒せるだけ倒す
    yoryoku = b[i] - min(nokori,b[i]); //勇者iの余力をセット
  }
  
  //最後の街n+1のモンスターを余力で倒す
  taoshita += min(a[n],yoryoku);
  
  cout << taoshita << endl;
    
  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;

int main()
{
    IOS;
    int n,k;cin>>n>>k;
    int gc=0,mx=-inf;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        mx=max(mx,a);
        gc=__gcd(gc,a);
    }
    if(k%gc==0&&k<=mx)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}








Measured memory_bytes: 3628
#include <stdio.h>

main(void)
{   int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
	 printf("a < b\n");
	}
	else if(a>b){
	 printf("a > b\n");
	}
	else{
	 printf("a == b\n");
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

ll A[100000], sum[100000];

int main() {

    int N; cin >> N;
    for (int i = 0; i < N; i++) 
        scanf("%lld", &A[i]);
    

    sort(A, A + N);


    sum[0] = A[0];

    for (int i = 1; i < N; i++) 
        sum[i] = sum[i-1] + A[i];

    int ans = 1;
    for (int i = N-2; i >= 0; i--) {
        if (A[i+1] <= 2 * sum[i])
            ans++;
        else break;
    }

    cout << ans << '\n';



}


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

namespace TakahashiCalender
{
	class Program
	{
		static void Main(string[] args)
		{
			int d1 = 0;
			int d10 = 0;

			int month = 0;
			int day = 0;

			string[] dataList = Console.ReadLine().Split(' ');

			month = int.Parse(dataList[0]);

			day = int.Parse(dataList[1]);

			int count = 0;
			string dd = null;

			for (int i = 22; i <= day; i++)
			{
				dd = i.ToString();

				d1 = int.Parse(dd[1].ToString());
				d10 = int.Parse(dd[0].ToString());

				if (d1 >= 2 && d10 >= 2)
				{
					for (int j = 4; j <= month; j++)
					{
						if (j == d1 * d10)
						{
							count++;
						}
					}
				}
			}
			Console.WriteLine(count);
			Console.ReadKey();

		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;

int n;
int id[1002], p[1002], q[1002], r[1002];
int P, Q, R, C;

int main(){
  while(cin >> n, n){
    vector<int> v;

    for(int i = 0; i < n; i++){
      cin >> id[i] >> p[i] >> q[i] >> r[i];
    }

    cin >> P >> Q >> R >> C;

    for(int i = 0; i < n; i++){
      if(P < p[i]) continue;
      if(Q < q[i]) continue;
      if(R < r[i]) continue;

      int cal = p[i] * 4 + q[i] * 9 + r[i] * 4;

      if(C < cal) continue;

      v.push_back(id[i]);
    }

    if(v.size() == 0){
      cout << "NA\n";
    }
    else{
      for(int i = 0; i < v.size(); i++){
        cout << v[i] << endl;
      }
    }
  }
}

Measured memory_bytes: 928
A,B,C,X,Y = map(int,input().split())
ans = float('inf')
for ci in range(max(2*X+1,2*Y+1)):
  val = ci*C +max(0,(X-ci//2)*A) + max(0,(Y-ci//2)*B)
  ans = min(val, ans)
print(ans)

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

using namespace std;

long mergecount(vector<int> &a) {
    long count = 0;
    int n = a.size();
    if (n > 1) {
        vector<int> b(a.begin(), a.begin() + n/2);
        vector<int> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i){
            if (k == c.size()) a[i] = b[j++];
            else if (j == b.size()) a[i] = c[k++];
            else if (b[j] <= c[k]) a[i] = b[j++];
            else{
                a[i] = c[k++];
                count += n/2 - j;
            }
        }
    }
    return count;
}

long calc(string s){
    int l = s.length();
    vector<int> a(l, 0);
    for(int i=0; i<l; ++i){
        if(s[i]=='A'){
            a[i]=1;
        }
    }
    return mergecount(a);
}

int main(){
    string s;
    cin>>s;
    long ans = 0;

    if(s.length() < 3){
        cout<<ans<<endl;
        return 0;
    }

    int l = s.length();
    string t = "";
    for(int i=0; i<l; ++i){
        if(i+1<l && s[i]=='B' && s[i+1]=='C'){
            t+="D";
            ++i;
        }else if((s[i] == 'B' || s[i] == 'C') && t[t.length()-1]!='B'){
            t+="B";
        }else if(s[i] == 'A'){
            t+="A";
        }
    }

    t="B"+t+"B";
    l = t.length();
    int a=0, b=0;
    bool flag = false;
    for(int i=0; i<l; ++i){
        if(t[i] == 'B'){
            if(flag==false){
                a=i+1;
                flag = true;
            }else{
                b=i-1;
                ans+=calc(t.substr(a, b-a+1));
                
                a=i+1;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int N;
   cin>>N;
   vector<ll>A(N);
   for(int i=0;i<N;i++)cin>>A[i];
   map<ll,bool>s;

   for(int i=0;i<N;i++){
      s[A[i]] = !(s[A[i]]);
   }

   ll ans = 0;
   for(auto it : s){
      if(it.second)ans++;
   }
   cout<<ans;
   return 0; 
}


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

using namespace std;

int main () {
	long long n, a, b;
	cin >> n >> a >> b;	
	if (n == 1 || b < a) {  
		cout << (a == b);
		return 0;
	}
	long long len = n - 2;
	long long mn = len * a;
	long long mx = len * b;
	cout << mx - mn + 1;
	return 0;
}

Measured memory_bytes: 256
N,Y=map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z=N-x-y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z==Y:
            print(x,y,z)
            exit()

print(-1,-1,-1)

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

int main() {
  
  for (int i = 0; ; i++) {
    int x;
    cin >> x;
    if (x != 0) {
      cout << "Case " << i+1 << ": " << x << endl;
    } else {
      break;
    }
  }
 
}


Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n;
	cin >> n;
	string s;
	cin >> s;

	vector<ll> r,g,b;
	rep(i,n) {
		if(s[i] == 'R') r.push_back(i);
		else if(s[i] == 'G') g.push_back(i);
		else b.push_back(i);
	}

	ll res = 0;
	rep(i,r.size()){
		rep(j,g.size()){
			ll tmpi = r[i]; ll tmpj = g[j];
			if(tmpi > tmpj) swap(tmpi,tmpj);

			ll cnt = b.size();
			if(2*tmpi - tmpj >= 0 && 2*tmpi - tmpj < n && s[2*tmpi - tmpj] == 'B') cnt--;
			if(2*tmpj - tmpi >= 0 && 2*tmpj - tmpi < n &&s[2*tmpj - tmpi] == 'B') cnt--;
			if((tmpj + tmpi)%2==0 && (tmpj + tmpi)/2 < n && s[(tmpj + tmpi)/2] == 'B') cnt--;

			res += cnt;
		}
	}

	cout << res << endl;
	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,q;
	long long res=0;
	cin>>n>>m>>q;
	int A[55],B[55],C[55],D[55];
	for (int i=0; i<q; i++) cin>>A[i]>>B[i]>>C[i]>>D[i];
	int b[21],a[21];
	for (int i=0; i<m; i++) b[i]=0;
	for (int i=m; i<n+m; i++) b[i]=1;
	do{
		int val=1,cnt=1;
		for (int i=0; i<n+m; i++){
			if (!b[i]) val++;
			else a[cnt++]=val;
		}
		long long sum=0;
		for (int i=0; i<q; i++)
			if (a[B[i]]-a[A[i]]==C[i])
				sum+=D[i];
		res=max(res,sum);
	}while (next_permutation(b+1,b+m+n));
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int  x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int H,W,i,ii;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0){break;}
        else{
            for(i=0;i<H;i=i+1){for(ii=0;ii<W;ii=ii+1)
            {if((i+ii)%2==0){cout<<"#";}else{cout<<".";}
            }
                cout<<endl;}}cout<<endl;}
    return 0;
}

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

int main(){

  int D,G;  cin >> D >> G;
  int p[10],c[10];
  for(int i = 0;i < D;i++)cin >> p[i] >> c[i];

  vector<int> ans;

  for(int i = 0;i < (1 << D);i++){

    int point = 0;
    int solved = 0;
    int max_index = 0;

    for(int j = 0;j < D;j++){
      if((i >> j) & 1){
        point += p[j] * 100 * (j+1) + c[j];
        solved += p[j];
      }
      else max_index = j;
    }

    int now_point = G - point;

    if(now_point > 0){
      int nokori = now_point/((max_index+1)*100);
      solved+= nokori;

      if(nokori > p[max_index])continue;

      if(nokori * (max_index+1) * 100 < now_point)solved++;

      ans.push_back(solved);
    }
    else ans.push_back(solved);

  }

  cout << *min_element(ans.begin(),ans.end()) << endl;




}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[3];
int main(){
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a + 3);
	if(a[0]==a[1] && a[1]==a[2]){
		cout << "No" << endl;
	}else{
		if(a[0]==a[1] || a[1]==a[2]){
			cout << "Yes" << endl;
		}else{
			cout << "No" <<endl;
		}
	}
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (A.size() < B.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < A.size(); i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
	}
	cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
import std.stdio : writefln;
import std.array;
import std.range;
import std.algorithm : filter;


void main(){
	while(true){
		int h = next!int();
		int m = next!int();
		int s = next!int();
		if(filter!(a => a == -1)([h, m, s]).array.length == 3){ break; }
		
		int rest = 2*60*60 - (h*60*60 + m*60 + s);
		writefln("%02d:%02d:%02d", rest/(60*60), (rest%(60*60))/60, ((rest%(60*60))%60));
		// 3倍録画から見た残り時間
		rest = 2*60*60*3 - (h*60*60 + m*60 + s)*3;
		writefln("%02d:%02d:%02d", rest/(60*60), (rest%(60*60))/60, ((rest%(60*60))%60));
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().ToInt();
            var pair = new Dictionary<Tuple<int, int>, int>();

            for (int i = 1; i <= n; i++)
            {
                int j;
                pair[P(i)] = pair.TryGetValue(P(i), out j) ? j + 1 : 1;
            }
            long ans = 0;
            for (int i = 1; i <= n; i++)
            {
                var p = P(i);
                int j;
                ans += pair.TryGetValue(new Tuple<int, int>(p.Item2, p.Item1), out j) ? j : 0;
            }
            WriteRead(ans);
        }

        private static Tuple<int, int> P(int x)
        {
            return new Tuple<int, int>(x.ToString().First().ToInt(), x.ToString().Last().ToInt());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }
    }
}


public static class Extentions
{
    public static int ToInt(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }
}



Measured memory_bytes: 17388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;

  vector<map<char, int>> ss(n);
  for (int i = 0; i < n; i++) {
    string temp;
    cin >> temp;

    for (int j = 0; j < temp.size(); j++) {
      ss[i][temp[j]]++;
    }
  }

  map<char, int> ans;

  for (char c = 'a'; c <= 'z'; c++) {
    int min = 99999;
    for (int i = 0; i < n; i++) {
      if (min > ss[i][c]) {
        min = ss[i][c];
      }
    }
    ans[c] = min;
  }

  for (auto it = ans.begin(); it != ans.end(); it++) {
    if (it->second == 0) {
      continue;
    } else {
      cout << string(it->second, it->first);
    }
  }
  cout << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }




int main() {
	/*int n;
	cin >> n;
	vector<int> b(n - 1);
	rep(i, n-1) {
		cin >> b[i];
	}


	cout << << endl;
	return 0;*/
	int n;
	cin >> n;
	cout << n * n*n << endl;
}


Measured memory_bytes: 256
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	a := stdin.ReadInt()
	b := stdin.ReadInt()

	ans := ModPow(2, n) - 1
	ans -= NoCacheC(n, a)
	ans += MOD
	ans %= MOD
	ans -= NoCacheC(n, b)
	ans += MOD
	ans %= MOD
	stdout.Println(ans)
}

const MOD = 1000000007

func ModPow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x = (x * x) % MOD
			y /= 2
		} else {
			z = (z * x) % MOD
			y--
		}
	}
	return z
}

func ModInv(x int) int {
	return ModPow(x, MOD-2)
}

func NoCacheC(n, r int) int {
	numer := 1
	denom := 1
	for i := 0; i < r; i++ {
		numer = numer * (n - i) % MOD
		denom = denom * (i + 1) % MOD
	}
	return numer * ModInv(denom) % MOD
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    string s;
    std::cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        std::cout << "Bad" << std::endl;
    }else{
        std::cout << "Good" << std::endl;
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	RII(n,p);
	int x = 0;
	RP(i,n) {
		RI(a);
		x += a&1;
	}
	ll v = x ? 1LL << (n - 1) : 1LL << n;
	PL(p ? (1LL<<n) - v : v);
}


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

int main() {
    ll n,ans,b;cin>>n;
    ans=0;
    vector<ll>v(n);
    rep(i,n){cin>>v[i];
    }
    rep(i,n-2){
    if(v[i]<v[i+1]&&v[i+1]<v[i+2]){
    ans=ans+1;
    }
    else if(v[i+2]<v[i+1]&&v[i+1]<v[i]){ans=ans+1;}
    else {ans=ans;}
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#define MAX 100005
typedef struct pp{
  char name[100];
  int t;
}P;
void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P x);
P dequeue(void);
P Q[MAX+1],Q2[MAX+1];
int head, tail, n;

int main(){
  int c,time=0;
  char elaps[100];
  int i, q;
  P u;
  initialize();
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }

  while(isEmpty()!=1){
    u=dequeue();
    strcpy(elaps,u.name);
    c=u.t-q;
    if(c>0){
      u.t=c;
      enqueue(u);
      time+=q;
    }
    else{
      time+=u.t;
      printf("%s %d\n",u.name,time);
    }
  }
  
 return 0;
}


void initialize(void){
  head=0;
  tail=0;
}

int isEmpty(void){
  
  if(head==tail)  return 1;
  else return 0;
}

int isFull(void){
  if(head==(tail+1)%MAX) return 1;
  else return 0 ;
  
}

void enqueue(P x){
  if(isFull()==1){
    fprintf(stderr,"??¨?????????????????????????????????\n");
    exit(1);
  }
  Q2[tail]=x;
  if(tail+1==MAX) tail=0;
  else tail++;
}
P dequeue(void){
  P x;
  if(isEmpty()==1){
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
  }
  x=Q2[head];
  if(head+1==MAX) head=0;
  else head++;
  return x;
}

Measured memory_bytes: 18876
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 998244353;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 3e3+10;

int n, a[N], sum, dp[N][N];

int solve(int idx, int s){
   if (s < 0){
      return 0; 
   }
   if (idx == n){
      return (s == 0);
   }

   int &ans = dp[idx][s];
   if (ans != -1){
      return ans;
   }

   ans = solve(idx+1, s)*2  + solve(idx+1, s - a[idx]);
   ans %= mod;
   return ans;
}

int32_t main(){_
   
   cin>>n>>sum;

   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
   }
   
   memset(dp, -1, sizeof dp);

   cout<<solve(0,sum);

   return 0;
}

Measured memory_bytes: 74560
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N :usize = sc.read();
    let x: usize = sc.read();
    if (2 <= x) && (x<= N*2-2) {
        println!("Yes");
    }else{
        println!("No");
        return;
    }

    if x == N {
        for i in 1..(N*2) {
            print!("{} ",i );
        }
        println!();
        return;
    }

    let mut ans = vec![0; N*2];
    let mut check = vec![0; N*2];
    ans[N] = x;
    check[x] = 1;
    if x < N{
        ans[N-1] = x-1;
        check[x-1] = 1;
        for i in (x+1)..(N+1){
            ans[i-2] = i;
            check[i] = 1;
        }

    }else{
        ans[N+1] = x+1;
        check[x+1] = 1;
        for i in (N+2)..(x+1){
            ans[i] = i-2;
            check[i-2] = 1;
        }
    }
    let mut t:usize = 1;
    // for i in 1..(N*2){
    //     println!("{} {}", ans[i], check[i]);
    // }
    for i in 1..(N*2){
        if check[i] != 0{
            continue;
        }
        while ans[t] > 0{
            t += 1;
        }
        ans[t] = i;
        check[i] = 1;
        t += 1;
    }

    for i in 1..(N*2){
        print!("{} ", ans[i]);
    }
    println!("");
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 7676
/*  -*- coding: utf-8 -*-
 *
 * 2806.cc: Weight Range
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

inline void setmin(int &a, int b) { if (a > b) a = b; }
inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  int m, n;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int sum = 0;
  for (int i = 0, j = 0;; i++) {
    int mina = as[j], maxa = as[j];
    for (int k = 0; k < m; k++) {
      setmin(mina, as[j]);
      setmax(maxa, as[j]);
      j = (j + 1) % n;
    }
    sum += maxa - mina;
    if (j == 0) break;
  }

  printf("%d\n", sum);
  return 0;
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll q,h,s,d,n;cin>>q>>h>>s>>d>>n;
  ll mn0=min(d, min(2*s, min(4*h, 8*q)));
  ll mn1=min(s, min(2*h, 4*q));
  if(n%2==0){
    // mn0でうめればよい
    P(mn0 * (n/2));
  }else{
    P(mn0 * (n/2) + mn1);
  }
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if (A>C) swap(A, C);
	if (B>C) swap(B, C);
	if (A>B) swap(A, B);
	B -= A;
	C -= A;
	int res = 0;
	if(B%2==0 && C%2==1){
		res++;
		C -= 1;
	}
	if(B%2==1 && C%2==0){
		res++;
		B -= 1;
	}
	if(B%2==1 && C%2==1){
		res++;
		B += 1;
		C += 1;
	}
	cout << res + (C/2) + ((C-B)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <set>

using namespace std;

int main() {
  int N;  
  cin >> N ;
  
  vector<int> vec;
  
  for (int i = 1; i <= 9; i++) {
    for (int j = i; j <= 9; j++){
      vec.push_back(i*j);
    }
  }
  string ans = "No";
  for (int l = 0; l < vec.size(); l++){
    if (N == vec[l]){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
//  Created by Sengxian on 2017/6/18.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 100000 + 3;
int n, a[MAX_N], b[MAX_N], sortedA[MAX_N], sortedB[MAX_N];
bool same[MAX_N];
vector<int> vs, pos[MAX_N];

int main() {
	n = readInt();
	int x = 0, y = 0;
	for (int i = 1; i <= n; ++i) x ^= sortedA[i] = a[i] = readInt();
	for (int i = 1; i <= n; ++i) y ^= sortedB[i] = b[i] = readInt();
	sortedA[0] = a[0] = x, sortedB[0] = b[0] = y;
	sort(sortedA, sortedA + n + 1);
	sort(sortedB, sortedB + n + 1);
	
	int idx = -1;
	for (int i = 0; i <= n; ++i)
		if (sortedA[i] != sortedB[i])
			return puts("-1"), 0;
	
	int m = unique(sortedA, sortedA + n + 1) - sortedA;
	for (int i = 1; i < n + 1; ++i) same[i] = a[i] == b[i];
	for (int i = 0; i < n + 1; ++i) a[i] = lower_bound(sortedA, sortedA + m, a[i]) - sortedA;
	for (int i = 0; i < n + 1; ++i) if (!same[i]) pos[a[i]].push_back(i);
	for (int i = 0; i < n + 1; ++i) b[i] = lower_bound(sortedA, sortedA + m, b[i]) - sortedA;
	
//	for (int i = 0; i < n + 1; ++i) cout << a[i] << ' '; cout << endl;
//	for (int i = 0; i < n + 1; ++i) cout << b[i] << ' '; cout << endl;
	
	static bool vis[MAX_N];
	int ans = 0;
	for (int i = 0; i < n + 1; ++i) if (!same[i] && !vis[i]) {
		static int q[MAX_N];
		int l = 0, r = 0;
		vis[i] = true, q[r++] = i;
		while (r - l >= 1) {
			int u = q[l++];
			for (int i = 0; i < (int)pos[b[u]].size(); ++i) {
				int v = pos[b[u]][i];
				if (!vis[v]) vis[v] = true, q[r++] = v;
			}
		}
		if (i == 0) ans += r - 1;
		else ans += r + 1;
	}
	
	printf("%d\n", ans);
			
	return 0;
}


Measured memory_bytes: 7808