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

int main(){
  long N,M,L,R;
  cin >> N >> M;
  long LMAX=0,RMIN=N;
  for(long i=0;i<M;i++){
    cin >> L >> R;
    LMAX = max(LMAX,L);
    RMIN = min(RMIN,R);
  }
  if(LMAX > RMIN){
    cout << 0 << endl;
  }else{
    cout << RMIN - LMAX + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

ll modpow(ll n, ll p, ll m) {
  if(p==0) return 1LL;
  if(p%2==0) {
    ll t = modpow(n, p/2, m);
    return t * t % m;
  }
  return n * modpow(n, p-1, m) % m;
}

int main() {
  ll x, y;
  cin >> x >> y;
  if((x+y)%3!=0 || x>2*y || y>2*x) {
    cout << 0 << endl;
    return 0;
  }
  ll z = (x+y)/3;
  ll cnt = 2*z-x;
  ll ans = 1;
  for(ll i = 1; i<=z; i++) {
    ans *= (ll)i;
    ans %= mod;
  }
  ll k = 1LL;
  for(ll i = 1; i<=cnt; i++) {
    k *= (ll)i;
    k %= mod;
  }
  ans *= modpow(k,mod-2,mod);
  ans %= mod;
  ll p = (ll)(z-cnt);
  ll q = 1LL;
  for(ll i = 1; i<=p; i++) {
    q *= (ll)i;
    q %= mod;
  }
  ans *= modpow(q,mod-2,mod);
  ans %= mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main(){
   int N;
   int x;
   cin >> N >> x;
   if(x==1 || x == 2*N-1){
      cout << "No" << endl;
   }
   else{
      bool used[2*N];
      memset(used,false,sizeof(used));
      int ans[2*N-1];
      ans[N-1]=x;
      used[x]=true;
      int left =1;
      int right = 2*N-1;
      int dir = 1;
      cout << "Yes" << endl;
      for(int i = 1 ; i < N; i++){
         while(used[left])left++;
         while(used[right])right--;
         used[left]=true;
         used[right]=true;
         ans[N-1+i*dir]=left;
         ans[N-1-i*dir]=right;
         dir*=-1;
      }
      for(int i=0;i<2*N-1;i++){
         cout << ans[i]<< endl;
      }
   }
   return 0;
}


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

using namespace std;

#define ALL(x) begin(x), end(x)

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> grid;
  vector<bool> cok(W,false);

  string rowstr;
  for(auto i = 0; i != H; ++i) {
    cin >> rowstr;
    if (rowstr == string(W,'.')) continue;
    grid.push_back(rowstr);
    for (auto j = 0; j != W; ++j) {
      cok[j] = cok[j] || (rowstr[j] == '#');
    }
  }

  for (auto &row: grid) {
    for (auto i = 0; i != W; ++i) {
      if (cok[i]) cout << row[i];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from math import floor, sqrt
n,d = map(int, input().split())
l = []
for _ in range(n):
	l.append(tuple(map(int, input().split())))
ans = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		s = 0
		for k in range(d):
			s += (l[i][k] - l[j][k]) ** 2
		x = sqrt(s)
		if floor(x) == x:
			ans += 1
print(ans)

Measured memory_bytes: 38256
while 1:
    n, r = map(int, input().split())
    if n+r < 1 : break
    *l, = range(n, 0, -1)
    for i in [0]*r:
        p, c = map(int, input().split())
        p -= 1
        l = l[p:p+c] + l[:p] + l[p+c:]
    print(l[0])

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

const int LIM = 3e5;

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    segtree<int, op, e> seg(LIM+1);
    rep(i, n) {
        int l = max(0, a[i]-k), r = min(LIM, a[i]+k)+1;
        int val = seg.prod(l, r);
        seg.set(a[i], val+1);
    }
    cout << seg.all_prod() << endl;
    return 0;
}


Measured memory_bytes: 9624
def long_diff(s, a):
    s = str(a) + s + str(a)
    index_num = [n for n, v in enumerate(s) if v == str(a)]
    res = 0
    for i in range(len(index_num)-1):
        tmp = index_num[i+1] - index_num[i]
        res = max(res,tmp)
    return res-1

s = input()
r = 100
for i in [chr(j) for j in range(97,97+26)]:
    r = min(r, long_diff(s, i))
print(r)

Measured memory_bytes: 3060
import re
def solve():
    s = input()
    H = [0] * len(s)
    last = 0
    for a, b in re.findall(r"(R+)(L+)", s, flags=0):
        a = len(a)
        b = len(b)
        r = (a + 1) // 2 + b // 2
        l = a // 2 + (b + 1) // 2
        H[last + a - 1] = r
        H[last + a] = l
        last += a + b
    print(*H)
solve()


Measured memory_bytes: 7668
#include <vector>
#include <queue>
#include <iostream>
#include <queue>
#include <utility>
#include <tuple>
using namespace std;
constexpr int INF = 1e9;

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  for(int i = 0; i < M; ++i){
    int u, v;
    cin >> u >> v;
    --u,--v;
    G[u].push_back(v);
  }
  int s, t;
  cin >> s >> t;
  --s,--t;
  vector<vector<int>> D(N,vector<int>(3,INF));
  D[s][0] = 0;
  queue<pair<int,int>> Q;
  Q.emplace(s,0);
  while(Q.size()){
    int v, d;
    tie(v,d) = Q.front();
    Q.pop();
    int c = D[v][d] + (d == 0);
    int d_ = (d+1)%3;
    for(auto v_ : G[v]){
      if(D[v_][d_] <= c) continue;
      D[v_][d_] = c;
      Q.emplace(v_,d_);
    }
  }
  if(D[t][0] >= INF){
    cout << -1 << endl;
    return 0;
  }
  cout << D[t][0] << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for (int i=0; i<N; ++i) cin >> a[i] >> b[i];

    ll sum = 0;
    for (int x : a) sum += x;
    int val = INF+1, ind = -1;
    for (int i=0; i<N; ++i) if (a[i] > b[i] && chmin(val, b[i])) ind = i;
    if (ind == -1) cout << 0 << '\n';
    else cout << sum - val << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
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);
}

typedef pair<int, int> P;

class DMaximumSumOfMinimum {
public:
    vector<int> G[10005];
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        REP(i, N - 1) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        vector<int> c(N);
        REP(i, N) cin >> c[i];
        sort(c.begin(), c.end(), greater<int>());
        int score = 0;
        FOR(i, 1, c.size() - 1) score += c[i];

        int cur = 0;
        vector<int> res(N);
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
            int i = q.front();
            q.pop();
            if (res[i] > 0) continue;
            res[i] = c[cur++];
            REP(j, G[i].size()) {
                int t = G[i][j];
                q.push(t);
            }
        }
        cout << score << endl;
        REP(i, res.size()) {
            cout << res[i] << " ";
        }
        cout << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DMaximumSumOfMinimum solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1152
# A

from decimal import *

n = int(input())
a_l = [int(Decimal(input()) * 10**9) for x in range(n)]

list = [[0] * 19 for _ in range(19)]
cs_list = [[0] * 19 for _ in range(19)]
b_l = [0, 0] * n

for i in range(n):
    _t2 = 0
    _t5 = 0
    _a = a_l[i]
    while _a % 2 == 0 and _t2 < 18:
        _t2 += 1
        _a /= 2

    _a = a_l[i]
    while _a % 5 == 0 and _t5 < 18:
        _t5 += 1
        _a /= 5
    
    list[_t2][_t5] += 1
    b_l[i] = [_t2, _t5]

for i in range(19):
    for j in range(19):
        for k in range(i+1):
            for l in range(j+1):
                cs_list[k][l] += list[i][j]

ans = 0
for i in range(n):
    _t,_f = b_l[i]
    if _t >= 9 and _f >= 9:
        ans -= 1
    ans += cs_list[18-_t][18-_f]
        
print(ans // 2)


Measured memory_bytes: 36808
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define f(i,n) for(ll i=0;i<n;i++)
    #define fz for(ll j=i+1;j<n;j++)
    #define f2(i,n) for(ll i=1;i<=n;i++)
    #define endl "\n"
    #define vll vector <ll>
    #define mod 1000000007
    #define pb push_back
    #define inf 1e13+5

    ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
    ll lcm(ll a, ll b){return a*b/gcd(a, b);}
    ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod; b/=2;a=a*a%mod;}return ans;}
    ll inverse(ll a, ll p){return fexp(a, p-2);} 

    
    
    void solve(){
       ll n;cin>>n;
       ll a=n%10;
       if(a==3)cout<<"bon\n";
       else if(a==0 || a==1 || a==6 || a==8){
           cout<<"pon\n";
       }
       else cout<<"hon\n";

    }


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

       

        ll t;
        t=1;
        // cin>>t;
        while(t--){
            solve();
        }

       

        
        return 0;
    }

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    string s;
    cin >> s;
    vector<ll> cnt(26);
    for (char c : s) ++cnt[c - 'a'];
    ll ans = 0;
    forn(i, 0, 26) forn(j, 0, i) ans += cnt[i] * cnt[j];
    cout << 1 + ans << '\n';
}


