akhauriyash/Code-Regression huggingface dataset:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tmp = 0
aa = [0]*(n+1)
for i in range(n):
    tmp += a[i]
    aa[i+1] = tmp

tmp = 0
bb = [0]*(m+1)
for i in range(m):
    tmp += b[i]
    bb[i+1] = tmp

j = m
ans = 0
for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k-aa[i] and j >= 0:
        j -= 1
    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 47504
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int dx[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2};
int dy[12] = { 2, 2, 2, 1, 0,-1,-2,-2,-2,-1, 0,-1};
vector<pair<int,int> > v;
bool ans = false;

void dfs(int n,int i,int y,int x)
{
	if(i == n)
	{
		ans = true;
		return;
	}
	else
	{
		bool flag = true;
		int f[10][10];
		memset(f,0,sizeof(f));

		REP(k,-1,2)
		{
			REP(l,-1,2)
			{
				int py = v[i].first + k;
				int px = v[i].second + l;

				if(0 <= py && py < 10 && 0 <= px && px < 10)
				{
					f[py][px] = 1;
				}
			}
		}

		rep(j,12)
		{
			int nx = x + dx[j];
			int ny = y + dy[j];

			if(0 <= ny && ny < 10 && 0<= nx && nx < 10)
			{
				if(f[ny][nx] == 1)
				{
					flag = true;
					dfs(n,i+1,ny,nx);
				}
			}
			
		}
		if(flag) return;
	}
}

int main()
{
	
	while(true)
	{
		int x,y;
		cin >> x >> y;
		if(x == 0 && y == 0) break;

		v.clear();
		ans = false;
		
		int n,sp_x,sp_y;
		cin >> n;

		rep(i,n)
		{
			cin >> sp_x >> sp_y;
			v.pb(mp(sp_y,sp_x));
		}

		dfs(n,0,y,x);

		if(ans) cout << "OK" << endl;
		else cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
//#include <vector>
#include <queue>
using namespace std;

int main() {
    int dx[4]={1,0,-1,0};
    int dy[4]={0,-1,0,1};

    int h,w;
    cin >> h >> w;
    char f[55][55];
    int s=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> f[i][j];
            if(f[i][j] == '.') s++;
        }
    }
    
    queue< pair<int,int> > que;
    que.push(make_pair(0,0));
    int c[55][55] = {};
    c[0][0]=1;

    while(!que.empty() && c[h-1][w-1] == 0){
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        for(int i=0; i<4; i++){
            int q=y+dy[i];
            int p=x+dx[i];
            if(0<=q && q<h && 0<=p && p<w && f[q][p] == '.' && c[q][p] == 0){
                c[q][p] = c[y][x]+1;
                que.push(make_pair(q,p));
            }
    }
    }
    if (c[h-1][w-1] == 0){
        cout << -1 << endl;
    } else {
        cout << s - c[h-1][w-1] << endl;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  ll l, r;
  cin >> l >> r;

  if (r - l + 1 >= 2019)
    cout << 0 << endl;
  else {
    ll m = INF;
    for (ll i = l; i <= r; i++){
      for (ll j = i + 1; j <= r; j++){
        m = min(m, i * j % 2019);
      }
    }
    cout << m << endl;
  }


  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    m = set()
    for i in range(1, 10):
        for j in range(1, 10):
            m.add(i * j)

    n = int(input())

    print('Yes' if n in m else 'No')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

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

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


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


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


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include <stdio.h>

int	main(void)
{
	char	N[200001];
	int		i, res;

	scanf("%s", N);
	for (i = 0; N[i] != 0; i++)
	{
		res += N[i] - '0';
		res %= 9;
	}
	if (res == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}

Measured memory_bytes: 1860
#include <cstdio>
#include <iterator>
#include <queue>
const int INFT = 1e9+7;
const int MAXN = 55;
const int MAXK = 105;
int dp[MAXN][MAXN][MAXK];
int V[MAXN];
int K, N;

int dfs(int l, int r, int m) {
    if (dp[l][r][m] != -INFT) {
        return dp[l][r][m];
    }
    int sum = 0;
    std::priority_queue<int> heap;
    for (int i = 1; i <= N; ++i) if ((i <= l) || (r <= i)) {
        sum += V[i];
        if (V[i] < 0) heap.push(-V[i]);
    }
    if (!m) {
        return dp[l][r][m] = sum;
    }
    // Operations C and D.
    for (int k = 0; (k < m) && !heap.empty(); ++k) {
        sum += heap.top();
        heap.pop();
    }
    // Operations A and B.
    if (l < r) {
        sum = std::max(dfs(l+1, r, m-1), sum);
        sum = std::max(dfs(l, r-1, m-1), sum);
    }
    return dp[l][r][m] = sum;
}

int main() {
    scanf(" %d%d", &N, &K);
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &V[i]);
    }
    for (int i = 0; i <= N + 1; ++i) {
        for (int j = 0; j <= N + 1; ++j) {
            for (int k = 0; k <= K; ++k) {
                dp[i][j][k] = -INFT;
            }
        }
    }
    printf("%d\n", dfs(0, N + 1, K));
    return 0;
}
// Case: 3 3 3 -1 3 = 6
// Handle indices: dp[-1][N+1]


Measured memory_bytes: 1408
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){
  int N; cin >> N;
  map<string, long long> m;
  for(int i=0; i < N; i++){
    string s; cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }

  long long ans = 0;
  auto begin = m.begin(), end = m.end();
  for(auto iter = begin; iter != end; iter++){
    string s = iter->first;
    ans += m[s] * (m[s]-1) / 2;
  }

  cout << ans << endl;

}

