akhauriyash/Code-Regression huggingface dataset:
N, M  = map(int, input().split())
a  = {}
for _ in range(M):
  a[int(input())] = 1
sdic  = {}
nn1 = 1
nn2 = 0
for n in reversed(range(N)):
  if n in a:
    nn2 = nn1
    nn1 = 0
    continue
  t = nn1 + nn2
  if t == 0:
    print(0)
    quit()
  nn2 = nn1
  nn1 = t
  
print(nn1%1000000007)


Measured memory_bytes: 15068
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    map<string,int> mp;
    int n,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++){
        string tmp;
        cin>>tmp;
        if(mp.count(tmp)) {
            mp[tmp]++;
            cnt=max(cnt,mp[tmp]);
        }
        else {
            mp[tmp]=1;
            cnt=max(cnt,mp[tmp]);
        }
    }
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second==cnt) cout<<itr->first<<endl;
    }
    return 0;
}


Measured memory_bytes: 25216
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

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

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int x, y;
  cin >> x >> y;
  for(int i = 0; i <= x; i++)
  {
    int reg = 2 * i + 4 * (x - i);
    if (reg == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3588
from math import factorial
import sys

sys.setrecursionlimit(2000)
mod = 10**9+7
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  if n < k:
    return 0
  if n / 2 < k:
    k = n - k
  if n in memo and k in memo[n]:
    return memo[n][k]
  v = 0
  if k == 0:
    v = 1
  elif k == 1:
    v = n
  else:
    v = combination(n-1,k) + combination(n-1,k-1)
  return memo.setdefault(n, {}).setdefault(k, v)

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%mod)


Measured memory_bytes: 217588
h, w= map(int, raw_input().split())
n = int(raw_input())
ais = map(int, raw_input().split())
mat = [[-1 for _ in range(w)] for ii in range(h)]
import collections
color = 0
vis = set([])
def bfs(start, color, count,mat):
	q = collections.deque([start])
	vis = set([start])
	while(q and count):
		count -=1
		cur = q.popleft()
		mat[cur[0]][cur[1]] = color + 1
		i,j = cur
		for ni,nj in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:
			if 0 <= ni < len(mat) and 0<= nj < len(mat[0]):
				if (ni,nj) not in vis:
					vis.add((ni,nj))
					q.append((ni,nj))

for i in range(len(mat)):
	for j in range(len(mat[0]))[::(-1 if i % 2 else 1)]:
		mat[i][j] = color +1
		ais[color] -= 1
		if ais[color] == 0: color +=1
for l in mat:
	print ' '.join(map(str,l))

Measured memory_bytes: 73944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define debug(x) #x << "=" << (x)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    int a, b;
    vector<P> v;
    REP(i, M) {
        cin >> a >> b;
        v.push_back({b, a});
    }

    sort(v.begin(), v.end());

    int ans = 0;
    int current = 0;
    for (P t : v) {
        if (t.second >= current) {
            current = t.first;
            ans++;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const ll mod = 1e9+7;

// combination c;
// c(n, k); => nCk
struct combination {
    const int max = 5100000;
    vector<long long> fact, ifact, inv;
    combination() {
        fact.resize(max);   // i!
        ifact.resize(max);  // (i!)^(mod-2)
        inv.resize(max);    // i^(mod-2)
        fact[0] = fact[1] = 1;
        ifact[0] = ifact[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < max; i++) {
            fact[i] = fact[i-1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod/i) % mod;
            ifact[i] = ifact[i-1] * inv[i] % mod;
        }
    }

    long long operator()(int n, int k) {
        if (n < k) return 0;
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]%mod*ifact[n-k]%mod;
    }
};

int main() {
    int x, y; cin >> x >> y;

    if ((2*y-x)%3 == 0) {
        int b = (2*y-x)/3, a = y-2*b;
        combination c;
        cout << c(a+b,a) << endl;
    } else {
        cout << 0 << endl;
    }
    
    return 0;
}

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



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

    vector <long long> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    string Ans = "Yes";

    for(int i = N-2; i >= 0 ; i--){
        if(H.at(i) > H.at(i+1)) H.at(i)--;
    }

    for(int i = 0; i < N-1; i++){
        if(H.at(i) > H.at(i+1)){
            Ans = "No";
            break;
        }
    }

    cout << Ans << endl;
}

Measured memory_bytes: 1024
def solve():
   N = int(input())
   table = [False] *1000000
   table[N] = True
   count = 1
   while True:
       if N&1:
           N = 3*N + 1
       else:
           N = N//2
       count += 1
       if not table[N]:
           table[N] = True
       else:
           print(count)
           break

if __name__ == '__main__':
    solve()

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

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

  vector<int> Nums(N+3);
  rep(i,N) cin >> Nums.at(i);

  ll money = 1000;
  ll stocks = 0;

  rep(i,N-1){
    if(Nums.at(i) < Nums.at(i+1)){
      stocks = money / Nums.at(i);
      money += (Nums.at(i+1)-Nums.at(i)) * stocks;
    }
  }

  cout << money << endl;
}


