akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" ; else cout << "No" ; cout << endl ;}
//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	map<ll,ll> s ;
	vll num(0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		if(s.count(a)) s[a]++ ;
		else{
			s[a] = 1 ;
			num.push_back(a) ;
		}
	}
	if(s.size()==1){
		yorn(num.at(0)==0) ;
		return 0 ;
	}
	if(s.size()==2){
		yorn(n%3==0&&s.count(0)&&s[0]==n/3) ;
		return 0 ;
	}
	if(s.size()==3){
		if(n%3!=0) yorn(0) ;
		else yorn(s[num.at(0)]==s[num.at(1)]&&s[num.at(1)]==s[num.at(2)]&&(num.at(0)^num.at(1)^num.at(2))==0) ;
		return 0;
	}
	yorn(0) ;
}


Measured memory_bytes: 5748
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[][]A = new int[N][];
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i] = new int[2]{int.Parse(str2[0]),int.Parse(str2[1])};
		}
		Array.Sort(A,(x,y)=>y[1].CompareTo(x[1]));
		List<int>[] list = new List<int>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int>();
		}
		for(var i=0;i<N;i++){
			list[A[i][0]-1].Add(A[i][1]);
		}
		for(var i=0;i<N;i++){
			list[i].Sort((x,y)=>y-x);
		}
		Array.Sort(list,(x,y)=>((y.Count>0 ? y[0] : 0).CompareTo(x.Count>0 ? x[0] : 0)));
		int[]C = new int[N];
		long ans = 0;
		int ct = 0;
		long bct = 0;
		for(var i=0;i<Math.Min(N,K);i++){
			if(list[i].Count == 0){
				break;
			}
			ct++;
			bct++;
			C[i]++;
			ans += list[i][0];
		}
		if(ct<K){
			var list2 = new List<int[]>();
			for(var i=0;i<N;i++){
				for(var j=C[i];j<list[i].Count;j++){
					list2.Add(new int[2]{list[i][j],i});
				}
			}
			list2.Sort((x,y)=>y[0]-x[0]);
			int ct2 = K-ct;
			for(var i=0;i<ct2;i++){
				ct++;
				C[list2[i][1]]++;
				ans += list2[i][0];
			}
		}
		var list3 = new List<int>();
		for(var i=0;i<N;i++){
			if(C[i]==1){
				list3.Add(list[i][0]);
			}
		}
		var list4 = new List<int>();
		for(var i=0;i<N;i++){
			for(var j=C[i];j<list[i].Count;j++){
				list4.Add(list[i][j]);
			}
		}
		list3.Sort();
		list4.Sort((x,y)=>y-x);
		int cta = 0;
		long ansmax = ans+bct*bct;
		while(true){
			if(cta >= list3.Count || cta >= list4.Count){
				break;
			}
			if(list4[cta]+((bct-1)*(bct-1))> list3[cta]+bct*bct){
				bct--;
				ans += list4[cta]-list3[cta];
				ansmax = Math.Max(ans+bct*bct,ansmax);
				cta++;
			} else if(list4[cta] > list3[cta]){
				bct--;
				ans += list4[cta]-list3[cta];
				ansmax = Math.Max(ans+bct*bct,ansmax);
				cta++;
			} else {
				break;
			}
		}
		Console.WriteLine(ansmax);
	}
}