Measured memory_bytes: 720
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
    static const int NUMMIN = 1;
    static const int NUMMAX  = 100;
    int num;
    std::cin >> num;
    assert(NUMMIN <= num && num <= NUMMAX); /* Precondition */
    std::cout << num*num*num << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int X, N;
    in2(X, N);

    set<int> p;
    rep(i, N)
    {
        int a;
        in(a);
        p.insert(a);
    }

    int ans = 1000000000;

    repse(i, 0, 101)
    {
        if (p.count(i) != 0) continue;

        if (abs(X - i) < abs(X - ans)) ans = i;
    }

    outl(ans);

    return 0;
}

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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back


typedef long long ll;

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  if(n % k == 0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }

  return 0;
}



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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for (size_t i = 0; i < N; ++i)
    {
        cin >> A.at(i) >> B.at(i);
    }

    vector<size_t> A_i(A.size());
    iota(A_i.begin(), A_i.end(), 0);

    sort(A_i.begin(), A_i.end(), [&A](size_t i1, size_t i2) {
        return A.at(i1) < A.at(i2);
    });

    size_t pay = 0;

    for (auto i : A_i)
    {
        for (size_t j = 0; j < B.at(i); ++j)
        {
            pay += A.at(i);
            --M;
            if (M == 0)
            {
                cout << pay << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())  # x = 1, y = 2

d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))


