akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> RiffleShuffle(int, vector<int>);

int main(){
  int i, n, r, c;
  vector<int> data;

  while(cin >> n >> r){
    for(i=0; i<n; ++i)
      data.push_back(i);

    for(i=0; i<r; ++i){
      cin >> c;
      data = RiffleShuffle(c, data);
    }

    cout << data[data.size()-1] << endl;
    data.clear();
  }

  return 0;
}

vector<int> RiffleShuffle(int c, vector<int> data){
  vector<int> A, B, C;

  copy(data.begin()+data.size()/2, data.end(), back_inserter(A));
  copy(data.begin(), data.begin()+data.size()/2, back_inserter(B));

  while(A.size() > c || B.size() > c){
    copy(A.begin(), A.begin()+c, back_inserter(C));
    A.erase(A.begin(), A.begin()+c);
    copy(B.begin(), B.begin()+c, back_inserter(C));
    B.erase(B.begin(), B.begin()+c);
  }

  copy(A.begin(), A.end(), back_inserter(C));
  copy(B.begin(), B.end(), back_inserter(C));

  return C;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  string S;
  cin >> S;
  if (S.length()<=K){
    cout << S;
  }
  else{
    for (int i=0; i<K; i++){
      cout << S[i];
    }
    cout << "...";
  }
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define len(x) (int)(x).size()



using namespace std;
//#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
#define int long long
const int N = 1e3 + 10 , MOD = (int)1e9 + 7;
int dp[2][N];

int C[N][N] , fact[N] , inv[N] , cnt[N][N], PW[N][N];
inline int sum(int x , int y){
    x += y;if(x >= MOD)x-=MOD;
    return x;
}
inline int mult(int x , int y){
    return (1ll * x * y) % MOD;
}

int pw(int a , int b){
    if(b == 0)return 1;
    int ans = pw(a , b >> 1);
    ans = mult(ans , ans);
    if(b & 1){
        ans = mult(ans , a);
    }
    return ans;
}
inline int INV(int x){
    return pw(x , MOD - 2);
}

void prec(){
    for(int i = 0 ; i < N; ++i){
        C[i][0] = 1;
        for(int j = 1; j <= i; ++j){
            C[i][j] = sum(C[i-1][j-1], C[i-1][j]);
        }
    }
    fact[0] = 1;
    for(int i = 1; i < N; ++i)
        fact[i] = mult(fact[i - 1] , i);
    inv[N - 1] = INV(fact[N - 1]);
    for(int i = N - 2; i >= 0;--i){
        inv[i] = mult(inv[i + 1] , i + 1);
        assert(inv[i] == INV(fact[i]));
    }



    for(int i = 0 ; i < N; ++i){
        for(int j = 1; j <= i; ++j){
            if(i % j ==0){
                cnt[i][j] = mult(mult(fact[i],pw(inv[j] , i / j)),inv[i/j]);
            }
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    prec();
//    cout << "LULZ\n";
    int n , a , b, c , d;cin >> n >> a >> b >> c >> d;
    dp[0][0] = 1;
    int bt = 1;

    for(int i = a; i <= b; ++i){
        for(int j = 0 ; j < N; ++j){
            dp[bt][j] = dp[bt^1][j];
        }
        int l = c , r = d;
        r = min(r , n / i);
        for(int cur = l ; cur <= r; ++cur){
            for(int k = 0; k <= n - cur * i;  ++k){
                dp[bt][k + cur * i] = sum(dp[bt][k+cur*i] , (1ll*dp[bt^1][k]*C[n-k][cur*i]%MOD*cnt[cur*i][i]%MOD));
            }
        }
//        cout << " LULZ " << i << '\n';
//        for(int j = 0 ; j <= 7; ++j)
//            cout << dp[bt][j] << ' ';
//        cout << '\n';
//        cout << " WTF \n";
        bt ^= 1;
    }
    cout << dp[bt^1][n];
    return 0;
}



Measured memory_bytes: 17352
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005],b[100005];
int main()
{
    int n;
    cin>>n;
    int sum=0;

    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
      sum=sum+b[i]-a[i]+1;
    }
      printf("%d\n",sum);

}


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

int main(){
  string s;
  cin>>s;
  char now=s[0];
  int ans=0;
  for(int i=1; i<s.size(); i++){
    if(now!=s[i]){
      ans++;
      now=s[i];
    }
  }
  cout<<ans<<endl;
}



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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  int ans=0;
  bool flag=false;
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  while(accumulate(h.begin(), h.end(), 0) != 0){
    for(int i=0;i<n;i++){
      if(h.at(i)>0){
        if(flag==false){
          flag=true;
          ans++;
        }
        h.at(i)--;
      }
      else if(h.at(i)==0 && flag==true){
        flag=false;
      }
    }
    flag=false;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 int main(){
     int a,b;
     cin>>a>>b;
     if((b+b)==a || (b+b)>a){
        cout<<0<<endl;
     }
     else{
        cout<<(a-(b+b))<<endl;
     }
     return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100003;

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

    int x;
    cin >> x;
    vector<bool> F(N + 1, true);
    for(int i = 2; i <= sqrt(N); i++){
        if(!F[i]) false;
        for(int j = i + i; j <= N; j += i){
            F[j] = false;
        }
    }

    for(int i = x; i <= N; i++){
        if(F[i]){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
S = input().strip()
N = len(S)+1
A = [0 for _ in range(N)]
flag = -1
B = []
for i in range(N-1):
    if flag==-1 and S[i]=="<":
        B.append(i)
        flag = 1
    elif flag==1 and S[i]==">":
        flag = -1
if flag==-1:
    B.append(N-1)
for b in B:
    for i in range(b,N-1):
        if S[i]=="<":
            A[i+1] = max(A[i+1],A[i]+1)
        else:break
    for i in range(b-1,-1,-1):
        if S[i]==">":
            A[i] = max(A[i],A[i+1]+1)
        else:break
print(sum(A))

Measured memory_bytes: 118596
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;

int main() {

	ll a, b, c, k;

	cin >> a >> b >> c >> k;

	char w[15] = "Unfair";


	if (k == 0) {
		if (a - b > INF) {
			cout << w << endl;
		}
		else {
			cout << a - b << endl;
		}
		return 0;
	}


	
		if (a-b > INF) {
			cout << w << endl;
		}
		else {
			if (k % 2 == 1) { cout << b - a << endl;
			}
			else {
				cout << a - b << endl;
			}
		}
	

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
c = gets.split(" ").map(&:to_i)

x = 0
a.each_with_index do |i, idx|
  if a[idx] + 1 == a[idx + 1]
    x += c[a[idx] - 1]
  end
end
puts b.inject(:+) + x


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


int main()
{
    int n,ans=0,x;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(i&1 && x&1) ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3500
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
// #MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(int argc, char const *argv[]) {
  float n;
  std::cin >> n;
  std::cout << n*2*M_PI << '\n';
  return 0;
}


Measured memory_bytes: 3804
using System;
using System.IO;
	class Program
	{
		public static void Main(string[] args)
		{
			double n=double.Parse(Console.ReadLine());
			int[] array= new int[(int)n];
			for(int k=0;k<array.Length;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			
			while((Math.Pow(3,m+1)-1)/2<n)//?????????m+1??????
			{
				m++;
			}
			
		/*	
			for(int gap=2;(Math.Pow(3,gap)-1)/2<n;gap++)
			{			
				m++;
			}
		*/	
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int s=0;s<G.Length;s++)
			{
				cnt+=sort( array, G[s]);//?????\???????????????????????????????????????????????´???????????????????????????????????????
				
				
				
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
Console.SetOut(sw);
/*????????????????????????*/
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			Console.Out.Flush();
			
		}
		public static int sort(int [] A,int g)
		{
			//g????????£??????
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				//?????\?????????
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0 &&
				       A[j]>v)//???&&????????§???????????????????????????
				{
					A[j+g]=A[j];
					
				A[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-g;
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				count ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 16804
s=int(input())
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1
a=[]
a.append(s)
i=1        
while True:
    x=f(a[i-1])
    if x in a:
        print(i+1)
        exit()
    else:
        a.append(x)
        i+=1


Measured memory_bytes: 2940
/* Author : Pranav Deshmukh
            PICT,Pune
   Purpose: Practice Atcoder
*/

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define dip(type,var)   type var; cin>>var;
#define dipi(x)			int x; cin>>x;
#define w(x)            int x; cin>>x; while(x--)
#define mka(arr,n,type) type *arr=new type[n];
#define fo(i,n)			for(int i=0;i<n;i++)
#define mod             pow(10,9)+7
#define inf             1e18
#define pi 				3.141592653589793238
#define fo(i,n)        for(int i=0;i<n;i++)
#define endl			"\n"
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mimp             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
	c_p_c();
	dipi(a);
	dipi(b);
	dipi(c);
	cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3576
L = int(input())

"""
max = 0
for a in range(L - 2 , 0, -1):
    for b in range(L - a, 0, -1):
        c = L - a - b
        if a * b * c > max:
            max = a * b * c
print(max)
"""

print((L/3) ** 3)


Measured memory_bytes: 2940
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

moduloN :: Int
moduloN = 10 ^ 9 + 7

modN = flip mod moduloN

mulMod x y = modN $ x * y

powerMod x 0 = 1
powerMod x y
    | even y = mulMod t t
    | otherwise = mulMod x $ mulMod t t
    where
        t = powerMod x $ div y 2

plusMod x y = modN $ x + y

minusMod x y | x < y = moduloN + x - y
             | otherwise = x - y

inv n = powerMod n $ moduloN - 2

comb n k | n - k < k = mulMod (foldr mulMod 1 [k+1..n]) . inv $ foldr mulMod 1 [1..n-k]
         | otherwise = mulMod (foldr mulMod 1 [n-k+1..n]) . inv $ foldr mulMod 1 [1..k]

main = do
    [n, a, b] <- getIntList
    print . minusMod ((powerMod 2 n) - 1) $ plusMod (comb n a) (comb n b)

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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  ll ans = 0;
  rep(i, n){
    ll a;
    cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))
const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

template <typename T> void print_vec(const vector<T>& v) {
	for(int i = 0; i < SZ(v); i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << "\n";
}

inline ll floorDiv(ll x, ll y) {
	ll d = x / y;
	ll r = x % y;
	return r ? (d - ((x < 0) ^ (y < 0))) : d;
}

ll ceilDiv(ll x, ll y) {
	return -floorDiv(-x,y);
}

bool predicate(ll mid) {
	return mid>10;
}

ll bin_search(ll lo, ll hi) {
	int sign = lo < hi ? 1 : -1;
	lo*=sign;
	hi*=sign;
	hi++;
	while(lo < hi) {
		ll mid = floorDiv(lo+hi,2);
		if (!predicate(sign*mid)) {
			lo = mid+1;
		} else {
			hi = mid;
		}
	}
	return sign*lo;
}
const ll MOD = 998244353;
const int MAXN = 200005;

typedef vector<ll> vll;
typedef vector<int> vi;
#define LSOne(S) ((S) & -(S)) 

class FenwickTree {                              // index 0 is not used
private:
  vll ft;                                        // internal FT is an array
public:
  FenwickTree(int m) { ft.assign(m+1, 0); }      // create an empty FT

  ll rsq(int j) {                                // returns RSQ(1, j)
    ll sum = 0;
    for (; j; j -= LSOne(j)) {
    	sum += ft[j];
    	sum=((sum%MOD)+MOD)%MOD;
    }      
    return sum;
  }

  ll rsq(int i, int j) { return (((rsq(j) - rsq(i-1))%MOD)+MOD)%MOD; } // inc/exclusion

  // updates value of the i-th element by v (v can be +ve/inc or -ve/dec)
  void update(int i, ll v) {
    for (; i < (int)ft.size(); i += LSOne(i)) {
    	ft[i] += v;
    	ft[i]=((ft[i]%MOD)+MOD)%MOD;
    }
  }

};

class RUPQ {                                     // RUPQ variant
private:
  FenwickTree ft;                                // internally use PURQ FT
public:
  RUPQ(int m) : ft(FenwickTree(m)) {}
  void range_update(int ui, int uj, ll v) {
    ft.update(ui, v);                            // [ui, ui+1, .., m] +v
    ft.update(uj+1, -v);                         // [uj+1, uj+2, .., m] -v
  }                                              // [ui, ui+1, .., uj] +v
  ll point_query(int i) { return ft.rsq(i); }    // rsq(i) is sufficient
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<pair<int,int>> ranges;
	while(k--) {
		int a, b;
		cin >> a >> b;
		ranges.emplace_back(a,b);
	}
	RUPQ ft(n);
	ft.range_update(1,1,1);
	for (int i = 1; i < n; i++){
		ll v = ft.point_query(i);
		for (auto p : ranges) {
			p.first+=i;
			p.second+=i;
			p.second = min(p.second, n);
			if (p.first > p.second) {
				continue;
			}
			ft.range_update(p.first,p.second,v);
		}		
	}
	
	cout << ft.point_query(n) << "\n";
	
	
	
}


Measured memory_bytes: 4772
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include<iomanip>
#include<map>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2; i*i <= n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main(){
  ll a, b;
  cin >> a >> b;

  if(a == 1 && b == 1) {
    cout << 1 << endl;
    return 0;
  }

  map<ll, ll> p_a = prime_factors(a);
  map<ll, ll> p_b = prime_factors(b);

  vector<ll> d_a, d_b;

  for(auto itr = p_a.begin(), end = p_a.end(); itr != end; ++itr) {
    d_a.push_back(itr->first);
  }

  for(auto itr = p_b.begin(), end = p_b.end(); itr != end; ++itr) {
    d_b.push_back(itr->first);
  }

  ll j = 0;
  ll ans = 1;
  for(ll i = 0; i < d_a.size(); ++i){
    if(d_a[i] == d_b[j]) {
        ++ans;
    }
    while(d_b[j] < d_a[i] && j < d_b.size()){
      ++j;
      if(d_a[i] == d_b[j]) {
        ++ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

template <typename T> void print(T x) { std::cout << x << '\n'; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T*)array, (T*)(array + N), val);
}
signed main(){
 int A,B,T;
  cin>>A>>B>>T;
  cout<<(T/A)*B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  long long int x;
  scanf("%lld", &x);
  long long int b = 100;
  int i = 0;
  while(b < x){
    b = b *1.01;
    i = i + 1;
  }
  printf("%d\n",i);
  return 0;
}

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

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

  vector<int64_t> lucas(87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i = 2; i <= N; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  cout << lucas.at(N) << endl;
}


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


int main() {
    int field[16][17], pattern[17][17];
    int X, Y, i, j, k;

    while ((cin >> X >> Y) && X) {
        for (i = 1; i <= Y; i++) {
            field[i][0] = field[i][X+1] = 0;
            for (j = 1; j <= X; j++) {
                cin >> field[i][j];
            }
        }

        for (i = 2; i <= Y+1; i++) {
            for (j = 0; j <= X + 1; j++) {
                pattern[i][j] = 0;
            }
        }
        for (j = 1; j <= X; j++) {
            pattern[1][j] = field[1][j] == 0;
        }

        for (i = 1; i < Y; i++) {
            for (j = 1; j <= X; j++) {
                switch (field[i][j]) {
                    case 0:
                    for (k = -1; k <= 1; k++) {
                        switch (field[i+1][j+k]) {
                            case 0:
                            pattern[i+1][j+k] += pattern[i][j];
                            break;
                            case 2:
                            if (k == 0) {
                                pattern[i+1][j+k] += pattern[i][j];
                            }
                            break;
                            default: break;
                        }
                    }
                    break;
                    case 2:
                    if (field[i+2][j] != 1) {
                        pattern[i+2][j] += pattern[i][j];
                    }
                    break;
                    default: break;
                }
            }
        }
        /* 
        for (i = 1; i <= Y; i++) {
            for (j = 1; j <= X; j++) {
                cout << " " << pattern[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
        int sum = 0;
        for (i = Y; i <= Y + 1; i++) {
            for (j = 1; j <= X; j++) {
                sum += pattern[i][j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

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

int cal(int &cookie,int &count){
    if(cookie%2)
        cookie-=1;
    count+=1;
    return cookie/2;}

int main(){
int A,B,K,d;
cin>>A>>B>>K;
int count=0;
while(count<K){
    d=cal(A,count);
    A-=d;
    B+=d;
    if(count==K)
        break;
    d=cal(B,count);
    B-=d;
    A+=d;
}
cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n,m,a[maxn];
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	ll k = 1;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i] /= 2;
	}
	sort(a,a+n);
	for(int i = n-1;i>=0;i--){
		k = lcm(k,a[i]);
		if(k > 1000000000){
			cout << 0 << endl;
			return 0;
		}
	}
//	cout << k << endl;
	for(int i = 0;i < n;i++){
		if((k / a[i]) % 2 == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = m / k;
	if(ans & 1) cout << (ans + 1) / 2 << endl;
	else cout << ans / 2 << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

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

using namespace std;

int a,b,ans,arr[100];

int main() {
	cin >> a >> b;
	for(int i = 0; i < a; i++) {
		cin >> arr[i];
	}
	sort(arr,arr+a);
	reverse(arr,arr+a);
	for(int i = 0; i < b; i++) {
		ans += arr[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys

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

if 0 in a:
  print(0)
  sys.exit(0)

s = 1
for x in a:
  s *= x
  if s > 1000000000000000000:
    break
if s > 1000000000000000000:
  print(-1)
else:
  print(s)


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

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {


            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var k = line[0];
            var x = line[1];

            var ans = new List<int>();

            for (int i = 0; i < k; i++)
            {
                var point = x + i;

                if (1000000 < point)
                {
                    break;
                }

                ans.Add(point);
            }

            for (int i = 0; i < k; i++)
            {
                var point = x + i * -1;

                if (-1000000 > point)
                {
                    break;
                }

                ans.Add(point);
            }

            Console.WriteLine(string.Join(" ", ans.Distinct().OrderBy(a => a)));

        }

    }


}


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

int cnt[10][10];

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    string s=to_string(i);
    cnt[s[0]-'0'][s[s.size()-1]-'0']++;
  }
  ll ans=0;
  rep(i,10) rep(j,10){
    ans+=cnt[i][j]*cnt[j][i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
const mod=10^9+7
function main()
	F=zeros(Int,4040)
	I=zeros(Int,4040)
	F[1]=1
	for i=1:4039
		F[i+1]=F[i]*i%mod
	end
	I[4040]=invmod(F[4040],mod)
	for i=4040:-1:2
		I[i-1]=I[i]*(i-1)%mod
	end
	function H(a,b)
		if a==b==0
			return 1
		end
		if a+b-1<0||a-1<0||b<0||a+b-1<b
			return 0
		end
		F[a+b]*I[a]%mod*I[b+1]%mod
	end
	N,K=map(x->parse(Int,x),split(readline()))
	for i=1:K
		ans=0
		for x=0:N-K
			ans=(ans+(N-K-x-i+1<0 ? 0 : H(i,K-i)*H(i-1,N-K-x-i+1)%mod*(x+1)%mod))%mod
		end
		println(ans)
	end
end
main()


Measured memory_bytes: 168468
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    a = int(input())
    b = int(input())
    h = int(input())

    ans = (a + b) * h // 2

    print(ans)

if __name__ == '__main__':
    solve()

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

int main()
{
    LL n, k;
    scanf("%lld%lld", &n, &k);
    LL ans = n, a = k, b = n - k;
    if (a < b) swap(a, b);
    while (a && b)
    {
        ans += 2 * b * (a / b);
        LL tmp = a;
        a = b, b = tmp % b;
    }
    printf("%lld\n", ans - a);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N,M;
  cin >> N >> M;
  M /=2;
  if(N == M) {
    cout << N << endl;
    return 0;
  }
  if(N > M) {
    cout << M << endl;
    return 0;
  }
  ll A = (M - N) / 2;
  cout << N + A << endl;
  return 0;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    string op;
    while (op != "?") {
        cin >> a >> op >> b;
        if (op == "+") {cout << a + b << endl;}
        else if (op == "-") {cout << a - b << endl;}
        else if (op == "*") {cout << a * b << endl;}
        else if (op == "/") {cout << a / b << endl;}
        else {}
        }
}
// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3228
from collections import deque

def main():
    n,m = map(int,input().split())
    arr = [[] for i in range(n)]
    for _ in range(m):
        a,b = map(int,input().split())
        arr[a-1].append(b-1)
        arr[b-1].append(a-1)
    q = deque()
    q.append(0)
    ans = [-1] * n
    ans[0] = 0
    while q:
        now = q.popleft()
        for i in arr[now]:
            if ans[i] == -1:
                ans[i] = now+1
                q.append(i)
        if len(q) == 0:
            break
    print('Yes')
    for i in range(1,n):
        print(ans[i])



if __name__=='__main__':
    main()


Measured memory_bytes: 36916
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

class Add_Segment_Tree {
	vector<long long int>v;
	long long int ret;
	int num;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		v[place] = Update(place * 2) + Update(place * 2 + 1);
		return v[place];
	}
public:
	Add_Segment_Tree(int n) {
		n++;
		num = 1;
		while (num < n * 2)num *= 2;
		v.resize(num, 0);
	}
	void Add(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] += num;
		if (!update)return;
		place /= 2;
		while (place) {
			v[place] = v[place * 2] + v[place * 2 + 1];
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int Sum(int a, int b) {
		ret = 0;
		b++;
		for (a += num / 2, b += num / 2; a < b; a >>= 1, b >>= 1) {
			if (a & 1)ret += v[a++];
			if (b & 1)ret += v[--b];
		}
		return ret;
	}
};

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> K;
	long long int ans = 0;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	Add_Segment_Tree asg(N);
	Add_Segment_Tree num(N);
	vector<long long int>by(N - K + 2, 1);
	by.back() = 1;
	for (int i = by.size() - 2; i >= 0; i--) {
		by[i] = by[i + 1] * (K - 1);
		by[i] %= MOD;
		by[i] *= power(K, MOD - 2, MOD);
		by[i] %= MOD;
	}
	ans += (K - 1)*K / 2 %MOD* power(2, MOD - 2, MOD);
	ans %= MOD;
	for (int i = 0; i < K; i++) {
		asg.Add(v[i], by[1], true);
		num.Add(v[i], 1, true);
	}
	for (int i = K; i < N; i++) {
		ans -= asg.Sum(v[i] + 1, N)%MOD*power(by[i - K + 2], MOD - 2, MOD) % MOD*power(2, MOD - 2, MOD) % MOD;
		ans += num.Sum(v[i] + 1, N);
		ans += asg.Sum(1, v[i] - 1)%MOD*power(by[i - K + 2], MOD - 2, MOD) % MOD*power(2, MOD - 2, MOD) % MOD;
		num.Add(v[i], 1, true);
		asg.Add(v[i], by[i - K + 2], true);
		ans += MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13732
#include <stdio.h>
 
int main() {

    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);

    int a[n][m] = {};
    int b[m][l] = {};

    int tmp;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    for (int i=0; i<m; i++)
    {
        for (int j=0; j<l; j++)
        {
            scanf("%d", &b[i][j]);
        }
    }
    
    long calc;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<l; j++)
        {
            calc = 0;
            for (int k=0; k<m; k++)
            {
                calc += a[i][k] * b[k][j];
            }
            printf("%ld", calc);
            if (j==(l-1))
                putchar('\n');
            else
                putchar(' ');
        }
    }
    return 0;
}


Measured memory_bytes: 2808
package main

import (
	"fmt"
    "os"
)

func main() {
	var n int
	fmt.Scan(&n)
    a := []int64{}
    exist_zero := false
	for i := 0; i < n; i++ {
		var tmp int64
		fmt.Scan(&tmp)
        if tmp == 0 {
            exist_zero = true
        }
        a = append(a, tmp)
    }
    if exist_zero {
        fmt.Println(0)
    } else {
        var ans int64 = 1
        var limit int64 = 1000000000000000000
        for _, elem := range a {
            if elem > limit / ans {
                fmt.Println(-1)
                os.Exit(0)
            }
            ans *= elem
        }
        fmt.Println(ans)
    }
}


Measured memory_bytes: 7460
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
inline void modAdd(int& _a, int _b, int _m) { _a = (_a + _b) % _m; }
inline void modAdd(lint& _a, lint _b, lint _m) { _a = (_a + _b) % _m; }
inline void minUpdate(int& _a, int _b) { _a = min(_a, _b); }
inline void minUpdate(lint& _a, lint _b) { _a = min(_a, _b); }
inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int n, k;
bool use[100010];

int dp[100010][2];

void solve() {
	minit(dp, 0);
	
	int ans = 0;
	
	for_(i,1,n+1) for_(j,0,2) {
		if (use[i]) {
			dp[i + 1][j] = dp[i][j] + 1;
			maxUpdate(ans, dp[i + 1][j]);
		} else if (!j && use[0]) {
			dp[i + 1][1] = dp[i][j] + 1;
			maxUpdate(ans, dp[i + 1][1]);
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> n >> k, n) {
		minit(use, 0);
		for_(i,0,k) {
			int a; cin >> a;
			use[a] = 1;
		}
		solve();
	}
	return 0;
}

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

long long int maxi(long long int a, long long int b){
    if(a>b){
        return a;
    }
    return b;
}

int main(){
    ios::sync_with_stdio(false);    cin.tie(NULL);  cout.tie(NULL);
    int n;  cin >> n;   vector<long long int> a(n+1), b(n+1), c(n+1);
    for(int i=1;n>=i;i++){
        cin >> a[i] >> b[i] >> c[i]; 
    }
    vector< vector<long long int> > dp(n+1, vector<long long int>(3));
    for(int i=1;n>=i;i++){
        dp[i][1]=a[i]+maxi(dp[i-1][2], dp[i-1][0]);
        dp[i][0]=b[i]+maxi(dp[i-1][1], dp[i-1][2]);
        dp[i][2]=c[i]+maxi(dp[i-1][0], dp[i-1][1]);
    }
    cout << maxi(dp[n][0], maxi(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 8064
#include <stdio.h>

int Hadd(int[], int, int);

int H[100], check, min;

int main(){
    int N, i, flg=0, ans=0, cnt, check;

    scanf("%d", &N);
    for(i=0; i<N; i++)
        scanf("%d", &H[i]);
    
    while(flg != 1){
        min = 101;
        cnt = 0;
        check = 0;
        for(i=0; i<N; i++){
            if(H[i] != 0){
                if(min > H[i])
                    min = H[i];

                if(check == 0)
                    cnt++;
                check = 1;
            }
            else{
                check = 0;
            }
        }
        
        if(min != 101){
            ans += min * cnt;
        }

        flg = Hadd(H, N, min);
    }

    printf("%d\n", ans);

    return 0;
}

int Hadd(int a[], int N, int x){
    int i, cnt=0;
    check=0;
    for(i=0; i<N; i++){
        if(a[i] > 0){
            a[i] -= x;
            if(a[i] < 0)
                a[i] = 0;
        }
        else
            cnt++;
    }

    if(cnt == N)
        return 1;
    else
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //in
  int n;
  cin >> n;
  vector<int> h(n);
  REP(i,n) cin >> h[i];

  //flg 0: h != 0 でcnt++ /flg = 1 0発見でflg 0に　初期flg-1
  int cnt = 0;
  REP(j,100){
    int flg = -1;
    REP(i,n){
      if(flg <= 0){
        if(h[i] != 0) {
          h[i]--;
          cnt++;
          flg = 1;
        }
      }
      else if (flg == 1){
        if(h[i] == 0) flg = 0;
        else h[i]--;
      }
    }
    if(flg == -1) break;
  }

  cout << cnt << endl;

  return 0;
}

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

int p[100];
pair<int, int> a[10000];

int root( int m ) {
	if ( p[m] != m )
		p[m] = root( p[m] );
	return p[m];
}

void unit( int x, int y ) {
	p[root( y )] = root( x );
}

bool same( int x, int y ) {
	return root( x ) == root( y );
}

int main() {
	int n, ai, pn, ans;
	cin >> n;
	for ( int i = 0; i < n * n; i++ ) {
		cin >> ai;
		if ( ai == -1 || i % n <= i / n )
			ai = 2001;
		a[i] = make_pair( ai, i );
	}
	sort( a, a + ( n * n ) );
	pn = 0;
	ans = 0;
	for ( int i = 0; i < n; i++ )
		p[i] = i;
	for ( int i = 0; i < n * n; i++ ) {
		if ( ! same( a[i].second % n, a[i].second / n ) ) {
			ans += a[i].first;
			pn++;
			unit( a[i].second % n, a[i].second / n );
			if ( pn >= n - 1 ) break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1240
# region header
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos, pi, e
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
N = ri()
p = ri_()
ans = 0
for i in range(1, N - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        ans += 1
print(ans)

Measured memory_bytes: 63340
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;

int main(){
	int n,x, cnt = 0;
	scanf("%d", &n);
	for(int i = 1;  i <= n; i++){
		scanf("%d", &x);
		if(x % 2 && i % 2) cnt++;
	}
	printf("%d", cnt);


}

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

using ll = long;
using namespace std;

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

    auto dfs = [&](auto dfs, char mx, ll i, const string &a) {
        if(i == n) {
            cout << a << endl;
            return;
        }
        string s = a;
        for(char c='a'; c<=mx+1; c++) {
            s[i] = c;
            dfs(dfs, max(mx, c), i+1, s);
        }
    };

    dfs(dfs, 'a'-1, 0, string(n, ' '));
}


Measured memory_bytes: 1536
class Array
    def sum
        if self.empty?
            0
        else
            self.inject(:+)
        end
    end
end

n = gets.to_i
w_list = gets.split.map(&:to_i)
num_list = (1..n).to_a
answer_list = []
(1..(n-1)).each do |t|
  less_list = []
  great_list = []

  num_list.zip(w_list).each do |num, w|
    if num <= t
      less_list << w
    else
      great_list << w
    end
  end
  
  answer_list << (less_list.sum - great_list.sum).abs
end

puts answer_list.min

Measured memory_bytes: 2044
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#define N 100010

using namespace std;

typedef pair<int,int> par;

int n;
int fa[N];
map<par,int> M,A;
multiset<int> S[N];
queue<par> Q;

inline par makep(int x,int y){
	if(x>y) return par(y,x);
	return par(x,y);
}

int find(int x){
	return x==fa[x]?x:fa[x]=find(fa[x]);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=2*n-2;i++){
		int x,y; par z;
		scanf("%d%d",&x,&y);
		z=makep(x,y);
		S[x].insert(y); S[y].insert(x);
		if((++M[z])>1&&!A.count(z))
			A[z]=1,Q.push(z);
	}
	for(int k=1;k<n;k++){
		int x,y;
		while(1){
			if(Q.empty()) return puts("NO"),0;
			x=find(Q.front().first),y=find(Q.front().second); Q.pop();
			if(x!=y) break;
		}
		if(S[x].size()>S[y].size()) swap(x,y); fa[x]=y;
		for(set<int>::iterator i=S[x].begin();i!=S[x].end();i++){
			int v=find(*i);
			if(v==y) continue;
			S[y].insert(v); S[v].insert(y);
			if((++M[makep(y,v)])>1&&!A.count(makep(y,v)))
				Q.push(makep(y,v)),A[makep(y,v)]=1;
			S[v].erase(S[v].find(x));
		}
		S[y].erase(x);
		S[x].clear();
	}
	puts("YES");
	return 0;
}

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

int main(){
  string s1, s2;
  cin >> s1 >> s2;
  bool ans = true;
  for(int i=0; i<(int)s1.size(); ++i){
    if(s1[i] != s2[i]) ans = false;
  }
  if(s1.size()+1 != s2.size()) ans = false;
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm> 
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    for(int i = 1; i <= 360; ++i) {
        if(x * i % 360 == 0) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    long count = 0;
    for(int i = 0; i < n; i ++) {
        cin >> a[i];
        while(a[i]%2==0) {
            count ++;
            a[i] /= 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix_2
# CreatedDate:  2020-08-08 01:59:29 +0900
# LastModified: 2020-08-08 02:11:36 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m  = map(int, input().split())
    h = [0] + list(map(int, input().split()))
    path = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        path[a].append(h[b])
        path[b].append(h[a])
    ans = 0
    for index in range(1, n+1):
        if path[index] and h[index] > max(path[index]):
            ans += 1
        elif not path[index]:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 22984
a, b, h, m = map(int, input().split())

import math
import numpy as np

hi = (360/12*h) + (360/12/60*m)
mi = 360/60*m
kakudo = 0
if abs(hi-mi) >= 180:
  kakudo = 360 - abs(hi-mi)
else:
  kakudo = abs(hi-mi)

c2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo))
c = np.sqrt(c2)
print(c)

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

int main(void)
{
    int i;
    int n;
    int r[200000];

    cin >> n;

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

    int min = r[0];
    int ret = INT_MIN;
    for (i = 1; i < n; i++) {
        int tmp = r[i] - min;
        ret = (tmp > ret)  ? tmp : ret;
        min = (r[i] < min) ? r[i] : min;
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 1940
let N = stdin.ReadLine() |> int
let P = stdin.ReadLine().Replace(" ", "")
let Q = stdin.ReadLine().Replace(" ", "")

let rec distribution e =
    function
    | [] -> [ [ e ] ]
    | x :: xs' as xs ->
        (e :: xs) :: [ for xs in distribution e xs' -> x :: xs ]

let rec permutation =
    function
    | [] -> [ [] ]
    | e :: xs -> List.collect (distribution e) (permutation xs)

let find lst s =
    lst
    |> List.find (fun (x, _) -> x = s)
    |> snd

permutation [ 1..N ]
|> List.sort
|> List.map (fun lst -> System.String.Concat(Array.ofList lst))
|> List.mapi (fun i x -> x, (i + 1))
|> fun lst -> abs (find lst P - find lst Q)
|> stdout.WriteLine


Measured memory_bytes: 37920
n = int(input())
h_list = list(map(int,input().split()))
num = 0
final_num_list = []
for i in range(n):
    if i<n-1:
        if  h_list[i] >= h_list[i+1]:
            num += 1
        else:
            final_num_list.append(num)
            num = 0
    else:
        final_num_list.append(num)
print(max(final_num_list))

Measured memory_bytes: 14336
#include<iostream>
using namespace std;
int main(){
    string s,t;
    cin >> s;
    cin >> t;
    for(int i=0;i<s.size();i++){
        if (s.at(i) != t.at(i)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int n = sc.nextInt();

		int result = 0;
		for (int j = 0; j < n; j++) {
			final int l = sc.nextInt();
			final int r = sc.nextInt();
			result = result + (r - l + 1);
		}

		System.out.println(result);

	}

}

Measured memory_bytes: 25576