akhauriyash/Code-Regression huggingface dataset:
#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 <cstdlib>  // abs() for integer
#include <math.h>     // math.h をインクルードする！
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

}

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

using namespace std;

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

	if (b <= a) {
		cout << "delicious";
	} else if (b - a <= x) {
		cout << "safe";
	} else {
		cout << "dangerous";
	}

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = readline().rstrip().decode()
ans = s.count('R') * s.count('G') * s.count('B')
for i, si in enumerate(s):
    for j, sj in enumerate(s[i + 1:]):
        k = 2 * (j + 1) + i
        if k >= n:
            break
        if si != sj and si != s[k] and sj != s[k]:
            ans -= 1
print(ans)


Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int X;
        int Y;

        try (Scanner sc = new Scanner(System.in)) {
            X = sc.nextInt();
            Y = sc.nextInt();
        }
        System.out.println( 6 - (X+Y));
        

    }


}


Measured memory_bytes: 22100
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    a,v = mi()
    b,w = mi()
    t = ii()
    if v <= w:
        print('NO')
        exit()

    if abs(b-a)<=(v-w)*t:
        print('YES')
    else:
        print('NO')




main()




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

int main() {
    int N,K;
    cin >> N >> K;
    int h[100000];
    for(int i=0; i<N; ++i) cin >> h[i];
    sort(h, h+N);
    int ans = 1001001001;
    for(int i=0; i + K - 1 < N; ++i) {
        ans = min(ans, h[i+K-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
N, L = map(int, input().split())
A = [0]*N
for i in range(N):
    A[i] = L + (i+1) - 1

ans = 0
if 0 in A:
    ans = sum(A)
else:
    if L < 0:
        ans = sum(A) - A[-1]
    else:
        ans = sum(A) - A[0]

print(ans)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define N 200100
const ll mod = 1e9 + 7;

int a[N];
int n, m;

ll solve(int b) {
	ll ans = 0;
	for(int i = 0; i < n; i++) ans += abs(a[i] - b);
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	while(cin >> n) {
		for(int i = 0; i < n; i++) {
			cin >> a[i];
			a[i] -= i+1;
		}
		sort(a, a + n);
		ll ans = 1e18;
		ans = min(ans, solve(a[n / 2]));
		ans = min(ans, solve(a[n / 2 + 1]));
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

inline int inv(int a, int m) {
	int i = 1, j = 0;
	for (int b = m; a > 1; swap(i, j), swap(a, b)) {
		j = (j + b / a * long(m - i)) % m;
		b %= a;
	}
	return i;
}
int p = 998244353;
int c[4444][4444];
int k, d[2222][4444];
int f(int n, int i) {
	if (n == 1) return k;
	if (!n) return 1;
	if (n < 0) return 0;
	if (d[n][i] >= 0) return d[n][i];
	if (i < 2) return d[n][i] = c[n + k - 1][k - 1];
	if (i == 2) return d[n][i] = (c[n + k - 2][k - 2] + c[n + k - 3][k - 2]) % p;
	d[n][i] = (f(n, i - 2) - f(n - 2, i - 2) + p) % p;
	return d[n][i];
}
int main() {
	int n;
	cin >> k >> n;
	for (int i = 0; i < 2222; i++)
		fill(d[i], d[i] + 4444, -1);
	for (int i = 0; i < 4444; i++)
		for (int j = 0; j <= min(i, 2221); j++)
			c[i][j] = j ? (c[i - 1][j - 1] * long(i) % p)*inv(j, p) % p : 1;
	for (int i = 2; i <= k * 2; i++)
		cout << f(n, min(i, k * 2 - i + 2)) << endl;
	return 0;
}


Measured memory_bytes: 115712
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef pair<int,int> pi;

const int N=100005,M=20;

int n,lg2[N];
struct ST_list{
	int ST[M][N],va[N];
	int Min(int x,int y){return va[x]<va[y]?x:y;}
	void build(){
		for(int i=1;i<=n;i++)ST[0][i]=i;
		for(int l=2,i=1;l<=n;l<<=1,i++)for(int j=1;j<=n-l+1;j++)
			ST[i][j]=min(ST[i-1][j],ST[i-1][j+(l>>1)]);
	}
	int min(int l,int r){
		int d=lg2[r-l+1];
		return Min(ST[d][l],ST[d][r-(1<<d)+1]);
	}
}A,B;

int m;pi id[N];
vector<int>e[N];

int solve(ST_list*a,ST_list*b,int l,int r,bool k){
	int x=a->min(l-k,r-k),y=b->min(x+k,r);
	int p=++m;id[p]={a->va[x],b->va[y]};
	if(l<=x-!k)e[p].pb(solve(a,b,l,x-!k,k));
	if(x+1<=y-k)e[p].pb(solve(b,a,x+1,y-k,k^1));
	if(y+1<=r)e[p].pb(solve(a,b,y+1,r,k));
	return p;
}

typedef pair<pi,int> ppi;
priority_queue<ppi,vector<ppi>,greater<ppi>> que;

int main(){
	scanf("%d",&n);n>>=1;
	for(int i=1;i<=n;i++)scanf("%d%d",&A.va[i],&B.va[i]);
	A.build();B.build();
	for(int i=2;i<=n;i++)lg2[i]=lg2[i-1]+!(i&(i-1));
	solve(&A,&B,1,n,0);
	que.push({id[1],1});
	while(que.size()){
		auto t=que.top();que.pop();
		printf("%d %d ",t.fi.fi,t.fi.se);
		for(int v:e[t.se])que.push({id[v],v});
	}
	return 0;
}

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;
    
    x=abs(x);
    ll m=x/d;
    ll ans=0;
    if(k<=m){
        ans=x-k*d;
        cout<<ans<<endl;
        return 0;
    }
    k-=m;
    if(k%2==0) ans=x-m*d;
    else ans=abs(x-(m+1)*d);
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC80(void);
void ABC81(void);
void ABC82(void);
void ABC83(void);
void ABC84(void);
void ABC85(void);
void ABC86(void);
void ABC87(void);
void ABC88(void);
void ABC89(void);

int main(void){
    ABC81();
}

void ABC81(){
    int i,n,count=0,c=0,b=2,ans=0;
    cin>>n;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    while(1){
        for(i=0;i<n;i++){
            if(vec[i]%b==0)count++;
        }
        if(count==n)ans++;
        else break;
        count=0;
        b*=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
range = xrange
input = raw_input

n,m = [int(x) for x in input().split()]

A = [int(x) for x in input().split()]

pairs = []
for _ in range(m):
    b,c = [int(x) for x in input().split()]
    pairs.append((c,b))
pairs.sort()

bestn = []
while len(bestn)<n and pairs:
    c,b = pairs.pop()
    bestn += [c]*b

A += bestn
A.sort(reverse=True)
print sum(A[:n])


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

int main() {
    string s;
    cin >> s;
    bool ans = false;
    if (s[2] == s[3] && s[4] == s[5]) ans =true;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  vector<int> num_w(N + 1, 0);
  vector<int> num_e(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'W') {
      num_w[i+1] = num_w[i] + 1;
      num_e[i+1] = num_e[i];
    } else {
      num_e[i+1] = num_e[i] + 1;
      num_w[i+1] = num_w[i];
    }
  }
  
  int ans = 300000;
  for (int i = 0; i < N; i++) {
    int count = 0;
    
    count += num_w[i] - num_w[0];
    count += num_e[N] - num_e[i + 1];
    
    ans = min(ans, count);
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  if (N!=1) {
    for (int i=2; i<N+1; i++) {
      L.at(i)=L.at(i-1)+L.at(i-2);
    }
  }
  cout << L.at(N) <<endl;
}


Measured memory_bytes: 3600
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	ll n, d;
	cin >> n >>d;
	d*=d;
	//set<pair<ll, ll>> has;
	int ans = 0;
	ll a, b;
	for(int i = 0; i < n; i++) {
		cin >> a >> b;
		//if(has.count({a, b}))
			//continue;
		//has.insert({a, b});
		if(a*a+b*b<=d)
			ans++;
	}
	cout <<ans << '\n';

	return 0;
}


Measured memory_bytes: 3660
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i128,
        a: [i128; n as usize],
        b: [i128; m as usize],
    }

    solve(n, m, k, &a, &b);
}

fn solve(n: usize, m: usize, k: i128, a: &[i128], b: &[i128]) {
    let mut x: Vec<i128> = vec![0];
    for i in 0..n {
        x.push(x[i] + a[i]);
    }

    let mut y: Vec<i128> = vec![0];
    for i in 0..m {
        y.push(y[i] + b[i]);
    }

    let mut ans = 0;
    let mut j = m;
    for i in 0..(n + 1) {
        if x[i] > k {
            break;
        }
        while x[i] + y[j] > k {
            j -= 1;
        }
        if ans < i + j {
            ans = i + j;
        }
    }

    println!("{}", ans);
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	ll x, k, d;
	cin >>x>>k>>d;
	x = abs(x);
	if (x/d>k) cout <<x-d*k<<endl;
	else {
		ll sol1 = x%d;
		ll kor = (x-sol1)/d;
		if (kor%2 == k%2) cout <<sol1<<endl;
		else cout <<abs(sol1-d)<<endl;
	}
	return 0;
}

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

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (int n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (int n = (a); n >= (b); --n)
#define _for(n, a, b) for (int n = (a); n < (b); ++n)
#define _rof(n, a, b) for (int n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f3f
#define ll  long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 998244353;
const ll maxn = 1e6 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    _rep(i, 1, n){
        s = s + "ACL";
    }
    cout << s<<endl;
}

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;


int main(void) {
	vector<ll> m(1000000, 0);
	ll s = 0;

	long long N, Q;
	cin >> N;
	vector<long long> A(N);
	rep(i, N) {
		cin >> A[i];
		m[A[i]]++;
		s += A[i];
	}


	cin >> Q;

	vector<long long> B(Q), C(Q);
	rep(i, Q) {
		cin >> B[i];
		cin >> C[i];
	}

	rep(i, Q) {
		long long temp = m[B[i]];
		m[C[i]] += temp;
		m[B[i]] = 0;

		s -= B[i] * temp;
		s += C[i] * temp;
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 13560
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

k,n=map(int,input().split())
a=list(map(int,input().split()))
# a.sort()
ans=float('inf')
for i in range(n-1):
    ans=min(ans, k-(a[i+1]-a[i]))
ans=min(ans,k-(a[0]+k-a[n-1]))
print(ans)

Measured memory_bytes: 97784
#include <iostream>
#include <cmath>
#include <algorithm>
#include <deque>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
// #define mp make_pair
// #define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define show(x) cout << #x << " = " << x << endl;



int main(){

  int m;
  cin >> m;
  cout << 48 -m << endl;

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	lint sum = 0;
	string pre_s = s;
	rep(bit,1 << (pre_s.size()-1)){
		lint tmp = 0;

		rep(j,pre_s.size()){
			if(bit>>j & 1){
				string s_t = s.substr(pre_s.size()-1-j);
				tmp += stol(s_t);
				s = s.substr(0,s.size()-s_t.size());
			}
		}
		tmp += stol(s);
		sum += tmp;
		s = pre_s;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>0)cout<<"Positive"<<endl;
    else if(a<=0&&b>=0)cout<<"Zero"<<endl;
    else if((abs(b)-abs(a))%2!=0)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
L, R = map(int,(input().split()))
mod_min = 2018
if(R-L >= 673):
  print("0")
else:
  for i in range(L,R):
    for j in range(L+1,R+1):
      temp_mod = (i*j % 2019)
      if (temp_mod < mod_min):
        mod_min = temp_mod
  print(mod_min)

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

int main()
{  
   int n;
   cin>>n;
   int c[n-1],s[n-1],f[n-1];
   for(int i=0;i<n-1;i++) cin>>c[i]>>s[i]>>f[i];
   for(int i=0;i<n-1;i++){
       int t=s[i];
       for(int j=i;j<n-1;j++){
           if(t<s[j]) t=s[j];
           if(t%f[j]!=0){
               t+=f[j]-t%f[j];
           }
           t+=c[j];
       }
       cout<<t<<endl;
   }
   cout<<0<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

typedef long long ll;


// 連続するn個の整数には必ずnの倍数が含まれる。
// R-Lが2019以上なら答えは0
int main() {
    ll L,R;
    cin >> L >> R;
    // LとRどっちが近いか
    if (R-L>3000) cout << 0 << endl;
    else {
        ll ans=2018;
        FOR(i,L,R) {
            FOR(j,i+1,R+1) {
                chmin(ans,((ll)i*j)%2019);
            }
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i,n){
        cin >> p.at(i);
    }
    int ans =0;
    for(int i=1; i < n-1; i++){
        if(IN(p.at(i-1), p.at(i), p.at(i+1)) || IN(p.at(i+1), p.at(i), p.at(i-1))) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int n, k;
  cin >> n >> k;
  int a[n], one;
  for(int i=0;i<n;i++){
    cin >> a[i];
	if(a[i]==1)one = i;
  }
  int count = 0;
  int left = one;
  int right = n - one - 1;
  //cout << right << " " << left << endl;
  if(k==n){
    cout << 1 << endl;
    return 0;
  }
  if((right<k-1)&&(right!=0)){
    left -= (k - right - 1);
    right = 0;
    count++;
    //cout << right << " r " << left << endl;
    count += (left / (k-1));
    if((left%(k-1)!=0)&&(left>0))count++;
    cout << count << endl;
  }else if((left<k-1)&&(left!=0)){
    right -= (k - left - 1);
    left = 0;
    count++;
    //cout << right << " l " << left << endl;
    count += (right / (k-1));
    if((right%(k-1)!=0)&&(right>0))count++;
    cout << count << endl;
  }else if (left<=right){
    int mod = left % (k-1);
    count += (left / (k-1));
    if(mod != 0){
      right -= k - mod - 1;
      count++;
    }
    //cout << right << " mod " << left << endl;
    count += (right / (k-1));
    if(right%(k-1)!=0)count++;
    cout << count << endl;
  }else{
    int mod = right % (k-1);
    count += (right / (k-1));
    if(mod != 0){
      left -= k - mod - 1;
      count++;
    }
    //cout << right << " mod " << left << endl;
    count += (left / (k-1));
    if(left%(k-1)!=0)count++;
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 640
main :: IO ()
main = f <$> readLn >>= putStrLn
  where
    f n = case n `mod` 10 of
      _n
        | any (== _n) [2, 4, 5, 7, 9] -> "hon"
        | any (== _n) [0, 1, 6, 8] -> "pon"
        | otherwise -> "bon"


Measured memory_bytes: 3928
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

typedef struct union_find{
	public:
	int *prev, *rank, *size_a;
	int root(int x){ return prev[x]==x?x:(prev[x]=root(prev[x])); }
	int size(int x){ return size_a[root(x)]; }
	void join(int x, int y){
		x=root(x), y=root(y); if(x==y) return;
		if(rank[x]<rank[y]){
			prev[x]=y; size_a[y]+=size_a[x];
		}else if(rank[x]>rank[y]){
			prev[y]=x; size_a[x]+=size_a[y];
		}else{
			prev[x]=y; rank[y]++; size_a[y]+=size_a[x];
		}
	}
	union_find(int n){
		prev = (int*) malloc(n*sizeof(int));
		rank = (int*) malloc(n*sizeof(int));
		size_a = (int*) malloc(n*sizeof(int));
		for(int i=0; i<n; i++){ prev[i]=i; rank[i]=1; size_a[i]=1; }
	}
} union_find;


union_find f(200001);

int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<m; i++){
		int a=nextint();
		int b=nextint();
		f.join(a, b);
	}
	int ans=0;
	for(int i=1; i<=n; i++){
		int now = f.size(i);
		if(now>ans) ans=now;
	}
	printf("%d\n", ans);
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	for(int i=0;i<N;i++)	cin >> A.at(i);

	long long sum=0,xx=0;
	for(int i=0;i<N;i++){
		sum+=A.at(i);
		if(i%2==1)	xx+=2*A.at(i);
	}
	long long pre=sum-xx;
	cout << pre << " ";
	for(int i=0;i<N-1;i++){
		pre=(A.at(i)-pre/2)*2;
		cout << pre << " ";
	}

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int n,a,b,h[100100];

bool check(ll t){
  ll cnt = 0;
  rep(i,n){
    ll last = h[i]-t*b;
    if(last<=0) continue;
    cnt += last/a;
    if(last%a) cnt++;
  }
  return cnt<=t;
}

signed main(){
	cin>>n>>a>>b;
  a -= b;
  rep(i,n) cin>>h[i];
  int low = 0, high = 1001001001;
  while(low+1!=high){
    int mid = (low+high)/2;
    if(check(mid)) high=mid;
    else low=mid;
  }
  cout << high << endl;


  return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	var k int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &n)
	fmt.Scanf("%d", &n)

	scanner.Scan()
	b := []byte(strings.TrimSuffix(scanner.Text(), "\n"))

	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &k)

	c := b[k-1]
	for i, v := range b {
		if v != c {
			b[i] = '*'
		}
	}
	fmt.Println(string(b))
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; -i)
#define INF (1 << 30)

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

int main() {
	int n, k, x, y;
	scanf("%d %d %d %d", &n, &k, &x, &y);
	int ans = 0;
	int cnt = 0;
	while(cnt < n) {
		++cnt;
		if(cnt <= k) ans += x;
		else ans += y;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define f(x) x*x

int main()
{
	int d,i;
	while(cin >>d){
		int area = 0;
		for(i=d;i<600;i+=d){
			area += f(i)*d;
		}
		cout << area << endl;
	}
	return 0;
}

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

vector<pair<long long, long long>> prime(long long n)
{
    vector<pair<long long, long long>> ret;
    for (long long a = 2; a * a <= n; ++a)
    {
        if (n % a != 0)
            continue;
        long long cnt = 0;
        while (n % a == 0)
        {
            cnt++;
            n /= a;
        }
        ret.push_back({a, cnt});
    }
    if (n != 1)
        ret.push_back({n, 1});
    return ret;
}

int main()
{
    ll a, b;
    cin >> a >> b;
    vector<pair<ll, ll>> primeA = prime(a);
    vector<pair<ll, ll>> primeB = prime(b);

    ll ans  = 0;
    ll lenA = primeA.size();
    ll lenB = primeB.size();
    rep (i, lenA)
        rep (j, lenB)
            if (primeA[i].first == primeB[j].first)
                ans++;
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main()
{

    ll a,b,c;
    cin>>a>>b>>c;

    ll ans(0);
    
    for(int i=a;i<b+1;i++)
    {
        if(c%i==0)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 1160
N, A, B, C, D = (int(i) for i in input().split())
S = input()

if B < C and C < D :
    if "##" in S[A-1:D-1] :
        print("No")
    else:
        print("Yes")
if B < D and D < C:
    if "##" in S[A-1:C-1] :
        print("No")
    else:
        # Bの一つ手前からDの次までに...があればよい
        if "..." in S[B-2:D+1]:
            print("Yes")
        else:
            print("No")

if C < B and B < D:
    # A..Cに2つ連続#がなければよい
    # B..Dに2つ連続#がなければよい
    if "##" in S[A-1:C-1] or "##" in S[B-1:D-1] :
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 40816
#include <iostream>
#include<set>
#include <vector>
#include <map>

using namespace std;

int main()
{
    map<int,bool>m;
    map<int,int>b;
    int n, mm;
    cin >> n >> mm;
    for(int i = 1; i <= n;i++)
        b[i] = 1;
    m[1] = true;
    for(int i = 0; i < mm; i++)
    {
        int x, y;
        cin >> x >> y;
        if(m[x])
            m[y] = true;
        b[x]--;
        b[y]++;
        if(!b[x] && m[x])
        {
            m[x] = false;
        }
    }
    int c = 0;
    for(int i = 1;i <= n;i++)
        if(m[i])
            c++;
        cout << c << endl;
}


Measured memory_bytes: 9600
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x;
    cin>>x;
    int n=x.length();
    int st=0,en=0;
    string st1=x.substr(0,7);
    string en1=x.substr(n-7);
    if(st1=="keyence"||en1=="keyence")
    {
        cout<<"YES\n";
        return 0;
    }
    for(int i=1;i<7;++i)
    {
        string y=x.substr(0,i)+x.substr(n-(7-i));
        if(y=="keyence")
        {
            cout<<"YES\n";
            return 0;
        }
    }
    cout<<"NO\n";
}


Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int ans = b;
	for (int i = 1; i < a; i++)ans *= b - 1;
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	int ans;
	if(N<600){
		ans=8;
	}
	else if(N<800){
		ans=7;
	}
	else if(N<1000){
		ans=6;
	}
	else if(N<1200){
		ans=5;
	}
	else if(N<1400){
		ans=4;
	}
	else if(N<1600){
		ans=3;
	}
	else if(N<1800){
		ans=2;
	}
	else{
		ans=1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3668
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10**9 + 7

N,K = map(int,read().split())

# 左からの流入量、コスト
L = N*(N-1)//2+1
dp = np.zeros((N,L),dtype=np.int64)
dp[0,0] = 1

for _ in range(1,N+1):
    prev = dp
    dp = np.zeros_like(prev)
    for n in range(N):
        # 自身を不動点にしてそのまま左右に流す
        dp[n,n:] += prev[n,:L-n]
        # 左からのものを採用、自身は左に流す
        if n > 0: dp[n-1,n-1:] += prev[n,:L-n+1] * n
        # 左からのものを採用、自身は右に流す
        dp[n,n:] += prev[n,:L-n] * n
        # 右からのものを採用、自身は左に流す
        dp[n,n:] += prev[n,:L-n] * n
        # 右からのものを採用、自身は右に流す
        if n+1 < N: dp[n+1,n+1:] += prev[n,:L-n-1] * (n+1)
    dp %= MOD

x = dp[0]
if K&1:
    answer = 0
elif K//2 < L:
    answer = x[K//2]
else:
    answer = 0
print(answer)

Measured memory_bytes: 14284
import numpy as np
import math

# def compare_each(a, b):
#     """辞書で比べる，もしaの方が小さければ，false，大きければtrue"""
#     if a is None:
#         return True
#     len_a = len(a)
#     len_b = len(b)
#     length = min(len_a, len_b)
#     for i in range(length):
#         if ord(a[i]) < ord(b[i]):
#             return False
#         elif ord(a[i] > b[i]):
#             return True
#     if len_a <= len_b:
#         return False
#     else:
#         return True

# def compare(str_, str_lists, K):
#     """str_listsは昇順で並んでいる．ここにstr_が入るのか戦う"""
#     for i in range(K, 0, -1):
#         print(str_lists[i - 1], str_)
#         if compare_each(str_lists[i - 1], str_):
#            str_lists.insert(i - 1, str_)
#            break
#     return str_lists[:K]


def main():
    s = input()
    K = int(input())
    str_lists = []
    for str_num in range(1, K + 1):
        for i in range(len(s)):
            str_ = s[i: i + str_num]
            if str_ not in str_lists:
                str_lists.append(str_)
    str_lists = sorted(str_lists)
    print(str_lists[K - 1])
    
            

if __name__ == '__main__':
    main()

Measured memory_bytes: 21744
// ABC-C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#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

using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(){
	int n; cin >> n; 
	vector<int> H(n);
	rep(i, n) {
		cin >> H[i];
	}
	int ans = 0, cnt = 0;

	rep(i, n - 1) {
		if (H[i] >= H[i + 1]) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}


	cout << ans << endl;
}


Measured memory_bytes: 640
void main() {
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], a = tmp[1], b = tmp[2];
    long[] x = readln.split.to!(long[]);
    long result;
    foreach (i; 1 .. n) {
        long diff = x[i] - x[i-1];
        result += min(a*diff, b);
    }
    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

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

    int x;
    cin >> x;
    if (x == 3 or x == 5 or x == 7)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
ll k; string s;
bool cmp(pll a, pll b) {
	ll an=a.second-a.first,bn=b.second-b.first;
	if (an<bn) return true;
	if (an>bn) return false;
	for (ll i=0;i<an;i++) {
		if (s[a.first+i]<s[b.first+i]) return true;
		if (s[a.first+i]>s[b.first+i]) return false;
	}
	return false;
}
string go(ll x, ll y) {
	return s.substr(x,y-x);
}
bool leq(pll a, pll b) {
	ll an=a.second-a.first,bn=b.second-b.first;
	if (an<bn) return true;
	if (an>bn) return false;
	for (ll i=0;i<an;i++) {
		//cout<<s[a.first+i]<<s[b.first+i]<<endl;
		if (s[a.first+i]<s[b.first+i]) return true;
		if (s[a.first+i]>s[b.first+i]) return false;
	}
	return true;
}
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>k>>s;
	ll n=s.length();
	ll q=max(1LL,n/(k+1));
	vector<pll> v;
	for (ll i=0;i<n;i++) {
		if (i+q<=n) v.PB(MP(i,i+q));
		if (i+q+1<=n) v.PB(MP(i,i+q+1));
	}
	//cout<<q<<endl;
	sort(v.begin(),v.end(),cmp);
	for (ll i=0;i<v.size();i++) {
		ll imid=i;
		//cout<<"i:"<<i<<":"<<go(v[imid].first,v[imid].second)<<endl;
	}
	ll imin=0,imax=v.size();
	while(imin<imax) {
		ll imid=(imin+imax)/2;
		//cout<<"imid"<<go(v[imid].first,v[imid].second)<<endl;
		ll x=0;
		bool ok=true;
		for (ll i=0;i<k+1;i++) {
			//cout<<go(x,min(x+q+1,n))<<"<=ISA?"<<go(v[imid].first,v[imid].second);
			if (leq(MP(x,min(x+q+1,n)),v[imid])) {
				//cout<<go(x,min(x+q+1,n))<<"<=A"<<go(v[imid].first,v[imid].second);
				x=min(x+q+1,n);
			}
			else if (leq(MP(x,min(x+q,n)),v[imid])) {
				//cout<<go(x,min(x+q,n))<<"<=B"<<go(v[imid].first,v[imid].second);
				x=min(x+q,n);
			}
			else {
				ok=false; break;
			}
			//cout<<x<<endl;
		}
		if (ok&&x==n) {
			imax=imid;
		}
		else {
			imin=imid+1;
		}
	}
	{
		ll x=v[imin].first,y=v[imin].second;
		cout<<s.substr(x,y-x)<<endl;
	}
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int X, Y, Z;
  cin >> X >> Y >> Z;

  cout << Z << " " << X << " " << Y << endl;



  return 0;
}


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

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

string lcs(vector<vector<int>> &dp, int i, int j, string s, string t){
    if(i == 0 || j == 0) return "";

    string ret = "";
    if(s[i-1] == t[j-1]){
        ret = lcs(dp, i-1, j-1, s, t) + s[i-1];
    }else{
        if(dp[i-1][j] >= dp[i][j-1]) ret = lcs(dp, i-1, j, s, t);
        else ret = lcs(dp, i, j-1, s, t);
    }
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    const int n = s.size(), m = t.size();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));

    REP(i, n){
        REP(j, m){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }else{
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    cout << lcs(dp, n, m, s, t) << endl;
}

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

using namespace std;

int main(){
    long long int N,M,X,ans = 1e9;
    cin >> N >> M >> X;
    vector<long long int> C(N);
    vector<vector<long long int>> A(N,vector<long long int> (M));
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }

    for(int i=0;i<pow(2,N+1);i++){

        vector<long long int> ok(N,0),skill(M,0);
        long long int tmp = 0;

        for(int j=0;j<N;j++){
            if(i>>j & 1 == 1){
                ok[j] = 1;
                tmp += C[j];
            }
        }


        for(int j=0;j<N;j++){
            if(ok[j]==1){
                for(int k=0;k<M;k++){
                    skill[k] += A[j][k];
                }
            }
        }


        for(int j=0;j<M;j++){
            if(skill[j]<X){
                break;
            }

            if(j==M-1){
                ans = min(ans,tmp);
            }
        }
    }

    if(ans==1e9){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 4108
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

A = []
C = []
for a, b in AB:
  A.append(a)
  C.append(a + b)
#print("C:", C)

C.sort()
C = C[::-1]

print(sum(A) - sum(C[1::2]))

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

int main(void){
	vector<int>k,w;
	int t;
	for(int i=0;i<10;i++){
		cin >> t;
		w.push_back(t);
	}
	for(int i=0;i<10;i++){
		cin >> t;
		k.push_back(t);
	}
	sort(w.begin(),w.end());
	sort(k.begin(),k.end());
	cout << w[9]+w[8]+w[7] << " " << k[9]+k[8]+k[7] << endl;
}

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

using namespace std;

using int64 = long long;

struct INFTY {
  const int64 infll = (1LL << 62) - 1;
  const int inf = (1 << 30) - 1;

  operator int64() { return infll; }

  operator int() { return inf; }
} inf;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

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

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  vector< int > ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), [&](int a, int b) {
    return A[a] > A[b];
  });
  int64 ret = 0;
  UnionFind uf(N);
  vector< int > used(N);
  for(auto &i : ord) {
    used[i] = true;
    int l = i, r = i;
    if(i && used[i - 1]) {
      l = i - uf.size(i - 1);
      uf.unite(i, i - 1);
    }
    if(i + 1 < N && used[i + 1]) {
      r = i + uf.size(i + 1);
      uf.unite(i, i + 1);
    }
    ret += 1LL * A[i] * (r-i+1)*(i-l+1);
  }
  cout << ret << endl;
}



Measured memory_bytes: 3456
#include<cstdio>
#include<algorithm>
using namespace std;
int a[300100];
bool cmp(int A,int B){
	return A>B;
}
int main(){
//	freopen("A.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n*3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n*3+1,cmp);
	long long ans=0;
	int cnt=0;
	for(int i=1;i<=n*3;i++)
	{
		if((i&1)==0&&cnt<n){
			cnt++;
			ans=ans+a[i];
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1280
/**
*    author:  y_takano
*    created: 18.06.2020 16:45:32
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int tmp1, tmp2;

  for (;;)
  {
      cin >> tmp1 >> tmp2;
      if (tmp1 != 0 || tmp2 != 0)
      {
          if (tmp1 > tmp2)
          {
              cout << tmp2 << " " << tmp1 << endl;
          }
          else
          {
              cout << tmp1 << " " << tmp2 << endl;
          }
      }
      else
      {
          break;
      }
  }
  
  return 0;
}


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

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

  int x = 1;
  for (int i = 0; i < N; i++) {
    int a = x * 2;
    int b = x + K;
    if (a < b) {
      x = a;
    } else {
      x = b;
    }
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define INF 1000000007
#define N 1000000
using namespace std;
int main() {
	int x = 2,dp[N+1],odddp[N+1];
	dp[0] = odddp[0] = 0;
	for (int i = 1; i <= N; ++i) dp[i] = odddp[i] = i;
	while (1) {
		int y = x * (x + 1)*(x + 2) / 6;
		if (y > N) break;
		for (int i = 0; i + y <= N; ++i) 
			dp[i + y] = min(dp[i + y], dp[i] + 1);
		if (y % 2)
			for (int i = 0; i + y <= N; ++i)
				odddp[i + y] = min(odddp[i + y], odddp[i] + 1);
		++x;
	}
	int n;
	while (cin >> n , n) {
		cout << dp[n] << " " << odddp[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 10908