Measured memory_bytes: 33028
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr ll mod = (ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int H, W; cin >> H >> W;
	Graph dp(10, vector<int>(10));
	vector<vector<int>>vec(H, vector<int>(W));
	rep(i, 0, 10) {
		rep(j, 0, 10) {
			int a; cin >> a;
			dp[i][j] = a;
		}
	}
	rep(i, 0, H)rep(j, 0, W)cin >> vec[i][j];
	rep(i, 0, 10)dp[i][i] = 0;
	rep(k, 0, 10) {
		rep(i, 0, 10) {
			rep(j, 0, 10) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	ll ans = 0;
	rep(i, 0, H) {
		rep(j, 0, W) {
			if (vec[i][j] == -1)continue;
			ans += dp[vec[i][j]][1];
		}
	}
	cout << ans << "\n";

	return 0;
}

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

const ll MOD = 1e9 + 7;

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

int main() {
    string l;
    cin >> l;
    int n = l.size();
    ll cnt = 0, ans = 0;
    rep(i, n) {
        if (l[i] == '0') continue;
        cnt++;
        ll rest = n - i - 1;
        ans += (modpow(2, cnt - 1) * modpow(3, rest)) % MOD;
        ans %= MOD;
    }
    ans += modpow(2, cnt);
    cout << ans % MOD << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

 #define rep(i,n) for (int i = 0; i < (n); i++)
 using namespace std;
 using ll = long long;

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

     int w[n];
     ll v[n];

     rep(i,n) cin >> w[i] >> v[i];

     ll dp[n+1][W+1];

     rep(j, W) dp[0][j] = -1;
     dp[0][W] = 0;

     for (int i = 0; i < n; i++) {
         for (int k = 0; k <= W; k++) {
             dp[i + 1][k] = dp[i][k];
             if (k - w[i] >= 0 && dp[i][k] >= 0) {
                 dp[i + 1][k - w[i]] = max(dp[i+1][k-w[i]], dp[i][k] + v[i]);
             }
         }
     }

     ll ans = 0;
     for (int k = 0; k <= W; k++) {
         if (ans < dp[n][k]) {
             ans = dp[n][k];
         }
     }

     cout << ans << endl;

     return 0;
 }


Measured memory_bytes: 81928
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ld> A(N);
    cout << fixed << setprecision(10);
    for(ll i=0;i<N;++i)cin>>A[i];
    ld L=0.1,R=2000000000;
    for(ll i=0;i<1000;++i){
        ld M=(L+R)/2;
        ll count=0;
        for(ll j=0;j<N;++j){
            
            count+=(ll)((A[j]-eps)/M);
        }
        //debug(count);
        //debug(M);
        if(count>K)L=M;
        else R=M;
    }
    ll m=(R-eps);
    //prt(R);
    prt(m+1);

    return 0;
}



Measured memory_bytes: 6460
//code by lynmisakura.wish to be accepted
/****************************/
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define itn int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 200020
int par[MAX_N];
int main(void){
	
	int n;cin >> n; int qe;cin >> qe;
	vector<vector<int>> T(n,vector<int>(0));
	rep(i,n-1){
		int a,b;cin >> a >> b;
		a--,b--;
		T[a].pb(b);T[b].pb(a);
	}
	vector<int> parent(n,-1);
	vector<ll> p(n,0LL);
	rep(i,qe){
		ll a,x;cin >> a >>x;
		a--;
		p[a] += x;
	}
	
	
	vector<ll> ans(n,0LL);
	
	
	queue<int> q;
	q.push(0);
	vector<int> check(n,0);
	check[0] = 1;
	q.push(0);
	parent[0] = 0;
	ans[0] = p[0];
	while(!q.empty()){
		int x = q.front(); q.pop();
		check[x] = 1;
		for(int i = 0;i < T[x].size();i++){
			if(check[T[x][i]] == 0){
				q.push(T[x][i]);
				ans[T[x][i]] = ans[x] + p[T[x][i]];
			}
		}
	}
	//rep(i,n) debug(p[i]);
	rep(i,n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 20212
#include<bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
  int main()
{
  string S,T,ans="UNRESTORABLE";
  int W=0;
  cin>>S>>T;
  
  for(int i=0;i<S.size();i++){
    W=0;
    for(int j=0;j<T.size();j++){
      if(S[i+j]==T[j]||S[i+j]=='?'){
        W++;
      }else{
        break;
      }
    }
    if(W==T.size()){
      ans=S;
      for(int j=0;j<S.size();j++){
        if(ans[j]=='?')ans[j]='a';
      }
      for(int j=0;j<T.size();j++){
        ans[j+i]=T[j];
      }
      ans[S.size()]='\0';
    }
  }
  cout<<ans;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

#if INPUT_FROM_FILE
#define IS ifs
#else
#define IS std::cin
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs = std::ifstream("test.txt");
#endif
	int n = 0;
	int q = 0;
	std::queue<std::pair<std::string, int> > queue;
	std::string name;
	int time = 0;

	IS >> n >> q;
	
	for(int i = 0; i < n; i++){
		IS >> name >> time;
		queue.push(std::pair<std::string, int>(name, time));
	}

	time = 0;
	for(int i = 0; !queue.empty(); i++){
		std::pair<std::string, int> job = queue.front();
		queue.pop();

		if(job.second <= q){
			time += job.second;
			std::cout << job.first << " " << time << std::endl;
		}
		else{
			job.second -= q;
			time += q;
			queue.push(job);
		}
	}
	
	return 0;
}

Measured memory_bytes: 6240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<ctype.h>
#define PI 3.141592653589
#define N_MAX 1001
#define NUM 26

int main()
{
  char buf[N_MAX], c;
  int a[NUM], tmp, i = 0, j;
  for(j = 0; j < NUM; j++)
    {
      a[j] = 0;
    }
  while((c = getchar()) != EOF)
    {
      buf[i] = tolower(c);
      if(isalpha(buf[i]) != 0)
	{
	  tmp = buf[i] - 'a';
	  a[tmp]++;
	}
      i++;
    }
  for(j = 0; j < NUM; j++)
    {
      printf("%c : %d\n",j + 'a', a[j]);
    }
  return 0; 
}

Measured memory_bytes: 524
#include <stdio.h>

int N, M, D;
char kaizyou[128][128];
int aki_count[256][256];

int main(void) {
	int i, j;
	int answer = 0;
	if (scanf("%d%d%d", &N, &M, &D) != 3) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%s", kaizyou[i] + 1) != 1) return 1;
	}

	for (i = 1; i <= N; i++) {
		for (j = 1; j <= M; j++) {
			aki_count[i][j] = (kaizyou[i][j] != '#');
		}
	}
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= M + D; j++) aki_count[i][j] += aki_count[i][j - 1];
	}
	for (j = 1; j <= M; j++) {
		for (i = 1; i <= N + D; i++) aki_count[i][j] += aki_count[i - 1][j];
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			if (aki_count[i + 1][j + D] - aki_count[i][j + D] - aki_count[i + 1][j] + aki_count[i][j] == D) answer++;
			if (aki_count[i + D][j + 1] - aki_count[i][j + 1] - aki_count[i + D][j] + aki_count[i][j] == D) answer++;
		}
	}

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

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

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9
#define PI 3.14159265359
#define mod 1000000007
#define ll long long int