bitl = 2**n - 1
for kashi in a:
    for i in kashi:
        bitl &= ~(1 << (i - 1))

print(bin(bitl).count("1"))


Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
int main()
{
  string b;
  cin >> b;
  if(b == "Sunny"){
    cout << "Cloudy" <<endl;
  }else if(b == "Cloudy"){
    cout << "Rainy" <<endl;
  }else{
    cout << "Sunny" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    bool ans = true;
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(i % 2 == 0 && S[i] == 'L'){
            ans = false;
        }
        if(i % 2 == 1 && S[i] == 'R'){
            ans = false;
        }
    }
    Yes(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,K,a[N],res,book[N];
int w[N],cnt,qwq;
signed main()
{
    n=read(), K=read();
    for(ri int i=1;i<=n;i++) a[i]=read(), book[a[i]]++;
    for(ri int i=1;i<=n;i++)
    {
        if(book[i]) qwq++, w[++cnt]=book[i];
    }
    sort(w+1,w+1+cnt);
    int now=0;
    while(qwq>K)
    {
        qwq--;
        res+=w[++now];
    }
    printf("%lld\n",res);
    return 0;
}

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

int main()
{
    int x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    int dx, dy;

    dx = x1 - x2;
    dy = y1 - y2;
    const int x3 = x2 + dy;
    const int y3 = y2 - dx;
    const int x4 = x1 + dy;
    const int y4 = y1 - dx;
    cout << x3 << " " << y3 << " "
         << x4 << " " << y4;

    return 0;
}

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

int main() {
  long N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1 || M == 1) {
    cout << (N * M) - 2 << endl;
  } else {
    cout << (N - 2) * (M - 2) << endl;
  }
}

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//
//using namespace __gnu_pbds;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//class Timer {
//    clock_t start;
//    string name;
//public:
//    Timer() {name = "";start = clock();}
//    Timer(string s){name = s;start = clock();}
//    ~Timer() {fprintf(stderr, "%s: %.3gs\n", name.c_str(), 1.0*(clock() - start) / CLOCKS_PER_SEC);}
//};

//#define isValid(a, b) ((a) >= 0 && (a) < (b))
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define um unordered_map
#define us unordered_set
#define endl '\n'
#define what_is(x) cerr << fixed << setprecision(2) << boolalpha << #x << " = " << x << endl

const double EPS = 1e-9;
const double PI = acos(-1.0);

template<typename T> inline T sq(T a){return a*a;}
template<typename T1, typename T2> inline pair<T1, T2> mp(T1 a, T2 b){return make_pair(a, b);}
template<typename T1, typename T2> inline T1 safeMod(T1 a, T2 m){return (a%m + m)%m;}/*handling negative sign of remainder*/
template<typename T1, typename T2> inline bool isEq(T1 a, T2 b){return abs(a - b) < EPS;}
template<typename T1, typename T2, typename T3> inline bool isEq(T1 a, T2 b, T3 eps){return abs(a - b) < eps;}
template<typename T> inline bool isKthBitOn(T n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;return bool((n & (ONE<<k)));}
template<typename T> inline void setKthBit(T& n, int k){assert(n <= numeric_limits<T>::max());assert(k<=numeric_limits<T>::digits);T ONE = 1;n = (n|(ONE<<k));}
//mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());
//template<typename T> inline T nextRand(T lo, T hi){return uniform_int_distribution<T>(lo, hi)(rng);}

#define toRad(deg) ((deg)*PI/180.0)
#define toDeg(rad) ((rad)*180.0/PI)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const int MAX = 200010;
const int MOD = 1000000007;
const int precision = 10;

int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    //assert(freopen("in.txt", "r", stdin));
    //assert(freopen("out.txt", "w", stdout));
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //cout << fixed << setprecision(precision);
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(d1 == months[m1])cout << 1;
    else cout << 0;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n;
  cin >> n;
  vector<string> str(n);
  
  for(i = 0; i < n; i++)
    cin >> str[i];
  char buf = str[0][str[0].size() - 1];
  bool judge = true;
  for(i = 1; i < n; i++){
    if(str[i][0] != buf){
      judge = false;
      //cout << buf spa str[i][0] spa i << endl;;
    }
    for(j = 0; j < i; j++)
      if(str[i] == str[j])
        judge = false;
    buf = str[i][str[i].size() - 1];
  }
  
  if(judge)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j;
	int n,k;
	int a,b,c[5];
	int min;
	
	scanf("%d",&n);
	scanf("%d",&k);
	for(i=0;i<k;i++){
		scanf("%d %d",&a,&b);
		c[0]=n-a;
		c[1]=n-b;
		c[2]=a-1;
		c[3]=b-1;
		min=c[0];
		for(j=1;j<4;j++){
			if(min>c[j]){
				min=c[j];
			}
		}
		if(min%3==0){
			printf("1\n");
		}
		else if(min%3==1){
			printf("2\n");
		}
		else if(min%3==2){
			printf("3\n");
		}		
	}
	return 0;
}

