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

int main() {
  int N;
  int i=0,pi;
  int ans=0;

  cin >> N;

  vector<int> p(N);

  while(i < N) {
    cin >> p[i];
    i++;
  }

  for(i=1;i<N-1;i++) {
    if(p[i-1] < p[i] && p[i] < p[i+1]) {ans++;}
    else if(p[i-1] > p[i] && p[i] > p[i+1]) {ans++;}
    else {}
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL H,W;

int main(){
	scanf("%lld%lld" , &H , &W);
	LL ans = min(H,W);
	if(H%3 == 0 || W%3 == 0) ans = 0;
	LL x,y;
	x = W/2;
	y = (W+1)/2;
	repp(i,1,H){
		ans = min(ans , max(abs(x*i-(H-i)*W),abs(y*i-(H-i)*W)));
	}
	x = H/2;
	y = (H+1)/2;
	repp(i,1,W){
		ans = min(ans , max(abs(x*i-(W-i)*H),abs(y*i-(W-i)*H)));
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 100000000
#define NUM 1000000007
#define all(x) begin(x), end(x)

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

	VI a(n+1),b(n);
	for (int i = 1; i < n + 1; i++) cin >> a[i];

	for (int i = 1; i < n + 1; i++) {
		b[i - 1] = a[i] - i;
	}

	sort(all(b));
	int b_ans = b[n / 2];
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(b[i] - b_ans);
		//cout << abs(b[i] - b_ans) << " " << endl;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  int a, b;
  char o;
  scanf("%d %c %d",&a,&o,&b);
  if(o == '+'){
    printf("%d\n",(a+b));
    return 0;
  }
  printf("%d\n",(a-b));
  return 0;
}
  


Measured memory_bytes: 384
import math
N=int(input())
X1=math.ceil(N/1.08)
X2=math.floor(N/1.08)
if N==math.floor(X1*1.08):
    print(X1)
    exit(0)
if N==math.floor(X2*1.08):
    print(X2)
    exit(0)
print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	char ch;
	while (true) {
		scanf("%c", &ch);
		if (0x41 <= ch && ch <= 0x5a) {
	    	printf("%c", ch + 0x20);
	    } else if (0x61 <= ch && ch <= 0x7a) {
	    	printf("%c", ch - 0x20);
	    } else {
	    	printf("%c", ch);
	    }

		if (ch == '\n') break;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    vector<vector<pair<ll, ll>> > e(n,vector<pair<ll, ll>>(0));
    vector<ll> ans(n,-1);
    ans[0] = 0;
    rep0(i, n - 1){
        ll a,b,c;
        cin >> a >> b >> c;
        --a;--b;c %= 2;
        e[a].push_back(make_pair(b, c));
        e[b].push_back(make_pair(a, c));
    }
    queue<ll> to,from,erase;
    to.push(0);
    while (!to.empty()) {
        from = to;
        to = erase;
        while (!from.empty()) {
            ll f = from.front();
            rep0(i, e[f].size()){
                if(ans[e[f][i].first] != -1)continue;
                if(e[f][i].second == 0)ans[e[f][i].first] = ans[f];
                else ans[e[f][i].first] = ans[f] ^ 1;
                to.push(e[f][i].first);
            }
            from.pop();
        }
    }
    rep0(i, n)pf(ans[i]);
    return 0;
}


Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s; string t;
  cin>>s;
  cin>>t;
  ll sl=s.length();
  ll tl=t.length();
  ll min=INT_MAX;
  for(ll i=0;i<=sl-tl;i++)
  {
    ll c=0;
    string st=s.substr(i,tl);
    for(ll j=0;j<tl;j++)
    {
      if(st[j]!=t[j])
        c++;
    }
    if(c<min)
      min=c;
  }
  cout<<min<<endl;
  return 0;
 
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

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

Measured memory_bytes: 640
from collections import Counter
import sys
import itertools
input = sys.stdin.readline

c = Counter()
H,W,N = map(int,input().split())
for _ in range(N):
  a,b = map(int,input().split())
  # そのセルを含む正方形の中心を記録
  for dx,dy in itertools.product([-1,0,1],repeat = 2):
    aa = a + dx
    bb = b + dy
    if 2 <= aa <= H-1 and 2 <= bb <= W-1:
	    c[(aa,bb)] += 1

result = Counter(c.values())
result[0] = (H-2)*(W-2) - sum(result.values())

for j in range(10):
  print(result[j])

Measured memory_bytes: 166856
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000;
//2次元配列 vector<vector<int>> vec(a,vector<int>(b))
int main() {
	ll K;
	cin >> K;
	string S;
	cin >> S;
	ll size = S.size();
	if (size <= K) cout << S << endl;
	else cout << S.substr(0, K) << "..." << endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# from numpy import array, sum

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

h_li = []

for i in range(N):
	h_li.append(int(input()))

def all_beatable_check(k):
	# All enemy get B damage every time
	h_damaged = [h - B*k for h in h_li]
	# print(h_damaged)
	# A-B damage will be additionally given to enemies s.t. HP > 0
	ex_dmg = A - B
	h_ex_needed = [(h+ex_dmg-1) // ex_dmg if h > 0 else 0 for h in h_damaged]
	# print(h_ex_needed)
	# how many A-B damage is needed to beat all enemies
	hits_needed = sum(h_ex_needed)
	if hits_needed > k:
		return False
	else:
		return True

MIN_K = 1
MAX_K = max(h_li)

while True:
	if MIN_K == MAX_K:
		print(MIN_K)
		break
	# print(f"{MIN_K}-{MAX_K} {MIN_K + (MAX_K - MIN_K) // 2}")
	k = MIN_K + (MAX_K - MIN_K) // 2
	res = all_beatable_check(k)
	if res is True:
		MAX_K = k
	elif res is False:
		MIN_K = k + 1

Measured memory_bytes: 14956
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int seg[800005];
int deg[200005];
pair<int,int>p[200005];

void build(int ver,int tl,int tr)
{
    if(tl>tr)
            return ;
    else if(tl==tr)
        seg[ver]=min(p[tl].first,p[tl].second);
    else
    {
        int tm=(tl+tr)/2;
        build(2*ver,tl,tm);
        build(2*ver+1,tm+1,tr);
        seg[ver]=max(seg[2*ver],seg[2*ver+1]);
    }
}

void upd(int ver,int tl,int tr,int pos,int val)
{
    if(tl>tr)
            return;
    else if(tl==tr)
            seg[ver]=val;
    else
    {
        int tm=(tl+tr)/2;
        if(tm>=pos)
            upd(2*ver,tl,tm,pos,val);
        else
            upd(2*ver+1,tm+1,tr,pos,val);
        seg[ver]=max(seg[2*ver],seg[2*ver+1]);
    }
}


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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int mmx=0,mmn=1e18;
    for(int i=1;i<=n;i++)
    {        
        cin>>p[i].first>>p[i].second;
        mmx=max(mmx,p[i].first);
        mmn=min(mmn,p[i].first);
        mmx=max(mmx,p[i].second);
        mmn=min(mmn,p[i].second);
    }
    int mn=5e18;
    int min_ans=1e18;
    int max_ans=0;
    vector<int>temp;
    multiset<pair<int,int> >s;
    for(int i=1;i<=n;i++)
    {
        temp.push_back(p[i].first);
        temp.push_back(p[i].second);
        s.insert({p[i].first,i});
        s.insert({p[i].second,i});
    }
    sort(temp.begin(),temp.end());
    build(1,1,n);
    bool flag=true;
    for(auto i:temp)
    {
        auto j=s.lower_bound({i,-1});
        vector<pair<int,int>> madar;
        if(j!=s.begin())
        {
            j--;
            while(1)
            {
                madar.push_back(*j);
                deg[j->second]++;
                if(deg[j->second]==1)
                {
                    upd(1,1,n,j->second,max(p[j->second].first,p[j->second].second));
                }
                else
                {
                    flag=false;
                    break;
                }
                if(j==s.begin())
                {
                    break;
                }
                j--;
            }
        }        
        for(auto j:madar)
            s.erase(s.find(j));
        if(!flag)
            break;
        mn=min(mn,seg[1]-i);
    }

    if(mn!=5e18)
        mn=mn*(mmx-mmn);
    for(int i=1;i<=n;i++)
    {
        int x=p[i].first;
        int y=p[i].second;
        max_ans=max(max_ans,min(x,y));            
        min_ans=min(min_ans,max(x,y));
    }
    mn=min(mn,(mmx-min_ans)*(max_ans-mmn));
    cout<<mn;
} 


Measured memory_bytes: 39404
#include<bits/stdc++.h>
using namespace std;
int gem[100],cost[100],to[100];
int main()
{
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) cin >> gem[i];
    for(int i=1;i<=n;i++) cin >> cost[i];
    for(int i=1;i<=n;i++) to[i]=gem[i]-cost[i];
    sort(to+1,to+n+1,greater<int>());
    int ans=0;
    for(int i=1;i<=n;i++) ans+=max(to[i],0);
    cout << ans;
}


Measured memory_bytes: 256
// tzl ak IOI! 

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}

template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }

template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }

template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }

template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }

#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif

void TZL();

void RANK1();

#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI

	TZL();
	RANK1();

#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

//---------------------------head----------------------------

const int N = 1e5 + 100;

int n, m;
vi g[N];
bool vis[N];
int cnt[N], dep[N];

void dfs(int u)
{
	vis[u] = 1;
	for(int v: g[u])
		if(!vis[v])
		{
			dep[v] = dep[u] + 1;
			dfs(v);
		}
		else if(dep[v] < dep[u])
		{
			++cnt[v];
			--cnt[u];
		}
}

void check(int u, int cur = 0)
{
	vis[u] = 1;
	cur += cnt[u];
	for(int v: g[u]) if(!vis[v])
	{
		if(cur & 1)
		{
			puts("NO"); exit(0);
		}
		check(v, cur);
	}
	return;
}

void TZL()
{
	scf(n, m);
	rep(i, m)
	{
		int u, v; scf(u, v);
		g[u].pb(v); g[v].pb(u);
	}
	vi root; root.clear();
	forn(i, 1, n) if(!vis[i]) dfs(i), root.pb(i);
	FILL(vis, 0);
	for(int u: root) check(u);
	puts("YES");
	return;
}

void RANK1()
{
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

int kai(int x){
    int ret =1;
    for(int i=1;i<=x;i++){
        ret *=i;
    }
    return ret;
}

signed main(){
    int N;
  	cin >>N;
    string X="";
    string Y="";
    string M="";
    REP(i,N){
        char a;
        cin >>a;
        X+=a;
    }
    REP(i,N){
        char b;
        cin >>b;
        Y+=b;
    }
    for(int i=1;i<=N;i++){
        string d =to_string(i);
  	    M+=d;
    }
    int acount=0;
    int bcount=0;
    REP(i,kai(N)){
        if(X>M){
            acount++;
        }
        if(Y>M){
            bcount++;
        }
        if(i!=kai(N)-1){
            next_permutation(M.begin(),M.end());
        }
    }
  cout <<abs(acount-bcount)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n),abig(n,0),afront(n,0);
    rep(i,n) cin >> a[i];
    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            if(a[i] < a[j]){
                if(j < i){
                    afront[i]++;
                    abig[i]++;
                }
                else abig[i]++;
            }
        }
    }

    // print(abig);
    // print(afront);
    ll abig_sum = 0;
    ll afront_sum = 0;
    abig_sum = accumulate(abig.begin(),abig.end(), 0) % N;
    afront_sum = accumulate(afront.begin(), afront.end(), 0) % N;
    ll ks = (k * (k-1)/2) % N;
    cout << (((ks * abig_sum)%N) + ((afront_sum * k)%N))%N << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var a, b, c bool
	for _, x := range s {
		if x == 'a' {
			a = true
		} else if x == 'b' {
			b = true
		} else if x == 'c' {
			c = true
		}
	}

	if a && b && c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main() {
  int a,b,i,M;
  cin >> a;
  M = 0 ; 
  vector<int> vec(a);
  for(i=0;i<a;i++)cin >> vec[i];
  for(i=1;i<a-1;i++)if (vec[i-1]<vec[i] && vec[i] <vec[i+1])M++;
  for(i=1;i<a-1;i++)if (vec[i-1]>vec[i] && vec[i] >vec[i+1])M++;


  cout << M << endl;
  
  
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,c,k,t,timeborder,cnt,ans;
vector<int> v;

main() {
    cin >> n >> c >> k;
    rep(i,n) cin >> t,v.pb(t)
    sort(all(v));
    rep(i,n) {
        if (!cnt) timeborder = v[i]+k,cnt++;
        else if (cnt==c || timeborder<v[i]) cnt=0,ans++,i--;
        else cnt++;
    }
    ct(++ans)
}



Measured memory_bytes: 1400
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a = instr()
res = ""
for i in range(8):
    s = '{0:03b}'.format(i)
    temp = a[0]
    total = int(a[0])
    j = 0
    for i in range(1, 4):

        if s[j] == '0':
            total += int(a[i])
            temp += "+" + a[i]
        else:
            total -= int(a[i])
            temp += "-" + a[i]

        j += 1

    if total == 7:
        res = temp
        break
print(res+"=7")


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

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,sum=0;
	cin>>n;
	for(long long int i=1;i<=n;i++)
	{
	if(i%3!=0&&i%5!=0)
	{
		sum=sum+i;
	}	
	}
	cout<<sum;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int n, m, t, count = 0;
	cin >> n >> m;
	vector<int>k(n);
	int a[30] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			cin >> t;
			a[t]++;

		}
	}
	for (int j = 1; j <= m; j++) {
		if (a[j] == n) {
			count++;
		}
	}
	if (n == 1) {
		cout << k[0] << endl;
	}
	else {
		cout << count << endl;

	}
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
mod = 10 ** 9 + 7