int main(){
    ll N,K;
    cin >> N >> K;
    ll res = 0;
    for(int i = K; i <= N+1; i++){
        ll temp = i*(N-i+1)+1;
        res += temp % mod ;
        res %= mod;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  double w;
  while(scanf("%lf",&w)!=EOF){
    if(w>91){
      printf("heavy");
    }else if(w>81){
      printf("light heavy");
    }else if(w>75){
      printf("middle");
    }else if(w>69){
      printf("light middle");
    }else if(w>64){
      printf("welter");
    }else if(w>60){
      printf("light welter");
    }else if(w>57){
      printf("light");
    }else if(w>54){
      printf("feather");
    }else if(w>51){
      printf("bantam");
    }else if(w>48){
      printf("fly");
    }else{
      printf("light fly");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 616
#include <iostream>
using namespace std;
int main(void) {
	int a, b, c, n;
	cin >> a >> b >> c >> n;
	if (a > b) {
		if (a > c) {
			for (int i = 0; i != n; i++) {
				a = a * 2;
			}
			cout << a + b + c << '\n';
		}
		else {
			for (int i = 0; i != n; i++) {
				c = c * 2;
			}
			cout << a + b + c << '\n';
		}
	}
	else {
		if (b > c) {
			for (int i = 0; i != n; i++) {
				b = b * 2;
			}
			cout << a + b + c << '\n';
		}
		else {
			for (int i = 0; i != n; i++) {
				c = c * 2;
			}
			cout << a + b + c << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#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
using namespace std;

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

	char s[100001];
	cin>>s;
	int i=0;
	int c=0;
	vector<char> a;
	vector<int> x;
	while(s[i]!='\0'){
		if(s[i]=='x'){
			c++;
		}else{
			a.push_back(s[i]);
			x.push_back(c);
			c=0;
		}
		i++;
	}
	x.push_back(c);
	/*
	rep(i,a.size()){
		cout<<a[i]<<endl;
	}
	cout<<endl;
	rep(i,x.size()){
		cout<<x[i]<<endl;
	}
	*/
	int as=a.size();
	rep(i,as/2){
		if(a[i]!=a[as-1-i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	int xs=x.size();
	int ans=0;
	rep(i,xs/2){
		ans+=max(x[i]-x[xs-1-i],x[xs-1-i]-x[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007
    #define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
    #define GCD(m,n) __gcd(m,n)
    #define LCM(m,n) m*(n/GCD(m,n))
    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n;
        cin>>n;
        vi a(n);
        inputarr(a,n);
        int count=0;
        rep(1,n-1){
            vi temp={a[i-1],a[i],a[i+1]};
            sort(all(temp));
            if(temp[1]==a[i]&&temp[1]!=temp[2]&&temp[1]!=temp[0]) count++;         
     }
     cout<<count;
        }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256
#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))


//21:43
//21:52 compiled
//21:54 passed sample

struct unifo{
	int n;
	int uni[100005];
	void init(int in){
		n=in;
		rep(i,n)uni[i]=i;
	}
	int find(int p){
		if(uni[p]==p)return p;
		else return (uni[p]=find(uni[p]));
	}
	void mer(int p,int q){
		if(!same(p,q))uni[find(p)]=find(q);
	}
	bool same(int p,int q){
		return find(p)==find(q);
	}
	void out(){
		vector<mp> ps;
		//printf("%d %d\n",i,find(i));
		rep(i,n)ps.push_back(mp(find(i),i));
		sort(ps.begin(),ps.end());
		printf("uni .. %d elem\n{ ",n);
		rep(i,n){
			if(i!=0 && ps[i-1].fir!=ps[i].fir)printf("}\n{ ");
			printf("%d ",ps[i].sec);
		}
		printf("}\n\n");
	}
} uni;


int n,w,h;

typedef pair<mp,int> mmp;
mp xs[40005];
mp ys[40005];

int gone[40005]={};

int main(void){
	scanf("%d%d%d",&n,&w,&h);
	uni.init(n+10);
	
	bool isw=false;
	rep(i,n){
		int x,y;
		scanf("%d%d",&x,&y);
		xs[i]=mp(x,i);
		ys[i]=mp(y,i);
		if(x==1 || x==w)isw=true;
		if(y==1 || y==h)isw=true;
	}
	sort(xs,xs+n);
	sort(ys,ys+n);
	
	rep(i,n-1){
		if(xs[i].fir==xs[i+1].fir)uni.mer(xs[i].sec,xs[i+1].sec);
		if(ys[i].fir==ys[i+1].fir)uni.mer(ys[i].sec,ys[i+1].sec);
	}
	
	int gn=0;
	rep(i,n){
		int p = uni.find(i);
		if(gone[p])continue;
		gone[p]=1; gn++;
	}
	
	int ans=n-1+gn;
	if(gn==1 || isw)ans--;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int n;    cin>>n;
    double ans=0;
    vector<int> v(n);
    for(int i=0;i<n;++i){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ans+=(v[0]+v[1]);
    ans/=(double)(pow(2,n-1));
    for(int i=2;i<n;++i){
        ans+=(v[i]/(double)(pow(2,n-i)));
    }
    cout<<ans;
}

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

#define rep(i, a, b) for(int i = a;i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
typedef vector<int> vi;

int n;

bool is_prime(int x){
    if(x == 1)
        return false;
    for(int i = 2;i * i <= x;i++){
        if(x % i == 0)
            return false;
    }
    return true;
}

bool find(int j, vector<vi>& g, vi& btoa, vi& vis) {
	if (btoa[j] == -1) return 1;
	vis[j] = 1; int di = btoa[j];
	trav(e, g[di])
		if (!vis[e] && find(e, g, btoa, vis)) {
			btoa[e] = di;
			return 1;
		}
	return 0;
}
int dfsMatching(vector<vi>& g, vi& btoa) {
	vi vis;
	rep(i,0,sz(g)) {
		vis.assign(sz(btoa), 0);
		trav(j,g[i])
			if (find(j, g, btoa, vis)) {
				btoa[j] = i;
				break;
			}
	}
	return sz(btoa) - (int)count(all(btoa), -1);
}

void insert(set<int> &s, int x){
    if(s.find(x) != s.end())
        s.erase(x);
    else
        s.insert(x);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    set<int> odd, even;
    for(int i = 1;i <= n;i++){
        int x;
        cin >> x;
        if(x & 1){
            insert(odd, x);
            insert(even, x + 1);
        }else{
            insert(odd, x + 1);
            insert(even, x);
        }
    }
    vi a, b;
    for(auto it : odd){
        a.push_back(it);
    }
    for(auto it : even){
        b.push_back(it);
    }
    vector<vi> g;
    for(int i = 0;i < a.size();i++){
        vi adj;
        for(int j = 0;j < b.size();j++){
            int u = a[i], v = b[j];
            if(is_prime(abs(u - v))){
                adj.push_back(j);       
            }  
        }
        g.push_back(adj);
    }
    vi btoa(b.size(), -1);
    int k = dfsMatching(g, btoa);
    int ans = k + ((a.size() - k) / 2 + (b.size() - k) / 2) * 2 + ((a.size() - k) % 2) * 3;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
n=int(input())
s=input()

r=0
g=0
b=0
count=0

for i in s:
  if i == "R":
    r += 1
  elif i == "G":
    g += 1
  elif i == "B":
    b += 1

count = r*g*b

# k-j==j-iの場合を引く
for i in range(n-2):
  si = s[i]
  for j in range(i+1,i+(n-i-1)//2+1):
    if si != s[j]:
      sj = s[j]
      k = j+(j-i)
      if s[k] != si and s[k] != sj:
        count -= 1
        
print(count)

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

using namespace std;

long long xorsum(long long in) {
  if (in <= 0) {
    return 0;
  }
  
  if (in % 4 == 0) {
    return in;
  }
  
  if (in % 4 == 1) {
    return in ^ (in - 1);
  }
  
  if (in % 4 == 2) {
    return in ^ (in - 1) ^ (in - 2);
  }
  
  if (in % 4 == 3) {
    return 0;
  }
}

int main() {
  long long A, B;
  
  cin >> A >> B;
  
  cout << (xorsum(B) ^ xorsum(A - 1)) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    int n;
    cin>>n;
    
    int c4=0,c2=0,c=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a%4==0) c4++;
        else if(a%2==0) c2++;
        else c++;
    }

    if(c2==0){
        if(c4>=c-1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        if(c4>=c) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const double PI = acos(-1);

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x / a;
  double rad;
  if(s >= a* b / 2){
    long double h = (a * b - s) * 2 / a;
    rad = atan2(h,a);
  }else{
    long double w = 2 * s / b;
    rad = atan2(b, w);
  }
  double ans = rad / (2 * PI) * 360;
  printf("%.10f\n", ans);
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    for (int i=0; i<N; ++i) cin >> h[i];

    long long int dp[N];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    
    for (int i=2; i<N; ++i) {
        long long int minl = 1000000000000;
        for (int j=i-1; j>=max(0, i-K); --j) {
            minl = min(minl, dp[j] + abs(h[i]-h[j]));
        }
        dp[i] = minl;
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1408
import heapq


def dijkstra(graph, node, start):
    dist = [float("inf") for _ in range(node)]
    dist[start] = 0
    q = []
    heapq.heappush(q, (0, start))
    while q:
        cost, cur_node = heapq.heappop(q)
        if dist[cur_node] < cost:
            continue
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heapq.heappush(q, (dist[nex_node], nex_node))
    return dist


(n, m) = map(int, input().split())
adj = [[] for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append((c, b))
    adj[b].append((c, a))

shortest = []
for i in range(n):
    shortest.append(dijkstra(adj, n, i))

ans = 0
for i in range(n):
    for cost, j in adj[i]:
        if cost > shortest[i][j]:
            ans += 1
print(ans // 2)


Measured memory_bytes: 3572
function Main(input) {
  const num = input.split(" ");
  const result = num[0] * num[1];
  if (result % 2 === 0) {
    console.log("Even");
  } else {
    console.log("Odd");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 1) ans += 300000;
  if (y == 1) ans += 300000;
  if (x == 2) ans += 200000;
  if (y == 2) ans += 200000;
  if (x == 3) ans += 100000;
  if (y == 3) ans += 100000;
  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
rect = [[1]*h for _ in range(w)]

for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for xx in range(x):
            for yy in range(h):
                rect[xx][yy] = 0
    elif a == 2:
        for xx in range(x, w):
            for yy in range(h):
                rect[xx][yy] = 0
    elif a == 3:
        for xx in range(w):
            for yy in range(y):
                rect[xx][yy] = 0
    else:
         for xx in range(w):
             for yy in range(y, h):
                 rect[xx][yy] = 0

ans = 0
for xx in range(w):
    for yy in range(h):
        ans += rect[xx][yy]

print(ans)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d %d", $n, $k);
$p = 0;
for($i=1; $i<=$n; $i++){
	$score = $i;
	$count = 0;
	while($score<$k){
		$score *= 2;
		$count++;
	}
	$p += 1/(2**$count);
}
echo $p/$n;


Measured memory_bytes: 4732
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 101
using namespace std;
short n,m,f[N][N][N][N],sx,sy,h[N][N],L[N][N];
char s[N][N];
void upd(short &x,short y)
{
	if(x<y) x=y;
}
int main()
{
	cin>>n>>m;
	for(short i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(short j=1;j<=m;j++) if(s[i][j]=='E') sx=i,sy=j;
	}
	for(short i=1;i<=n;i++)
		for(short j=1;j<=m;j++)
		{
			L[i][j]=L[i-1][j];
			h[i][j]=h[i][j-1];
			if(s[i][j]=='o') h[i][j]++,L[i][j]++;
		}
	short ln=m-sy,rn=sy-1,un=n-sx,dn=sx-1;
	for(short i=0;i<=ln;i++)
		for(short j=0;j<=rn;j++)
			for(short x=0;x<=un;x++)
				for(short y=0;y<=dn;y++)
				{
					short t,now,l,r;
					if(i<ln)
					{
						now=sy+i+1;t=0;
						if(now+j<=m)
						{
							l=max(sx-y,x+1);r=min(sx+x,n-y);
							if(l<=r) t=L[r][now]-L[l-1][now];
						}
						upd(f[i+1][j][x][y],f[i][j][x][y]+t);
					}
					if(j<rn)
					{
						now=sy-j-1;t=0;
						if(now-i>=1)
						{
							l=max(sx-y,x+1);r=min(sx+x,n-y);
							if(l<=r) t=L[r][now]-L[l-1][now];
						}
						upd(f[i][j+1][x][y],f[i][j][x][y]+t);
					}
					if(i==1 && j==0 && x==0 && y==1)
					{short oo=1;}
					if(x<un)
					{
						now=sx+x+1;t=0;
						if(now+y<=n)
						{
							l=max(sy-j,i+1);r=min(sy+i,m-j);
							if(l<=r) t=h[now][r]-h[now][l-1];
						}
						upd(f[i][j][x+1][y],f[i][j][x][y]+t);
					}
					if(y<dn)
					{
						now=sx-y-1;t=0;
						if(now-x>=1)
						{
							l=max(sy-j,i+1);r=min(sy+i,m-j);
							if(l<=r) t=h[now][r]-h[now][l-1];
						}
						upd(f[i][j][x][y+1],f[i][j][x][y]+t);
					}
					if(f[1][0][1][1]==4)
					{short oo=1;}
				}
	cout<<f[ln][rn][un][dn]<<endl;
	return 0;
}

Measured memory_bytes: 198912
#include <cstdio>
#include<iomanip>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

main(){
	int n;
	cin >> n;
	double a[n];
	double ans_inv=0;
	double ans;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans_inv+=1/a[i];
	}
	ans=1/ans_inv;
	cout << setprecision(10) << ans <<endl;
	
	
}


Measured memory_bytes: 256
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=4100000,mod=1e9+7;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,k,f[2010][2010],fac[maxn],inv[maxn];
inline int pls(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int c(int n,int m){return m>n?0:(ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}
int power(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=(ll)x*x%mod)
	  if(y&1)
	    res=(ll)res*x%mod;
	return res;
}
int init(int n)
{
	fac[0]=1;
	for(rg int i=1;i<=n;i++) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=power(fac[n],mod-2);
	for(rg int i=n-1;~i;i--) inv[i]=(ll)inv[i+1]*(i+1)%mod;
}
int main()
{
	read(n);read(k);
	if(k==1){puts("1");return 0;}
	init(n*k+k+k);
	f[0][0]=1;
	for(rg int i=0;i<=n;i++)
	  for(rg int j=i;j<=n;j++)
	  {
	  	if(i) f[i][j]=f[i-1][j];
	  	if(j) f[i][j]=pls(f[i][j],(ll)f[i][j-1]*c(i+(j-1)*(k-1)+k-2,k-2)%mod);;
	  }
	printf("%lld\n",(ll)f[n][n]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 47616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

PDD solve(double p1x, double p1y, double p2x, double p2y, double px, double py) {
	PDD re;

	if (p1x == p2x) {
		re = mp(p1x, py);
	}
	else if (p1y == p2y) {
		re = mp(px, p1y);
	}
	else {
		double l1s, l1y, l2s, l2y;
		l1s = (p1y - p2y) / (p1x - p2x);
		l1y = p1y + l1s * (p1x * -1);
		l2s = (1 / l1s)*-1;
		l2y = py + l2s * (px*-1);

		//cout << "line1 : y=" << l1s << "*x+" << l1y << endl;
		//cout << "line2 : y=" << l2s << "*x+" << l2y << endl;

		double ax, ay;
		ax = (l2y - l1y) / (l1s - l2s);
		ay = l1s * ax + l1y;
		re = mp(ax, ay);
	}

	return re;
}


int main() {
	double w, x, y, z; cin >> w >> x >> y >> z;
	int q; cin >> q;
	rep(i, q) {
		double a, b; cin >> a >> b;
		PDD ans = solve(w, x, y, z, a, b);
		printf("%.20f %.20f\n", ans.first, ans.second);
	}
}


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

using namespace std;

int s[10] = {0,2,5,5,4,5,6,3,7,6};

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

	vector<int> A(M);
	for(auto &x: A) cin >> x;

	//N本K桁(桁の最大は全て1を使った場合のN/2桁)
	vector<vector<int> > dp(N / 2 + 1, vector<int> (N + 1, 0));


	for(int i = 0 ; i <= N / 2; i++) {
		for(int j = 2; j <= N; j++) {
			for(int k = 0; k < M; k++) {
				if(j - s[A[k]] < 0) continue;
				if(i == 0) dp[i][j] = j == s[A[k]] ? max(dp[i][j], A[k]) : dp[i][j];
				else if(dp[i - 1][j - s[A[k]]] != 0) dp[i][j] = max(dp[i][j], A[k]);
			}
		}
	}

	int i = N / 2, j = N;
	while(dp[i][j] == 0) i--;
	while(j > 0) {
		if(dp[i][j] == 0) break;
		cout << dp[i][j];
		j -= s[dp[i][j]];
		i--;
	}
	cout << endl;
}


Measured memory_bytes: 195840
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
#include <random>


#pragma warning(disable: 4996)

using namespace std;
using LL = long long;
const int MAX = 210000;
const LL base = LL(1e9 + 7);

inline void mod_add(LL & a, const LL& b) { a = (a + b) % base; }
inline void mod_mul(LL & a, const LL& b) { a = (a*b) % base; }

using VI = vector<int>;
using VVI = vector< VI >;
using VL = vector<LL>;
using PII = pair<int, int>;
using VPII = vector< PII >;

template <typename T> inline void max_s(T&a, const T&b) { a = max(a, b); }
template <typename T> inline void min_s(T&a, const T&b) { a = min(a, b); }

template <typename T>  void sort_v(T & x) { sort(x.begin(), x.end()); }
template <typename T>  void erase_dup(T & x) { x.erase(unique(x.begin(), x.end()), x.end()); }    // erase duplicate
template <typename T, typename V>  int pos_l(const T & x, const V & v) { return lower_bound(x.begin(), x.end(), v) - x.begin(); }
template <typename T, typename V>  int pos_u(const T & x, const V & v) { return upper_bound(x.begin(), x.end(), v) - x.begin(); }

inline unsigned rand_g() {
	static mt19937 mt_rand((int)time(0));
	return mt_rand();
}

struct Node {
	int x, y, w;
};
bool operator < (const Node & n0, const Node & n1) {
	return n0.x< n1.y;
}

void solve() {

	LL result = 0;
	int n, q;

	cin >> n>> q;
	VL za(n);
	VL zpre(n + 1);
	VL zfi(n+1);
	for (int i = 0; i < n; ++i) {
		cin >> za[i];
		zpre[i + 1] = zpre[i] + za[i];
		zfi[i + 1] = zfi[i];
		if (i % 2 != n % 2) {
			zfi[i + 1] += za[i];
		}
	}
	LL x;

	auto work = [&](int f) {
		if (n < 2 * f - 1) return false;
		//if (za[n - 2 * f + 1] >= x) return true;
		LL d1 = abs(x - za[n - f]);
		LL d2 = abs(x - za[n - 2 * f + 1]);
		if (d2 <= d1) return true;
		return false;
	};

	for (int ggg = 0; ggg < q; ++ggg) {
		cin >> x;
		int u0, u1;
		u0 = 1; 
		u1 = n / 2 + 2;
		while (u0 + 1 < u1) {
			int mid = (u0 + u1) / 2;
			auto ok = work(mid);
			if (ok) {
				u0 = mid;
			}
			else {
				u1 = mid;
			}
		}
		auto r = zpre[n] - zpre[n - u0];
		r += zfi[n - u0 * 2 + 1];
		cout << r << '\n';
	}

	 
}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);
		if (r == nullptr) {
			cerr << "invalid input file " << s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr << "invalid output file " << s;
		}
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;


int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  swap(X,Y);
  swap(X,Z);
  printf("%d %d %d",X,Y,Z);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N, W;
	cin >> N >> W;
	vector<int> v(N), w(N);
	REP(i, N) {
		cin >> v[i] >> w[i];
	}
	static int dp[101][10001];
	auto update = [](int &a, int b) { return a = max(a, b); };
	REP(i, N) {
		FOR(j, 1, W + 1) {
			dp[i + 1][j] = dp[i][j];
			if (w[i] <= j) {
				update(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;

	return 0;
}


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

bool a[1000001] = {false};

int f(int n){
    if (n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int main(void)
{
    int s;
    cin >> s;
    a[s] = true;
    int no = 1;
    while(1){
        no++;
        s = f(s);
        if (a[s] == true) break;
        a[s] = true;
    }
    cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_cumu = [0] + list(accumulate(A))
B_cumu = [0] + list(accumulate(B))

curr_max = 0
for i in range(N + 1):
    curr = A_cumu[i]
    if curr > K:
        break
    j = bisect_right(B_cumu, K - curr) - 1
    curr_max = max(curr_max, i + j)

print(curr_max)


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

int n, k, a[5010], ans;
short fdp[5010][5010], bdp[5010][5010];

int main(){
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	fdp[0][0] = bdp[n + 1][0] = 1;
	for(int i = 1, b = n; i <= n; i++, b--){
		for(int j = 0; j < k; j++){
			fdp[i][j] = (j < a[i] ? 0 : fdp[i - 1][j - a[i]]) || fdp[i - 1][j];
			bdp[b][j] = (j < a[b] ? 0 : bdp[b + 1][j - a[b]]) || bdp[b + 1][j];
		}
	}
	for(int i = 1; i <= n; i++){
		for(int j = k - 1; j >= 0; j--){
			fdp[i][j] = fdp[i][j] + fdp[i][j + 1];
			bdp[i][j] = bdp[i][j] + bdp[i][j + 1];
		}
	}
	for(int i = 1; i <= n; i++){
        if(a[i] >= k){ ans++; continue; }
        for(int j = 0; j <= k; j++){
			if((fdp[i - 1][j] - fdp[i - 1][j + 1]) && (bdp[i + 1][max(0, k - a[i] - j)] - bdp[i + 1][k - j]))
				{ ans++; break; }
        }
	}
	printf("%d\n", n - ans);
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
int a[N];

int b[N];
char s[N];
char t[N];
ll f[N];
int used[15];
int cmp1(ll a,ll b)
{
    return b<a;
}

multiset<int> ss;
map<int,int>mp;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=k+1;i<=n;i++){
        if(a[i]>a[i-k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }



}


Measured memory_bytes: 4396
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int M, X, ans = 0;
        {int[] a = r.ii(); M = a[1]; X = a[2];}
        int[] A = r.ii();
        for(int i = 0; i < M; i++){
            if(X < A[i]){
                ans = Math.min(i, M-i);
                break;
            }                 
        }
        print(ans);
    }

    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int Int(String s){
            return Integer.parseInt(s);
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

Measured memory_bytes: 23252
import queue

K = int(input())
L = queue.Queue()

for i in range(1,10):
  L.put(i)
for i in range(K-1):
  x = L.get()
  p = 10*x
  m = x%10
  if m != 0:
    L.put(p+m-1)
  L.put(p+m)
  if x%10 != 9:
    L.put(p+m+1)
print(L.get())
    

Measured memory_bytes: 12504
n = int(input())
input_str = input()
left_black = 0
right_white = input_str.count('.')
ans = [left_black + right_white]

for s in input_str:
  if( s == '#' ):
    left_black += 1
  if( s == '.' ):
    right_white -= 1
  ans.append(left_black + right_white)
print(min(ans))

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int n , x;
    cin >> n >> x;
    ll count = 0;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    if(a[0] > x){
        count += a[0] - x;
        a[0] = x;
    }
    for(int i = 1; i < n; i++){
        if(a[i] + a[i - 1] > x){
            count += a[i] + a[i - 1] - x;
            a[i] -= a[i] + a[i - 1] - x;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4056
import sys

str_input = input()
n = int(str_input)

str_input = input()
v = []
for value in str_input.split():
    v.append(int(value))

str_input = input()
c = []
for value in str_input.split():
    c.append(int(value))

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

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   int l;cin>>l;
   cout.precision(8);
   cout<<(l/3.0)*(l/3.0)*(l/3.0);
   
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string s;
    cin >> s;

    int ans = 0;
    if(s.size() == 1){
        ans = s[0] - '0';
    }else{
        ans = 9 * (s.size() - 1);
        bool nine = true;
        for (int i = 1; i < s.size(); ++i) {
            if(s[i] != '9'){
                nine = false;
            }
        }

        ans += s[0] - '0';

        if(!nine){
            ans--;
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b,c;cin>>a>>b>>c;
    bool f=false;
    for(int i=1;i<=b;i++){
        if((i*a)%b==c) f=true;
    }
    if(f) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

int main() {
  int N;
  vector<int> a(100);
  int score = 0;
  
  cin >> N;
  
  for (int i = 0; i < N; i++)
    cin >> a.at(i);
  
  sort (a.begin() , a.end());
  reverse (a.begin() , a.end());
  
  for (int i = 0; i < N; i++) {
    if (i % 2)
      score -= a.at(i);
    else score += a.at(i);
  }
  cout << score << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, m;
ll x[101010], y[101010];
ll cnt[101010];
bool red[101010];

int main() {
    cin>>n>>m;
    REP(i, 0, m){
        ll xx, yy;
        cin>>xx>>yy;
        x[i]=xx-1; y[i]=yy-1;
    }

    REP(i, 0, n) cnt[i]=1;
    red[0]=true;

    REP(i, 0, m){
        if(red[x[i]]){
            red[y[i]]=true;
            if(cnt[x[i]]<=1){
                red[x[i]]=false;
            }
        }
        cnt[x[i]]--;
        cnt[y[i]]++;
    }

    ll sum=0;
    REP(i, 0, n){
        if(red[i]) sum++;
    }
    cout<<sum<<endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define N 1503
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef pair<int,int> pii;
typedef long long int ll;
typedef long int li;
int mod1 = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 200008
int n,m,q;
int arr[maxn];
int sum[maxn];
int cha[maxn];
vector<int> v1[maxn];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		v1[a].push_back(b);
	}
	for(int i=1;i<=n;i++){
		sort(v1[i].begin(),v1[i].end());
	}
	int ans=0;
	for(int i=1;i<=q;i++){
		int a,b;
		ans=0;
		scanf("%d%d",&a,&b);
		for(int j=a;j<=b;j++){
			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8320
import itertools
n = int(input())
s = [input()[0] for _ in range(n)]
c = list(itertools.combinations(set(filter(lambda x: x in "MARCH", s)), 3))

ans = 0
for _c in c:
    ans += s.count(_c[0])*s.count(_c[1])*s.count(_c[2])
print(ans)


Measured memory_bytes: 3888