akhauriyash/Code-Regression huggingface dataset:
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn calc(a: &mut [i64]) -> u64 {
    let n = a.len();
    if n <= 1 {
        return 0;
    }
    let m = n / 2;
    let mut ans = calc(&mut a[..m]) + calc(&mut a[m..]);
    let mut b = vec![];
    let mut i = 0;
    let mut j = m;
    while i < m && j < n {
        if a[i] <= a[j] {
            ans += (n - j) as u64;
            b.push(a[i]);
            i += 1;
        } else {
            b.push(a[j]);
            j += 1;
        }
    }
    while i < m {
        b.push(a[i]);
        i += 1;
    }
    for i in 0..b.len() {
        a[i] = b[i];
    }
    ans
}

fn run() {
    input! {
        n: usize,
        k: i64,
        a: [i64; n],
    }
    let mut a = a;
    for a in a.iter_mut() {
        *a -= k;
    }
    a.push(0);
    a.reverse();
    for i in 1..(n + 1) {
        a[i] += a[i - 1];
    }
    let ans = calc(&mut a);
    println!("{}", ans);
}

fn main() {
    run();
}



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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            
            bool include9 = false;
            string imp = Console.ReadLine();
            int L = imp.Length;
            for(int i =0; i<L;i++)
            { 
                switch(imp[i])
                {
                    case ('9'):
                        include9 = true;
                        break;
                    default:
                        
                        break;
                }
            }
            switch (include9)
            {
                case (true):
                    Console.Write("Yes");
                    break;
                default:
                    Console.Write("No");
                    break;
            }
            
            
            
            //System.Threading.Thread.Sleep(1000);
        }
    }
    
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{   int n,m,a;
    while(~scanf("%d %d %d",&n,&m,&a))
    {
            if(n+m>a&&a>n)
            {
                printf("YES\n");

            }
            else if(a==n)
            {
                printf("YES\n");
            }
            else
            {
                printf("NO\n");

            }
    }
    return 0;
}

