akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N;
    R(N);
    VI AA(N);
    int ss=0;
    REP(i,N){
        R(AA[i]);
        ss+=AA[i];
    }
    sort(ALL(AA));
    if(AA.back()*2<ss)W("Yes");
    else W("No");
    return 0;
}


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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, H, W;
	cin >> N >> H >> W;
	cout << (N - H + 1) * (N - W + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.shift();
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(arr.length / 2); i >= 0; i--) maxHeapify(i);
}



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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    int n;
    cin >> n;
    int res = 0;
    switch (n) {
    case 0:
        res = 1;
        break;
    case 1:
        res = 2;
        break;
    case 2:
        res = 1;
        break;
    }
    cout << res << endl;
}

Measured memory_bytes: 3088
n=int(input())
a=[int(x) for x in input().rstrip().split()]
b=[int(x) for x in input().rstrip().split()]
ans=0
for i in range(len(b)):
  if a[i]+a[i+1]<=b[i]:
    ans+=a[i]+a[i+1]
    a[i]=0
    a[i+1]=0
  
  elif a[i]<=b[i]:
    ans+=a[i]
    ans+=(b[i]-a[i])
    a[i+1]=a[i+1]-(b[i]-a[i])
  else:
    a[i]-=b[i]
    ans+=b[i]
print(ans)

Measured memory_bytes: 25352
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
 
  int A,B,C,D,ans;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  if(B<=C){
    ans = 0;
  }
  if(A<=C && C<=B && B<=D){
    ans = B-C;
    }
    if(A<=C && D<=B){
      ans = D-C;
    }
 
    if(D<=A){
      ans = 0;
    }
    if(C<=A && A<=D && D<=B){
      ans = D-A;
      }
      if(C<=A && B<=D){
        ans = B-A;
      }
      printf("%d",ans);
return 0;
}

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

int a[100005];
bool vis[100005];
int dist[100005];

void dfs(int x) {
  if (vis[x]) return;
  vis[x] = true;
  dist[a[x]] = dist[a[x]] == 0 ? dist[x] + 1 : dist[a[x]];
  dfs(a[x]);
}

