akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);
int fac[MAXSIZE+6];
int inv[MAXSIZE+6];

void pre(){
	fac[0] = 1;
	for(int i=1;i<=MAXSIZE;i++){
		fac[i] = fac[i-1] * (i);
		fac[i]%=mod;
	}
	inv[MAXSIZE] = mod_pow(fac[MAXSIZE],mod-2,mod);
	for(int i=MAXSIZE-1;i>=0;i--){
		inv[i] = (i+1) * inv[i+1];
		inv[i]%=mod;
	}
}

int nCr(int n, int r){
	
	if(r>n) return 0;
	assert(r >= 0);
	assert(n >= 0);
	int ans = fac[n];
	ans%=mod;
	ans = ans * inv[r];
	ans%=mod;
	ans = ans * inv[n-r];
	ans%=mod;
	return ans;
}


int32_t main(){
	fastio();
	pre();
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int k = n - (i * 3) + i - 1;
		ans += nCr(k , i - 1);
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 19280
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

var (
	reader io.Reader = os.Stdin
	writer io.Writer = os.Stdout
)

type input [][]int

func (in input) Len() int { return len(in) }
func (in input) Less(i, j int) bool {
	return in[i][0] < in[j][0]
}
func (in input) Swap(i, j int) { in[i], in[j] = in[j], in[i] }

func main() {
	run()
}

func run() {
	var N int
	fmt.Fscan(reader, &N)

	// prevTime, prevX, prevY := 0, 0, 0
	reader := bufio.NewReaderSize(reader, 19)
	inputs := make(input, 0, N)

	for i := 0; i < N; i++ {
		buffer, isPrefix, err := reader.ReadLine()
		buf := make([]byte, 0, 19)

		if err != nil || isPrefix {
			panic(err)
		}

		buf = append(buf, buffer...)

		var t, x, y int
		fmt.Sscan(string(buf), &t, &x, &y)

		inputs = append(inputs, []int{t, x, y})
	}

	sort.Sort(&inputs)

	prevTime, prevX, prevY := 0, 0, 0

	for _, ints := range inputs {
		t, x, y := ints[0], ints[1], ints[2]
		distance := abs(x-prevX) + abs(y-prevY)
		time := t - prevTime

		if t == prevTime || distance > time || (time-distance)%2 != 0 {
			fmt.Fprintln(writer, "No")

			return
		}

		prevTime, prevX, prevY = t, x, y
	}

	fmt.Fprintln(writer, "Yes")
}

func abs(a int) int {
	if a < 0 {
		return -a
	}

	return a
}


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

int n[100000], m[100000];
vector<int>rinsetu[100000];
signed main() {
	unordered_map<int, int>X, Y;
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); c--; d--;
	for (int e = 0; e < b; e++) {
		int f, g; scanf("%d%d", &f, &g);
		f--; g--;
		rinsetu[f].push_back(g);
		rinsetu[g].push_back(f);
	}
	memset(n, -1, sizeof(n));
	memset(m, -1, sizeof(m));
	n[c] = 0; m[d] = 0;
	queue<int>Q;
	Q.push(c);
	while (Q.size()) {
		int e = Q.front(); Q.pop();
		X[n[e]]++;
		for (int f : rinsetu[e]) {
			if (n[f] == -1) {
				n[f] = n[e] + 1;
				Q.push(f);
			}
		}
	}
	Q.push(d);
	while (Q.size()) {
		int e = Q.front(); Q.pop();
		Y[m[e]]++;
		for (int f : rinsetu[e]) {
			if (m[f] == -1) {
				m[f] = m[e] + 1;
				Q.push(f);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < a; i++) {
		if(m[i]!=-1)ans += X[n[d] - m[i] - 2];
		if(n[i]!=-1)ans += Y[m[c] - n[i] - 2];
	}
	printf("%lld\n", ans / 2);
}

Measured memory_bytes: 10208
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
ll dp[100001];
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int main(void) {
  int n,a,b;
  scanf("%d",&n);
  FOR(n){
    scanf("%d %d",&a,&b);
    PRN((a-1)%b+1);
  }
  return 0;
}


Measured memory_bytes: 2132
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int n,m;
    cin >> n >> m;
    vector<vi> g(n);
    vi in(n);
    rep(i,n-1+m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        in[b]++;
    }
    queue<int> q;
    vi ans(n,-1);
    rep(i,n)if(in[i] == 0){
        q.push(i);
        ans[i] = 0;
    }
    while(q.size()){
        int now = q.front();
        q.pop();
        rep(i,g[now].size()){
            int ne = g[now][i];
            if(in[ne] == 1){
                ans[ne] = now+1;
                q.push(ne);
            }
            in[ne]--;
        }
    }
    rep(i,n)cout << ans[i] << endl;
}


Measured memory_bytes: 7808
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

void swap(i64 *x,i64 *y){
    i64 t=*x;
    *x=*y;
    *y=t;
    return;
}

i32 main(void){
    i64 x,y;
    while(1){
        scanf("%lli%lli",&x,&y);
        if(x==0LL&&y==0LL) break;
        if(x>y) swap(&x,&y);
        printf("%lli %lli\n",x,y);
    }
    return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  int N; cin >> N;
  string S; cin >> S;
  REP(x, (ll)S.size()) {
    char ac = S.at(x) + N;
    if (ac > 'Z') {
      ac -= 'Z' - 'A' + 1;
    }
    printf("%c", ac);
  }
  cout << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(N), B(N);
    vector<pair<int64_t, int64_t>> BA(N);
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
        if(A[i] < B[i]) swap(A[i], B[i]);
        BA[i] = {B[i], A[i]};
    }
    int64_t Amax = *max_element(A.begin(), A.end());
    int64_t Amin = *min_element(A.begin(), A.end());
    sort(BA.begin(), BA.end());
    int64_t Bmin = BA[0].first, Bmax = BA[N-1].first;
    int64_t ans = (Amax-Amin) * (Bmax-Bmin);
    int64_t Amin0 = Amin;

    for(int i=0; i<N-1; i++){
        int64_t b = BA[i].first, a = BA[i].second;
        if(b >= Amin0) break;
        Bmin = min(Amin0, BA[i+1].first);
        Amin = min(Amin, b);
        Bmax = max(Bmax, a);
        ans = min(ans, (Amax-Amin) * (Bmax-Bmin));
    }
    cout << ans << endl;
}

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