Measured memory_bytes: 128
unittest
{
	assert( [ "3", "1 2", "2 3" ].parse.expand.solve == "2\n1\n2" );
	assert( [ "8", "1 2", "2 3", "2 4", "2 5", "4 7", "5 6", "6 8" ].parse.expand.solve == "4\n1\n2\n3\n4\n1\n1\n2" );
	assert( [ "6", "1 2", "1 3", "1 4", "1 5", "1 6" ].parse.expand.solve == "5\n1\n2\n3\n4\n5" );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abs = new long[ 2 ][ n - 1 ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( n, abs );
}

auto solve( long n, long[ 2 ][] abs )
{
	auto abis = new long[ 3 ][ abs.length ];
	foreach( i, ab; abs )
	{
		abis[ i ][ 0 .. 2 ] = ab;
		abis[ i ][ 2 ] = i;
	}
	abis.sort();
	
	auto m = 0L;
	auto p = 0L;
	auto pcs = new long[ n ];
	auto bcs = new long[ abs.length ];
	auto c = 1L;
	foreach( i, abi; abis )
	{
		if( abi[ 0 ] != p )
		{
			p = abi[ 0 ];
			c = 1L;
		}
		c += ( c == pcs[ abi[ 0 ] ] );
		pcs[ abi[ 1 ] ] = c;
		bcs[ abi[ 2 ] ] = c;
		m = max( m, c );
		c++;
	}
	return format( "%s\n%s", m, bcs.to!( string[] ).join( "\n" ) );
}


Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
signed main(){
    int N; cin >> N;
    using tp = tuple<int,int>;
    vector<tp>ans;
    for(int i = 1; i <= N; ++i){
        int nvalid = N - i + (N % 2 == 0);
        for(int v = 1; v <= N; ++v){
            if(v == i or v == nvalid)continue;
            int mini = min(v,i);
            int maxi = max(v,i);
            if(find(ans.begin(), ans.end(),tp(mini,maxi)) != ans.end())continue;
            ans.emplace_back(mini,maxi);
        }
    }
    bool debug = true;
    if(debug){
        map<int,int>mp;
        for(auto p : ans){
            int u,v; tie(u,v) = p;
            mp[u] += v; mp[v] += u;
        }
        for(auto itr : mp){
            for(auto it : mp){
                if(itr.second != it.second){
                    cout << itr.first << " " << it.first << endl;
                    return 8;
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans){
        cout << get<0>(p) << " " << get<1>(p) << endl;
    }
}


Measured memory_bytes: 512
N, M = map(int, input().split())
a, b, c, d = [0] * N, [0] * N, [0] * M, [0] * M
for i in range(N):
	a[i], b[i] = map(int, input().split())
for i in range(M):
	c[i], d[i] = map(int, input().split())

for j in range(N):
	ans = "nan"
	diff = float("inf")
	for k in range(M):
		if abs(a[j] - c[k]) + abs(b[j] - d[k]) < diff:
			diff = abs(a[j] - c[k]) + abs(b[j] - d[k])
			ans = k
	print(ans + 1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[3];
string b;

int main(){
    cin>>b;
    for(int i=0;i<3;i++){
        if(b[i]==49){b[i]=57;}
        else if(b[i]==57){b[i]=49;}
    }
    cout<<b<<endl;

}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Supports two operations.
// - Adds a value to a single element.
// - Returns a sum of a range.
// Verified: CF573Div1D
class BinaryIndexedTree {
 private:
  int n;
  vector<int> xs;
 public:
  BinaryIndexedTree(int n) : n(n), xs(n) {}

  // Adds x to the i-th element.
  void Add(int i, int x) {
    int cur = i;
    while (cur < n) {
      xs[cur] += x;
      cur = cur | (cur + 1);
    }
  }

  // Returns a sum of a range [l r).
  int SumOfRange(int l, int r) {
    if (l >= r) return 0;
    if (l > 0) {
      return SumOfRange(0, r) - SumOfRange(0, l);
    }
    int s = 0;
    int i = r - 1;
    while (i >= 0) {
      s += xs[i];
      i = (i & (i + 1)) - 1;
    }
    return s;
  }
};

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

  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> length_to_segments(m + 1);
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    length_to_segments[r + 1 - l].push_back({l, r + 1});
  }

  BinaryIndexedTree bit(m + 1);
  int c = n;
  for (int d = 1; d <= m; d++) {
    for (const auto& segment : length_to_segments[d - 1]) {
      if (DEBUG) cout << segment.first << " " << segment.second << endl;
      bit.Add(segment.first, 1);
      bit.Add(segment.second, -1);
      c--;
    }

    int r = c;
    for (int x = d; x <= m; x += d) {
      r += bit.SumOfRange(0, x + 1);
    }
    cout << r << "\n";
  }
}

Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int solve(int n, int k)
{
    if(n % k == 0)
        return n / k;

    int left = 1;
    int right = n / (n / k + 1);
    while(left < right){
        int mid = (left + right + 1) / 2;
        int m = n - (n / k + 1) * mid;
        if(m / k == n / k)
            left = mid;
        else
            right = mid - 1;
    }

    return solve(n - (n / k + 1) * left, k);
}

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

    int grundy = 0;
    for(int i=0; i<n; ++i){
        int a, k;
        cin >> a >> k;
        grundy ^= solve(a, k);
    }

    if(grundy == 0)
        cout << "Aoki" << endl;
    else
        cout << "Takahashi" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N, result = 0, tmp;
    cin >> N;
    vector<vector<int> > A(2, vector<int>(N));
    REP(i, N) {
        cin >> A[0][i];
    }
    REP(i, N) {
        cin >> A[1][i];
    }
    REP(i, N) {
        tmp = 0;
        REP(j, i+1) {
            tmp += A[0][j];
        }
        FOR(j, i, N) {
            tmp += A[1][j];
        }
        if (tmp > result) {
            result = tmp;
        }
    }
    cout << result << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }
                         //  0   1  2   3    4  5   6    7  8   9  10 11 12
int days[2][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},
		    {0,31,29,31,30,31,30,31,31,30,31,30,31}};//leap year

// if the variable year is leap year, this method return true otherwise false
bool isLeap(int year)
  {
    return ((year%4) == 0 && (year%100) != 0 || ( year % 400 ) == 0);
  }



void compute() {

}

int main() {
  int a,b;
  cin >> a >> b;
  int cnt = 0;
  REP(i,1,a+1) {
    int ep = days[isLeap(2018)][i];
    if( i == a ) ep = b;
    REP(j,1,ep+1) {
      if( i == j ) ++cnt;
    }
  }
  cout << cnt << endl;
  compute();
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll n = s.size();
    vector<ll> a(n+1);
    a[0] = 0;
    ll now = 1;
    rep(i, s.size()) {
        ll v = s[i] - '0';
        a[i+1] = (a[i] + v*now)%2019;
        now = (now*10)%2019;
    }
    
    ll ans = 0;
    map<ll, ll> mp;
    rep(i, a.size()) {
        ans += mp[a[i]];
        mp[a[i]]++;
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> a){
	sort(a.begin(),a.end(),greater<ll>());
	ll res = 0;
	rep(i, 2*N) {
		if (i%2 == 1) res += a[i];
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> a(3*N-1+1);
	for(int i = 0 ; i <= 3*N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, a);
	return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

V<int> G[200010];
ll X[200010] = {};
ll A[200010] = {};

void dfs(int par, int node, ll x) {
    A[node] = x + X[node];
    for (int v : G[node]) {
        if (v == par) continue;
        dfs(node, v, x + X[node]);
    }
}

int main() {
    int n, q; cin >> n >> q;
    loop (n - 1, i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    loop (q, i) {
        int p, x; cin >> p >> x;
        X[p] += x;
    }
    dfs(-1, 1, 0);

    loop (n - 1, i) {
        cout << A[i + 1] << " ";
    }
    cout << A[n] << endl;

    return 0;
}



Measured memory_bytes: 28672
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

int main(void) {

  int n;
  while(cin >> n){
    if( n == 0 ) break;
    vector<long long int> ans;
    vector<long long int> u(4001, 0);
    vector<bool> b(4001, false);
    vector<long long int> e(n);
    vector<long long int> p(n);
    vector<long long int> q(n);
    for(int i=0; i<n; i++){
      cin >> e[i] >> p[i] >> q[i];
      u[ e[i] ] += p[i]*q[i];
    }
    for(int i=0; i<n; i++){
      if( b[e[i]] ) continue;
      if( u[ e[i] ] >= 1000000 ){
        ans.push_back(e[i]);
        b[ e[i] ] = true;
      }
    }
    if( ans.size() == 0 ) cout << "NA" << endl;
    else for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;
  }

  return 0;
}

// EOF

Measured memory_bytes: 3128
N=int(input())
A=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
X=[A[i] for i in range(N+1)]
for i in range(N):
    if X[i]<C[i]:
        C[i]-=X[i]
        X[i]=0
        X[i+1]=max(0,X[i+1]-C[i])
    else:
        X[i]-=C[i]
        C[i]=0
print(sum(A)-sum(X))


Measured memory_bytes: 18620
#include"bits/stdc++.h"
using namespace std;

const int mod = 1000000007;

void Main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  long long ans = 0;
  for (int i = 0; i < 60; i++) {
    long long x = 0;
    for (int j = 0; j < n; j++) {
      if (a[j] >> i & 1) ++x;
    }
    long long now = x * (n - x) % mod;
    for (int j = 0; j < i; j++) now = now * 2 % mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 2222;
const int MAXM = 100100;
const ll INF = 1ll<<60;
int K[MAXN], S[MAXM];
ll sum[MAXM];

ll dp[MAXN][MAXN];
int N, M, L;

ll dfs(int lp, int rp) {
	ll& ret = dp[lp][rp];
	if (ret >= 0) return ret;
	if (min(lp, rp) == 0) {
		int maxi = max(lp, rp), mini = min(lp, rp);
		return ret = (sum[K[maxi]+1] - sum[K[mini]]) / L;
	}
	int now = min(lp, rp)-1;
	ret = (sum[K[lp]+1]-sum[K[now]])/L + dfs(now, rp);
	ret = min(ret, (sum[K[rp]+1]-sum[K[now]])/L + dfs(lp, now));
	return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> L;
    for (int i = 0; i < N; i++) {
    	cin >> K[i];
    	K[i]--;
    }
    sort(K, K+N);
    for (int i = 0; i < M; i++)
    	cin >> S[i];
    for (int i = 0; i < M; i++) {
    	sum[i+1] = sum[i] + S[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << dfs(N-1, N-2) + (sum[K[N-1]+1]-sum[K[N-2]])/L << endl;
    return 0;
}

Measured memory_bytes: 42996
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9
for i in range(k-1, n):
  dR = abs(x[i]) + abs(x[i] - x[i-k+1])
  dL = abs(x[i-k+1]) + abs(x[i] - x[i-k+1])
  ans = min(ans, dR, dL)
print(ans)

Measured memory_bytes: 14224
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#define INF 10e10

using namespace std;

//  #define y cout << "yes"<< endl
  #define Y cout << "YES" << endl
  #define y cout << "Yes" << endl
//  #define n cout << "no"<< endl
  #define N cout << "NO" << endl
  #define n cout << "No" << endl
  #define pu(q) cout << q ;
  #define put(q) cout << q << " ";
  #define puts(q) cout << q << endl;
  
  
	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h,ans,res;
//	string a,b,c,d,e,f,g,h,ans,res;
//	double a,b,c,d,e,f,g,h,ans,res;
	
void take(int x);
  
int main(void){
	take(2);//数
	puts(max(max(a+b,a-b),a*b));
	
	return 0;
}
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long N, T, i, j;
  i = scanf("%ld %ld", &N, &T);
  long long sum = T;
  long t[2];
  i = scanf("%ld", t);
  for(i = 1; i < N; i ++){
    j = scanf("%ld", t+1);
    if(t[1] - t[0] < T){
      sum += t[1] - t[0];
    }
    else{
      sum += T;
    }
    t[0] = t[1];
  }
  printf("%lld\n", sum);
  return 0;
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int n;
    cin>>n;

    vector <int> a(n);
    int c=0;

    loop(i,0,n) cin>>a[i];

    loop(i,1,n-1)
    {
        if((a[i-1]<a[i] and a[i]<a[i+1]) or (a[i]>a[i+1] and a[i]<a[i-1]))
            c++;
    }
    cout<<c;


    return 0;
}


Measured memory_bytes: 3616
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
dl = []
for i in range(1,int(s**0.5)+1):
    if s%i == 0:
        dl.append(i)
        if i != s//i:
            dl.append(s//i)
dl.sort(reverse = True)

def search(x):
    ml = []
    for i in a:
        ml.append(i%x)
    ml.sort(reverse = True)
    ms = sum(ml)
    count = 0
    i = 0
    while k > count and ms > count:
        mi = x-ml[i]
        if k >= mi:
            count += mi
            ms -= ml[i]
            
        else:
            break
        i += 1

    if k >= count and count == ms:
        return True
    else:
        return False

for i in dl:
    
    if search(i):
        print(i)
        exit()



Measured memory_bytes: 3064
N,K,*A = $<.read.split.map &:to_i
A.sort!
P = A.bsearch_index {|a| a>0} || N
Z = A[0,P].bsearch_index {|a| a>=0} || P
if K <= Z*(N-P)
  X = A[0]*A[-1] .. A[Z-1]*A[P]
  B,C = Z<N-P && A.map!(&:-@) ? [A[P..-1].reverse!,A[0,Z]] : [A[0,Z],A[P..-1].reverse!]
  p X.bsearch {|x;t|
    u = -(x/-B[-1]) 
    i = C.bsearch_index {|c| t>c} or next true  if t!=u && t=u
    j,k = B.size-1, i*B.size
    C[i,N].any? {|c;u|
      if u != v=x/c
        h,u = 1,v
        h += h  while h<j && B[j-h] > u
        j = j<h ? 0 : j-h
        j += h if B[j+h] <= u  while 0 < h>>=1
        j += 1 if B[j] <= u 
        break  if j==0
      end
      K <= k+=j
    }
  }
  exit
end
exit p(0)  if K <= l = Z*(N-P) + (P-Z)*(2*(N-P+Z)+(P-Z-1))/2
x = [A[P-N]*A[P+1-N], A[0]*A[1], A[Z-1]*A[Z-2]].select {|x| x>0}
X = x.min .. [A[0]*A[1], A[-2]*A[-1]].max
B = A[0,Z].map!(&:-@).reverse
C = A[P,N-P]
p X.bsearch {|x|
  k = l
  [B,C].each{|a|
    j = a.size-1
    next if j<1 || a[0]*a[1] > x
    t = x/a[-1]
    i = a[0,j].bsearch_index {|a| a > t} || j
    k += (j+j-i+1)*i/2
    while j >= i+=1
      h,t = 1,x/a[i-1]
      h += h  while i<=j-h && a[j-h] > t
      j = i<=j-h ? j-h : i
      j += h if a[j+h] <= t  while 0 < h>>=1
      j += 1 if a[j] <= t
      break  if K <= k += j-i
    end
  }
  K <= k
}

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

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n, a, b, count=0, bcount=0; string s; cin >> n >> a >> b >> s;
    for(int i=0;i<n;i++){
        //cout << a << ':' << b << ':' << count << ':' << bcount << endl;
        if(s[i] == 'a' && count < a+b) {cout << "Yes" << endl; count++;}
        else if(s[i] == 'b' && count < a+b && bcount < b) {cout << "Yes" << endl; bcount++; count++;}
        else cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
vector<int> dx = {0,0,1,-1};
vector<int> dy = {1,-1,0,0};
int w,h;
int maze[23][23];
int seen[23][23];
int ans = 100;

int id(int i,int j){
    return i + j * h;
}

void dfs(int now,int c=0){
    if(c>10) return;
    int i = now % h;
    int j = now / h;
    if(maze[i][j]==3){
        //cout << c << endl;
        ans = min(ans,c);
        return;
    }

    int next_i = i,next_j = j;
    rep(k,4){
        if(maze[i+dx[k]][j+dy[k]]==1) continue;
        
        bool out = false;
        while(maze[next_i][next_j]==0){
            next_i += dx[k];
            next_j += dy[k];
            if(next_i < 0 || next_j < 0 || h <= next_i || w <= next_j){
                out = true;
                break;
            }
        }

        if(out){
            next_i = i;
            next_j = j;
            continue;
        }

        if(maze[next_i][next_j]==3){
            dfs(id(next_i,next_j),c+1);
        }
        else{
            maze[next_i][next_j] = 0;
            next_i -= dx[k];
            next_j -= dy[k];
            dfs(id(next_i,next_j),c+1);
            maze[next_i+dx[k]][next_j+dy[k]] = 1;
        }

        next_i = i;
        next_j = j;
    }

    return;
}

int main(){
    while(1){
        cin >> w >> h;
        if(w==0 && h==0) break;
        rep(i,h)rep(j,w) cin >> maze[i][j];
        int si,sj;
        rep(i,h)rep(j,w){
            if(maze[i][j]==2) si = i,sj = j;
        }
        maze[si][sj] = 0;
        ans = 100;
        dfs(id(si,sj));

        if(ans==100) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll h, w;
  cin >> h >> w;
  vector <string> c(h);
  forll(i, 0, h)
	cin >> c[i];

  forll(i, 0, 2 * h)
	cout << c[i / 2] << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 65;

llint n;
vector<int> v;
deque<int> d;

int count() {
  int m = (int)v.size();
  int ret = 0;
  REP(mask, (1 << m)) {
    vector<int> t;
    REP(i, m) if (mask & (1 << i)) t.push_back(v[i]);
    if ((int)t.size() % 2 == 1) continue;
    if (t.empty()) continue;

    int k = (int)t.size() / 2;
    bool ok = true;
    REP(i, k) if (t[i] != t[k+i]) ok = false;
    
    if (ok) {
      REP(i, 2 * k) printf("%d ",t[i]);
      printf("\n");
      ++ret;
    }
  }
  return ret;
}

int main(void) {
  scanf("%lld",&n);
  ++n;
  
  int lo = 1, hi = 100;
  while (n > 1) {
    if (!(n & 1)) {
      v.push_back(lo);
      n /= 2;
      ++lo;
    }
    else {
      v.push_back(hi);
      --n;
      --hi;
    }
  }
  
  auto tmp = v;
  sort(tmp.begin(), tmp.end());
  for (int x : tmp) v.push_back(x);

  printf("%d\n",(int)v.size());
  REP(i, (int)v.size()) printf("%d ",v[i]);
  printf("\n");
  //TRACE(count());
  
  return 0;
}


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

int f(int X){
    int S = 0;
    while (X > 0){
        S += X % 10;
        X /= 10;
    }

    return S;
}

int main(){
    int N;
    cin >> N;
    if (N % f(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _n: usize = read()[0];
    let mut a: Vec<i64> = read();
    a.sort_by_key(|&x| -x);
    let mut pre = 0;
    let mut l1 = 0;
    let mut l2 = 0;
    for &x in a.iter() {
        if pre == 0 || pre != x {
            pre = x;
            continue;
        }

        if l1 == 0 {
            l1 = x;
            pre = 0;
        } else {
            l2 = x;
            break;
        }
    }
    println!("{}", l1 * l2);
}


Measured memory_bytes: 6396
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MN 200005
#define ll long long
using namespace std;
int a[MN],mx,n;
ll ans;

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

int main()
{
	register int i;
	n=read();
	for (i=1;i<=n;++i) a[i]=read();
	for (i=n;i;--i,--mx)
	{
		if (a[i]>mx) ans+=a[i],mx=a[i];
		else if (a[i]<mx) return 0*printf("-1");
	}
	if (mx!=-1) printf("-1"); else printf("%lld\n",ans);
}

Measured memory_bytes: 896
def check(inpyt):
    count = 0
    if inpyt.count('S') == len(inpyt):
        return 0
    for ele in range(0, len(inpyt)):
        if ele < len(inpyt)+1:
            if inpyt[ele]=='R':
                try:
                    if inpyt[ele+1]==inpyt[ele]:
                        count +=1
                except IndexError as e:
                    pass
    return count+1
    


inpyt = list(input())
print(check(inpyt))

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

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

  vector<int> v(1e5+2, 0);
  rep(i, n){
    ++v[a[i]];
    ++v[a[i] + 1];
    ++v[a[i] + 2];
  }
  vector<int>::iterator ans = max_element(v.begin(), v.end());
  cout << *ans << endl;
  return 0;
}

Measured memory_bytes: 4044
k, t = map(int, input().split())
A = sorted(map(int, input().split()))
if t == 1:
    print(k - 1)
else:
    dev = k - A[-1] + 1
    ans = max(0, (A[-1] // dev - 1) * dev + A[-1] % dev)
    print(ans)


Measured memory_bytes: 61992
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m = I[:2]
ab = I[2:2+n*2].reshape(-1, 2)
cd = I[2+n*2:].reshape(-1, 2)

def main():
    res = np.absolute(cd - ab[:, None])
    res = np.sum(res, axis=2)
    ans = np.argmin(res, axis=1) + 1
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 13456
#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	
	if(n%1000==0){
		printf("%d",0);
	}
	else{
		int hasil=1000;
		while(hasil<n){
			hasil +=1000;
		}
		printf("%d",hasil-n);
	}
	return 0;
}


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

double trunc(double d) {
    d *= 1000;

    if (d < 0) {
        d -= 0.5;
    } else {
        d += 0.5;
    }

    return d / 1000;
}

int main() {

    double a, b, c, d, e, f;
    while (cin >> a >> b >> c >> d >> e >> f) {
        double x = (b * f - c * e) / (b * d - a * e);
        double y = (d * c - a * f) / (b * d - a * e);

        if (x == -0.000) x = 0.0;
        if (y == -0.000) y = 0.0;

        cout << fixed << setprecision(3) << x << " " << y << endl;
    }

    return 0;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    if (N%2 ==0) cout << N;
    else cout << N*2;
    cout << 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 REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	cin >> n;
	cout << DOUBLE << 2*pi*n << endl;
	return 0;
}

Measured memory_bytes: 3788
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll t[1000005];
int main() {
	ll n, c, k;
	cin >> n >> c >> k;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	sort(t,t+n);
	int ans = 0;
	for (int i = 0; i < n;) {
		++ans;
		int start = i;
		while (i < n && t[i] - t[start] <= k && i - start < c) {
			++i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4420
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>
#include <cstdlib>

using namespace std;

typedef pair<int, int> P;

#define MAX 128

int main()
{
	while(1) {
		int n;
		set<int> know[MAX];
		bool leak[MAX];

		for(int i = 0; i < MAX; i++) {
			leak[i] = true;
		}
		
		scanf("%d", &n);
		if(!n) break;
		for(int i = 1; i <= n; i++) {
			int m;
			scanf("%d", &m);
			while(m--) {
				int p;
				scanf("%d", &p);
				know[i].insert(p);
			}
		}

		int k;
		scanf("%d", &k);
		while(k--) {
			int l;
			scanf("%d", &l);
			for(int i = 1; i <= n; i++) {
				if(!leak[i]) continue;
				set<int>::iterator it = know[i].find(l);
				if(it == know[i].end()) {
					leak[i] = false;
				}
			}
		}

		int ans = -1;
		for(int i = 1; i <= n; i++) {
			if(!leak[i]) continue;
			if(ans > 0) {
				ans = -1;
				break;
			}
			ans = i;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1572
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}



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


    int h,w,a;
    cin>>h>>w>>a;
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    sx--,sy--,gx--,gy--;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    s[sx][sy]='S';
    s[gx][gy]='G';
    int d[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j] = 1e9;
        }
    }
    queue<array<int,5>> q;
    q.push({0,sx,sy,-1,0});
    while(q.size()){
        array<int,5> p = q.front(); q.pop();
        int x = p[1], y = p[2], dist = p[0];
        int r = p[3], ok = (p[4]==a);
        int ndist = dist + 1;
        if(d[x][y] < dist) continue;
        for(int i=0;i<4;i++){
            if(i + r == 3)continue;
            if(i == r && !ok)continue;
            for(int k=1;k<=a;k++){
                int nx = x + k*dx[i];
                int ny = y + k*dy[i];
                if(nx>=h || ny>=w)break;
                if(nx>=0 && ny>=0){
                    if(s[nx][ny] == '@')break;
                    if(d[nx][ny] <= ndist)continue;
                    chmin(d[nx][ny],ndist);
                    if(s[nx][ny] == 'G'){
                        cout << dist+1 << endl;
                        return 0;
                    }
                    q.push({ndist,nx,ny,i,k});
                }
            }
        }
    }
    cout << -1 << endl;
    
}

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

int N;
map<int, int> A;

int main()
{
    cin >> N;
    for (int i=0; i<N; i++)
    {
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }
    cout << A.size() - (N - A.size()) % 2 << endl;
}


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

int in(){int x;scanf("%d",&x);return x;}

signed main(){

  bitset<32> a(in()),b(in());
  cout<< (a&b) <<endl;
  cout<< (a|b) <<endl;
  cout<< (a^b) <<endl;
  

}


Measured memory_bytes: 3244
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define INTINF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;

int n,pos;
std::vector<int> pre, in, post;

void rec(int l, int r) {
  if (l>=r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(in.begin(),in.end(), root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve(){
  pos=0;
  rec(0, pre.size());
  for (size_t i = 0; i < n; i++) {
    if (i) std::cout << " ";
    std::cout << post[i];
  }
  std::cout << '\n';
}

void input(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  std::cin >> n;
  for (size_t i = 0; i < n; i++) {
    std::cin >> k;
    pre.push_back(k);
  }
  for (size_t i = 0; i < n; i++) {
    std::cin >> k;
    in.push_back(k);
  }
}

int main(int argc, char const *argv[]) {
  input();
  solve();
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i,m;
    string a,b;
    cin >> a >> b;
    n = a.length();
    int ans = 0;
    f(i,0,n)
        if(a[i] != b[i])
            ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3776
def read_input():
    n = int(input())
    return n

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def submit():
    n = read_input()
    divisors = make_divisors(n)
    
    s = 0
    for d in divisors:
        m = (n - d) // d
        if d >= m:
            break
        s += m

    print(s)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 41744
H, N = [int(i) for i in input().split()]
M = []
for i in range(N):
  A, B = [int(i) for i in input().split()]
  M.append((A, B))

dp = [0 for i in range(H + 1)]

for i in range(1, H+1):
  cand = []
  for A, B in M:
    cand.append(dp[max(0, i-A)] + B)
  dp[i] = min(cand)
print(dp[H])


Measured memory_bytes: 74380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int a,b;
    cin>>a>>b;
    if( a>=1 && a<=9 &&b>=1 && b<=9 ){
	cout<<a*b<<endl;
    }else{
	cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
X = int(input())

a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit()
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

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

void a()
{
    int n;
    cin >> n;
    string n_str = to_string(n);
    for (int i = 0; i < 3; i++)
    {
        if (n_str[i] == n_str[i + 1])
        {
            cout << "Bad";
            return;
        }
    }
    cout << "Good";
    return;
}
void b()
{
    int n, l;
    cin >> n >> l;
    int lmax = l + n - 1;
    int lmin = l;
    int sum = (l - 1) * n + n * (n + 1) / 2;
    if (lmax > 0 && lmin < 0)
    {
    }
    else if (lmax <= 0)
        sum -= lmax;
    else
        sum -= lmin;
    cout << sum;
    return;
}
long long int gcd(long long int c, long long int d)
{
    long long int temp;
    if (c < d)
    {
        temp = d;
        d = c;
        c = temp;
    }
    if (c % d == 0)
        return d;
    else
        return gcd(d, c % d);
}
long long int unable_to_div(long long int l, long long int c, long long int d)
{
    long long int x = l / c;
    long long int y = l / d;
    long long int z = l / (c * d / gcd(c, d));
    return l - x - y + z;
}
void c()
{
    long long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long long int l = a - 1;
    long long int m = b;
    long long int sum_l = unable_to_div(l, c, d);
    long long int sum_m = unable_to_div(m, c, d);
    cout << sum_m - sum_l;
}
void d()
{
    int n;
    cin >> n;
    vector<pair<int, int>> tasks;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        tasks.push_back(make_pair(a, b));
    }
    sort(tasks.begin(), tasks.end(), [](const pair<int, int> &a, const pair<int, int> &b) {
        return a.second < b.second;
    });
    int time = 0;
    for (int i = 0; i < n; i++)
    {
        time += tasks[i].first;
        if (time > tasks[i].second)
        {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
    return;
}
int main(void)
{
    d();
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

map<int, int> mp;
vector<int> sieve(1000001, -1);

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    // cout << "1\n";
    sieve[1] = 1;
    for (int i = 2; i < 1000001; i++)
    {
        if (sieve[i] != -1)
            continue;
        sieve[i] = i;
        for (int j = i * 2; j < 1000001; j += i)
            if (sieve[j] == -1)
                sieve[j] = i;
    }
    // cout << "2\n";
    for (int i = 0; i < n; i++)
    {
        while (a[i] != 1)
        {
            int p = sieve[a[i]];
            while (a[i] % p == 0)
                a[i] /= p;
            mp[p]++;
        }
    }
    // cout << "3\n";
    bool a1 = true;
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        if (it->second != 1)
        {
            a1 = false;
            break;
        }
    }
    if (a1)
    {
        cout << "pairwise coprime\n";
        return 0;
    }
    bool a2 = true;
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        if (it->second == n)
        {
            a2 = false;
            break;
        }
    }
    // cout << "4\n";
    if (a2)
    {
        cout << "setwise coprime\n";
    }
    else
        cout << "not coprime\n";
}

Measured memory_bytes: 14776
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define isWorking()   cout<<"Wroking"<<endl
#define all(x)        (x).begin(),(x).end()
#define allr(x)       (x).rbegin(),(x).rend()
#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl
#define DoublePrint(x,a) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e8,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

char Change(char x){
    if(x=='1') return '0';
    return '1';
}

int main() {
    Fast_Input

    while(testCase--) {
        string str; cin >> str;

        string str2 = str;

        int n = str.size() , ans1 = 0, ans2 = 0;

        for(int i=1; i<n; i++){
            if(str[i] == str[i-1]){
                str[i] = Change(str[i-1]);
                ans1 ++;
            }
        }

        str2[0] = Change(str2[0]);
        ans2 ++;

        for(int i=1; i<n; i++){
            if(str2[i] == str2[i-1]){
                str2[i] = Change(str2[i-1]);
                ans2 ++;
            }
        }

        cout << min(ans1,ans2) << endl;
    }
    return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

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

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int H, W;
int grid[2002][2002];

signed main(){
    string str;
    cin >> H >> W;
    REP(i, H){
        cin >> str;
        REP(j, W){
            if(str[j] == '#') grid[i + 1][j + 1] = -1;
            else grid[i + 1][j + 1] = 0;
        }
    }
    REP(i, H + 2) grid[i][0] = grid[i][W + 1] = -1;
    REP(j, W + 2) grid[0][j] = grid[H + 1][j] = -1;
    REP(i, H + 2){
        int cnt = 0, head = 0;
        REP(j, W + 2){
            if(grid[i][j] == -1) {
                FOR(k, head, j) grid[i][k] += cnt;
                cnt = 0; head = j + 1;
            }else{
                cnt++;
            }
        }
    }
    REP(j, W + 2){
        int cnt = 0, head = 0;
        REP(i, H + 2){
            if(grid[i][j] == -1){
                FOR(k, head, i) grid[k][j] += cnt;
                cnt = 0; head = i + 1;
            }else{
                cnt++;
            }
        }
    }
    int m = 0;
    FOR(i, 1, H + 1) FOR(j, 1, W + 1) m = max(m, grid[i][j] - 1);
    PRINT(m);
    return 0;
}

Measured memory_bytes: 15872
M,D=map(int,input().split())
ans=0
for m in range(1,M+1):
    for d in range(1,D+1):
        #i月j日
        s=str(d)
        if len(s)==1:
            s="0"+s
        d1,d10=int(str(s)[0]),int(str(s)[1])
        if m==d1*d10 and d1>=2 and d10>=2:
            ans+=1
print(ans)

        

Measured memory_bytes: 40432