Measured memory_bytes: 11136
a=int(input())
b=int(input())
c=int(input())
x=int(input())
way=0
for i in range(0,a+1):
  for j in range(0,b+1):
    for k in range(0,c+1):
      if(i*500+j*100+k*50==x):
        way+=1
print(way)

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

int main(void) {

  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  vector<bool> ans(10000, false);
  for(int i=0; i<n; i++){
    int tmp = 0;
    for(int j=0; j<4; j++){
      if( i + j >= n ) break;
      tmp += d[i+j];
      ans[tmp] = true;
      tmp *= 10;
    }
  }
  for(int i=0; i<10000; i++) if( !ans[i] ){
    cout << i << endl;
    break;
  }


  return 0;
}

// EOF

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



int main() {
  int a,b,c;
  cin >> a >> b >>c;
  int cnt1 =0,cnt2 =0;

  int d = min(min(a,b),c);
  int f = max(max(a,b),c);
  int e = a+b+c-d-f;
  int ans;
  if (((f-d)+(f-e))%2 == 0){
      while(d<=f){
         d+=2;
         if (d>f) {d-=2;break;}
         cnt1++;
      }
      while(e<=f){
          e+=2;
          if(e>f){e-=2;break;}
          cnt1++;
      }
      if(f>d||f>e) ans= cnt1+1;
      else ans = cnt1;
  }
  else {
      while(d<=f){
         d+=2;
         if(d>f){d-=2;break;}
         cnt2++;
      }
      while(e<=f){
          e+=2;
          if(e>f){e-=2;break;}
          cnt2++;
      }
      ans = cnt2+2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C;
    cin>>A>>B>>C;

    bool ok=false;
    for(int i=1;i<=B;i++){
        if(A*i%B==C) ok=true;
    }
    cout<<(ok? "YES":"NO")<<endl;

}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
   int r,g,b,k,cnt=0;cin>>r>>g>>b>>k;
   while(g<=r)g*=2,cnt++;
   while(b<=g)b*=2,cnt++;
   if(cnt<=k)cout<<"Yes\n";
   else cout<<"No\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3648
n,a,b = map(int,input().split())
mod = 10**9+7
from functools import reduce

def comb(r):
    num = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    dem = reduce(lambda x, y: x * y % mod, [k+1 for k in range(r)])
    return num*pow(dem,mod-2,mod)%mod

ans = (pow(2,n,mod)-1-comb(a)-comb(b))%mod
print(ans)

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

int main() {
    int m, f, r;

    while (true) {
        std::cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;

        if (m == -1 || f == -1) {
            std::cout << 'F' << std::endl;
        } else if (m + f >= 80) {
            std::cout << 'A' << std::endl;
        } else if (m + f >= 65) {
            std::cout << 'B' << std::endl;
        } else if (m + f >= 50) {
            std::cout << 'C' << std::endl;
        } else if (m + f >= 30) {
            if (r >= 50) {
                std::cout << 'C' << std::endl;
            } else {
                std::cout << 'D' << std::endl;
            }
        } else {
            std::cout << 'F' << std::endl;
        }
    }
}



Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
typedef pair<P, int>PP;
const long long inf = 1ll << 61;
int a[105];
signed main() {
	int n, m; cin >> n >> m;
	int s = 0;
	rep(i, n) {
		cin >> a[i]; s += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (s <= 4 * a[i] * m)cnt++;
	}
	if (cnt >= m)puts("Yes");
	else puts("No");
}

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

int main()
{
	cout << fixed << setprecision(8);
	int n, r;
	while (cin >> r >> n, r | n) {
		vector<int> h(40);
		for (int i = 0, xl, xr, hi; i < n; i++) {
			cin >> xl >> xr >> hi;
			for (int j = xl + 20; j < xr + 20; j++) {
				h[j] = max(h[j], hi);
			}
		}
		int cnt = 100;
		ld lb = 0, ub = 30;
		while (cnt--) {
			ld c = (lb + ub) / 2.0;
			bool flag = true;
			for (int i = 0; i < 40; i++) {
				int t1 = r * r - (i - 20) * (i - 20), t2 = r * r - (i - 19) * (i - 19);
				if (t1 < 0 || t2 < 0) continue;
				if (max(sqrtl(t1), sqrtl(t2)) - r + c > h[i]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				lb = c;
			}
			else {
				ub = c;
			}
		}
		cout << lb << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


int d, g;
int p[15], c[15], cmp[15];
int ans = INF;
void dfs(int i, int sum, int cnt, int unused) {
	if (i == d) {
		if (sum >= g) {
			ans = min(ans, cnt);
		}
		else {
			if (unused != -1) {
				int tmp = (g - sum + (unused + 1) * 100 - 1) / ((unused + 1) * 100);
				if (tmp < p[unused]) {
					ans = min(ans, cnt + tmp);
				}
			}
		}
	}
	else {
		dfs(i + 1, sum + cmp[i], cnt + p[i], unused);
		dfs(i + 1, sum, cnt, i);
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> d >> g;
	rep(i, d) {
		cin >> p[i] >> c[i];
		cmp[i] = 100 * (i + 1)*p[i] + c[i];
	}
	dfs(0, 0, 0, -1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    p = [int(a) for a in input().split()]
    rate = defaultdict(int)
    for i in range(N):
        score = p[i]
        if 1 <= score <= 399:
            rate["GRAY"] += 1
        elif 400  <= score <= 799:
            rate["BROWN"] += 1
        elif 800  <= score <= 1199:
            rate["GREEN"] += 1
        elif 1200 <= score <= 1599:
            rate["LBLUE"] += 1
        elif 1600 <= score <= 1999:
            rate["BLUE"] += 1
        elif 2000 <= score <= 2399:
            rate["YELLOW"] += 1
        elif 2400 <= score <= 2799:
            rate["ORANGE"] += 1
        elif 2800 <= score <= 3199:
            rate["RED"] += 1
        elif 3200 <= score:
            rate["FREE"] += 1
    color = 0
    free  = 0
    for k, v in rate.items():
        if k != "FREE":
            if rate[k] > 0:
                color += 1
        else:
            free += rate[k]
    if color == 0 and free != 0:
        print(1, free)
    else:
        print(color , color + free)
main()

Measured memory_bytes: 3316
n, k, q = map(int, input().split())
x = [0]*n
for i in range(q):
  a = int(input())
  a -= 1
  x[a] += 1

y = [k]*n
for i in range(n):
  y[i] -= (q-x[i])
  if y[i] <= 0:
    print('No')
  else:
    print('Yes')
  

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (i%k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


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

    int sum = 0;
    rep(i,n) sum += a[i];

    if (h <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}  

Measured memory_bytes: 3780
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := nextInt()

	if n == 1 && m == 1 {
		fmt.Println(1)
		return
	}
	if n == 1 {
		fmt.Println(m - 2)
		return
	}
	if m == 1 {
		fmt.Println(n - 2)
		return
	}

	fmt.Println((n - 2) * (m - 2))

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main() {
  int n,k,ans;
  cin >> n >> k;
  ans = 0;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  for(int i=0;i<k;i++){
    ans += vec.at(i);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};



int main(){
 
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int r = 1000000000;
    int l = 0;
    while(r-l > 1){
        int x = (l+r)/2;
        auto f = [&](int x){
            ll now = 0;
            rep(i,n){
                now += (a[i] -1)/x;
            }
            return now <= k;
        };
        if(f(x)) r = x;
        else l = x;
    }
    cout << r << endl;



    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

struct LazySegTree { //参照は + sz - 1;
	ll sz;
	vector<ll> node, lazy;
	vector<bool> lazyFlag;
	LazySegTree(ll n) {
		sz = 1;
		while (sz < n) sz *= 2;
		node.resize(2 * sz - 1);
		lazy.resize(2 * sz - 1);
		lazyFlag.resize(2 * sz - 1);
	}
	void eval(ll k, ll l, ll r) {
		if (lazyFlag[k]) { //いらないとき消す(挙動が怪しい)
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k];
				lazy[2 * k + 2] += lazy[k];
				lazyFlag[2 * k + 1] = lazyFlag[2 * k + 2] = true;
			}
			lazyFlag[k] = false;
			//lazy[k] = 0;
		}
	}
	void update(ll a, ll b, ll x, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = (r - l) * x;
			lazyFlag[k] = true;
			eval(k, l, r);

		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}
	void update(ll a, ll x) {
		update(a, a + 1, x);
	}
	ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		eval(k, l, r);
		if (b <= l || r <= a) return 0;
		if (a <= l && r <= b) return node[k];
		ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
	void init() {
		REPR(i, sz - 2) node[i] = node[2 * i + 1] + node[2 * i + 2];
	}
};

int main() {
	ll n, q;
	cin >> n >> q;
	LazySegTree seg(n);
	REP(i, q) {
		ll t;
		cin >> t;
		if (t == 0) {
			ll a, b;
			cin >> a >> b;
			a--;
			seg.update(a, b);
		}
		else {
			ll a, b;
			cin >> a >> b;
			a--;
			cout << seg.query(a, b) << endl;
		}
	}
}



Measured memory_bytes: 7064
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
for bb in b:
    anum = bisect.bisect_left(a, bb)
    cnum = n - bisect.bisect_right(c, bb)
    cnt += (anum * cnum)
print(cnt)

Measured memory_bytes: 23200
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string str;
  int str_size;
  while(getline( cin , str )){
    str_size = str.size();
    while(1){
      for(int i=0;i<str_size;i++){
	if(str[i] == 'z')str[i]='a';
	else if(str[i] != '.' && str[i] != ' ')str[i]++;
      }
      if(str.find( "the" ) != -1)break;
      if(str.find( "that" ) != -1)break;
      if(str.find( "this" ) != -1)break;
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstring>

using namespace std;

const double EPS=(1e-10);
bool EQ(double a,double b){
    return abs(a-b)<EPS;
}

typedef complex<double> P;
typedef pair<double,double> pdd;

double calc(double a1,double b1,double a2,double b2,double x,double r){
    return (a2*a1*x*x*x)/3.0+(x*x*(a1*a2*r+b2*a1+a2*b1))/2.0+(a2*b1*r+b1*b2)*x;
}

int main(){
    int n;
    double r;
    while(cin>>n>>r&&!(n==0&&EQ(r,0))){
        vector<P> dots;
        vector<pdd> co;
        dots.push_back(P(-1000,0));
        for(int i=0;i<n;i++){
            double x,y;
            cin>>x>>y;
            dots.push_back(P(x,y));
        }
        dots.push_back(P(1000,0));
        double sum=0;
        for(int i=1;i<=n+1;i++){
            double a=(dots[i-1].imag()-dots[i].imag())/(dots[i-1].real()-dots[i].real());
            double b=dots[i-1].imag()-a*dots[i-1].real();
            co.push_back(pdd(a,b));
        }
        double ax=dots[1].real();
        double bx=ax+r;
        int nxtApos=n+2;
        int nxtBpos=n+2;
        // rツづ個値ツつェツづづ個凝ヲツ甘板づ可甘慊づ慊づェツづつ「ツづゥツつゥツづーツ探ツ催オ
        for(int i=0;i<=n+1;i++){
            if(dots[i].real()>bx&&!EQ(dots[i].real(),bx)){
                nxtBpos=i;
                break;
            }
        }
        for(int i=0;i<=n+1;i++){
            if(dots[i].real()>ax&&!EQ(dots[i].real(),ax)){
                nxtApos=i;
                break;
            }
        }
        bool rev=false;
        if(ax>bx){
            swap(ax,bx);
            swap(nxtApos,nxtBpos);
            rev=true;
        }
        // nxtBposツつェnツづ可づ按づゥツづ慊づ堕アツつッツづゥ
        while(nxtBpos!=n+2){
            // ツ篠淞づ個湘ェツ渉環づ鳴づ個仰猟猟」ツつェツ渉ャツつウツつ「ツづ個づ債づつソツづァツつゥ
            double adis=dots[nxtApos].real()-ax;
            double bdis=dots[nxtBpos].real()-bx;
            double dis=min(adis,bdis);
            double t=ax+dis;
            double s=ax;
            if(rev){
                t=bx+dis;
                s=bx;
                sum+=calc(co[nxtBpos-1].first,co[nxtBpos-1].second,co[nxtApos-1].first,co[nxtApos-1].second,t,r);
                sum-=calc(co[nxtBpos-1].first,co[nxtBpos-1].second,co[nxtApos-1].first,co[nxtApos-1].second,s,r);
            }
            else{
                sum+=calc(co[nxtApos-1].first,co[nxtApos-1].second,co[nxtBpos-1].first,co[nxtBpos-1].second,t,r);
                sum-=calc(co[nxtApos-1].first,co[nxtApos-1].second,co[nxtBpos-1].first,co[nxtBpos-1].second,s,r);
            }
            ax+=dis;bx+=dis;
            if(EQ(adis,bdis)){
                nxtApos++;
                nxtBpos++;
            }
            else if(adis<bdis)nxtApos++;
            else nxtBpos++;
        }
        printf("%.10f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const double EPS = 1e-7;
  int N;
  cin >> N;
  long long x[N], y[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  double ans = 100000;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        long long det
            = (x[i] - x[j]) * (y[j] - y[k]) - (y[i] - y[j]) * (x[j] - x[k]);
        long long u = x[i] * x[i] - x[j] * x[j] + y[i] * y[i] - y[j] * y[j];
        long long v = x[j] * x[j] - x[k] * x[k] + y[j] * y[j] - y[k] * y[k];
        double a = (y[j] - y[k]) * u + (y[j] - y[i]) * v;
        a /= 2 * det;
        double b = (x[k] - x[j]) * u + (x[i] - x[j]) * v;
        b /= 2 * det;
        double r2 = (x[i] - a) * (x[i] - a) + (y[i] - b) * (y[i] - b);
        bool isok = true;
        for (int l = 0; l < N; l++) {
          double dis = (x[l] - a) * (x[l] - a) + (y[l] - b) * (y[l] - b);
          isok &= dis <= r2 + EPS;
        }
        if (isok) {
          ans = min(ans, sqrt(r2));
        }
      }
      double a = double(x[i] + x[j]) / 2;
      double b = double(y[i] + y[j]) / 2;
      double r2 = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
      r2 /= 4;
      bool isok = true;
      for (int l = 0; l < N; l++) {
        double dis = (x[l] - a) * (x[l] - a) + (y[l] - b) * (y[l] - b);
        isok &= dis <= r2 + EPS;
      }
      if (isok) {
        ans = min(ans, sqrt(r2));
      }
    }
  }
  printf("%.8lf\n", ans);
  return 0;
}


Measured memory_bytes: 3808
local mfl, mmi, mma = math.floor, math.min, math.max
local function lower_bound(ary, x)
  if(x <= ary[1]) then return 1 end
  local num = #ary
  if(ary[num] < x) then return num + 1 end
  local min, max = 1, num
  while(1 < max - min) do
    local mid = mfl((min + max) / 2)
    if(ary[mid] < x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end
local ior = io.input()
local a, b, q = ior:read("*n", "*n", "*n")
local s, t = {}, {}
for i = 1, a do s[i] = ior:read("*n") end
for i = 1, b do t[i] = ior:read("*n") end
for i = 1, q do
  local pos = ior:read("*n")
  local s_right = lower_bound(s, pos)
  local s_left = s_right - 1
  local t_right = lower_bound(t, pos)
  local t_left = t_right - 1
  local len = 20000000000
  local ll, lr, rl, rr = true, true, true, true
  if(s_right == a + 1) then
    rl, rr = false, false
  elseif(s_right == 1) then
    ll, lr = false, false
  end
  if(t_right == b + 1) then
    lr, rr = false, false
  elseif(t_right == 1) then
    ll, rl = false, false
  end
  if(ll) then len = mmi(len, mma(pos - s[s_left], pos - t[t_left])) end
  if(rr) then len = mmi(len, mma(s[s_right] - pos, t[t_right] - pos)) end
  if(lr) then len = mmi(len, -s[s_left] + t[t_right] + mmi(pos - s[s_left], t[t_right] - pos)) end
  if(rl) then len = mmi(len, -t[t_left] + s[s_right] + mmi(pos - t[t_left], s[s_right] - pos)) end
  print(len)
end


Measured memory_bytes: 3456
#include <cstdio>

using namespace std;

int main(){
  int n, max = -1, min = 1000000;
  int a[1000];

  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    if(a[i] > max)
      max = a[i];
    if(a[i] < min)
      min = a[i];
  }

  printf("%d\n", max - min);

  return 0;
}
  


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		int n = b - a;
		result = n * (n + 1) / 2 - b;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define pairint pair<int,int>
namespace i207M
{

template<class T>il void in(T &x)
{
	x=0; bool f=0;char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	if(f) x=-x;
}
#define N 305
#define md 1000000007
int f[N][N][N];
vector<pairint>lm[N]; 
int n,m;
int ck[N][N][N];
bool ok(int x,int y,int z)
{
	if(~ck[x][y][z]) return ck[x][y][z];
	for(ri i=0;i<lm[x].size();++i)
	{
		if(lm[x][i].se==1) 
		{
			if(z>=lm[x][i].fi) return ck[x][y][z]=0;
		}
		else if(lm[x][i].se==2)
		{
			if(!(y<lm[x][i].fi&&z>=lm[x][i].fi)) return ck[x][y][z]=0;
		}
		else 
		{
			if(y<lm[x][i].fi) return ck[x][y][z]=0;
		}
	}
	return ck[x][y][z]=1;
}
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
#endif
	in(n),in(m);
	memset(ck,-1,sizeof ck);
	for(ri i=1,l,r,x;i<=m;++i)
	{
		in(l),in(r),in(x);
		lm[r].pb(mkp(l,x));
	}
	f[0][0][0]=1;
	for(ri i=0;i<n;++i)
		for(ri j=0;j<=i;++j)
			for(ri k=j;k<=i;++k)
				if(f[i][j][k])
				{
					// j < k
					if(ok(i+1,j,k)) (f[i+1][j][k]+=f[i][j][k])%=md;
					if(ok(i+1,j,i)) (f[i+1][j][i]+=f[i][j][k])%=md;
					if(ok(i+1,k,i)) (f[i+1][k][i]+=f[i][j][k])%=md;
				}
	int ans=0;
	for(ri i=0;i<n;++i)
		for(ri j=i;j<n;++j) (ans+=f[n][i][j])%=md;
	printf("%d",ans);
	return 0;
}

}
int main()
{
	i207M::main();
	return 0;
}

Measured memory_bytes: 221568
<?php

$s = new Scanner();

$N=$s->nextInt();
$K=$s->nextInt();
$intArr=array_fill(0, 10, 0);

for ($i=0; $i < $N; $i++) {
    $intArr[$s->nextInt()-1]++;
}
rsort($intArr);
// print_r($intArr);

// $povit=0;
$sum=0;
for ($i=$K; $i < $N; $i++) {
    # code...
    if ($intArr[$i]==0) {
        // $povit=$i;
        break;
    }
    $sum+=$intArr[$i];
}
// out::println('povit'.$povit);
out::println($sum);


#文字列・数値の標準入力クラス
class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext()
    {
        return $this->pointer < $this->count;
    }
    public function nextInt()
    {
        return (int)$this->next();
    }
    public function nextDouble()
    {
        return (double)$this->next();
    }
}

#改行ありの標準出力クラス
class out
{
    public static function println($str = "")
    {
        echo $str . PHP_EOL;
    }
}


Measured memory_bytes: 68628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> l,r;
    int zero = 0;
    rep(i,n){
        ll now;
        cin >> now;
        if(now == 0) zero++;
        else if(now > 0) r.push_back(now);
        else if(now < 0) l.push_back(now);
    }
    sort(l.rbegin(),l.rend());
    if(zero >= k){
        cout << 0 << endl;
        return 0;
    }
    k -= zero;
    ll ans = 1e12;
    for(ll L=0; L<=k; L++){
        ll R = k-L;
        if(L<=(int)l.size() && R<=(int)r.size()){
            ll now;
            if(L==0){
                now = r[k-1];
            } 
            else if(R==0){
                now = abs(l[k-1]);
            }
            else{
                now = min(2*abs(l[L-1])+r[R-1],2*r[R-1]+abs(l[L-1]));
            }
            ans = min(ans,now);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4504
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

void rec(int d, long long val, vector<long long> &all)
{
	// 格納
	all.push_back(val);

	// 10桁打ち切り
	if (d == 10) return;

	int md = val % 10;
	// 次へ進む処理
	for (int i = -1; i <= 1; ++i)
	{
		md = val % 10 + i;
		if (md >= 0 && md <= 9) rec(d + 1, val * 10 + md, all);
	}

	return;
}

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

	int d = 0;
	vector<ll> all;
	for (int i = 1; i <= 9; ++i)
	{
		rec(1, i, all);
	}

	sort(all.begin(), all.end());
	cout << all.at(K - 1) << endl;

	return 0;
}

Measured memory_bytes: 5328
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

vector<ll> make_seq(ll N, ll A, ll B) {
    if (A + B - 1 > N) {
        return {};
    }
    if (A * B < N) {
        return {};
    }
    struct NumInfo {
        ll idx;
        ll number;
    };
    vector<ll> ans;
    vector<NumInfo> num_infos;
    for (ll i = 0; i < B; i++) {
        ans.push_back(-(ll)i * 1000000);
        num_infos.push_back(NumInfo{(ll)ans.size()-1, ans.back()});
        ll cnt = 0;
        while (N - ans.size() > B - i - 1 && cnt < A - 1) {
            ans.push_back(ans.back() + 1);
            num_infos.push_back(NumInfo{(ll)ans.size()-1, ans.back()});
            cnt++;
        }
    }
    sort(num_infos.begin(), num_infos.end(), [](NumInfo lhs, NumInfo rhs){ return lhs.number < rhs.number; });
    for (ll i = 0; i < num_infos.size(); i++) {
        NumInfo info = num_infos[i];
        ans[info.idx] = i + 1;
    }
    return ans;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> ans = make_seq(N, A, B);
    if (ans.empty()) {
        cout << -1 << endl;
    } else {
        for (ll i = 0; i < ans.size(); i++) {
            cout << ans[i];
            if (i < ans.size() - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}



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

using namespace std;

struct Interval {
    int i, j;
    Interval(): i(0), j(1000000010) {}
    Interval(int i, int j): i(i), j(j) {}
    Interval operator&(const Interval& o) const {
        int new_i = max(i, o.i);
        int new_j = min(j, o.j);
        return Interval(new_i, new_j);
    }
    int size() {
        return max(0, j - i);
    }
    bool operator<(const Interval& o) const {
        return j < o.j;
    }
    friend istream& operator>>(istream& in, Interval& interval) {
        in >> interval.i >> interval.j;
        ++interval.j;
        return in;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<Interval> intervals(n);
    for (auto& interval : intervals) {
        cin >> interval;
    }
    sort(intervals.begin(), intervals.end());
    vector<Interval> from_left(n+1), from_right(n+1);
    // from_left[i] = I_0 & I_1 & ... & I_{i-1}
    // from_right[i] = I_i & I_{i+1} & ... & I_{n-1}
    for (int i = 0; i < n; ++i) {
        from_left[i+1] = from_left[i] & intervals[i];
    }
    for (int i = n-1; i >= 0; --i) {
        from_right[i] = from_right[i+1] & intervals[i];
    }
    int best = 0;
    
    // all but one:
    for (int i = 0; i < n; ++i) {
        auto left = from_left[i];
        auto right = from_right[i+1];
        int total_size = (left & right).size() + intervals[i].size();
        best = max(best, total_size);
    }
    
    // first i
    for (int i = 1; i < n; ++i) {
        auto left = from_left[i];
        auto right = from_right[i];
        int total_size = left.size() + right.size();
        best = max(best, total_size);
    }
    
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 2560
N=int(input())
A=list(map(int,input().split()))
ans=1000
dp=[0]
for i in range(N-1):
  if A[i]<A[i+1]:
    dp.append(1)
  else:
    dp.append(0)
o=len(dp)
dp.append(0)
for i in range(o):
  if dp[i]==1 and dp[i+1]==0:
    dp[i]=2
  if dp[i]==0 and dp[i+1]==1:
    dp[i]=-1
p=0
for i in range(N):
  if dp[i]==-1:
    p=ans//A[i]
    ans=ans%A[i]
  if dp[i]==2:
    ans+=A[i]*p
    p=0
print(ans)

Measured memory_bytes: 8928
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Measured memory_bytes: 13216
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
map<int ,int> mp;
vi vr;
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);



int n=RD(),a;
set<int>st;
fr{
 a=RD();
 st.insert(a);
}
cout<<st.size()<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	int result = 0;
	int c1 = 0;
	int c2 = 0;
	int c3 = 0;

	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;

		for (int j = 0; j < s.size() - 1; j++)
		{
			if (s[j] == 'A' && s[j + 1] == 'B')
			{
				result++;
			}
		}

		if (s.front() == 'B' && s.back() == 'A') c1++;
		else if (s.front() == 'B') c2++;
		else if (s.back() == 'A') c3++;
	}

	if (c1 == 0)
	{
		result += min(c2, c3);
	}
	else
	{
		if (c2 == 0 && c3 == 0)
		{
			result += c1 - 1;
		}
		else
		{
			result += c1 + min(c2, c3);
		}
	}

	cout << result;

	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  ll x = 1;
  rep(i, n){
    if(a[i] == x){
      x++;
    }
  }
  x--;
  if(x == 0){
    print(-1);
    return 0;
  }
  print(n-x);
}


Measured memory_bytes: 1792
#include <cstdint>
#include <iostream>

using namespace std;

int main()
{
    int64_t r, d, x;
    cin >> r >> d >> x;

    for (auto i = 0; i < 10; i += 1) {
        x = r * x - d;
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll cnt[200010];
int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=n-1;i>=0;i--){
		if(s[i]=='.'){
			cnt[i]=1;
		}
	}
	for(ll i=n-2;i>=0;i--){
		cnt[i]=cnt[i]+cnt[i+1];
	}
	ll ans=cnt[0];
	ll ans1=0;
	for(ll i=0;i<n;i++){
		if(s[i]=='#'){
			ans1++;
		}
		ans=min(ans,ans1+cnt[i+1]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 2180