mx = np.sqrt(n).astype(int)

dp_u = np.ones(mx, np.int64)

N = np.full(mx, n, np.int64)
L = N // np.arange(1, mx + 1)
R = np.maximum(N // np.arange(2, mx + 2), mx)
coef = L - R
dp_d = coef

for _ in range(2, k + 1):
    acc_u = np.cumsum(dp_u) % mod
    acc_d = np.cumsum(dp_d[::-1])[::-1] % mod
    dp_u = (dp_u.sum() + acc_d) % mod
    dp_d = coef * acc_u % mod

ans = (dp_u.sum() + dp_d.sum()) % mod
print(ans)


Measured memory_bytes: 14936
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;

typedef struct{
 int x;
 int y;
}P;//表示坐?

char graph[1000][1000];
P aim[10];
P s,g;//s起点，g?点
int N,W,H;
int vis[1000][1000]; //用来存?距?
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(P s,P g);

int main(){
    int i,j,t,step=0;
    cin>>H>>W>>N;

    for(i=0;i<H;i++)
    for(j=0;j<W;j++){
        cin>>graph[i][j];
      if(graph[i][j]<='9'&&graph[i][j]>='1'){
         t=graph[i][j]-'0';
         aim[t].x=i;
         aim[t].y=j;
      } //把1-N的坐?保存在 aim数?中
      else if(graph[i][j]=='S'){
          s.x=i;
          s.y=j;
          graph[i][j]='.';
      }//得到最初的起点
    }

    for(i=1;i<=N;i++){
       g.x=aim[i].x;
       g.y=aim[i].y;//1-N ，从小到大，?次把一个 作??点
       step+=bfs(s,g);
       s.x=g.x;
       s.y=g.y;//到??个?点后??点?起点
       graph[g.x][g.y]='.';
    }

    cout<<step<<endl;
     /*for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                printf("%c",graph[i][j]);
            }
            printf("\n");
        }
        */
}

int bfs(P s,P g){
    queue<P> que;
      P n;

    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
     vis[i][j]=-1;

     que.push(s);
     vis[s.x][s.y]=0;

     while(que.size()){

       P p=que.front();
         que.pop();
       if(p.x==g.x&&p.y==g.y)
       break;

       for(int i=0;i<4;i++){
           n.x=p.x+dx[i];
           n.y=p.y+dy[i];//向四方漫射
        if(0<=n.x&&n.x<H&&0<=n.y&&n.y<W&&graph[n.x][n.y]!='X'&&vis[n.x][n.y]==-1){
               que.push(n);
               //graph[n.x][n.y]='#';
               vis[n.x][n.y]=vis[p.x][p.y]+1;
           }
       }
   }
     return vis[g.x][g.y];
}

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    bool flg=0;

    while(n!=0)
    {
        if(n%10==7)
        {
            flg=1;
            cout << "Yes" << endl;
            break;

        }

        n=n/10;

    }

    if(flg==0)
    {
        cout << "No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())
d = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += d[i]*d[j]

print(ans)

Measured memory_bytes: 77504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h;
  cin >> n >> h;
  vector<pair<int,int>> c(2*n);
  for(int i=0;i<2*n;i++){
    int a;
    cin >> a;
    if(i%2==0){
      c[i]=make_pair(a,0);
    }
    else{
      c[i]=make_pair(a,1);
    }
  }
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  int sum=0;
  int ans=0;
  for(int i=0;i<2*n;i++){
    if(c[i].second==0){
      ans+=(h-sum+c[i].first-1)/c[i].first;
      break;
    }
    if(sum<h){
      sum+=c[i].first;
      ans++;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    double left,right;
    int la,ra,lb,rb,lc,rc,ld,rd;
    
    la = ra = lb = rb = lc = rc = ld = rd = 0;
    
    while(scanf("%lf%lf" ,&left ,&right) != EOF){
        if(left >= 1.1) la++;
        else if(0.6 <= left && left < 1.1) lb++;
        else if(0.2 <= left && left < 0.6) lc++;
        else ld++;
        
        if(right >= 1.1) ra++;
        else if(0.6 <= right && right < 1.1) rb++;
        else if(0.2 <= right && right < 0.6) rc++;
        else rd++;
    }
    
    printf("%d %d\n%d %d\n%d %d\n%d %d\n" ,la,ra,lb,rb,lc,rc,ld,rd);

    return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;

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

int n,k;
llint dp[110000];
void solve(){
  cin >> n >> k;

  int h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<110000;i++)dp[i]=1LL<<60;
  dp[0]=0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[n-1] << endl;

}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 1536
class UnionFind:
    def __init__(self, num):
        self.parent = [-1] * num

    def find(self, node):
        if self.parent[node] < 0:
            return node
        self.parent[node] = self.find(self.parent[node])
        return self.parent[node]

    def union(self, node1, node2):
        node1 = self.find(node1)
        node2 = self.find(node2)
        if node1 == node2:
            return
        if self.parent[node1] > self.parent[node2]:
            node1, node2 = node2, node1
        self.parent[node1] += self.parent[node2]
        self.parent[node2] = node1
        return

    def same(self, node1, node2):
        return self.find(node1) == self.find(node2)

    def size(self, x):
        return -self.parent[self.find(x)]


n, m = map(int, input().split())

uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

ans = float(0)

for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)


Measured memory_bytes: 77312
function main(input) {
  var temp = input.split(' ').map(Number);
  var a = temp[0];
  var b = temp[1];
  var c = temp[2];
  var count = 0;
  for (var i = a; i <= b; i++) {
    if (c%i == 0) {
      count++
    }
  }
  console.log(count);
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


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

int main(){
    ll h;
    cin>>h;
    ll n=0;
    while(pow(2,n)<=h) n++;
    ll ans=-1LL*(1LL-pow(2,n));
    cout<<ans<<endl;
}

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

typedef complex<double> xy_t;

int main() {

	int N, x, y;
	xy_t P[60];

	cin >> N;

	for ( int i = 0; i < N; i++ ) {

		cin >> x >> y;
		P[i] = xy_t( x, y );

	}

	if ( N % 2 == 0 ) {
	
		xy_t a = ( P[0] + P[N/2] ) * 0.5;

		for ( int i = 1; i < N / 2; i++) {

			xy_t b = ( P[i] + P[i+N/2] ) * 0.5;
		
			if ( abs( a - b ) < 1e-4 ) { 
		
				printf( "%.5f %.5f\n", a.real(), a.imag() );
			
				return 0;
		
			}

		}

	}
	
	cout << "NA" << endl;
	
	return 0;

}

Measured memory_bytes: 1208
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = new int[N + 1];
		int count = 0;
		for (int i = 1; i <= N; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 1; i <= N; i++) {
			if (a[a[i]] == i) {
				count++;
			}
		}
		System.out.println(count / 2);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 10308
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int main(void) {
  REP(i, 1, 10001) {
    int x;
    cin >> x;
    if(x == 0) break;

    cout << "Case " << i << ": " << x << endl;
  }

  return 0;
}

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

//LIFE IS NOT A PROBLEM TO BE SOLVED

#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )
#define F first
#define S second
#define pb push_back
#define debug(a) cout << #a << " = " << a << endl;
#define debug2(a,b) cout << #a << " = " << a << " --- " << #b << " = " << b << endl;
#define debugP(a) cout << a.F << " " << a.S << endl;
#define debugM(mat,n,m) rep( i, 0, n ){ rep( j, 0, m ) cout << mat[i][j] << " "; cout << endl; }
#define all(s) s.begin(), s.end()

using namespace std;

typedef long long int ll;
typedef pair<int, int> ii;

int main(){
	
	string s; int ans = 0;
	cin >> s;
	
	stack<char> st;
	rep(i, 0, s.size()){
		if(!st.size()) st.push(s[i]);
		else{
			if(st.top()!=s[i]) st.pop(), ans+=2;
			else st.push(s[i]);
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}

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

int n, s;
int num[10];
int dfs(int sum, int i, int j) {
    if(sum == s && j == 0) return 1;
    if(i > 9 || j<= 0) return 0;
    return dfs(sum+num[i], i+1, j-1) + dfs(sum, i+1, j);
}


int main() {
    for(int i=0;i<10;i++) num[i] = i;
    while(true) {
        cin >> n >> s;
        if(!n && !s) break;
        int ans = dfs(0, 0, n);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2968
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using pairint = pair<int, int>;

bool compare(pairint BC1, pairint BC2){
    return BC1.second > BC2.second;
}

int main(void){

    int N, M;
    cin >> N >> M;
    vector<int> A(N, 0);
    vector<pairint> BCall;
    
    for(int i=0; i<N; i++)cin >> A[i];

    sort(A.begin(), A.end());

    for(int i=0; i<M; i++){
        int B;
        int C;
        cin >> B >> C;
        BCall.push_back(pairint(B,C));
    }

    sort(BCall.begin(), BCall.end(), compare);

    long long result=0;
    int j=0;
    int k=0;

    for(int i=0; i<N; i++){
        if((j<M)&&(A[i]<BCall[j].second)){
            result=result+(long long)(max(A[i],BCall[j].second));
            k++;
            if (k>=BCall[j].first){
                k=0;
                j++;
            }
        }else result=result+(long long)(A[i]);
    }

    cout << result << endl;

    return 0;
}

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn nth(n: usize) -> usize {
    let mut i = n;
    let v : Vec<usize> = vec![0, 3, 5, 7];
    let mut x = 0;
    let mut d = 1;
    while i > 0 {
        let j = i % 4;
        x += d * v[j];
        i /= 4;
        d *= 10;
    }
    x
}

fn check(x: usize) -> bool {
    let mut x = x;
    let mut c1 = 0;
    let mut c2 = 0;
    let mut c3 = 0;
    while x > 0 {
        match x % 10 {
            3 => c1 += 1,
            5 => c2 += 1,
            7 => c3 += 1,
            _ => return false,
        }
        x /= 10;
    }
    c1 > 0 && c2 > 0 && c3 > 0
}

fn main() {
    input! {
        n: usize,
    }
    let mut ans = 0;
    let mut i = 0;
    loop {
        let x = nth(i);
        if x > n {
            break;
        }
        if check(x) {
            ans += 1;
        }
        i += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-23-03.25.36 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#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 forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = 3100;
const i64 mod = 998244353;
i64 dp[maxn], n, s, a[maxn], ans=0;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> s;
    for1(i, n) cin >> a[i];
    ms(dp, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = s; j >= a[i]; --j) dp[j] = (dp[j]+dp[j-a[i]])%mod;
        dp[a[i]] = (dp[a[i]]+i)%mod;
        ans = (ans+dp[s])%mod;
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int [n];
		for(int i =0 ; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int cnt = 0;
		int nowMax =0;
		for(int i =0; i < n; i++) {
			if(a[nowMax] <= a[i]) {
				nowMax = i;
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23764
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

a, b, c, d = map(int, input().split())

res = -float("inf")
for x in [a, b]:
    for y in [c, d]:
        val = x * y
        res = max(res, val)

print(res)

Measured memory_bytes: 65296
L,R = [int(zz) for zz in input().split()]

if R-L >= 2018:
    print(0)
else:
    ans = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans,i*j%2019)
    print(ans)


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

int main(){
    int N,M,i,j;

    vector<int> a(50);
    vector<int> b(50);

    cin >> N >> M;

    vector<int> count(N,0);

    for(i=0;i<M;i++){
        cin >> a.at(i) >> b.at(i);
        count.at(a.at(i)-1)+=1;
        count.at(b.at(i)-1)+=1;
    }

    for(i=0;i<N;i++){
        cout << count.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

#define inc(...)      \
  char __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    inc(a ,b);
    out(a == b ? "H" : "D");
}


Measured memory_bytes: 3628
using System;
namespace AOJ01
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            for (int i = 0; i < 10; i++)
            {
                ans += (int.Parse(Console.ReadLine()));
            }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,a,j,k;
    cin>>n;
    vector<ll> v;
    for(i=0;i<n;i++)
    {
        cin>>a;
        v.push_back(a);
    }
    
    sort(v.begin(),v.end());
    ll ans=0;
    
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k])
                {
                    if(v[i]+v[j]>v[k])
                        ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const int OFS = 15000;
int h, w, a[81][81], b[81][81], dp[81][81][2 * OFS + 100];
int main() {
  cin >> h >> w;
  for (auto c : {a, b}) {
    for (int i = 1; i <= h; ++i) {
      for (int j = 1; j <= w; ++j) {
        cin >> c[i][j];
      }
    }
  }

  dp[0][1][OFS] = 1;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      for (int k = 0; k < 2; ++k) {
        int d = a[i][j] - b[i][j];
        if (k == 1) d = -d;
        for (int l = 100; l <= 2 * OFS - 100; ++l) {
          dp[i][j][l] |= dp[i][j - 1][l - d] | dp[i - 1][j][l - d];
        }
      }
    }
  }

  int ans = 1 << 30;
  for (int i = 0; i <= 2 * OFS; ++i) {
    if (dp[h][w][i] == 1) ans = min(ans, abs(i - OFS));
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 763520
#include <stdio.h>

int main(void)
{
	int a,b,c;
	int count = 0;
	scanf("%d%d%d", &a,&b,&c);
	int tmp_a = a, tmp_b = b, tmp_c = c;
	if (a % 2== 0 && b % 2 == 0 && c % 2 == 0)
	{
		if (a == b && b == c && b == c)
		{
			printf("-1");
			return 0;
		}
	}
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
	{
		a = (tmp_b / 2) + (tmp_c / 2);
		b = (tmp_c / 2) + (tmp_a / 2);
		c = (tmp_b / 2) + (tmp_a / 2);
		tmp_a = a;
		tmp_b = b;
		tmp_c = c;
		count++;
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
import sys

N = int(input())
l = [int(x) for x in input().split()]
if 0 in l:
  print(0)
  sys.exit()
ans = 1
for i in range(N):
  if ans > pow(10, 18):
    ans = -1
    break
  else:
    ans *= l[i]
if ans > pow(10, 18):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21780
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,a,b;
    cin>>N>>a>>b;
    
    N-=a;
    N%=b;
    cout1(N)
}

Measured memory_bytes: 256