Measured memory_bytes: 3624
//:::: Alien :::://
// Muhammad Eid //
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define prINT pair<int, int>

void Mo35(){ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
Mo35();

    int n, f = 0, s = 0;
    for(int i=0; i<3; ++i){
        cin>> n;
        if(n == 5) f++; else s++;
    }
    if(f == 2 && s == 1) cout<< "YES"; else cout<< "NO";

return 0;
}


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

long long int N, L, i, A[100002], P[100002], m, j;
long long int* B = P + 1;
vector<pair<long long int, long long int> > a;

int main(){
    scanf("%lld%lld", &N, &L);
    for(; i < N; ++i){
        scanf("%lld", A + i);
        a.push_back(make_pair(A[i], i));
    }
    sort(a.begin(), a.end(), greater<pair<long long int, long long int> >());
    for(i = 0; i < N; ++i){
        j = a[i].second;
        B[j] = max(B[j - 1], B[j + 1]) + L - A[j];
        m = max(m, B[j]);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 6072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

// youtube editorial
void solve() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;

  vector<int> v;
  rep(i, sz(s)) {
    if (s[i] == 'o') {
      v.eb(i);
      i += c;
    }
  }
  if (sz(v) != k) {
    return;
  }
  vector<int> v2;
  for (int i = sz(s) - 1; i >= 0; --i) {
    if (s[i] == 'o') {
      v2.eb(i);
      i -= c;
    }
  }
  reverse(all(v2));
  // cout << v << endl << v2 << endl;
  rep(i, sz(s)) {
    // そのマスに置かない
    if (s[i] == 'o') {
      int it = lb(v, i);
      it--;
      int it2 = ub(v2, i);
      int sum = 0;
      sum += it + 1;
      sum += sz(v2) - it2;
      // cout << sum << endl;
      if (it >= 0 && it2 != sz(v2) && v[it] + c >= v2[it2]) sum--;
      // cout << i << " " << it << " " << it2 << " " << sum << endl;
      if (sum < k) cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3468
#include <cstdio>
using namespace std;

int main () {

    int N, K;
    scanf("%d %d", &N, &K);

    int h[N];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
        if (h[i] >= K) {
            ans++;
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

int main(){
  int S;
  int h,m,s;
  cin >> S;
  h = S / (60 * 60);
  m = (S % (60 * 60)) / 60;
  s = S % 60;

  cout << h << ":" << m << ":" << s << endl;
  return 0;
}



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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif


//a>b return true
bool diffStr(string a,string b){
	if(a.size()>b.size())return true;
	if(b.size()>a.size())return false;

	return (a>b);
}


int main(){
	int w,h;
	while(cin>>w>>h){
		if(w==0 && h==0)break;

		char data[100][100];
		rep(i,h){
			rep(j,w){
				cin>>data[i][j];
			}
		}

		string dp[100][100];
		for(int i=h-1;i>=0;i--){
			for(int j=w-1;j>=0;j--){
				if( isalpha(data[i][j]) )dp[i][j]="";
				else{
					string r="",u="";

					if( i+1<h && j+1<w ){
						r=string(1,data[i][j])+dp[i+1][j];
						u=string(1,data[i][j])+dp[i][j+1];

						if( diffStr(r,u) )	dp[i][j]=r;
						else		dp[i][j]=u;

					}else if( i+1<h ){
						r=string(1,data[i][j])+dp[i+1][j];
						dp[i][j]=r;

					}else if( j+1<w ){
						u=string(1,data[i][j])+dp[i][j+1];
						dp[i][j]=u;

					}else{
						dp[i][j]=data[i][j];
					}
				}
			}
		}
		string ans="0";
		rep(i,h){
			rep(j,w){
				if(dp[i][j][0]=='0'){
					int c=0;
					rep(k,dp[i][j].size()){
						if( dp[i][j][k]=='0' ){
							c++;
						}
						else{
							break;
						}
					}
					dp[i][j]=dp[i][j].substr(c,dp[i][j].size()-c);
				}
				if( diffStr(dp[i][j],ans) )ans=dp[i][j];
			}
		}
		cout<<ans<<endl;
	}
}

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

int prime(int i);

int main() {
    int i;
    int N;
    cin >> N;
    int count = 0;
    for(i = 2; i < 55555; i++){
        if(prime(i) && i % 5 == 2){
            printf("%d ", i);
            count++;
        }
        if(count == N){
            break;
        }
    }
}

int prime(int i){
    int ans = 1;
    int j;
    for(j = 2; j <= sqrt(i); j++){
        if(i % j == 0){
            ans = 0;
        }
    }
    return ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

int n, m, k, v[N], l[N], r[N];
string a;
int main()
{
	int i, j;
	cin >> n >> m >> k;
	cin >> a;
	for (i = 0, j = 0; i < n && j < m; ) {
		if (a[i] == 'o') {
			l[j] = i;
			v[i]++;
			j++;
			i += k + 1;
		} else i++;
	}
	if (j < m) {
		return 0;
	}
	for (i = n - 1, j = 0; i >= 0 && j < m; ) {
		if (a[i] == 'o') {
			r[m - j - 1] = i;
			v[i]++;
			j++;
			i -= (k + 1);
		} else i--;
	}
	for (i = 0; i < m; i++) if (l[i] == r[i]) printf("%d\n", l[i] + 1);
//	for (i = 0; i <n; i++) if (v[i] == 2) printf("%d\n", i + 1);
    return 0;
}


Measured memory_bytes: 4228
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;
int main(){
  ll k,cnt=0,n=50;
  ll a[n];
  cin >> k;
  if(k==0){
    cout << "4\n3 3 3 3\n";
    return 0;
  }
  cout << n<<endl;
  for(int i=0;i<n;i++){
    a[i]=i;
  }
  for(int i=0;i<n;i++){
    a[i]+=k/n;
  }
  for(int i=0;i<n;i++){
    if(i<k%n) a[i]+=n-(k%n-1);
    else a[i]-=(k%n);
  }
  for(int i=0;i<n;i++){
    cout << a[i] << " ";
  }
  cout <<"\n";
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = []
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)
l = []
for f in range(2**n):
    p = [0]*(m+1)
    for i in range(n):
        if (bin(f >> i)[-1] == '1'):
            for j in range(m+1):
                p[j] += a[i][j]
    if min(p[1:]) >= x:
        l.append(p[0])
if len(l) == 0:
    print('-1')
else:
    print(min(l))

Measured memory_bytes: 68936
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        int[] gcd_left = new int[N];
        int[] gcd_right = new int[N];
        gcd_left[0] = A[0];
        gcd_right[N-1] = A[N-1];
        for(int i = 0; i < N-1; i++){
            gcd_left[i+1] = gcd(gcd_left[i],A[i+1]);
            gcd_right[N-2-i] = gcd(gcd_right[N-1-i],A[N-2-i]);
        }
        
        int max_gcd = 1;
        int tmp_left = 0;
        int tmp_right = 0;
        if(N>2){
            if(max_gcd < gcd_right[1]){
                max_gcd = gcd_right[1];}
            if(max_gcd < gcd_left[N-2]){
                max_gcd = gcd_left[N-2];}
            for(int i = 0; i < N-2; i++){
                tmp_left = gcd_left[i];
                tmp_right = gcd_right[i+2];
                int tmp = gcd(tmp_left,tmp_right);
                if(tmp > max_gcd){
                    max_gcd = tmp;}
            }
        } else{
            max_gcd = Math.max(A[0],A[1]);
        }
        System.out.println(max_gcd);
        
 
    }
    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
}

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

using namespace std;
ll dp[105][100005];

ll solve(int n,int w,int wa[],ll val[]){
	if(n==0||w==0)
		return 0;
	if(dp[n][w]!=0)
		return dp[n][w] ;
	ll op1 ;
	op1 =  0;
	if(w-wa[n]>=0)
		op1 = val[n]+solve(n-1,w-wa[n],wa,val);
	ll op2 = solve(n-1,w,wa,val);

	dp[n][w] = max(op1,op2);
	//cout<<dp[n];
	return dp[n][w];
		
}

int main(){

/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
int n,w;
cin>>n>>w;
int wa[n+1];
ll val[n+1];
for(int i=1;i<=n;i++){
	cin>>wa[i]>>val[i];
}
memset(dp,0,sizeof(dp));
cout<<solve(n,w,wa,val);
}
		

Measured memory_bytes: 82304
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

int N;
ll x[100000], y[100000];
char d[100000];

ll L(ll t){
	ll ret = LLONG_MAX;
	rep(i, N){
		if(d[i] == 'L') ret = min(ret, x[i]-t);
		else if(d[i] == 'R') ret = min(ret, x[i]+t);
		else ret = min(ret, x[i]);
	}
	return ret;
}

ll R(ll t){
	ll ret = LLONG_MIN;
	rep(i, N){
		if(d[i] == 'L') ret = max(ret, x[i]-t);
		else if(d[i] == 'R') ret = max(ret, x[i]+t);
		else ret = max(ret, x[i]);
	}
	return ret;
}

ll U(ll t){
	ll ret = LLONG_MAX;
	rep(i, N){
		if(d[i] == 'U') ret = min(ret, y[i]+t);
		else if(d[i] == 'D') ret = min(ret, y[i]-t);
		else ret = min(ret, y[i]);
	}
	return ret;
}

ll D(ll t){
	ll ret = LLONG_MIN;
	rep(i, N){
		if(d[i] == 'U') ret = max(ret, y[i]+t);
		else if(d[i] == 'D') ret = max(ret, y[i]-t);
		else ret = max(ret, y[i]);
	}
	return ret;
}

ll l, r;
ll a[9];

signed main() {
	cin >> N;
	rep(i, N){
		cin >> x[i] >> y[i] >> d[i];
		x[i] *= 2;
		y[i] *= 2;
	}

	//L
	l = 0; r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(L(m)-L(0) == m) l = m;
		else r = m;
	}
	a[0] = l;
	r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(L(m)-L(a[0]) == 0) l = m;
		else r = m;
	}
	a[1] = l;
	//R
	l = 0; r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(R(m)-R(0) == -m) l = m;
		else r = m;
	}
	a[2] = l;
	r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(R(m)-R(a[2]) == 0) l = m;
		else r = m;
	}
	a[3] = l;
	//U
	l = 0; r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(U(m)-U(0) == m) l = m;
		else r = m;
	}
	a[4] = l;
	r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(U(m)-U(a[4]) == 0) l = m;
		else r = m;
	}
	a[5] = l;
	//D
	l = 0; r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(D(m)-D(0) == -m) l = m;
		else r = m;
	}
	a[6] = l;
	r = 1000000000;
	while(r-l > 1){
		ll m = (l+r)/2;
		if(D(m)-D(a[6]) == 0) l = m;
		else r = m;
	}
	a[7] = l;

	ll ans = LLONG_MAX;
	a[8] = 0;
	rep(i, 9){
		ans = min(ans, (R(a[i])-L(a[i]))*(D(a[i])-U(a[i])));
	}
	cout << setprecision(32) << ans / 4.0 << endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[100005],i,ans;
	unsigned long long sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	sort(a,a+n);
	sum=0;
	ans=0;
	for(i=0;i<n;i++)
	{
		if(a[i]<=2*sum)
		{
			sum+=a[i];
			ans++;
		}
		else
		{
			sum+=a[i];
			ans=1;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  ll vec[n];
  ll sum[n+1];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  map<ll,ll> ma;
  sum[0]=0;
  ma[sum[0]]++;
  for(int i=0;i<n;i++){
    sum[i+1]=sum[i]+vec[i];
    ma[sum[i+1]]++;
  }
  ll ans;
  for(int i=0;i<n;i++){
    ans+=(ma[sum[i]]*(ma[sum[i]]-1))/2;
    ma[sum[i]]=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,k;
    cin >> n >> k;

    if(k == 1){
        cout << 0 << endl;
    }else{
        cout << n - k << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	int N,K;
	cin >> N >> K;
	int d=1;
	while(N/K>0) {
		N/=K;
		d++;
	}

	cout << d << endl;
	return 0;
}




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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

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

	int ma = 0;
	int maNum = 0;
	for (int i = 0; i < n; i++) {
		if (ma < l[i]) {
			ma = l[i];
			maNum = i;
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (maNum != i) {
			sum += l[i];
		}
	}

	if (ma < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100100;
int n;
ll a[N][3];
pli b[N];
bool used[N];
ll X;
ll S;

bool solve(ll H) {
	int k = H / X;
	H %= X;
	for (int i = 0; i < n; i++)
		used[i] = false;
	ll cur = S;
	for (int i = 0; i < k; i++) {
		used[b[i].second] = true;
		cur -= b[i].first;
	}
	if (cur <= 0) return true;
	if (H == 0) return false;
	for (int i = 0; i < n; i++) {
		ll nw = cur;
		if (used[i]) {
			nw += a[i][2] * (X - a[i][0]) + a[i][1] * a[i][0];
			nw -= b[k].first;
		}
		nw -= a[i][0] * a[i][1];
		if (H < a[i][0]) {
			nw -= (H - a[i][0]) * a[i][1];
		} else {
			nw -= (H - a[i][0]) * a[i][2];
		}
		if (nw <= 0) return true;
	}
	return false;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%lld", &n, &X);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++)
			scanf("%lld", &a[i][j]);
		S += a[i][0] * a[i][1];
		b[i].first = a[i][2] * (X - a[i][0]) + a[i][1] * a[i][0];
		b[i].second = i;
	}
	sort(b, b + n);
	reverse(b, b + n);
	ll l = -1, r = n * X;
	while(r - l > 1) {
		ll x = (l + r) / 2;
		if (solve(x))
			r = x;
		else
			l = x;
	}
	printf("%lld\n", r);

	return 0;
}


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

int main()
{
	int n;
	cin>>n;
	vector<int> v(n);
	for (int i=0; i<n; i++)
		cin>>v[i];
	sort(v.begin(),v.end(),greater<int>());
	long long ans=v[0];
	long long m=n-2;
	for (int i=0; i<m; i++)
	   ans+=v[i/2+1];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4052
s =  "0" + input()
n = len(s) - 1 
if s[1] != "1" or s[n] != "0":
  print(-1)
  exit()
for i in range(1,n//2):
  if s[i] != s[n-i]:
    print(-1)
    exit()
q = [1]
for i in range(2,n):
  if s[i] == "1":
    for x in q:
      print(x,i)
    q = [i]
  else:
    q.append(i)
for x in q:
  print(x,n)

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

class BIT{
	vector<int> bit;
	public:
	BIT(int siz) : bit(siz + 1,0){}
	void add(int i,int x){
		while(i < bit.size()){
			bit[i] += x;
			i += i & -i;
		}
	}
	int sum(int i){
		int s = 0;
		while(i){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

int main(){
	int n,m;
	vector<int> vec[100001];
	cin >> n >> m;
	BIT bit(m);
	for(int i = 0;i < n;i++){
		int l,r;
		cin >> l >> r;
		vec[r - l].push_back(l);
	}
	int ans = n;
	for(int i = 0;i < m;i++){
		int add = 0;
		for(int j = i + 1;j <= m;j += i + 1) add += bit.sum(j);
		cout << ans + add << endl;
		for(int l : vec[i]){
			ans--;
			bit.add(l,1);
			bit.add(l + i + 1,-1);
		}
	}
	return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define all(v) v.begin(),v.end()
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
void solve()
{
    int n,m,i; cin>>n>>m;
    double k,sum=0;
	vector<int>v(n);
	for(i=0;i<n;i++) cin>>v[i],sum+=v[i];
	k=sum/(m*4);
	bool ok=true;
	sort(v.begin(),v.end());
	for(i=0;i<m;i++)
	{
		if(v[n-1-i]<k)
		{ok=false;break;}
	}
	if(ok) cout<<"Yes"<<lc;
	else cout<<"No"<<lc;
}
int main() 
{
    fastio
    int t=1; //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3608
# -*- coding:utf-8 -*-

N = int(input())
h = list(map(int, input().split()))

dp = [float("inf")]*N
dp[0] = 0
for i in range(1, N):
    cost1 = abs(h[i] - h[i-1])
    dp[i] = min(dp[i], dp[i-1] + cost1)
    if i > 1:
        cost2 = abs(h[i] - h[i - 2])
        dp[i] = min(dp[i], dp[i-2] + cost2)

print(dp[-1])






Measured memory_bytes: 13980
program main
  implicit none
  integer :: n, m
  read *, n
  m = modulo(n, 10)
  if (m == 3) then
    print "(a)", "bon"
  else if ((m == 0 .or. m == 1) .or. (m == 6 .or. m == 8)) then
    print "(a)", "pon"
  else
    print "(a)", "hon"
  end if
end program main


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

using namespace std;

const int mod = 1e9 + 7;
const int N = 2e5 + 3;

int n, sz[N], dp[N], ans[N];
int fact[N], inv_fact[N];
vector <int> g[N];

int bin_pow(int a, int n) {
    int ret = 1;
    while (n) {
        if (n & 1)
            ret = (ret * 1ll * a) % mod;
        a = (a * 1ll * a) % mod;
        n >>= 1;
    }
    return ret;
}

int C(int n, int k) {
    int ret = fact[n];
    ret = (ret *1ll* inv_fact[k]) % mod;
    ret = (ret *1ll* inv_fact[n - k]) % mod;
    return ret;
}

void dfs(int v, int pr = -1) {
    dp[v] = 1;
    for (int to : g[v]) {
        if (to == pr) continue;
        dfs(to, v);
        sz[v] += sz[to];
        int ret = (C(sz[v], sz[to]) * 1ll * dp[to]) % mod;
        dp[v] = (dp[v] * 1ll * ret) % mod;
    }
    sz[v] ++;
}

void dfs2(int v, int pr = -1, int up = 1) {
    ans[v] = (C(n - 1, n - sz[v]) * 1ll * up) % mod;
    ans[v] = (dp[v] * 1ll * ans[v]) % mod;
    int all = n - sz[v];
    for (int to : g[v]) {
        if (to == pr) continue;
        all += sz[to];
        int ret = (C(all, sz[to]) * 1ll * dp[to]) % mod;
        up = (up * 1ll * ret) % mod;
    }
    for (int to : g[v]) {
        if (to == pr) continue;
        int ret = (C(all, sz[to]) * 1ll * dp[to]) % mod;
        ret = bin_pow(ret, mod - 2);
        dfs2(to, v, (up * 1ll * ret) % mod);
    }
}

int main() {
    fact[0] = 1;
    inv_fact[0] = 1;
    for (int i = 1; i < N; i++) {
        fact[i] = (fact[i - 1] * 1ll * i) % mod;
        inv_fact[i] = bin_pow(fact[i], mod - 2);
    }

    cin >> n;

    for (int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }

    dfs(1);
    dfs2(1);

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 17780
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;//sum
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

int n;
int bs(int M,int f,int s){
	if(f==0){
		//左側
		if(segcalc(0,M).a<s)return -1;
		int l=0,r=M;
		while(r-l>1){
			int m=(l+r)/2;
			if(segcalc(m,M).a<s)r=m;
			else l=m;
		}
		return l;
	}else{
		//右側
		if(segcalc(M,n).a<s)return n;
		int l=M,r=n;
		while(r-l>1){
			int m=(l+r)/2;
			if(segcalc(M,m).a<s)l=m;
			else r=m;
		}
		return r-1;
	}
}

int a[100010];
int main(){
	scanf("%d",&n);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		a[t]=i;
	}
	//数tがいる位置はa[t]
	seguse(1<<17);
	ll ans=0;
	for(int i=n;i>=1;i--){
		ll m=a[i];
		ll l1=bs(m,0,1);
		ll l2=bs(m,0,2);
		ll r1=bs(m,1,1);
		ll r2=bs(m,1,2);
		ll cnt=(l1-l2)*(r1-m)+(m-l1)*(r2-r1);
		ans+=cnt*i;
//		printf("%d %d %d %d %d\n",l2,l1,m,r1,r2);
//		printf("%d %d\n",(l1-l2)*(r1-m),(m-l1)*(r2-r1));
		atai x={1};
		segupdate(m,x);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int a, b;
	cin >> a >> b;

	cout << (a*3 + b)/2 << endl;


}

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

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
cout << fixed << setprecision(16);
  ll n;
  string s;
  cin>>n>>s;
  if(n%2!=0)putout("No");
  else{
    vector<char> c(n);
    loop(i,n){
      c[i]=s[i];
    }
    bool z=true;
    loop(i,n/2){
      if(c[i]!=c[i+(n/2)])z=false;
    }
      if(z)putout("Yes");
    else putout("No");
  }

}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, elements):
        self.elements = elements

    def same(self, a, b):
        return self.find(a) == self.find(b)

    def find(self, a):
        parent = self.elements[a]
        if parent < 0:
            return a
        self.elements[a] = self.find(parent)
        return self.elements[a]

    def unite(self, a, b):
        a_parent = self.find(a)
        b_parent = self.find(b)

        # already same union
        if a_parent == b_parent:
            return

        self.elements[a_parent] += self.elements[b_parent]
        self.elements[b_parent] = a_parent


N, K, L = map(int, input().split())
road_union = UnionFind([-1 for i in range(N)])
for _ in range(K):
    a, b = map(int, input().split())
    road_union.unite(a - 1, b - 1)

train_union = UnionFind([-1 for i in range(N)])
for _ in range(L):
    a, b = map(int, input().split())
    train_union.unite(a - 1, b - 1)

ma = dict()
for i in range(N):
    p = (road_union.find(i), train_union.find(i))
    ma[p] = ma.get(p, 0) + 1

for i in range(N):
    p = (road_union.find(i), train_union.find(i))
    print(ma[p], end=' ')


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vec h(n + 1);
    For(i, 1, n) cin >> h[i];

    mat<int> g = mmat<int>(n + 1);
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }

    int ans = 0;
    For(i, 1, n) {
        int self = h[i];
        bool ok = true;
        repall (e, g[i]) {
            if (self <= h[e]) ok = false;
        }
        if (ok) ans++;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 9796
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	a(x,3,x)
	for t in r(i,i+30):b(p:=t+30);a(q:=p+1,3,q),*map(b,r(q,v:=i+60));a(v,x,t,1);b(p);a(q,t,q)
p(3934)
a(0,1,3)
a(2,3,3,1)
d(0,9)
d(1,50)
for t in r(60):a(2,2,2);[t-31<s<30!=(a(8+t-s,50+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String	strIn = parseStdin();
		if (strIn != null) {
			int cnt = Integer.parseInt(strIn);
			for (int n = 0; n < cnt; n++) {
				byte[][]	map = solve();
				System.out.println("Data " + (n + 1) + ":");
				for (int i = 0; i < 8; i++) {
					for (int j = 0; j < 8; j++) {
						System.out.print(map[i][j]);
					}
					System.out.println("");
				}
			}
		}
	}

	private static byte[][] solve() {
		byte[][]	map = new byte[8][8];

		parseStdin();
		for (int n = 0; n < 8; n++) {
			int	m = 0;
			for (char c : parseStdin().toCharArray()) {
				map[n][m++] = (byte)(c - '0');
			}
		}

		int[]	oPos  = { Integer.parseInt(parseStdin()) - 1, Integer.parseInt(parseStdin()) - 1 };
		if (clear(map, oPos[0], oPos[1]) == (byte)1) {
			bomb(map, oPos);
		}

		return map;
	}

	private static void bomb(byte[][] map, int[] oPos) {
		bombCore(map, oPos, 0);
		bombCore(map, oPos, 1);
		bombCore(map, oPos, 2);
		bombCore(map, oPos, 3);
	}

	private static void bombCore(byte[][] map, int[] oPos, int dir) {
		int[] nPos = new int[2]; 
		for (int n = 1; n <= 3; n++) {
			switch (dir) {
			case 0:
				nPos[0] = oPos[0];
				nPos[1] = oPos[1] - n;
				break;
			case 1:
				nPos[0] = oPos[0];
				nPos[1] = oPos[1] + n;
				break;
			case 2:
				nPos[0] = oPos[0] - n;
				nPos[1] = oPos[1];
				break;
			case 3:
				nPos[0] = oPos[0] + n;
				nPos[1] = oPos[1];
				break;
			}

			if (clear(map, nPos[0], nPos[1]) == (byte)1) {
				bomb(map, nPos);
			}
		}
	}

	private static byte clear(byte[][] map, int x, int y) {
		byte	ret = -1;

		if (0 <= y && y < map.length && 0 <= x && x < map[0].length) {
			ret       = map[y][x];
			map[y][x] = 0;
		}

		return ret;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16944
s=list(input())
t=list(input())
l=[0]*(len(s)+1)
for i in range(len(t)+1):
    old=l.copy()
    for j in range(len(s)+1):
        if i==0 or j==0:
            l[j]=max(i,j)
        else:
            c=0 if s[j-1]==t[i-1] else 1
            l[j]=min(l[j-1]+1,old[j]+1,old[j-1]+c)
print(l[len(s)])


Measured memory_bytes: 5600
N = int(input())
S = []

for k in range(N):
    a = input()
    S.append(a)

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
    if S[i] == 'AC':
        ac += 1
    if S[i] == 'WA':
        wa += 1
    if S[i] == 'TLE':
        tle += 1
    if S[i] == 'RE':
        re += 1
        
print("AC x " ,ac)
print("WA x " ,wa)
print("TLE x " ,tle)
print("RE x " ,re)

Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
string s;


bool search2(string t,int i){
  if(t[i]=='S'){
    if(s[i]=='o'&&t[(n+i-1)%n]==t[(i+1)%n]) return false;
    if(s[i]=='x'&&t[(n+i-1)%n]!=t[(i+1)%n]) return false;
  }
  if(t[i]=='W'){
    if(s[i]=='x'&&t[(n+i-1)%n]==t[(i+1)%n]) return false;
    if(s[i]=='o'&&t[(n+i-1)%n]!=t[(i+1)%n]) return false;
  }

  return true;
}

bool search(string t){

  rep(i,n){
    if(search2(t,i)) return false;
  }

  
  return true;
}

bool f(string u){


  for(int i=2;i<n;i++){
    if(s[i-1]=='o'){
      if(u[i-1]=='S')
        u.push_back(u[i-2]);
      if(u[i-1]=='W')
        u.push_back(u[i-2]=='W'?'S':'W');
    }
    if(s[i-1]=='x'){
      if(u[i-1]=='S')
        u.push_back(u[i-2]=='W'?'S':'W');
      if(u[i-1]=='W')
        u.push_back(u[i-2]);
    }
  }

  if(search(u)){
    cout<<u<<endl;
    return false;
  }

  return true;
}


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

  if(f("SS")&&f("SW")&&f("WS")&&f("WW"))
    cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

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

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool f = false;
    while (a > 0 && c > 0){
        c -= b;
        if (c <= 0) f = true;
        a -= d;
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3616
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define INF INT_MAX/3

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

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 100
#define MAX_T 100
#define LOSE 1
#define BACK -1

struct dataset {
  int board[MAX_N];
  int n;
  int t;
};

int load(dataset* ds) {
  int n, t, l, b;
  scanf("%d %d %d %d", &n, &t, &l, &b);
  if( !(n or t or l or b) ) return 0;
  ds->n = n;
  ds->t = t;
  memset(ds->board, 0, n*sizeof(int));

  REP(i, l) {
    int k;
    scanf("%d", &k);
    ds->board[k] = LOSE;
  }

  REP(i, b) {
    int k;
    scanf("%d", &k);
    ds->board[k] = BACK;
  }
  return 1;
}

void solve(dataset* ds, double dp[MAX_T+1][MAX_N+1]) {
  memset(dp, 0, (MAX_T+1)*(MAX_N+1)*sizeof(double));
  dp[0][ds->n] = 1;

  FOR(i, 1, 1+ds->t) REP(j, 1+ds->n) {
    if( j == ds->n ) {
      dp[i][j] = 1;
      continue;
    }

    switch( ds->board[j] ) {

    case LOSE:
      if( i < 2 ) {
        dp[i][j] = 0;
        break;
      }
      FOR(m, 1, 7) {
        int p = j+m;
        if( p > ds->n ) p = 2*ds->n - p;
        dp[i][j] += dp[i-2][p]/6;
      }
      break;

    case BACK:
      dp[i][j] = dp[i][0];
      break;

    default:
      FOR(m, 1, 7) {
        int p = j+m;
        if( p > ds->n ) p = 2*ds->n - p;
        dp[i][j] += dp[i-1][p]/6;
      }
      break;

    }
  }
  printf("%lf\n", dp[ds->t][0]);
}

int main() {
  dataset ds;
  double dp[MAX_T+1][MAX_N+1];
  while( load(&ds) ) solve(&ds, dp);

  return 0;
}

Measured memory_bytes: 1300
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <numeric>
#include <cstring>

using namespace std;

#define ll          long long
#define VI          vector<int>
#define ALL(a)      (a).begin(), (a).end()
#define SORT(a)     sort( ALL(a) )
#define PB          push_back
#define FOR(i,a,b)  for( int i = (a); i < (int)(b); i++ )
#define dump_(x)     cerr << #x << " = " << (x) << " ";
#define dump(x)     cerr << #x << " = " << (x) << endl
#define dump_vec(x) FOR(zZz,0,x.size()) cout << x[zZz] << " "; cout << endl

int main()
{
  int N;
  vector<int> vec;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int t;
    scanf("%d", &t);
    vec.push_back(t);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int a = vec[N/2 - 1], b = vec[N/2];
  int res = a - b;
  if (res < 0) res = 0;
  printf("%d", res);
  return 0;
}


Measured memory_bytes: 892