int main() {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dist[1] = 0;
  dfs(1);
  
  cout << (vis[2] ? dist[2] : -1) << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll modpow(ll x, ll n){
    ll res = 1;
    ll r = x;
    while(n){
        if(n % 2) res = res * r % MOD;
        r = r * r % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    vector<ll> fmemo;
    vector<ll> imemo;
    vector<ll> ifmemo;
    
    ll modpow(ll x, ll n){
        ll res = 1;
        ll mul = x;
        while(n){
            if(n % 2) res = res * mul % MOD;
            mul = mul * mul % MOD;
            n /= 2;
        }
        return res;
    }

    Combination(int maxn) : maxn(maxn){
        fmemo.resize(maxn + 1);
        imemo.resize(maxn + 1);
        ifmemo.resize(maxn + 1);
        for(ll i = 1; i <= maxn; i++){
            imemo[i] = modpow(i, MOD - 2);
        }
    }

    ll fact(ll n){
        if(n == 0) return 1;
        if(fmemo[n]) return fmemo[n];
        return fmemo[n] = n * fact(n - 1) % MOD;
    }

    ll ifact(ll n){
        if(n == 0) return 1;
        if(ifmemo[n]) return ifmemo[n];
        return ifmemo[n] = imemo[n] * ifact(n - 1) % MOD;
    }

    ll com(ll n, ll k){
        if(k > n) return 0;
        if(k == n || k == 0) return 1;
        return (fact(n) * ifact(k) % MOD) * ifact(n - k) % MOD;
    }
};

int main()
{
    ll b, w;
    cin >> b >> w;
    ll p[200003];
    p[0] = 1;
    for(int i = 1; i < b + w; i++) p[i] = p[i - 1] * modpow(2, MOD - 2) % MOD;
    Combination c(b + w);
    ll ans = p[1];
    for(ll i = 1; i <= w + b; i++){
        if(i > b){
            ans = (ans + MOD - p[i - 1] * c.com(i - 2, i - b - 1) % MOD) % MOD;
            ans = (ans + MOD - p[i] * c.com(i - 1, i - b) % MOD * (b - 1) % MOD * modpow(i - 1, MOD - 2) % MOD) % MOD;
            ans = (ans + p[i] * c.com(i - 1, i - b) % MOD) % MOD;
        }
        if(i > w){
            ans = (ans + p[i - 1] * c.com(i - 2, i - w - 1) % MOD) % MOD;
            ans = (ans + MOD - p[i] * c.com(i - 1, i - w) % MOD * (i - w) % MOD * modpow(i - 1, MOD - 2) % MOD) % MOD;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 10752
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> doup;


int main(void) {
    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    ll ans;
    if(n>k) {
        ans=k*x+(n-k)*y;
    }else {
        ans=n*x;
    }
    cout << ans << endl;
}


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

typedef long long ll;
const int N = 200054, M = 4054, mod = 1000000007, iv2 = (mod + 1) / 2;

int n, A, B;
int a[N], b[N];
int f[M][M], g[M][M];

inline void up(int &x, const int y) {x < y ? x = y : 0;}
inline void add(int &x, const int y) {x += y - mod, x += x >> 31 & mod;}

int main() {
	int i, j; ll s = 0;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) scanf("%d%d", a + i, b + i), up(A, a[i]), up(B, b[i]);
	for (i = 0; i < n; ++i) ++f[A - a[i]][B - b[i]];
	for (**g = 1, i = 0; i <= 2 * A; ++i)
		for (j = 0; j <= 2 * B; ++j)
			add(f[i][j + 1], f[i][j]), add(f[i + 1][j], f[i][j]),
			add(g[i][j + 1], g[i][j]), add(g[i + 1][j], g[i][j]);
	for (i = 0; i < n; ++i) s += f[A + a[i]][B + b[i]] - g[a[i] * 2][b[i] * 2];
	s = s % mod * iv2 % mod;
	printf("%d\n", int(s + (s >> 63 & mod)));
	return 0;
}

Measured memory_bytes: 130176
import sys

s = sys.stdin.readline().rstrip()

def main():
    a, b = int(s[:2]), int(s[2:])
    if 1 <= a <= 12:
        if 1 <= b <= 12:
            return 'AMBIGUOUS'
        else:
            return 'MMYY'
    else:
        if 1 <= b <= 12:
            return 'YYMM'
        else:
            return 'NA'

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main()
{
    int H, W;
    while (true)
    {
        cin >> H >> W;
        if (H == 0 && W == 0)
        {
            break;
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
N, *XY = map(int, open(0).read().split())

XY = [(x, y) for x, y in zip(*[iter(XY)] * 2)]
XY = list(set(XY))

Ax, Ay = max(XY, key=lambda t: t[0] + t[1])
Bx, By = max(XY, key=lambda t: -t[0] + t[1])
Cx, Cy = max(XY, key=lambda t: t[0] - t[1])
Dx, Dy = max(XY, key=lambda t: -t[0] - t[1])

ans = 0
for x, y in XY:
    ans = max(
        ans,
        abs(x - Ax) + abs(y - Ay),
        abs(x - Bx) + abs(y - By),
        abs(x - Cx) + abs(y - Cy),
        abs(x - Dx) + abs(y - Dy),
    )

print(ans)

Measured memory_bytes: 55056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int l, r;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> l;
    cin >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 2001

char resultTable[SIZE];
int n,q,elems[20];

void calc(int sum,int index){
	if(index == n){
		if(sum >= 1 && sum <= 2000){
			resultTable[sum] = 'y';
		}
	}else{
		calc(sum+elems[index],index+1);
		calc(sum,index+1);
	}
}

int main(){

	for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';

	scanf("%d",&n);
	for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
	calc(0,0);

	scanf("%d",&q);

	int tmp;
	for(int i = 0; i < q; i++){
		scanf("%d",&tmp);
		if(resultTable[tmp] == 'y'){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
}







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

#define xx first
#define yy second

typedef pair<int,int> pii;
typedef long long LL;

int main() {
  //freopen("in", "r", stdin);
  int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n,m; cin >> n >> m;
    vector<int> a(m),b(m);
    for(int i = 0;i < m;i ++) cin >> a.at(i) >> b.at(i);
    vector<int> s(0),g(0);
    for(int i = 0;i < m;i ++){
        if(a.at(i) == 1) s.push_back(b.at(i));
        else if(b.at(i) == 1) s.push_back(a.at(i));
        else if(a.at(i) == n) g.push_back(b.at(i));
        else if(b.at(i) == n) g.push_back(a.at(i));
    }
    if(s.size() == 0 || g.size() == 0){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    sort(s.begin(),s.end());
    sort(g.begin(),g.end());


    for(int i = 0;i < s.size();i ++){
        if(lower_bound(g.begin(),g.end(),s.at(i)) != upper_bound(g.begin(),g.end(),s.at(i))){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

}

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

int n,a[100010],x,y,cnt;

int main(){
    cin >> n;
    for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    for(int i = n;i >= 1;--i){
        if(a[i] == a[i-1]){
            if(cnt == 0){
                x = a[i];
                cnt++;
            }
            else{
                y = a[i];
                cnt++;
            }
            i--;
        }
        if(cnt == 2) break;
    }
    cout << 1LL * x * y << endl;

    return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int K, S, res = 0;
  cin >> K >> S;
  rep(x, K + 1) rep(y, K + 1) {
    int z = S - x - y;
    if (z >= 0 && z <= K)
      res++;
  }
  cout << res << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n,p,q,yo;
	cin>>n;
	yo=n;
	pair<int,int> a[n];
	vector<pair<int,int>> v;
	cin>>p>>q;
	a[0]=make_pair(p,q);
	for(int i=1;i<n;i++){
		cin>>p>>q;
		a[i]=make_pair(p,q);
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				v.push_back(make_pair(a[i].first-a[j].first,a[i].second-a[j].second));
				v.push_back(make_pair(a[j].first-a[i].first,a[j].second-a[i].second));
			}
		}
	sort(v.begin(),v.end());
	n=0;
	int o=0;
	vector<int> z;
	for(int i=1;i<v.size();i++){
		if(v[i].first==v[i-1].first&&v[i].second==v[i-1].second){
		n++;
		}
		else{
			n=0;
		}
			if(o<n)
			o=n;
	}
	if(yo==1){
		cout<<1;
		return 0;
	}
	o++;
	cout<<yo-o;
	return 0;
}

Measured memory_bytes: 256
N,W=map(int,input().split())
w_list=[0]*N
v_list=[0]*N
for i in range(N):
    w_list[i],v_list[i]=map(int,input().split())
    
V=N*1000
inf=float("inf")
dp=[[inf]*(V+1) for _ in range(N+1)]
dp[0][0]=0

for v in range(V+1):
    for n in range(N):
        if v>=v_list[n]:
            dp[n+1][v] = min(dp[n][v-v_list[n]]+w_list[n],dp[n][v])
        else:
            dp[n+1][v]=dp[n][v]

ans=0
for i in range(V+1):
    if dp[N][i]<=W:
        ans=i
print(ans)

Measured memory_bytes: 390712
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
#define mod 1000000007
#define inf 2147483647
#define top 1000000000
using namespace std;

struct aa{int l, r;}a[N];
struct bb{int x, y;}b[N];
struct tt{int l, r, mn, mx;}t[10000010];
int n, f[N], l, ans, s[N], now;

inline bool cmp(bb a, bb b){return a.y<b.y;}
inline bool cmp1(aa a, aa b){return a.l==b.l?a.r<b.r:a.l<b.l;}

inline void ins(int i, int x, int y, int L, int R){
	if(L==R){t[i].mn=min(t[i].mn, y); t[i].mx=max(t[i].mx, y); return;}
	int mid=(L+R)>>1;
	if(x<=mid){
		if(!t[i].l){l++; t[i].l=l; t[l].l=t[l].r=t[l].mx=0; t[l].mn=inf;}
		ins(t[i].l, x, y, L, mid);
	}else{
		if(!t[i].r){l++; t[i].r=l; t[l].l=t[l].r=t[l].mx=0; t[l].mn=inf;}
		ins(t[i].r, x, y, mid+1, R);
	}
	t[i].mn=inf; t[i].mx=0;
	if(t[i].l){t[i].mn=min(t[i].mn, t[t[i].l].mn); t[i].mx=max(t[i].mx, t[t[i].l].mx);}
	if(t[i].r){t[i].mn=min(t[i].mn, t[t[i].r].mn); t[i].mx=max(t[i].mx, t[t[i].r].mx);}
}
inline int cmn(int i, int a, int b, int L, int R){
	if(!i)return inf;
	if(a<=L&&R<=b)return t[i].mn;
	int mid=(L+R)>>1, s=inf;
	if(a<=mid)s=min(s, cmn(t[i].l, a, b, L, mid));
	if(mid<b)s=min(s, cmn(t[i].r, a, b, mid+1, R));
	return s;
}
inline int cmx(int i, int a, int b, int L, int R){
	if(!i)return 0;
	if(a<=L&&R<=b)return t[i].mx;
	int mid=(L+R)>>1, s=0;
	if(a<=mid)s=max(s, cmx(t[i].l, a, b, L, mid));
	if(mid<b)s=max(s, cmx(t[i].r, a, b, mid+1, R));
	return s;
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)scanf("%d%d", &b[i].x, &b[i].y);
	sort(b+1, b+1+n, cmp);
	l=1; t[1].l=t[1].r=t[1].mx=0; t[1].mn=inf;
	for(int i=1; i<=n; i++){ins(1, b[i].x, i, 1, top); a[i].l=cmn(1, b[i].x, top, 1, top);}
	l=1; t[1].l=t[1].r=t[1].mx=0; t[1].mn=inf;
	for(int i=n; i; i--){ins(1, b[i].x, i, 1, top); a[i].r=cmx(1, 1, b[i].x, 1, top);}
	sort(a+1, a+1+n, cmp1);
	f[0]=1; s[0]=1; now=0; a[0].r=0;
	for(int i=1; i<=n; i++){
		while(a[now].r<a[i].l-1)now++;
		if(!now)f[i]=s[i-1];
		else f[i]=(s[i-1]-s[now-1]+mod)%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	ans=0; for(int i=1; i<=n; i++)if(a[i].r==n)ans=(ans+f[i])%mod; printf("%d", ans);
	return 0;
}

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


    typedef long long ll;



    
    const ll mx = 105;
    const ll mx1 = 1000001;
    const ll mod = 1000000007;

   vector<vector<ll> >edges;
    void adds(ll &a, ll b){
        a+= b;
        if(a >= mod)
        a-=mod;
    }
    ll mul(ll a, ll b){
        return (ll) a * b % mod;
    }

    // void subs(ll &a, ll b){
    //     a-= b;
    //     if(a < 0)
    //      a+=mod;
    // }
    void max_self(ll &a, ll b){
        a = max(a, b);
    }

    int main(){
        ll n, i, j, k;

        cin>>n;
        vector<ll> h(n), a(n);

        for(i =0 ;i < n;i++)
         cin>>h[i];

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

        ll base = 1;

        while(base <= n){
            base *= 2;
        }  
        vector<ll> tree(2*base);
        vector<ll> dp(n+1);
        
        for(ll flower = 0;flower < n;flower++){
            ll best = 0, x = h[flower] + base;

            while(x > 1){
                if(x%2 == 1){
                    max_self(best, tree[x-1]);
                }
                x /= 2;
            }
            dp[h[flower]] = best + a[flower];
            for(i = base+h[flower];i >= 1;i /= 2){
                max_self(tree[i], dp[h[flower]]);
            }

        }
        ll res = 0;
        for(i = 1;i <= n;i++)
         res = max(res, dp[i]);
        cout<<res;
    }

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

int main(){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
int mx=INT_MAX;
int cnt=0;
for(int i=0;i<n;i++){
    if(arr[i]<mx){
        cnt++;
    }
    if(mx>
       arr[i]){
        mx=arr[i];
    }


}
cout<<cnt<<endl;

return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int sum,n,s;
void func(int np,int nn,int pre){
	if(np==s&&nn==n)
		sum++;
	else
	if(nn<n)
	for(int i=pre+1;i<10;i++)
		if(np+i<=s)
			func(np+i,nn+1,i);
}
int main(){
	while(cin>>n>>s,n||s){
		sum=0;
		func(0,0,-1);
		cout<<sum<<endl;
	}
	return 0;
}

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

using ll = long long;
int main() {
  ll s;
  cin >> s;

  ll x2 = 1e9;
  ll y2 = 1LL;
  ll x3, y3;

  if(s % x2 == 0) {
    y3 = s / x2;
    x3 = 0;
  } else {
    y3 = s / x2 + 1;
    x3 = x2 - s % x2;
  }

  cout << "0 0 " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

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

int main() {
	ll n;
	cin >> n;
	ll cnt_odd = 0;
	ll cnt_four = 0;
	rep(i,n) {
		ll a;
		cin >> a;
		if (a%2==1) cnt_odd++;
		else if (a%4==0) cnt_four++;
	}
	if (cnt_odd<=cnt_four) cout << "Yes" << endl;
	else if (cnt_odd==cnt_four+1 && cnt_odd+cnt_four==n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int q = in.nextInt();
			Uft[] uft = Uft.makeSet(n);

			for (int i = 0; i < q; i++) {
				int command = in.nextInt();
				int x = in.nextInt();
				int y = in.nextInt();

				if (command == 0) {
					Uft.unite(uft, x, y);
				} else {
					if (Uft.isSame(uft, x, y)) {
						out.println(1);
					} else {
						out.println(0);
					}
				}
			}

		}
	}

	static class Uft {

		int p, rank;
		Uft(int p) {
			this.p = p;
			this.rank = 0;
		}
		static Uft[] makeSet(int n) {
			Uft[] uft = new Uft[n];
			for (int i = 0; i < n; i++) {
				uft[i] = new Uft(i);
			}
			return uft;
		}
		static void unite(Uft[] uft, int x, int y) {
			link(uft, findSet(uft, x), findSet(uft, y));
		}
		static boolean isSame(Uft[] uft, int x, int y) {
			return findSet(uft, x) == findSet(uft, y);
		}
		static void link(Uft[] uft, int x, int y) {
			if (uft[x].rank > uft[y].rank) {
				uft[y].p = x;
			} else {
				uft[x].p = y;
				if (uft[x].rank == uft[y].rank) {
					uft[y].rank++;
				}
			}
		}
		static int findSet(Uft[] uft, int x) {
			if (uft[x].p != x) {
				x = findSet(uft, uft[x].p);
			}
			return uft[x].p;
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 59320
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int len = S.length();
        final int Mod = 1000000000+7;
        long[] A = new long[123456];
        long[] AB = new long[123456];
        long[] dp = new long[123456];
        long base = 1L;
        for(int i=1;i<=len;i++){
            if(S.charAt(i-1)=='A'){
                AB[i] = AB[i-1];
                dp[i] = dp[i-1];
                A[i] = (A[i-1]+base)%Mod;
            }
            else if(S.charAt(i-1)=='B'){
                A[i] = A[i-1];
                dp[i] = dp[i-1];
                AB[i] = (AB[i-1] + A[i-1])%Mod;
            }
            else if(S.charAt(i-1)=='C'){
                A[i] = A[i-1];
                AB[i] = AB[i-1];
                dp[i] = (dp[i-1]+AB[i-1])%Mod;
            }
            else{ // charAt == '?'
                A[i] = ((3*A[i-1])%Mod+base)%Mod;
                AB[i] = ((3*AB[i-1])%Mod + A[i-1])%Mod;
                dp[i] = ((3*dp[i-1])%Mod+AB[i-1])%Mod;
                base = (3*base)%Mod;
            }
        }
        long ans = dp[len];
        System.out.println(ans);
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int d[k], a[k][n];
  vector<bool> tricked(n, true);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
    for (int j = 0; j < d[i]; j++) {
      cin >> a[i][j];
      tricked[a[i][j] - 1] = false;
    }
  }
  
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (tricked[i]) count++;
  }
  
  cout << count;
  
  return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#define N 100
#define INF 1000000000

int m[N][N], p[N+1];

void mChain(int n){
  int i, j, k, l, q;
  for(i = 1;i < n+1;i++)
    m[i][i] = 0;
  for(l = 2;l < n+1;l++){
    for(i = 1;i < n-l+2;i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k = i;k < j;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }
}

int min(int a, int b){
  if(a <= b) return a;
  else return b;
}

int main(){
  int i, n;
  scanf("%d", &n);
  for(i = 0;i < n;i++) scanf("%d%d", &p[i], &p[i+1]);
  mChain(n);
  printf("%d\n", m[1][n]);
  return 0;
}

Measured memory_bytes: 632
package main

import (
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
	"strings"
)

func Calc(n, a, b int64) int64 {
	var sum int64 = 0
	var i int64 = 0
	for ; i <= n; i++ {
		var csum int64 = 0
		for _, j := range strings.Split(strconv.FormatInt(i, 10), "") {
			cnum, _ := strconv.ParseInt(j, 0, 64)
			csum += cnum
		}

		if a <= csum && csum <= b {
			sum += i
		}
	}
	return sum
}

func Run(in io.Reader, out io.Writer) error {
	var n, a, b int64
	fmt.Fscan(in, &n, &a, &b)

	cnt := Calc(n, a, b)
	fmt.Fprintf(out, "%d\n", cnt)

	return nil
}

func main() {
	err := Run(os.Stdin, os.Stdout)

	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define PI 3.14159265358979323846264338327950L
 
int main(){
  string str;
  cin >> str;
  for(int i = 0;i < str.size();i++){

    if(i == 0){
      if(str.at(0) == '?'){
        str.at(0) = 'D';
      }
      continue;
    }
    if(str.at(i) == '?'){
      str.at(i) = 'D';
    }

  }
  cout << str << endl;


  }


Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int b[n];
    for(int i=0;i<n-1;++i) cin>>b[i];
    int sum=b[0]+b[n-2];
    for(int i=1;i<n-1;++i)
    {
        sum+=min(b[i-1],b[i]);
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "stdio.h"
#include "math.h"
#include "ctype.h"
#include "memory.h"
#include "string"
#include "algorithm"
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	string aa[100];
	int flag = 0;
	for(int i = 0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int j = 0;j< i;j++)
		{
			if(aa[j] == s)
			{
				flag =1;
			}
			if (i != 0 && s[0] != aa[i -1][aa[i-1].length() - 1])
			{
				flag = 1;
			}
		}
		aa[i] = s;
	}

	if (flag)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, k;
int a[200];
bool dp[200000];
//石が今i個残っているときの商社が今操作をしようとしているプレイヤーか
bool used[200000];
bool solve(int t) {
	if (t == 0) return 0;
	if (used[t]) return dp[t];
	bool res = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] <= t)
			res = res | (!solve(t - a[i]));
	}
	used[t] = 1;
	return dp[t] = res;
}
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i];
	if (solve(k)) {
		cout << "First\n";
	}
	else cout << "Second\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  string s;
  cin >> a >> s;
  int ans = 0, b = 0;
  for (int i = 0; i < a; i++) {
    if (s[i] == 'I') b++;
    else b--;
    ans = max(ans, b);
  }
  cout << ans << endl;
}

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

int main(){
  int x; cin >> x;
  if(x == 2){
    cout << 2 << endl;
    return 0;
  }
  if(x % 2 == 0) x++;
  for(int i = x; i < 1000000; i += 2){
    int j;
    for(j = 3; j <= i - 2; j += 2){
      if(i % j == 0) break;
    }
    if(j == i){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            exit()
            
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const int bn = 32;

ll digit(int n) {
	ll t = 0;
	while (n) {
		n /= 10;
		t++;
	}
	return t;
}

int main() {
	ll n; cin >> n;
	ll minV = 1 << 21;

	repe(i, 1, sqrt(n)) {
		if (n % i == 0) {
			//se.insert(n);
			//se.insert(i);
			//cout << n / i << " " << i << endl;
			minV = min(minV, max(digit(n / i), digit(i)));
		}
	}

	cout << minV << endl;
	return 0;
}

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

int main(void)
{
    int a,b;

    cin >> a >> b;
    if(a==b)
    {
        cout << "Draw" << endl;
    }
    else
    {
        if(a == 1)
        {
             cout << "Alice" << "\n";
             return 0;
        }
        if(b == 1)
        {
            cout << "Bob" << "\n";
            return 0;
        } 

        if(a > b) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
    return 0;
}

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

int A[100010];
priority_queue<int> pq;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, M;

	cin >> N >> M;
	for(int i = 0; i < N; i++) cin >> A[i];

	for(int i = 0; i < N; i++) pq.push(A[i]);
	for(int i = 0; i < M; i++) {
		int t = pq.top();
		pq.pop();
		pq.push(t / 2);
	}

	long long ans = 0;
	while(!pq.empty()) {
		ans += pq.top();
		pq.pop();
	}
	cout << ans;
	return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N, A[202020];
vector<ll> Av;
ll i,j,ans;
int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        Av.push_back(A[i]);
    }
    sort(Av.begin(), Av.end());
    fornum(i,0,N){
            printf("%lld\n", A[i] == Av[N - 1] ? Av[N - 2] : Av[N - 1]);

    }

    return 0;
}

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

int main() {
  int n; cin >> n;
  string s = "MARCH";
  int c[5] = {0};
  rep(i,n) {
    string t;
    cin >> t;
    rep(j,5) {
      if (t[0] == s[j]) {
        c[j]++;
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += (ll)c[i] * c[j] * c[k];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
fun main() {
    val n = nextInt()
    val a = nextIntList()
    var stock = 0L
    var account = 1000L
    repeat(n - 1) {
        when {
            a[it] < a[it + 1] -> {
                stock += account / a[it]
                account %= a[it]
            }
            a[it] > a[it + 1] -> {
                account += stock * a[it]
                stock = 0
            }
            else -> Unit
        }
    }
    account += stock * a.last()
    println(account)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}


Measured memory_bytes: 36540
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string t;
    cin >> t;
  int n;
  n=t.size();
    for (int i = 0; i < n; i++) {
      if(t[i]=='?'){
        t.replace(i, 1, "D") ;
      }
    }
  cout <<t<<endl; 
}

Measured memory_bytes: 3756
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

import sys
N = int(input())
if N == 1:
    print(0)
    sys.exit()
A = factorization(N)
ans = 0
for i in range(len(A)):
    for j in range(1,A[i][1]+1):
        if N % A[i][0]**j == 0:
            ans += 1
            N //= A[i][0]**j
        else:
            break

print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n; cin >> n;
    vint h(n);
    rep(i, n) cin >> h[i];
    reverse(all(h));
    int ans = 0, temp = 0;
    for (int i = 1; i < n; i++) {
        if (h[i - 1] <= h[i]) temp++;
        else temp = 0;
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> dp(n + 1, -1);
    queue<int> que;
    dp[0] = 0; que.emplace(0);
    while (!que.empty()) {
        int i = que.front(); que.pop();
        for (int pow6 = 1; i + pow6 <= n; pow6 *= 6) {
            if (dp[i + pow6] == -1) {
                dp[i + pow6] = dp[i] + 1;
                que.emplace(i + pow6);
            }
        }
        for (int pow9 = 1; i + pow9 <= n; pow9 *= 9) {
            if (dp[i + pow9] == -1) {
                dp[i + pow9] = dp[i] + 1;
                que.emplace(i + pow9);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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

int main() {
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  if(d == 24) cout << "Christmas Eve" << endl;
  if(d == 23) cout << "Christmas Eve Eve" << endl;
  if(d == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	
	ll n ;
	cin>> n ; 
	ll ans = (n/500)*1000 + ((n%500)/5)*5;
	cout<<ans<<endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

#define __STDC_FORMAT_MACROS
#define p64 PRId64

using namespace std;
using ll = int64_t;

vector< pair<ll, ll> > xv;

vector<ll> va;
vector<ll> vb;

int main()
{
    ll N, C;
    cin >> N >> C;

    xv.resize(N);

    va.resize(N);
    vb.resize(N);

    ll vsum = 0;
    ll bkv = 0;

    REP(i, N)
    {
        ll x, v;
        cin >> x >> v;

        xv[i] = make_pair(x, v);
        vsum += v;

        if (bkv < vsum - x) bkv = vsum - x;

        va[i] = bkv;
    }

    vsum = 0;
    bkv = 0;

    for (int i = N - 1; 0 <= i; i--)
    {
        vsum += xv[i].second;

        ll Bv = vsum - (C - xv[i].first);
        if (bkv < Bv) bkv = Bv;

        vb[i] = bkv;
    }

    ll ans = 0;
    for (int i = N - 1; 0 <= i; i--)
    {
        ll Ax = 0;
        ll Av = 0;

        if (i != 0)
        {
            Ax = xv[i - 1].first;
            Av = va[i - 1];
        }

        ll Bx = C - xv[i].first;
        ll Bv = vb[i];

        // ここで Ax または Bx は
        // 引きすぎているように見えるが
        // 各地点ごとに処理している為
        // しかるべき地点で max 更新しており問題無い
        // O B O A
        ans = max(ans, Av + Bv - Bx);
        // O A O B
        ans = max(ans, Bv + Av - Ax);
    }

    // O A
    ans = max(ans, va[N - 1]);

    // O B
    ans = max(ans, vb[0]);

    cout << ans << endl;
    return 0;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  int n,m,q; cin >> n >> m >> q;
  vvi im(n+1,vi(n+1));
  rep(i,m){
    int l,r; cin >> l >> r; l--; r--;
    // [0,l]x[r,n)に加算
    im[0][r]++;
    im[0][n]--;
    im[l+1][r]--;
    im[l+1][n]++;
  }
  rep(i,n) rep(j,n)
    im[i+1][j] += im[i][j];
  rep(j,n) rep(i,n)
    im[i][j+1] += im[i][j];

  rep(i,q){
    int a,b; cin >> a >> b;
    cout << im[a-1][b-1] << endl;
  }
}

Measured memory_bytes: 2944
MOD = 10 ** 9 + 7

def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = MOD
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

def prep(n):
    for i in range(2, n):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)


def main():
    n, k = map(int, input().split())
    A = sorted(map(int, input().split()))
    c = 1
    ma = 0
    prep(n)
    for i, (amax, amin) in enumerate(zip(A[k - 1:], reversed(A[:n - k + 1])), k - 1):
        ma = (ma + cmb(i, k - 1, MOD) * (amax - amin)) % MOD
    print(ma)

main()


Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, a, b; cin >> n >> a >> b;
	int x = 0, y = 0, z = 0;
	while( n-- ){
		int sc; cin >> sc;
		if( sc <= a ) ++x;
		else if( sc <= b ) ++y;
		else ++z;
	}
	cout << min({x, y, z}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()

int main(){
	int N,X;cin>>N>>X;
	int L[N];
	int d=0,count=1;
	rep(i,0,N){
		cin>>L[i];
		d+=L[i];
		if(d<=X) count++;
	}cout<<count<<endl;
}


Measured memory_bytes: 256
n = int(input())
seq_n = 0
max_seq = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        seq_n +=1
        max_seq = max(max_seq, seq_n)
    else:
        seq_n = 0
if max_seq < 3:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
#define INF int(1e9)

template<class T,class U> ostream& operator<<(ostream& ost, const pair<T,U> &p) { ost << "(" << p.first << ", " << p.second << ")"; return ost; }
#define ostream_container { ost << "{"; for(const auto &t : v) { if (&t != &*v.begin()) ost << ", "; ost << t; } ost << "}"; return ost; }
template<class T> ostream& operator<<(ostream &ost, const vector<T> &v) ostream_container
template<class T> ostream& operator<<(ostream &ost, const set<T> &v) ostream_container
template<class T,class U> ostream& operator<<(ostream &ost, const map<T,U> &v) ostream_container

template<class H> void recursive_debug(string s, H h) {
    cerr << "\033[33m" << s << " = " << h << endl << "\033[m";
}
template<class H,class... T> void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << "\033[33m" << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}
#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)


ll mul(ll a, ll b, ll mod) {
    return (a*b)%mod;
}
ll mpow(ll a, ll r, ll mod) {
    if(r == 0) return 1;
    return mul(mpow(mul(a,a,mod), (r/2), mod), (r&1 ? a : 1), mod);
}

void f(ll x, ll &cnt) {
    if (x == 0) return;
    cnt++;
    f(x % __builtin_popcountll(x), cnt);
}

int main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll M = count(all(s), '1');
    ll fx1 = 0, fx2 = 0;
    reverse(all(s));
    rep(i,n) {
        if (s[i] == '1') {
            if (M == 1) {
                fx1 = 0;
            } else {
                fx1 += mpow(2, i, M-1);
                fx2 += mpow(2, i, M+1);
            }
        }
    }
    vector<ll> res;
    rep(i,n){
        ll fx;
        if (s[i] == '1' && M == 1) {
            res.push_back(0);
            continue;
        } else if (s[i] == '1') {
            fx = (fx1 - mpow(2, i, M-1) + (M-1) ) % (M-1);
        } else {
            fx = (fx2 + mpow(2, i, M+1) + (M+1) ) % (M+1);
        }
        ll cnt = 1;
        f(fx, cnt);
        res.push_back(cnt);
    }
    reverse(all(res));
    rep(i,n){
        cout << res[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5548