bool check(string t){
  bool flag = true;
  for(int i = 1; i < t.size(); i++){
    if(t[i] != t[i-1]){
      flag = false;
      break;
    }
  }
  return flag;
}

void solve(string s){
  int steps = 0, result = 1e9; // 10^9
  string t, newT; 

  for(int i = 0; i < s.size(); i++){
    char c = s[i];
    steps = 0; 
    t = s;
    while(check(t) == false){
      newT = "";
      for(int i = 0; i < t.size()-1; i++){
        if(t[i] == c || t[i+1]==c){
          newT += c;
        }
        else newT += t[i];
      }
      t = newT;
      steps++;
    }
    // Find the min
    result = min(result, steps);
  }
  cout << result << endl; 
}

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

  solve(s);
}

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

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

Measured memory_bytes: 5124
from collections import deque

INF = float("inf")


def main():
    N = int(input())
    E = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        E[a] += [(b, c)]
        E[b] += [(a, c)]
    path = [INF] * (N+1)
    Q, K = map(int, input().split())
    q = deque([(K, 0)])
    while len(q):
        x, cost = q.popleft()
        path[x] = cost
        for e in E[x]:
            nx, nc = e
            if path[nx] == INF:
                q.append((nx, cost+nc))
    for _ in range(Q):
        x, y = map(int, input().split())
        print(path[x] + path[y])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, K, q;