Measured memory_bytes: 580
def main():
    x, y = [int(e) for e in input().split()]

    A = [2] * x
    for i in range(x):
        if sum(A) == y:
            print('Yes')
            exit()

        A[i] = 4

    if sum(A) == y:
        print('Yes')
        exit()

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62828
import java.io.*;
import java.util.*;
import java.lang.*;

class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Pair<Long,Long>[] robots = new Pair[N];
        for(int n=0; n<N; n++){
            long X = sc.nextLong();
            long L = sc.nextLong();
            robots[n] = new Pair<>(X-L,X+L);
        }
        Arrays.sort(robots, (x,y)->x.second!=y.second ? Long.compare(x.second,y.second) : Long.compare(x.first,y.first));

        long right = -2000000000L;
        int ans = 0;
        for(int n=0; n<N; n++){
            if(robots[n].first >= right){
                right = robots[n].second;
                ans++;
            }
        }
        System.out.println(ans);

    }


}


Measured memory_bytes: 98884
#include <iostream>
using namespace std;
int main() {
    long long n; cin >> n;
    int len = 1;
    long long w = 26, lb = 1, ub = 26;
    while (n > ub) {
        w *= 26;
        len++;
        lb = ub + 1;
        ub = lb + w - 1;
    }
    w /= 26;
    string ans = "";
    while (w > 0) {
        ans = ans + string(1, 'a' + (n - lb) / w);
        lb += w * ((n - lb) / w);
        w /= 26;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
import math
a, b = map(int, input().split())
bit = 0
for i in range(1, 1001):
  if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
    print(i)
    bit = 1
    break
if bit == 0:
  print(-1)
 

Measured memory_bytes: 2940
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll num = 1;
  for(int i = 1;i <= N;i++){
    num *= i;
    num %= MOD;
  }
  cout << num <<endl;
}


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

using namespace std;

bool used[26];

int main() {
  string s;
  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << "-1" << endl;
    return 0;
  }
  memset(used, false, sizeof used);
  string ans = "~";
  for (int i = 0; i < (int)s.length(); ++i) {
    int t = s[i] - 'a';
    for (int nt = t + 1; nt < 26; ++nt) {
      if (used[nt]) {
        continue;
      }
      string cur = "";
      for (int j = 0; j < i; ++j) {
        cur += s[j];
      }
      cur += (char)('a' + nt);
      ans = min(ans, cur);
    }
    used[t] = true;
  }
  for (int j = 0; j < 26; ++j) {
    if (!used[j]) {
      s += (char)('a' + j);
      ans = min(ans, s);
      break;
    }
  }
  cout << ans << endl;
}


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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define FOR(i,a,n) for(ll i=a;i<=n;i++)
#define ROF(i,n,a) for(ll i=n;i>=a;i--)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    int a; ll sum=0;
    FOR(i,0,m-1){
        cin>>a; 
          sum+=a;
    }
    if(sum>n)
      cout<<"-1"<<endl;
    else
      cout<<abs(n-sum)<<endl;  
   return 0; 
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n], dp[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        int temp=INT_MAX;
        for(int j=i-1;j>=0 && j>=i-k;j--){
            temp=min(temp,dp[j]+abs(arr[i]-arr[j]));
        }
        dp[i]=temp;
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
	string s;
	cin>>s;
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
		cout<<"3\n";
	else if((s[0]=='R'&&s[1]=='R') || (s[1]=='R'&& s[2]=='R'))
		cout<<"2\n";
	else if(s[0]=='R'||s[1]=='R'||s[2]=='R')
		cout<<"1\n";
	else
		cout<<"0\n";
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    while (true) {
        int a,b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }else{
            if (a > b) {
                cout << b << " " << a << endl;
            }else{
                cout << a << " " << b << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3064
function solve(Y,M,D){
    if(Y<2019)return true;
    if(Y>2019)return false;
    if(M<4)return true;
    if(M>4)return false;
    return D<=30
}
function Main(raw) {
    const input = raw.split("\n");
    const S = input[0].split("/");
    const Y= parseInt(S[0],10)
    const M= parseInt(S[1],10)
    const D= parseInt(S[2],10)
    
    //出力
    console.log("%s", solve(Y,M,D)?'Heisei':'TBD');
  }
  
  //DO NOT EDIT
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i < n - 1; i++)
    {
        if (a[i - 1] < a[i] && a[i] < a[i + 1])
            cnt++;
        if (a[i + 1] < a[i] && a[i] < a[i - 1])
            cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int X;
	int tmp;
	int count500;
	int count5;
	int count = 0;

	scanf("%d", &X);
	tmp = X;
	count500 = tmp/500;
	count += count500 * 1000;
	tmp  = tmp%500;

	count5 = tmp/5;
	count += count5 * 5;

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

	return 0;
}


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

using namespace std;

vector <int> D;

bool ret(int ans){
        int re=ans;
        while(re!=0){
                for(int i=0;i<(int)D.size();i++){
                        if(re%10==D[i]){
                                return false;
                        }
                }
                re/=10;
        }
        return true;
}

int main(){
        int N, K;
        cin>>N>>K;
        for(int i=0;i<K;i++){
                int dd;
                cin>>dd;
                D.push_back(dd);
        }
        int ans=N;
        while(!ret(ans)){
                ans++;
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 256
def solve(n, p_list):
    p_list_cum_min = [0] * n
    p_list_cum_min[0] = p_list[0]
    for i in range(1, n):
        p_list_cum_min[i] = min(p_list[i], p_list_cum_min[i - 1])

    res = 0
    for i in range(n):
        if p_list[i] <= p_list_cum_min[i]:
            res += 1

    return res


def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    res = solve(n, p_list)
    print(res)


def test():
    assert solve(5, [4, 2, 5, 1, 3]) == 3
    assert solve(4, [4, 3, 2, 1]) == 4
    assert solve(6, [1, 2, 3, 4, 5, 6]) == 1
    assert solve(8, [5, 7, 4, 2, 6, 8, 1, 3]) == 4
    assert solve(1, [1]) == 1


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 25736
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    map<int, int> z;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        z[a[i]]++;
    }
    ll ans = 0;
    auto it = z.begin();
    for (; it != z.end(); ++it) {
        int num=it->second;
        ans += ((ll)num*(num - 1) / 2);
    }

    for (i = 0; i < n; i++) {
        int tmp=z[a[i]];
        ll add = (ll)(tmp - 1)*(tmp - 2) / 2 - (ll)tmp*(tmp - 1) / 2;
        printf("%lld\n", ans + add);
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 8320
N, K = map(int, input().split())
V = list(map(int,input().split()))

ans = -1 * float("INF")
for l in range(K+1):
  for r in range(K+1-l):
    if l + r > N:
      break
    d = K - l - r
    s = V[0:l] + V[N-1:N-1-r:-1]
    value = sum(s)
    s.sort()
    for i in range(d):
      if i >= len(s):
        break
      if s[i] < 0:
        value -= s[i]
      else:
        break
    ans = max(ans, value)
print(ans)

Measured memory_bytes: 3064
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define PB push_back
#define SZ size
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
struct EE{int v, nx;}E[N * 4]; int hd[N], EN;
void init_edge(int num){EN = 0; memset(hd, -1, (num + 3) << 2);}
void add_edge(int u, int v){
    E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
    E[EN].v = u; E[EN].nx = hd[v]; hd[v] = EN++;
}
int n, h, w, k;
int fa[N], out[N];
int a[N], cnt;
bool vis[N];
int u, v;
int main(){
   // IN;
    SC(n);
    init_edge(n);
    FF(i, 1, n - 1){
        SCC(u, v);
        add_edge(u, v);
    }
    if(n % 2){
        puts("First");
        return 0;
    }
    queue<int>Q;
    Q.push(1);
    vis[1] = 1;
    fa[1] = 0;
    cnt = 1;
    a[1] = 1;
    while(!Q.empty()){
        int u = Q.front();
        Q.pop();
        for(int k = hd[u]; ~k; k = E[k].nx){
            int v = E[k].v;
            if(vis[v]) continue;
            ++out[u];
            a[++cnt] = v;
            fa[v] = u;
            Q.push(v);
            vis[v] = 1;
        }
    }
    CL(vis, 0);
    bool ok = 0;
    RR(i, cnt, 1){
        int u = a[i];
        if(vis[u]) continue;
        if(out[fa[u]] > 1){
            ok = 1;
            break;
        }
        vis[u] = 1;
        vis[fa[u]] = 1;
        --out[fa[fa[u]]];
    }
    if(ok) puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 5632
N,M = map(int,input().split())
A = [[] for i in range(N)]
for i in range(N):
    A[i] = list(map(int,input().split()))

cnt = 0
for i in range(1,M+1):
    for j in range(N):
        # print(A[j][1:])
        if i not in A[j][1:]:
            break
    else:
        # print(i)
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;
int N, P;
string SS;
int S[200000];
int S_modP[200000];
int sum[200001];
int c;
int main() {

	cin >> N >> P;
	cin >> SS;
	for (int i = 0; i < N; i++) {
		S[i] = SS[i] - '0';
	}

	long long ans = 0;

	/*Pが2と5の場合だけ特別*/
	if (P == 2 || P == 5) {
		for (int i = 0; i < N; i++) {
			if (S[i] % P == 0) {
				ans += (i + 1);
			}
		}
		cout << ans;
		return 0;
	}

	c = 1;
	for (int i = N - 1; i >= 0; i--) {
		S_modP[i] = (S[i] * c) % P;
		c = (c * 10) % P;
	}

	sum[0] = 0;
	for (int i = 0; i < N; i++) {
		sum[i + 1] = (sum[i] + S_modP[i]) % P;
	}
	

	long long cnt[100000];
	for (int i = 0; i < P; i++) {
		cnt[i] = 0;
	}
	for (int i = 0; i < N + 1; i++) {
		cnt[sum[i]] += 1;
	}
	for (int i = 0; i < P; i++) {
		ans += cnt[i] * (cnt[i] - 1) / 2;
	}

	cout << ans;
}

Measured memory_bytes: 2948
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i,n){
    cin >> p[i];
  }
  int res=0;
  for(int i=1;i<n-1;i++){
    if(p[i-1]<p[i]&&p[i]<=p[i+1] || p[i+1]<p[i]&&p[i]<=p[i-1]){
      res++;
    }
  }
  cout << res << endl;
}


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

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

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

int main(){
	ll n ; cin >> n ;
	vll cnt(n,0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		cnt.at(a)++ ;
	}
	if(n&1){
		if(cnt.at(0)!=1){
			cout << 0 << endl ;
			return 0 ;
		}
		for(int i=1;i<cnt.size();i++){
			if(i&1){
				if(cnt.at(i)>0){
					cout << 0 << endl ;
					return 0 ;
				}
			}else{
				if(cnt.at(i)!=2){
					cout << 0 << endl ;
					return 0 ;
				}
			}
		}
	}else{
		for(int i=0;i<cnt.size();i++){
			if(i&1){
				if(cnt.at(i)!=2){
					cout << 0 << endl ;
					return 0 ;
				}
			}else{
				if(cnt.at(i)>0){
					cout << 0 << endl ;
					return 0 ;
				}
			}
		}
	}
	ll ans = 1 ;
	for(int i=0;i<n/2;i++){
		ans *= 2 ;
		ans %= mod ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 1024
N,A,B = list(map(int,input().split()))

item=[]
for i in range(N):
    a,b,c = list(map(int,input().split()))
    item.append([a,b,c])

D = [[[10**27 for i in range(401)] for j in range(401)] for k in range(N+1)]
D[0][0][0] = 0
for i in range(N):
    for j in range(401):
        for k in range(401):
            if D[i][j][k]<10**26:
                D[i+1][j][k]=min(D[i+1][j][k],D[i][j][k])
                D[i+1][j+item[i][0]][k+item[i][1]] = min(D[i+1][j+item[i][0]][k+item[i][1]],D[i][j][k]+item[i][2])

i=1
min_cost=10**27
while A*i<=400 and B*i<=400:
    min_cost = min(D[N][A*i][B*i],min_cost)
    i+=1
if min_cost==10**27:
	print(-1)
else:
	print(min_cost)

Measured memory_bytes: 100956
//
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 200005


int main() {
	int n;
	int a[MAX_N];
	cin >> n;
	rep(i,n)cin >> a[i];

	ll left[MAX_N],right[MAX_N];
	memset(left,0,sizeof(left));
	memset(right,0,sizeof(right));
	rep(i,n){
		if(i>=2 && a[i]<=i-1) right[i-1-a[i]]++;
		if(i<=n-3 && a[i] <= n-2-i) left[a[i]+i-1]++;
	}
	ll ans = 0;
	rep(i,n-2){
		ans += left[i]*right[i];
		// outsp(left[i]);outl(right[i]);
	}
	outl(ans);

    return 0;
}



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

int main(){
   int n;
   cin >> n;
   int v[n], c[n];

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

   int ans = 0;
   for(int i = 0; i < n; ++i){
      if(v[i] - c[i] > 0){
         ans += v[i] - c[i];
      }
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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; }
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main(){
    string s;
    cin >> s;
    map<char, int> m;
    for(int i=0; i<s.size(); i++){
        if(m.find(s[i]) == m.end()) m[s[i]] = 0;
        m[s[i]]++;
    }
    if(m.size() != 2){
        cout << "No" << endl;
        return 0;
    }
    for(auto p: m){
        if(p.second != 2) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AAtCoderBeginnerContest999 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string n;
	    in >> n;
	    for(int i=0; i<n.size(); i++){
	        if(n[i] == '1'){
	            n[i] = '9';
	            continue;
	        }
            if(n[i] == '9'){
                n[i] = '1';
            }
	    }

	    out << n << endl;
	}
};


int main() {
	AAtCoderBeginnerContest999 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    int a, b;
    cin >> a >> b;
    
    cout << 6 - a - b << endl;

    return 0;
}


Measured memory_bytes: 256