akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from numba import njit

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

@njit
def solve(N, M, S, T):
    dp = np.ones((N+1, M+1), np.int64)
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1]
            if s != t:
                dp[i+1][j+1] -= dp[i][j]
            dp[i+1][j+1] %= MOD
    return dp[N][M]

print(solve(N, M, S, T))


Measured memory_bytes: 147376
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n , odd = 0; cin >> n;
    for(int i=0;i<n;i++){
        int t; cin >> t;
        if(t & 1)odd++;
    }if(odd & 1)return cout << "NO\n" , 0;
    return cout << "YES\n" , 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  int n;cin>>n;
  long long a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  long long ans = 0;
  for(int i = 1 ; n > i; i++){
    if(a[i-1] >= a[i]){
      ans++;
    }
  }
  cout << ans+1 << endl;
  cout << n << endl;

}


Measured memory_bytes: 3880
#include <iostream>
// #include <vector>
// #include <cmath>
using namespace std;
using ll = long long;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int sep1 = 1, sep2 = 2, sep3 = 3;
    ll acc1 = 0, acc2 = 0, acc3 = 0, acc4 = 0;
    int i = 0;
    while (i < sep1) acc1 += a[i++];
    while (i < sep2) acc2 += a[i++];
    while (i < sep3) acc3 += a[i++];
    while (i < n)    acc4 += a[i++];
    ll ans = 1000000001;
    while (sep2 <= n-1) {
        while (acc1 - acc2 + (a[sep1] << 1) < 0) {
            acc1 += a[sep1];
            acc2 -= a[sep1++];
        }
        if (abs(acc1-acc2) >= abs(acc1 - acc2 + (a[sep1] << 1))) {
            acc1 += a[sep1];
            acc2 -= a[sep1++];
        }
        while (acc3 - acc4 + (a[sep3] << 1) < 0) {
            acc3 += a[sep3];
            acc4 -= a[sep3++];
        }
        if (abs(acc3-acc4) >= abs(acc3 - acc4 + (a[sep3] << 1))) {
            acc3 += a[sep3];
            acc4 -= a[sep3++];
        }
        ans = min(ans, max(max(acc1,acc2),max(acc3,acc4)) - min(min(acc1,acc2),min(acc3,acc4)));
        acc2 += a[sep2];
        acc3 -= a[sep2++];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 
    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ
*/

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

    string s, t; cin >> s >> t;
    cout << t << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

int n;
VV(pii) G;
vector<LL> rests;
vector<int> vis;

bool dfs(int u, int tgt, LL mask){
	vis[u] = 1;
	bool r = u == tgt;
	for(cauto e : G[u]){
		if(!vis[e.first]){
			bool s = dfs(e.first, tgt, mask);
			r |= s;
			if(s){ rests[e.second] |= mask; }
		}
	}
	return r;
}

void mainmain(){
	cin >> n;
	G.resize(n);
	for(int i = 0; i < n - 1; ++i){
		int a, b;
		cin >> a >> b;
		G[a - 1].emplace_back(b - 1, i);
		G[b - 1].emplace_back(a - 1, i);
	}
	int m;
	cin >> m;

	rests.assign(n - 1, 0);
	for(int i = 0; i < m; ++i){
		int u, v;
		cin >> u >> v;
		vis.assign(n, 0);
		dfs(u - 1, v - 1, 1LL << i);
	}

	LL ans = 0;
	for(int S = 0; S < (1 << m); ++S){
		int und = 0;
		for(LL x : rests){
			if(!(x & S)){ ++und; }
		}
		LL val = 1LL << und;
		if(__builtin_parity(S)){ val = -val; }
		ans += val;
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


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

int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    vector<ll> a(n),s(n),spos(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        if(i) s[i] = s[i-1]+a[i],spos[i] = spos[i-1]+(a[i]<0?0:a[i]);
        else s[i] = a[i],spos[i] = a[i]<0?0:a[i];
    }
    for(int i = 0;i < n-k+1;i ++){
        ll b;
        if(i) {
            b = max(s[i+k-1]-s[i-1],0ll);
            b += spos[i-1]+(spos[n-1]-spos[i+k-1]);
        }else{
            b = s[i+k-1];
            b += spos[n-1]-spos[i+k-1];
        }
        ans = max(b,ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 0;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
    if (T.at(i) >= K) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin>>N;
  vector<long> r(N);
  for (int j = 0; j < N; j++) cin>>r[j];
  long minv = r[0];
  long maxv = -9999999999999;
  for (int i=1;i<N;i++){
    maxv = max(maxv, r[i]-minv);
    minv = min(minv, r[i]);
  }

cout<<maxv<<endl;

  }



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


int main() {
	
	int N;
	int cnt = 0;
	cin >> N;
	for (int i=0; i<N; i++) {
		int l, r;
		cin >> l >> r;
		cnt += r - l + 1;
	}
	cout << cnt << endl;
	
	
	return 0;
}

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

using namespace std;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

int main() {
  int N;
  cin >> N;
  vector<int> S;
  S.push_back(0);
  for (int i = 0; i < N; i++) {
    int w;
    cin >> w;
    S.push_back(S.back()+w);
  }

  transform(ALL(S),S.begin(),[&](int x){return abs(S.back()-2*x);});
  cout << *min_element(ALL(S)) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
const int N = 1e6 + 10;
int a;

int main() {
	cin >> a;
	cout << a + a * a + a * a*a << endl;
	return 0;
}

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

typedef long long ll;

int mod = 1e9 + 7;
ll p = 2e6 + 100;
vector<ll> com(p + 1);
vector<ll> inv(p + 1);
vector<ll> mul(p + 1);


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

ll C(ll n, ll k) {
	ll maxm = max(k,n - k);
	ll minn = min(k,n - k);
	ll ans = 1;
	for (ll i = n; i > maxm; --i) {
		ans = (ans * i) % mod;
	}
	return (ans * mul[minn]) % mod;
}

int main() {	
	com[0] = 1;
	for (ll i = 1; i <= p; ++i) {
		com[i] = (com[i - 1] * i) % mod;
	} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	ll n, a , b;
	cin >> n >> a >> b;
	//cout << power(2,n);
	ll ans = (power(2,n) - 1 - C(n,a) - C(n,b) + mod + mod) % mod;
	cout << ans;
}









Measured memory_bytes: 50084
//           ––=‹‹BISMILLAHITR RAHMANIR RAHIM››=––
//  Problem name: atcoder bc 179a
//  Lang: C++
//  ©: _Shakib Hossen Shanto   _ CSE Dept__Begum Rokeya University,Rangpur

#include<bits/stdc++.h>
using namespace std;

#define uns unsigned
#define ll long long
#define dl double
#define st string
#define ch char
#define tc ll t;cin>>t;while(t--)


int main()
{
    st s;
    cin >> s;
    int a;
    for(int i=0; i<s.size(); i++)
    {
        if(s[s.size()-1]=='s') a=1;
        else a=2;
        break;
    }
    if(a==1) cout<<s<<"es"<<endl;
    else cout<<s<<"s\n";

   return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());
    auto start = clock();


    int n, m, k, t; cin >> n >> m >> k >> t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int st = 0, en = n;
    while(en - st > 1) {
        int mid = (en + st) / 2;
        int need = a[mid] + m;
        ll cnt = 0;
        if (need < a[t - 1]) {
            en = mid;
            continue;
        }
        for (int i = n - 1; i >= 0; --i) {
            if (i == mid) continue;
            if (i >= t - 1) {
                cnt += min(m, max(0, need - a[i]));
            } else {
                cnt += m;
            }
        }
        if (cnt >= 1LL * m * (k - 1)) {
            st = mid;
        } else {
            en = mid;
        }
    }
    cout << st + 1 << endl;



    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

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

using namespace std;
int main() {
 int N;
 cin >> N;
 int A[2][N];
rep(j,2){
  rep(i,N){
    cin >> A[j][i];
   }
 }
int score[N];
rep(i,N){
  score[i]=0;
}
rep(i,N){
  for(int j=0;j<i+1;j++){
        score[i]+= A[0][j];
  }
  for(int j=i;j<N;j++){
    score[i]+= A[1][j];
  }
}
/*
rep(i,N){
  cout << score[i] << endl;
}
*/

int max = 0;
rep(i,N){
  if(score[i]>max){
    max = score[i];
  }
}
cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
nums=list(map(int,input().split()))
permit=True
for num in nums:
  if num % 2==0:
    if num % 3 !=0 and num % 5 != 0:
      permit=False
  else:
    pass
if permit:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 2940
from itertools import product, permutations,combinations

N, M = map(int, input().split())
rel = [tuple(map(int, input().split())) for i in range(M)]
memo = [[0]*N for i in range(N)]
for r in rel:
        memo[r[0]-1][r[1]-1] = 1
        memo[r[1]-1][r[0]-1] = 1

V = [i+1 for i in range(N)]

cnt = 0
for i in permutations(V, N):
    if i[0] > 1:
        break
        
    for j in range(N-1):
        if memo[i[j]-1][i[j+1]-1] == 0:
            break
    else:
        cnt+=1

print(cnt)

Measured memory_bytes: 3064
<?php
[$N, $M, $Q] = ints();
for($i = 0; $i < $Q; $i++){
    list($aa, $bb, $c[], $d[]) = ints();
    $a[] = $aa-1;
    $b[] = $bb-1;
}
dfs([], 1);
$max = 0;
foreach($ret as $array){
    $score = 0;
    for($i = 0; $i < $Q; $i++){
        if($array[$b[$i]]-$array[$a[$i]]==$c[$i])$score+=$d[$i];
    }
    chmax($max, $score);
}
echo $max;

function dfs($array, $min){
    global $N, $M, $ret;
    if(count($array) == $N){
        $ret[] = $array;
        return;
    }
    for($i = $min; $i <= $M; $i++){
        $array2 = $array;
        $array2[] = $i;
        dfs($array2, $i);
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}



function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 82756
using System;

class GoHome
{
	static public void Main(string[] args)
	{
		int X =int.Parse(Console.ReadLine());
		long n = 0;

		for(int i=1; i<1000000000; i++)
		{
			n += i;
			if(n >= X)
			{
				Console.WriteLine(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 13140
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = 1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = 0;
    if (A + B > 2 * C) {
        while (X > 0 && Y > 0) {
            ans += 2 * C;
            --X;
            --Y;
        }
    }
    while (X > 0) {
        ans += min(A, 2 * C);
        --X;
    }
    while (Y > 0) {
        ans += min(B, 2 * C);
        --Y;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	
	int a;
	cin >> a;
	cout << ((a >= 3) ? a / 3 : 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    if(x==y) printf("%d\n",x);
    else
    {
        int z,Z,n,k;
        if(x<y) z=x,Z=y;
        else    z=y,Z=x;
        int r;
        for(;;)
        {
              r=Z%z;
              if(r==0) break;
              Z=z;
              z=r;
         }
         printf("%d\n",z);
     }
     return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
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;}

const int INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int a;cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int n, m;
	cin >> n >> m;
	int a[10004];
	ll sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (n - sum >= 0) {
		cout << n - sum << endl;
	}
	else {
		cout << "-1" << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<int> x(n), y(n), vx(n), vy(n);
	for(int i = 0; i < n; i++){
		cin>>x[i]>>y[i];
		vx[i] = x[i];
		vy[i] = y[i];
	}
	sort(vx.begin(), vx.end());
	sort(vy.begin(), vy.end());
	ll ans = LLONG_MAX;
	for(int il = 0; il + 1 < n; il++){
		for(int ir = il + 1; ir < n; ir++){
			for(int jl = 0; jl + 1 < n; jl++){
				for(int jr = jl + 1; jr < n; jr++){
					int cnt = 0;
					for(int i = 0; i < n; i++){
						if(vx[il] <= x[i] && x[i] <= vx[ir] && vy[jl] <= y[i] && y[i] <= vy[jr])cnt++;
					}
					if(cnt >= k)ans = min(ans, (vx[ir] - vx[il])*1LL*(vy[jr] - vy[jl]));
				}
			}
		}
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <stdlib.h>
using namespace std;



int main()
{
  int i;
  long long int M = 1000000007;
  long long int n,m;
  long long int x,y;
  long long int ans = 0;
  cin >> n >> m;
  x = y =  0;

  for(i=0;i<n;i++){
    long long int tmp_sum,tmp;
    cin >> tmp;
    tmp_sum = (tmp * ( (1 - n) + 2 * i ) ) % M;
    x += tmp_sum;
    x %= M;
  }

  for(i=0;i<m;i++){
    long long int tmp_sum,tmp;
    cin >> tmp;
    tmp_sum = (tmp * ( (1 - m) + 2 * i ) ) % M;
    y += tmp_sum;
    y %= M;
  }

  ans = ( y * x ) % M;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
n_flowers = int(input())
heights = [int(h) for h in input().split()]
diff = [h for h in heights]
n_pour = 0

for i in range(n_flowers):
  while diff[i] > 0:
    for j in range(i, n_flowers):
      if diff[j] <= 0:
        diff[i:j] = [d - 1 for d in diff[i:j]]
        n_pour += 1
        break
      elif j == n_flowers - 1:
        diff[i:n_flowers] = [d - 1 for d in diff[i:n_flowers]]
        n_pour += 1
        break

print(n_pour)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
using namespace std;
int main(){
	set<int>s;
	int n;
	cin>>n;
	while(n--){
		int k;
		cin>>k;
		if(s.find(k)==s.end())
			s.insert(k);
		else
			s.erase(k);
		
	}
	cout<<s.size()<<endl;
	return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    string cbs;
    cin>>cbs;
    int zs=0;
    int ns=0;
    int ot=0;
    for(int i=0;i<cbs.length();i++){
        if(cbs[i]=='0'){
            zs++;
            if(zs<=ns)
                ot+=2;
        }
        else if(cbs[i]=='1'){
            ns++;
            if(ns<=zs)
                ot+=2;
        }
    }
    cout << ot << endl;
    return 0;
}


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

int aa[1300];
int main()
{
    int te=10,c,r;
    LL a,b;
   string st;
   cin>>st;
   int l=st.size();
   for(int i=0;i<l;i++)
   {
       if(aa[st[i]-'a'])
       {
           cout<<"no\n";
           return 0;
       }
       aa[st[i]-'a']=1;
   }
   cout<<"yes\n";

    return 0;
}


Measured memory_bytes: 256
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};    // King's move
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hx[]={-2,-2,-1,+1,+2,+2,-1,+1};    // Knight's move
int hy[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;

ll a[MAXN];

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n; for(i=1; i<=n; i++) cin>>a[i];

    ll XOR = 0;
    for(i=1; i<=n; i++) XOR = XOR^a[i];


    for(i=1; i<=n; i++)
    {
        cout<<(XOR^a[i])<<" ";
    }
    cout<<endl;

  //  main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 5072
"""
 // Author : snape_here - Susanta Mukherjee
 // Date : 27/07/2019

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading


# For getting input from input.txt file 
#sys.stdin = open('input.txt', 'r')  
  
# Printing the Output to output.txt file 
#sys.stdout = open('output.txt', 'w') 

def ii(): return int(input())
def fi(): return float(input())
def si(): return str(input())
def mi(): return map(int,input().split())
def li(): return list(mi())

def main():
    
    N = ii()
    H = li()
    l = 0
    for h in H:
        if l > h:
            print('No')
            break
        if h - 1 > l:
            l = h - 1
    else:
        print('Yes')

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 46248
sx, sy, tx, ty = map(int, input().split())
status = [0, 0]

if sx < tx:
	status[0] = 1
elif sx > tx:
	status[0] = -1

if sy < ty:
	status[1] = 1
elif sy > ty:
	status[1] = -1

# 第一象限
if status[0] == 1 and status[1] == 1:
	for i in range(tx - sx):
		print("R", end="")
	for i in range(ty - sy):
		print("U", end="")
	for i in range(tx - sx):
		print("L", end="")
	for i in range(ty - sy):
		print("D", end="")
	print("L", end="")
	for i in range(ty - sy + 1):
		print("U", end="")
	for i in range(tx - sx + 1):
		print("R", end="")
	print("D", end="")
	print("R", end="")
	for i in range(ty - sy + 1):
		print("D", end="")
	for i in range(tx - sx + 1):
		print("L", end="")
	print("U", end="")

Measured memory_bytes: 51820
#include<stdio.h>
int main(){
  int i,j,k;
  int d;	//365
  int c[26];
  int score[9490];
  int t[365] = {0};
  int day1[26] = {0};
  double x = 0.36787944117;
  int tmp1=-999999,tmp2=-999999;
  int tmpi = 0;
  
  scanf("%d",&d);
  for(i=0;i<26;i++){
      scanf("%d ",&c[i]);
  }
  for(i=0;i<d*26;i++){
      scanf("%d ",&score[i]);
  }
  //st
  
  for(i=0;i<26;i++){
    if(c[i]>tmp1){
     tmp1 = c[i];
    }
    tmpi = i;
  }
  tmp1 = -999999;/*
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      if(score[i*26+j]-c[j]*(1+day1[j])>tmp1){
       	t[i] = j;
      }
    }
  }
  */
  //en
  int sp[26]={0};
  int pp=-999999;
  int pp2 = 0;
  for(i=0;i<d;i++){
    
    
    
    pp2=0;
    for(k=0;k<26;k++){  
    if(sp[k]==0&&score[k]-c[k]*day1[k]>pp){	
      pp=score[k];
      pp2 = k;
    }}
    pp=-999999;
    sp[pp2]=1;
    printf("%d\n",pp2+1);
    //printf("%d\n",(tmpi+i)%26+1);
    if(i%26==25){
    	for(k=0;k<26;k++){
         sp[k]=0; 
        }
    }  
    
    
    for(k=0;k<26;k++){
      day1[k] += 1;
    }
    day1[pp2]=0;
  }
 return 0; 
}






Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a+b+c+d)/60 << endl;
    cout << (a+b+c+d)%60 << endl;
}


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

int main() {
  int N, value;cin >> N;value=N;
  if (value>=10^7 &&value !=10^8){int j[8];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;j[3]=N%10;N/=10;j[4]=N%10;N/=10;j[5]=N%10;N/=10;j[6]=N%10;N/=10;j[7]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2]+j[3]+j[4]+j[5]+j[6]+j[7])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10^6){int j[7];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;j[3]=N%10;N/=10;j[4]=N%10;N/=10;j[5]=N%10;N/=10;j[6]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2]+j[3]+j[4]+j[5]+j[6])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10^5){int j[6];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;j[3]=N%10;N/=10;j[4]=N%10;N/=10;j[5]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2]+j[3]+j[4]+j[5])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10^4){int j[5];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;j[3]=N%10;N/=10;j[4]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2]+j[3]+j[4])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10^3){int j[4];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;j[3]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2]+j[3])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10^2){int j[3];j[0]=N%10;N/=10;j[1]=N%10;N/=10;j[2]=N%10;N/=10;
   if (value%(j[0]+j[1]+j[2])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else if (value>=10){int j[2];j[0]=N%10;N/=10;j[1]=N%10;N/=10;
   if (value%(j[0]+j[1])==0){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
  }
  else{cout<<"Yes"<<endl;}
}


Measured memory_bytes: 256
const lines = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

reader.on("line", function (line) {
  lines.push(line);
});
reader.on("close", function () {
  const input = (lines[0] as string).split(" ");
  const a = +input[0];
  const b = +input[1];

  const res = (a * b) % 2 === 0 ? "Even" : "Odd";

  console.log(res);
});


Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
# define MOD 1000000007
int dp[2][1000001];
long long util(vector<int> adj[], int n, int u, int parent, int flag){
    if(dp[flag][u] != -1) return dp[flag][u]%MOD;
    int white = 1;
    for(int i=0;i<adj[u].size();i++){
        int v = adj[u][i];
        if(v != parent) white = ((white%MOD)*(util(adj, n, v, u, 0)%MOD)+MOD)%MOD;
    }
    int res = white;
    if(flag == 0){
        int black = 1;
        for(int i=0;i<adj[u].size();i++){
            int v = adj[u][i];
            if(v != parent) black = ((black%MOD)*(util(adj, n, v, u, 1)%MOD)+MOD)%MOD;
        }
        res = (res%MOD + black%MOD)%MOD;
    }
    res = res%MOD;
    dp[flag][u] = res;
    return res;
}
int main(){
	int n;
	cin>>n;
    vector<int> adj[n];
    for(int i=0;i<n-1;i++){
        int xi, yi;
        cin>>xi>>yi;
        adj[xi-1].push_back(yi-1);
        adj[yi-1].push_back(xi-1);
    }
    memset(dp, -1, sizeof(dp));
    cout<<util(adj, n, 0, -1, 0);
	return 0;
}

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

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

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

    cin >> m;
	int search[m] = {};
	for(int i=0;i<m;i++) cin >> search[i];

	int count =0;
	int left,right;
	for(int i=0;i<m;i++){
		left =0; right =n;

		while(left+1 < right){
			int mid = (left +right) /2;
			if(search[i] >= arr[mid] ) left = mid;
			else right = mid;
		}

		if(search[i] != arr[left]) continue;
		count++;
	}

	cout << count << endl;


    return 0;
}



Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
const int Kmax=1e6;
typedef long  long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<ll> sum(n+1),xo(n+1),a(n+1);
	int l=0;
	ll ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
		xo[i]=xo[i-1]^a[i];
		while((sum[i]-sum[l])!=(xo[i]^xo[l])){
			l++;
		}
		ans=ans+i-l;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << 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; }

using namespace std;

struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return ;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }

};

int main(){
    int N; cin >> N;
    vector<ll> x(N), y(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

    using pint = pair<int, int>;
    using Edge = pair<ll, pint>;
    vector<Edge> edges;

    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int i = 0; i + 1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i + 1];
        edges.push_back(Edge(x[v]-x[u], pint(u, v)));
    }

    sort(ids.begin(), ids.end(), [&](int i, int j){ return y[i] < y[j]; });
    for (int i = 0; i+1 < ids.size(); ++i) {
        int u = ids[i], v = ids[i+1];
        edges.push_back(Edge(y[v]-y[u], pint(u, v)));
    }

    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    ll res = 0;
    for (auto e: edges) {
        int u = e.second.first, v = e.second.second;
        ll cost = e.first;
        if (uf.issame(u, v)) continue;
        uf.merge(u, v);
        res += cost;
    }

    cout << res << endl;






}

Measured memory_bytes: 8432
#include <stdio.h>
#include <string.h>

#define MAX 100000
#define SENTINEL 1000000000

typedef struct{
  int n;
  char c;
}Card;

int partition(Card *A, int p, int r){
  int i, j;
  int x;
  Card t;
  x = A[r].n;
  i = p-1;
  for(j=p; j<r; j++){
    if (A[j].n <= x) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(Card *A, int p, int r){
  int q;
  if (p<r) {
    q = partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

void merge(Card *B, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left, n2 = right - mid;
  Card L[n1+1],R[n2+1];

  for(i = 0 ; i < n1 ; i++){
    L[i].c = B[left + i].c;
    L[i].n = B[left + i].n;
  }
  for(i = 0 ; i < n2 ; i++){
    R[i].c = B[mid + i].c;
    R[i].n = B[mid + i].n;
  }
  L[n1] = R[n2] = (Card){SENTINEL, '#'};
  for(i = 0,j = 0,k = left ; k < right ; k++){
    if(L[i].n <= R[j].n){
      B[k] = L[i++];
    }else{
      B[k] = R[j++];
    }
  }
}

void mergeSort(Card *B, int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(B, left, mid);
    mergeSort(B, mid, right);
    merge(B, left, mid, right);
  }
}

int isStable(Card *A, Card *B, int n){
  int i, j;
  int isStable = 1;
  for(i = 0 ; i < n ; i++){
    if(A[i].c != B[i].c || A[i].n != B[i].n){
      isStable = 0;
      break;
    }
  }
  return isStable;
}

int main(int argc, char const *argv[]) {
  Card A[MAX], B[MAX];
  int i, n;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    getchar();
    scanf("%c%d", &A[i].c, &A[i].n);
    B[i].c = A[i].c;
    B[i].n = A[i].n;
  }
  quickSort(A, 0, n-1);
  mergeSort(B, 0, n);
  printf("%s\n", (isStable(A, B, n)? "Stable" : "Not stable"));
  for(i=0; i<n; i++){
    printf("%c %d\n", A[i].c, A[i].n);
  }
  return 0;
}



Measured memory_bytes: 4048
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
a = []
b = []
for i in range(n):
    a.append(ins())
for i in range(m):
    b.append(ins())
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            if a[i+k][j:j+m]!=b[k]:
                ok = False
                break
        if ok:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 38256
H1, M1, H2, M2, K = map(int, input().split())
Hk, Mk = K//60, K%60
Htmp = H2 - Hk
Mtmp = M2 - Mk
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1
    
Htmp = Htmp - H1
Mtmp = Mtmp - M1
if Mtmp < 0:
    Mtmp += 60
    Htmp -= 1

    
print(Htmp * 60 + Mtmp)

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

int main() {


  long A,B,C,K;
  cin >> A>>B>>C>>K;
 if(A >=K){
  cout << K << endl; 
 }
  
  else if((A+B)>=K){
    cout << A<< endl;
  }
  
  else if((A+B+C)>=K){
   cout<< A-(K-(A+B))<<endl; 
  }
    
  
  return 0;

}

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

int main(){
  ll N;
  cin >> N;
  ll ans=0;
  ll M;
  int i=1;
  
  if(N<2)ans=0;
  else if(N%2==1)ans=0;
  else 
for(;i>0;i++)
  {
   M=2*pow(5,i);
   ans=ans+(N-N%M)/M;
  if(M>pow(10,18))break;
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <vector>
#define CL(a) memset(a,0,sizeof(a))
#define cl(a,b) memset(a,(b),sizeof(a))
#define For(i,a,b) for(int i=a;i<=b;i++)
#define _for(i,a,b) for(int i=a;i<b;i++)
#define LL long long 
using namespace std;
const int maxn = 2e5 + 100;
int pre[maxn];
#define v val 
long long val[maxn];
int Find(int x)
{
	if(x==pre[x])
	{
		return x;
	}
	else 
	{
		int tmp = pre[x];
		pre[x] = Find(pre[x]);
		v[x]+=v[tmp];
		return pre[x];
	}
}

bool link(int x,int y,long long d)
{
	int fx = Find(x);
	int fy = Find(y);
	if(fx==fy)
	{
		return v[y]==v[x]+d;
	}
	pre[fy] = fx;
	v[fy] = d+v[x]-v[y];
	return true;
}
int main()
{
	int m,n;
	int L,R; 
	long long D;
	bool flag;
	while(cin>>n>>m)
	{
		flag = true;
		for(int i=0;i<maxn;i++)
			pre[i] = i,val[i] = 0;
		
		for(int i=0;i<m;i++)
		{
			scanf("%d%d%lld",&L,&R,&D);
			if(!flag) continue;
			if(!link(L,R,D)) flag = false;
		}
		//for(int i=1;i<=n;i++)
		//	cout<<val[i]<<" ";cout<<endl;
		for(int i=1;flag&&i<=n;i++)
			if(val[i]>1e9) flag = false;
		if(flag) printf("Yes\n");
		else printf("No\n");
	
	
	}


        

	return 0;
}

Measured memory_bytes: 2560
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    H, N = map(int,input().split())
    M = [list(map(int,input().split())) for k in range(N)]

    dp = [10**9 for k in range(10**4+1)]
    dp[0] = 0
    for e in M:
        A, B = e[0], e[1]
        for k in range(A+1):
            dp[k] = min(dp[k],B)
        for k in range(A+1,H+1):
            dp[k] = min(dp[k],dp[k-A]+B)

    print(dp[H])

if __name__ == '__main__':
    main()


Measured memory_bytes: 40944
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int a[2000010];
int main()
{
	int n,m;
	scanf("%d %d", &n,&m);
	for (int i = 0; i < n; i++)
	{
		int q;
		scanf("%d", &q);
		a[q]++;
	}
	sort(a, a + n+1);
	int dap = 0;
	for (int i = n - m; i >= 1; i--)
		dap += a[i];
	printf("%d", dap);
}

Measured memory_bytes: 896
#! /usr/bin/python3
# Factors of Factorial

"""
1≦N≦103
"""

import math
import collections
# import sympy

test = False

N = int(input())


def prime_factors(n):
    """
    自然数 n の素因数のリスト
    """
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            # n = n // i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def yakusu_no_kosu(n):
    """
    n! の約数の個数
    """

    l = prime_factors(math.factorial(n))
    c = collections.Counter(l)
    l_c = list(c.values())
    if test:
        print('l =', l)
        print('c =', c)
        print('l_c =', l_c)


    kosu = 1
    # 約数の数
    for v in l_c:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出

    """
    d = sympy.factorint(math.factorial(n))
    # n!を素因数分解 {素因数1: 個数, 素因数2: 個数, …}
    l_d = list(d.values())
    # 各素因数(key)の個数(value)のみリストにする

    if test:
        print('l_d =', l_d)

    kosu = 1
    # 約数の数

    for v in l_d:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出
    """

    return kosu


def main():
    """
    N! の約数の個数を 10^9+7 で割った余りを出力
    """
    print(yakusu_no_kosu(N) % (10**9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int id;
  int depth;
  int height;
  int deg;
};
typedef struct node *NodePointer;

void findDepth(NodePointer, int);
int findHeight(NodePointer);
void findDegree(NodePointer);
void nodeJudge(NodePointer);

int main(){
  int n, id, left_id, right_id, i, j;
  NodePointer T;

  scanf("%d",&n);
  T = (NodePointer)malloc( n * sizeof( struct node ) );
  for(i = 0; i < n; i++){
    T[i].parent = NULL;
    T[i].deg = 0;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id, &left_id, &right_id);
    T[id].id = id;
    if( left_id == -1 ) T[id].left = NULL;
    else{
      T[id].left = &T[left_id];
      T[id].left->parent = &T[id];
    }
    if( right_id == -1 ) T[id].right = NULL;
    else{
      T[id].right = &T[right_id];
      T[id].right->parent = &T[id];
    }
  }

  for(i = 0; i < n; i++){
    if( T[i].parent == NULL ){
      findDepth(&T[i], 0);
      break;
    }
  }

  for(i = 0; i < n; i++){
    T[i].height = findHeight(&T[i]);
    findDegree(&T[i]);
  }

  // Output
  for(i = 0; i < n; i++){    
    printf("node %d: ",T[i].id);
    if( T[i].parent == NULL ) printf("parent = -1, ");
    else printf("parent = %d, ",T[i].parent->id);
    printf("sibling = ");
    if( T[i].parent != NULL &&
	(T[i].parent->left != NULL && T[i].parent->right != NULL) ){
      if( T[i].parent->left != &T[i] ) printf("%d, ",T[i].parent->left->id);
      else printf("%d, ",T[i].parent->right->id);
    }
    else printf("-1, ");
    printf("degree = %d, ",T[i].deg);
    printf("depth = %d, ",T[i].depth);
    printf("height = %d, ",T[i].height);
    nodeJudge(&T[i]);
  }

  free(T);
  return 0;
}

void findDepth(NodePointer x, int depth){
  x->depth = depth;
  if( x->left != NULL ) findDepth( x->left, depth+1);
  if( x->right != NULL ) findDepth( x->right, depth+1);
}

int findHeight(NodePointer x){
  int h1=0, h2=0;
  if( x->left != NULL ) h1 = findHeight(x->left)+1;
  if( x->right != NULL ) h2 = findHeight(x->right)+1;
  return h1 > h2 ? h1 : h2;
}

void findDegree(NodePointer x){
  if( x->left != NULL ) x->deg++;
  if( x->right != NULL ) x-> deg++;
}

void nodeJudge(NodePointer x){
  if( x->parent == NULL ) printf("root\n");
  else if( x->left == NULL && x->right == NULL ) printf("leaf\n");
  else printf("internal node\n");
}



Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;

struct Node {
  int v; ll w;
};
ll d[100005];
vector<Node> m[100005];
int N;

int main(void) {
    scanf("%d", &N);
    
    rep(i, 0, N) {
      int u, v;
      ll w;
      scanf("%d %d %lld", &u, &v, &w);
      Node n = {v, w};
      Node n2 = {u, w};
      m[u].push_back(n);
      m[v].push_back(n2);
    }

    rep(i, 1, N+1) {
      d[i] = -1LL;
    }

    queue<int> q;
    q.push(1);
    d[1] = 0;
    while(!q.empty()) {
      int u = q.front(); q.pop();
      for (int i = 0; i < m[u].size(); i++) {
        int v = m[u][i].v;
        if (d[v] == -1) {
          q.push(v);
          d[v] = d[u]+m[u][i].w;
        
        }
      
      }
    
    
    }
    
    rep(i, 1, N+1) {
      if (d[i]%2==0) puts("0");
      else puts("1");
    
    }
	return 0;
}


Measured memory_bytes: 8704