ll dp[500][500][500];

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

  cin >> n >> K;
  rrep(i, 1, n + 1) cin >> a[i];

  rep(i, 500) rep(j, 500) rep(k, 500) dp[i][j][k] = LINF;
  dp[0][0][0] = 0;

  rrep(i, 1, n + 1) {
    rep(j, n + 1) {
      ll N_remove_cost = LINF;
      rep(k, n) {
        if (j >= 1) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k]);

        N_remove_cost =
            min(N_remove_cost, dp[i - 1][j][k] + max(0LL, a[i] - a[k]));
      }
      dp[i][j][i] = min(dp[i][j][i], N_remove_cost);
    }
  }

  ans = LINF;
  rep(i, n + 1) { ans = min(ans, dp[n][K][i]); }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 977280
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<sstream>
#include<cstdio>
#include<algorithm>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0;i < S.length();i++){
        if (S[i] != T[i]){
            ans++;
        }
    }
    cout << ans;
    return 0;
}

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

          

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data(10, vector<int> (10));
  for(int i = 1; i <= N; i++) {
    int a = i % 10;
    int b = i;
    while(b >= 10) {
      b /= 10;
    }
    data.at(b).at(a)++;
  }
  int ans = 0;
  for(int i = 1; i <= 9; i++) {
    for(int j = 1; j <= 9; j++) {
      ans += data.at(i).at(j) * data.at(j).at(i);
    }
  }
  cout << ans << endl;
}

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 X,Y;

int main(){
	cin >> X >> Y;
	int ans = 0;
	while(X<=Y){
		X <<= 1;
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())

s_list = []
t_list = []
for i in range(N):
    s, t = map(str, input().split())
    s_list.append(s)
    t_list.append(int(t))

X = str(input())

ans = sum(t_list)
for i in range(N):
    if X == s_list[i]:
        ans -= t_list[i]
        break
    else:
        ans -= t_list[i]
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
using namespace std;
const int N=25010,K=410;
const int MOD=1e9+7;
int n,o,m; // o=k
int a[N];
void readData(){
	scanf("%d%d%d",&n,&o,&m);
	for(int i=1;i<=m;i++) scanf("%d",&a[i]);
}
int fastPow(int x,int y){
	int res=1;
	for(;y;x=1ll*x*x%MOD,y>>=1)
		if(y&1)
			res=1ll*res*x%MOD;
	return res;
}
int getType(){
	static int sum[K];
	int haveCnt=0;
	for(int i=1;i<=m;i++){
		if(!sum[a[i]])
			haveCnt++;
		sum[a[i]]++;
		if(i-o>0){
			if(sum[a[i-o]]==1)
				haveCnt--;
			sum[a[i-o]]--;
		}
		if(haveCnt==o)
			return 0;
	}
	for(int i=1;i<=o;i++) sum[i]=0;
	for(int i=1;i<=m;i++){
		if(sum[a[i]])
			return 2;
		sum[a[i]]++;
	}
	return 1;
}
int dp(){
	static int f[N][K],g[N][K];
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=o-1;j>=1;j--){
			if(j){
				(f[i][j]+=1ll*(f[i-1][j-1]-f[i-1][j])%MOD*(o-(j-1))%MOD)%=MOD;
				(g[i][j]+=1ll*(g[i-1][j-1]-g[i-1][j])%MOD*(o-(j-1))%MOD)%=MOD;
			}
			(f[i][j]+=f[i-1][j])%=MOD;
			(g[i][j]+=g[i-1][j])%=MOD;
			if(j>=m)
				(g[i][j]+=f[i][j])%=MOD;
			(f[i][j]+=f[i][j+1])%=MOD;
			(g[i][j]+=g[i][j+1])%=MOD;
		}
		f[i][0]=f[i][1];
		g[i][0]=g[i][1];
	}
	return g[n][0];
}
int calcDistinct(){
	int div=1;
	for(int i=o;i>o-m;i--)
		div=1ll*div*i%MOD;
	return 1ll*dp()*fastPow(div,MOD-2)%MOD;
}
void dp(int f[][K],int up,int ready){
	f[0][ready]=1;
	for(int j=o-2;j>=1;j--) (f[0][j]+=f[0][j+1])%=MOD;
	for(int i=1;i<=up;i++){
		for(int j=o-1;j>=1;j--){
			if(j>1)
				(f[i][j]+=1ll*(f[i-1][j-1]-f[i-1][j])%MOD*(o-(j-1))%MOD)%=MOD;
			(f[i][j]+=f[i-1][j])%=MOD;
			(f[i][j]+=f[i][j+1])%=MOD;
		}
	}
}
int calcAppend(){
	static bool exist[K];
	int l,r;
	for(l=1;l<=m&&!exist[a[l]];l++)
		exist[a[l]]=true;
	l--;
	memset(exist,0,sizeof exist);
	for(r=m;r>=1&&!exist[a[r]];r--)
		exist[a[r]]=true;
	r++;
	static int f1[N][K],f2[N][K];
	dp(f1,n-m,l);
	dp(f2,n-m,m-r+1);
	int res=0;
	for(int i=0;i<=n-m;i++)
		(res+=1ll*f1[i][1]*f2[n-m-i][1]%MOD)%=MOD;
	return res;
}
void solve(){
	int ans=1ll*(n-m+1)*fastPow(o,n-m)%MOD;
	int type=getType();
	if(type==1)
		(ans-=calcDistinct())%=MOD;
	else if(type==2)
		(ans-=calcAppend())%=MOD;
	printf("%d\n",ans>=0?ans:ans+MOD);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 82048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
const int mod = 1e9 + 7;
int main()
{

  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll a,b,c,d;
  cin >> a >> b >> c >>d;
  ll f=0;
  while(a>0||c>0){
      if(f==0){
          c=c-b;
          f=1;
          if(c<=0){cout<<"Yes\n";break;}
      }
      else if(f==1){
          a=a-d;
          f=0;
          if(a<=0){cout<<"No\n";break;}
      }
  }
  //if(a<=0)cout<<"No\n";
  //else cout<<"Yes\n";
  

} 

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
#define int long long
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 gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

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

  int ans=n-1;
  for(int i=2;i*i<=n;++i){
    if(n%i)continue;
    chmin(ans,n/i+n/(n/i)-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    let n: i64 = line.trim().parse().unwrap();
    let mut sum = 0;
    for i in 1..=n {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(){
    int N,sum;
    int a;
    cin >> N;
    vector<int>X;
    vector<int>x;
    for(int i = 0; i < N; i++){
        cin >> a;
        X.push_back(a);
        x.push_back(a);
    }
    sort(X.begin(), X.end());
    int t = N/2;
    // cout << t;
    for(int i = 0; i < N; i++){
        // cout << X[i] << endl;
        if(x[i] <= X[t-1]){
            cout << X[t] << endl;
        }else{
            cout << X[t-1] << endl;
        }
    }
}

Measured memory_bytes: 3948
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)


a,b = get_nums_l()

for x in range(10000):
    if int(x*0.08) == a and int(x*0.1) == b:
        print(x)
        exit()
print(-1)

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

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

int main()
{
  int K, T;
  cin >> K >> T;
  vector<int> a(T);
  rep(i, T)
    {
      cin >> a[i];
    }
  int old_max_a = -1;
  rep(i, K)
    {
      int flag = 0;
      int max_a = 0;
      rep(i, T)
	{
	  if(i != old_max_a && a[i] > a[max_a])
	    {
	      max_a = i;
	    }
	  if(a[i] == 0)
	    {
	      flag++;
	    }
	}
      old_max_a = max_a;
      a[max_a]--;
      if(flag == T-1)
	{
	  cout << a[max_a] << endl;
	  return 0;
	}
    }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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


Measured memory_bytes: 888
import java.util.*;

public class Main {
    static long count = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列の長さ
        int[] a = new int[n]; //数列A
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int x = partition(a, 0, a.length-1);
        StringBuilder sb = new StringBuilder();
        for(int i=0; i<n; i++) {
            if(i>0) sb.append(" ");
            if(i==x) sb.append("[" + a[i] + "]");
            else sb.append(a[i]);
        }
        System.out.println(sb); //出力
    }
    /**
     * Partition
     */
    static int partition(int[] a, int p, int r) {
        int x = a[r];
        int i = p-1;
        for(int j=p; j<r; j++) {
            if(a[j]<=x) {
                i++;
                int g = a[j];
                a[j] = a[i];
                a[i] = g;
            }
        }
        int g = a[i+1];
        a[i+1] = a[r];
        a[r] = g;
        return i+1;
    }
}


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

using namespace std;

vector<int> G[100000];
bool used[100000];

int cnt;
void dfs(int v){
    used[v] = true;
    cnt++;
    for(int i = 0;i < G[v].size(); i++){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--;
        Y--;
        G[X].push_back(Y);
        G[Y].push_back(X);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(!used[i]){
            dfs(i);
            ans++;
        }
    }
    cout << ans << endl;
}

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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int p = sc.NextInt();
        Console.WriteLine((a * 3 + p) / 2);
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11220
//In the name of "Allah"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll ans = 0;
    for( ll i = 0 ; i < s.size() ; i++ )
    {
        ans += (ll)(s[i]-'0');
    }
    if(ans%9==0)
    {
        cout << "Yes\n" <<endl;
    }
    else
    {
        cout <<"No\n" <<endl;
    }
}


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

int mod = 1000000007;

int main()
{
    int N, tmp;
    cin >> N;
    bool x = true;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        if (tmp % 2 == 0 && (tmp % 3 != 0 && tmp % 5 != 0))
            x = false;
    }
    cout << (x ? "APPROVED" : "DENIED");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
  return 0;
}

Measured memory_bytes: 3592
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    H = sorted([int(input()) for _ in range(N)], reverse=True)
    print(min([a - b for a, b in zip(H[:N-K+1], H[K-1:])]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12476
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;

void Main(){

  int N,K; cin>>N>>K;
  string S; cin>>S;

  vector<int> ves;
  vector<int> veg;

  ves.emplace_back(0);
  rep(i,N){
    //if(i==0 or i==N-1) continue;
    if(i!=0 and S[i]=='1' and S[i-1]=='0') ves.emplace_back(i);
    if(i!=N-1 and S[i]=='1' and S[i+1]=='0') veg.emplace_back(i);
  }
  veg.emplace_back(N-1);
/*
  rep(i,ves.size()){
    db(ves[i]);
  }
  rep(i,veg.size()){
    db(veg[i]);
  }
*/
  int ans=0;
  rep(i,ves.size()){
    int k=min(-1+(int)veg.size(),i+K-(S[0]=='0'));
    maxi(ans,veg[k]-ves[i]+1);
  }

  cout<< ans<<"\n";

}

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


Measured memory_bytes: 1024
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

#define max(a, b) ((a)>(b))? (a):(b)
long long n, k;

int main()
{
    long long m = 0;
    cin>>n>>k;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    for(int b=k+1; b<=n; b++){
        m += ((n/b)*(b-k));
        m += max(0, (n%b)-k+1);
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1,y1,x2,y2,x,y;
  cin>>x1>>y1>>x2>>y2;
  x=y2-y1,y=x1-x2;
  cout<<x2-x<<" "<<y2-y<<" "<<x1-x<<" "<<y1-y;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#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>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> cnt(9);
    rep(i, n) {
        int a;
        cin >> a;
        cnt[min(a/400, 8)]++;
    }
    if (cnt[8] == n) {
        cout << 1 << " " << n << endl;
    } else {
        int ans = 0;
        rep(i, 8) {
            if (cnt[i]) ans++;
        }
        cout << ans << " " << ans + cnt[8] << endl;
    }
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#  define _CRT_SECURE_NO_WARNINGS
#  define _USE_MATH_DEFINES
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
using u32 = unsigned int; using u64 = unsigned long long int;
template <class T> using vec = vector<T>;
void in(){}; template <class T, class...TS> void in(T &&x, TS &&...xs) { cin >> x; in(move(xs)...); };
template <class T> void out(T &&x) { cout << x << "\n"; }; template <class T, class...TS> void out(T &&x, TS &&...xs) { cout << x << " "; out(move(xs)...); }
#define indef(t, ...) t __VA_ARGS__; in(__VA_ARGS__)
#define get(t) []{ t _; cin >> _; return _; }()
#define times(n, i) for (i32 i =  0 ; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define even(x) ((abs(x) & 1) == 0)
#define odd(x) ((abs(x) & 1) == 1)
#define bit(x, i) (((x) >> i) & 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007ll;
const f64 EPS = 1e-10;

bool solve() {
    indef(i32, n);
    i32 a[100000] = {};
    i32 mina = INT_MAX, maxa = 0, mincnt = 0;
    times(n, ni) {
        in(a[ni]);
        mina = min(mina, a[ni]);
        maxa = max(maxa, a[ni]);
    }
    times(n, ni) {
        mincnt += a[ni] == mina ? 1 : 0;
    }
    if (maxa > mina+1) return false;
    if (mina == maxa) {
        return mina == n-1 || mina*2 <= n;
    }
    return (mincnt < maxa) && (2 * maxa <= n + mincnt);
}

i32 main()
{
    ios::sync_with_stdio(false);

#ifdef _MSC_VER
    /**
    ifstream fin("input.txt"); cin.rdbuf(fin.rdbuf()); assert(fin);
    ofstream fout("output.txt"); cout.rdbuf(fout.rdbuf()); assert(fout);
    /**/
#endif

    out(solve() ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;


//typedef pair<int,int> data;
//vector<data> input[100010];
//int p[100010];
//int y[100010];
//char  ans[100010][12];
//
//
//bool cmp(data d1,data d2){
//    return d1.first<d2.first;
//}
//
//int n,m;
//int main(){
//    cin>>n>>m;
//    for(int i=1;i<=m;i++){
//        scanf("%d%d",p+i,y+i);
//        input[p[i]].push_back(make_pair(y[i],i));
//    }
//    for(int i=1;i<=100010;i++){
//        if(input[i].size()>0)
//            sort(input[i].begin(),input[i].end(),cmp);
//    }
//    return 0;
//}

#define mod 1000000007
long long dp[9][101];     //从该点到出口的方法总数
int h,w,k;
long long ans;
int cmb[7]={0,2,3,5,8,13,21};


long long dfs(int dep,int from,int to){ //dep为to所在点高度，
    //from=to -> |
    //from<to -> |_
    //from>to -> _|

    if(dep==h){
        if(to==k)
            return 1;
        else
            return 0;
    }
    if(dp[to][dep]==-1){
        int next=0;
        int add;
        if(to>1){
            add=1;
            if(to-1>2)
                add*=cmb[to-1-2];
            if(to<w-1)
                add*=cmb[w-to-1];
            next=(next+dfs(dep+1,to,to-1)*add)%mod;
        }
        if(to<w){
            add=1;
            if(to>2)
                add*=cmb[to-2];
            if(to+1<w-1)
                add*=cmb[w-(to+1)-1];
            next=(next+dfs(dep+1,to,to+1)*add)%mod;
        }
        add=1;
        if(to>2)
            add*=cmb[to-2];
        if(to<w-1)
            add*=cmb[w-to-1];
        next=(next+dfs(dep+1,to,to)*add)%mod;
        dp[to][dep]=next;
    }
    //printf("dp[%d][%d]=%I64d\n",to,dep+1,dp[to][dep+1]);
    return dp[to][dep];
}

int main(){
    cin>>h>>w>>k;
    int res=0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=w;i++)
        dp[i][h]=(i==k?1:0);
//    if(k==1){
//        res=1;
//        if(w-2>0){
//            for(int i=0;i<h;i++)
//                res=(res*cmb[w-2])%mod;
//        }
//        if(w>1)
//            res+=(dfs(1,1,2,1)%mod);
//    }else{
        res+=(dfs(0,1,1)%mod);
        //res+=(dfs(1,1,2,1)%mod);
//    }
    cout<<res%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Tuesday, 14 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    int N, K;

    cin >> N >> K;
    unordered_set<int> A;
    vector<int> digits;

    for(int i = 0; i < K; ++i) {
        int a;
        cin >> a;
        A.insert(a);
    }

    int i;
    bool found = false;
    for(i = N; found != true ;i++) {
        found = true;
        int b = i;
        while(b) {
            int c = b;
            b /= 10;
            c = c - b*10;
            if(A.count(c)) {
                found = false;
                break;
            }
        }
        
    }
 
    cout << i-1 << "\n";
    
    return 0;
    
}


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

using namespace std;

string S;
int sizeOfString;
int flag = 0;

int main()
{
	cin >> S;
	sizeOfString = S.size();
	for(int i = 1; i < sizeOfString; i++)
	{
		if(S[i] == 'C' && S[i - 1] == 'A')
		{
			flag++;
		}
	}
	if(flag)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    string s[3];
    for(int i=0;i<3;i++){
        cin>>s[i];
        s[i]=s[i].substr(0,1);
        transform (s[i].begin(),s[i].end(),s[i].begin(),::toupper);
    }
    cout<<s[0]+s[1]+s[2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N, K; char S[10]; 
    scanf("%d%s%d", &N, S, &K);
    char base = S[K - 1];
    for (int i = 0; i < N; i++)
    {
        if (S[i] != base) S[i] = '*';
    }
    printf("%s\n", S);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mpr make_pair
#define MX 100010
#define ui unsigned int
#define ll long long
#define ld long double 
#define fi first
#define se second
#define endl '\n'
#define debug(bug) cout<<"akshat"<<" "<<bug<<endl
#define printarray(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define printvector(Aneveruse,neverusen) for(int neveruse=0;neveruse<neverusen;neveruse++) cout<<Aneveruse[neveruse]<<" "; cout<<endl
#define dd long double 
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL)
const ll inf=1000000000000;
const int mod=1000000007;
// priority_queue <int, vector<int>, greater<int> > pq; //minimum priority queue
int n;
int A[MX];
ll dp[MX];
int main()
{
  fast_io;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>A[i];
  }
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),(i-2<0?inf:dp[i-2])+abs(A[i]-(i-2<0?0:A[i-2])));
  }

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

 
  return 0;
}


Measured memory_bytes: 1408
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

for l in [A, B, C]:
    l.sort()

exists = set()
q = [(-(A[X - 1] + B[Y - 1] + C[Z - 1]), (X - 1, Y - 1, Z - 1))]
for _ in range(K):
    v, n = heappop(q)
    print(-v)
    for i in range(3):
        if n[i] > 0:
            t = [n[j] for j in range(3)]
            t[i] -= 1
            nn = tuple(t)
            if nn not in exists:
                exists.add(nn)
                nv = A[nn[0]] + B[nn[1]] + C[nn[2]]
                heappush(q, (-nv, nn))


Measured memory_bytes: 4968
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n];
    for( int i = 0; i < n; ++i ) cin >> a[i];
    int res = 0;
    for( int i = 1; i < n - 1; ++i ) {
        if( a[i - 1] < a[i] && a[i] < a[i + 1] || a[i - 1] > a[i] && a[i] > a[i + 1] ) ++res;

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



Measured memory_bytes: 256
n, m = map(int, input().split())
shops = []
money = 0
for i in range(n):
  shops.append(list(map(int, input().split())))
shops.sort(key=lambda x: x[0])
for shop in shops:
  if shop[1] <= m:
    money += shop[0] * shop[1]
    m -= shop[1]
  elif shop[1] > m:
    money += shop[0] * m
    break
print(money)

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

#define INF 0x3f3f3f3f
#define int long long
#define pii pair<int, int>

const int N = 100005;



int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, i, j, ans, dp[2][3];
    memset(dp, 0, sizeof(dp));
    cin >> n;
    while(n--) {
        for(i = 0 ; i < 3 ; i++)
            cin >> dp[1][i];
        dp[1][0] = max(dp[0][1], dp[0][2]) + dp[1][0];
        dp[1][1] = max(dp[0][0], dp[0][2]) + dp[1][1];
        dp[1][2] = max(dp[0][0], dp[0][1]) + dp[1][2];
        for(i = 0 ; i < 3 ; i++) {
            dp[0][i] = dp[1][i];
        }
    }
    ans = 0;
    for(i = 0 ; i < 3 ; i++)
        ans = max(ans, dp[1][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

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

int main()
{
    int a, b; cin >> a >> b;
    if (abs(a-b) <= 1)
        cout << "Yay!" << endl;
    else
        cout << ":("<< endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;

int main(void)
{
	int a;
	cin >> a;
	string c;
	if (a >= 2800) {
		c = "AGC";
	}
	else if (a >= 1200) {
		c = "ARC";
	}
	else {
		c = "ABC";
	}
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll a, b; cin >> a >> b;
    ll n = (a&b);
    vector<int> v;
    for(int i=0; i<32; ++i){
        v.push_back(n&1);
        n>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
    v.clear();
    n = a|b;
    for(int i=0; i<32; ++i){
        v.push_back(n&1);
        n>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
    v.clear();
    n = a^b;
    for(int i=0; i<32; ++i){
        v.push_back(n&1);
        n>>=1;
    }
    reverse(v.begin(), v.end());
    for(auto e: v) cout << e;
    cout << endl;
    
	return 0;
}


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

int num_load(std::vector<int>::iterator begin, std::vector<int>::iterator end, int k, int p)
{
  auto n = std::distance(begin, end);

  auto itr = begin;
  for (int i=0; i<k; i++)
    {
      auto s = 0;
      while ((s + (*itr)) <= p)
        {
          s += *itr;
          ++itr;
          if (itr == end) return n;
        }
    }
  return std::distance(begin, itr);
}

int main ()
{
  int n, k;
  std::vector<int> pkgs;

  std::cin >> n >> k;
  for (int i=0; i<n; ++i)
    {
      int tmp;
      std::cin >> tmp;
      pkgs.push_back(tmp);
    }

  long long p_left = 0;
  long long p_right = 10000*100000;
  long long p_mid;
  while (p_left < p_right - 1)
    {
      p_mid = (p_left + p_right) / 2;
      auto n_load = num_load(pkgs.begin(), pkgs.end(), k, p_mid);
      //std::cout << p_left << " " << p_mid << " " << p_right << ":" << n_load << std::endl;

      if (n_load >= n) p_right = p_mid;
      else p_left = p_mid;
    }
  std::cout << p_right << std::endl;
}



Measured memory_bytes: 3528
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
R = [[0,0,0],[0,0,0],[0,0,0]]
Rt = [[0,0,0],[0,0,0],[0,0,0]] 
for i in range(3):
  for j in range(3):
    for k in range(N):
      if(A[i][j] == B[k]):
        R[i][j] = 1
        Rt[j][i] = 1
        break
bingo = [1,1,1]
if(R[0] == bingo or R[1] == bingo or R[2] == bingo):
  print("Yes")
elif(Rt[0] == bingo or Rt[1] == bingo or Rt[2] == bingo):
  print("Yes")
elif([R[0][0], R[1][1], R[2][2]] == bingo or [R[0][2], R[1][1], R[2][0]] == bingo):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
S = input()

# 0 to 99 YY
# 1 to 12 MM

AA = int(S[:2])
BB = int(S[2:])

A = ""
B = ""
ans = ""
if AA == 0 or AA > 12:
    A = "YY"
else:
    A = "MM"
    
if BB == 0 or BB > 12:
    B = "YY"
else:
    B = "MM"
    
if A == "YY" and  B == "YY":
    ans = "NA"
elif A == "YY" and B == "MM":
    ans = "YYMM"
elif A == "MM" and B == "YY":
    ans = "MMYY"
else:
    ans = "AMBIGUOUS"
        
print(ans)
    

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  ll N, msum = 0, usum = 0, ans = -(1LL << 60);
  cin >> N;
  priority_queue<ll, vector<ll>, greater<ll> > mae_que;
  priority_queue<ll> usiro_que;
  ll a[N*3], mae_sum[N*3], usiro_sum[N*3];

  rep(i, N*3){
    cin >> a[i];
    if (N > i) {
      msum += a[i];
      mae_que.push(a[i]);
    }
    if (i >= N*2) {
      usum += a[i];
      usiro_que.push(a[i]);
    }
  }

  for(int i = N; i <= 2*N; i++){
    // cout << msum << "  " << i << endl;
    mae_sum[i] = msum;
    mae_que.push(a[i]);
    msum += a[i];
    msum -= mae_que.top();
    mae_que.pop();
  }

  usiro_sum[2*N] = usum;
  for(int i = 2*N-1; i >= N; i--) {
    usiro_que.push(a[i]);
    usum += a[i];
    usum -= usiro_que.top();
    usiro_que.pop();
    // cout << usum << "  " <<  i << endl;
    usiro_sum[i] = usum;
  }

  for(int i = N; i <= 2*N; i++) {
    ans = max(ans, mae_sum[i]-usiro_sum[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 8948