akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int main(){

	int n,k;
	while(cin >> n >> k && !(n == 0 && k == 0)){
		int card[100001];
		for(int i = 0; i < k; i++){
			cin >> card[i];
		}
		sort(card,card+k);

		int prv = -1;
		bool zero = false;
		vector<vector<int> > cruster;
		vector<int> elem;
		for(int i = 0; i < k; i++){
			if(card[i] == 0){
				zero = true;
				continue;
			}
			if(prv == -1 || prv + 1 == card[i]){
				prv = card[i];
				elem.push_back(card[i]);
				if(i == k - 1){
					cruster.push_back(elem);
					elem.clear();
					prv = -1;
				}
			}
			else{
				cruster.push_back(elem);
				elem.clear();
				prv = card[i];
				elem.push_back(prv);
			}
		}
		int maxSize = 0;
		for(int i = 0; i < cruster.size()-1; i++){
			if(zero && cruster[i][cruster[i].size()-1] + 2 == cruster[i+1][0]){
				maxSize = max(maxSize,(int)cruster[i].size() + (int)cruster[i+1].size() + 1);
			}
			maxSize = max(maxSize,(int)cruster[i].size());
		}
		maxSize = max(maxSize,(int)cruster[cruster.size()-1].size());
		cout << maxSize << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    map<ll, ll> mp;
    ll cnt = 0;
    rep(i, n) {
        cnt += mp[as[i] - i];
        mp[-as[i] - i]++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 27432
/* Binary tree 1 */
#include <stdio.h>
#include <stdlib.h>

struct node{
  
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
};

typedef struct node * Node;

#define NIL NULL

Node root;


/* 二分探索木Tに対してkeyがkのノードを挿入する関数 */
void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  /* 挿入するノードzを作成 */
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  /* zを挿入する場所を求める */
  while( x != NIL )
    {
      y = x;     /* 親を設定 */

      if( z->key < x->key )
	x = x->left;       /* 左の子に移動 */
      else
	x = x->right;      /* 右の子に移動 */
    }

  z->parent = y;           /* zの親を設定 */

  if( y == NIL )
    root = z;              /* Tが空の場合 */
  else if( z->key < y->key )
    y->left = z;           /* 左の子として挿入する場合 */
  else
    y->right = z;          /* 右の子として挿入する場合 */
}


/* 二分探索木Tを中間順巡回によって出力する関数 */
void inorder(Node u)
{
  if( u == NIL )
    return;

  inorder(u->left);       /* 左の子に進む */
  printf(" %d", u->key);
  inorder(u->right);      /* 右の子に進む */
}


/* 二分探索木Tを先行順巡回によって出力する関数 */
void preorder(Node u)
{
  if( u == NIL )
    return;
  
  printf(" %d", u->key);
  preorder(u->left);       /* 左の子に進む */
  preorder(u->right);      /* 右の子に進む */
}


int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
   
    if ( com[0] == 'i' )
      {
	scanf("%d", &x);
	insert(x);
      }
    else if ( com[0] == 'p' )
      {
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      }
  }

  return 0;
}



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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define pb          push_back
#define eb          emplace_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

ll dp[3001][3001][4];
int val[3000][3000];

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

    int r, c, k;
    cin >> r >> c >> k;
    rep(i, k) {
        int x, y, v;
        cin >> x >> y >> v;
        val[--x][--y] = v;
    }

    rep(i, r) {
        rep(j, c) {
            rep(k, 4) {
                dp[i + 1][j + 1][k] = max({
                    dp[i + 1][j][k],
                    dp[i][j + 1][0],
                    dp[i][j + 1][1],
                    dp[i][j + 1][2],
                    dp[i][j + 1][3]
                });
            }
            for (int k = 3; k > 0; k--) {
                dp[i + 1][j + 1][k] = max(
                        dp[i + 1][j + 1][k],
                        dp[i + 1][j + 1][k - 1] + val[i][j]
                        );
            }
        }
    }

    cout << max({dp[r][c][0],dp[r][c][1], dp[r][c][2], dp[r][c][3]});
}


Measured memory_bytes: 320064
#b
import sys
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
ren = 0
for i in d:
    
    if i[0]==i[1]:
        ren += 1
    else:
        ren = 0
    if ren == 3:
        print("Yes")
        sys.exit()
print("No")

Measured memory_bytes: 9176
#include <queue>
#include <cstring>
#include <iostream>
using namespace std;

const int MAXN = 1e3 + 5;

int n, m;
int sx, sy, tx, ty;
int ans[MAXN][MAXN];
int tox[10] = {0, 1, -1, 0, 0};
int toy[10] = {0, 0, 0, 1, -1};

char map[MAXN][MAXN];

bool vis[MAXN][MAXN];

int bfs ();

struct node {
	int x, y, val;
	node () {}
	node (int X, int Y, int VAL) {
		x = X, y = Y, val = VAL;
	}
};

bool operator < (const node &x, const node &y) {
	return x.val > y.val;
}

int main () {
	cin >> n >> m;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 1; i <= n; i++) {
		scanf ("%s", map[i] + 1);
	}
//	printf ("\n");
//	for (int i = 1; i <= n; i++) {
//		for (int j = 1; j <= m; j++) {
//			printf ("%c", map[i][j]);
//		}
//		printf ("\n");
//	}
//	printf ("\n");
	int ans = bfs ();
	if (ans == 0x3f3f3f3f) cout << "-1";
	else cout << ans;
}

int bfs () {
	memset (ans, 0x3f, sizeof ans);
	priority_queue <node > q; q.push ( node (sx, sy, 0)); ans[sx][sy] = 0;
	while (!q.empty ()) {
		node tem = q.top (); q.pop ();
		int x = tem.x, y = tem.y;
		if (vis[x][y] == 1) continue;
		for (int i = 1; i <= 4; i++) {
			int xx = x + tox[i], yy = y + toy[i];
			if (xx < 1 || xx > n) continue;
			if (yy < 1 || yy > m) continue;
			if (map[xx][yy] == '#') continue;
//			cout << xx << " " << yy << endl;
			if (ans[xx][yy] > ans[x][y]) {
				ans[xx][yy] = ans[x][y];
				q.push ( node (xx, yy, ans[xx][yy]));
			}
		}
		for (int i = x - 2; i <= x + 2; i++) {
			for (int j = y - 2; j <= y + 2; j++) {
				if (i < 1 || i > n) break;
				if (j < 1 || j > m) continue;
				if (map[i][j] == '#') continue;
//				cout << i << " " << j << endl;
				if (ans[i][j] > ans[x][y] + 1) {
					ans[i][j] = ans[x][y] + 1;
					q.push ( node (i, j, ans[i][j]));
				}
			}
		}
//		for (int i = 1; i <= n; i++) {
//			for (int j = 1; j <= m; j++)
//				printf ("%d ", ans[i][j]);
//			printf ("\n");
//		}
//		printf ("\n\n\n");
	}
	return ans[tx][ty];
}

Measured memory_bytes: 8580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll A, B, m;
  cin >> A >> B >> m;
  vl a(A);
  vl b(B);
  ll minia = INF;
  ll minib = INF;
  rep(i, A){
    cin >> a[i];
    chmin(minia, a[i]);
  }
  rep(i,B){
    cin >> b[i];
    chmin(minib, b[i]);
  }
  ll ans = minia + minib;
  rep(i, m){
    ll x, y, c;
    cin >> x >> y >> c;
    ll tmp = a[x - 1] + b[y - 1] - c;
    chmin(ans, tmp);
  }
  print(ans);
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
bool to_zero(string s, string sq, string dir, int pos) {
    if (pos == 0) return true;
    for(int i = 0; i < sq.size(); i++) { // O(q)
        if (s[pos] == sq[i]) {
            if (dir[i] == 'L')
                pos -= 1;
            else
                pos += 1;
            if (pos == 0)
                return true;
        }
    }
    return false;
}
bool to_N1(string s, string sq, string dir, int pos) {
    for(int i = 0; i < sq.size(); i++) { // O(q)
        if (s[pos] == sq[i]) {
            if (dir[i] == 'R')
                pos += 1;
            else
                pos -= 1;
            if (pos == s.length()-1) // N+2-1
                return true;
        }
    }
    if (pos == s.length()-1)
        return true;
    return false;
}
int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    s = "@" + s + "@";
    string sq, dir;
    char c1, c2;
    for(int i = 0; i < Q; i++) {
        cin >> c1 >> c2;
        sq += c1;
        dir += c2;
    }
    // find rightmost move to 0: binary search
    int l = 0, r = N; // edge case
    while (l < r) {
        int m = l + (r-l) / 2;
        if (to_zero(s, sq, dir, m) == true) {
            l = m;
            if (r == l+1) {
                r = (to_zero(s, sq, dir, r) == true) ? r : l;
                break;
            }
        } else {
            r = m-1;
        }
        // cout << "m = " << m << l << r << endl;
    }
    int ans = N - (r);
    // cout << "left: " << r << endl;
    // find leftmost move to N+1 : binary search
    l = 1, r = N+1; // edge case
    while (l < r) {
        int m = l + (r-l) / 2;
        if (to_N1(s, sq, dir, m) == false) {
            l = m+1;
        } else {
            r = m;
        }
    }
    // cout << "right:" << r << endl;
    ans -= (N-r+1);
    cout << max(ans, 0) << endl;

    return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
using namespace std;
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>())
#define FR(A, e) for (auto& e : A)
#define SHOW(A) for (auto& e : A) {cout << e << " ";}; cout << endl;
#define within(x,_left,_right) (_left <= x && x <= _right)
#define rwithin(x, _l, _r) (_l < x && x < _r)
#define ALL(A) A.begin(),A.end()
#define RALL(A) (A).rbegin(),(A).rend()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define sz(x) ((int)x.size())
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define bitcnt(x) (__builtin_popcountll(x))
#define fi first
#define se second
#define bg(A) A.begin()
#define ed(A) A.end()
#define rbg(A) A.rbegin()
#define red(A) A.rend()
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
const LL MOD = 1e9 + 7;
const LL LMAX = 0x7fffffffffffffff;
const LL LMIN = 0x8000000000000000;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::pair<int, char> PIC;
// int dx[4] = {1, -1, 0, 0}; // 冯诺依曼型邻居
// int dy[4] = {0, 0, 1, -1};
// int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; // 摩尔型邻居
// int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
// #include<iomanip> cout << fixed <<  setprecision(k) 输出k位精度

const int N = 2e5 + 50;
int arr[N];

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

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

    LL res = 0;
    sort(arr, arr + n, greater<int>());
    if (n & 1){
        for (int i = 0; i < (n / 2) + 1; ++ i){
            res += (1LL * 2 * arr[i]);
        }
        res -= (arr[0] + arr[(n / 2)]);
    }else {
        for (int i = 0; i < n / 2; ++ i){
            res += 1LL * 2 * arr[i];
        }
        res -= arr[0];
    }
    
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


string s;
int x, y;
int tx, ty;
int cx[8010], cy[8010];
bool dpx[8010][2][8010];
bool dpy[8010][2][8010];


int sign(int x){
	return x >= 0 ? 0 : 1;
}


void makeDP(){
	int n = SIZE(s);
	int t = 0;
	rep(i, 0, n){
		int d = 0;
		while(s[i] != 'T' && i < n) i++, d++;
		if(t%2 == 0) cx[tx] = d, tx++;
		else cy[ty] = d, ty++;
		t++;
	}
	dpx[0][0][cx[0]] = true;
	dpy[0][0][cy[0]] = dpy[0][cy[0] ? 1 : 0][cy[0]] = true;
	rep(i, 1, tx)
		repe(j, -n, n)
			if(dpx[i-1][sign(j)][abs(j)]) dpx[i][sign(j+cx[i])][abs(j+cx[i])] = dpx[i][sign(j-cx[i])][abs(j-cx[i])] = true;
	rep(i, 1, ty)
		repe(j, -n, n)
			if(dpy[i-1][sign(j)][abs(j)]) dpy[i][sign(j+cy[i])][abs(j+cy[i])] = dpy[i][sign(j-cy[i])][abs(j-cy[i])] = true;
}


signed main(){
	cin >> s;
	cin >> x >> y;

	makeDP();

	if(dpx[max(tx-1, 0)][sign(x)][abs(x)] && dpy[max(ty-1, 0)][sign(y)][abs(y)]) Yes;
	else No;

	return 0;
}

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

int main(void)
{
    int K;
    int ans = 0;
    int odd, even;
    cin >> K;
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j < i; j++)
        {
            if (i % 2 == 0 && j % 2 == 1)
            {
                ans += 1;
            }
            else if (i % 2 == 1 and j % 2 == 0)
            {
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//{{{
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
// clang-format off
void _print() { cerr << "]\033[0m\n"; }
template <typename T> void __print(T x) { cerr << x; }
template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifdef LOCAL
#define debug(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m["; _print(x)
#define debug_arr(x...) cerr << "\033[1;34m[" << #x << "] = \033[1;32m" << (x) << "\033[0m\n"
#else
#define debug(x...)
#define debug_arr(x...)
#endif
// clang-format on
//}}}

int T;

const int N = 5e3 + 10;

const LL inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;

int n, k;

LL p[N], c[N];
LL sum[N], cnt[N];
bool vis[N];

LL func(int pos)
{
    LL t = k;
    LL ret = 0;

    if (t > 10 * cnt[pos])
    {
        if (sum[pos] > 0)
        {
            LL d = t / cnt[pos];
            assert(d >= 10);
            d -= 10;
            ret += d * sum[pos];
            t -= cnt[pos] * d;
        }
        else
            t = cnt[pos];
    }

    // if (sum[pos] > 0)
    //{
    // ret += t / cnt[pos] * sum[pos];
    // t = t % cnt[pos];
    //}
    // else
    //{
    // t = t % cnt[pos];
    // if (t == 0) t = cnt[pos];
    //}

    // if (t == 0) return ret;

    int cur = pos;
    LL val = c[p[cur]];
    cur = p[cur];

    LL v = val;
    for (int i = 2; i <= t; i++)
    {
        int nxt = p[cur];
        v += c[nxt];
        val = max(val, v);
        cur = nxt;
    }
    ret += val;

    return ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (cin >> n >> k)
    {
        for (int i = 1; i <= n; ++i) cin >> p[i];
        for (int i = 1; i <= n; ++i) cin >> c[i];

        clr(vis, false);
        for (int i = 1; i <= n; i++)
        {
            if (vis[i] == true) continue;

            set<int> st;
            LL cur = i;
            LL v = c[p[cur]];
            st.insert(p[cur]);

            cur = p[cur];

            for (int a = 2; a <= 2 * n; a++)
            {
                int nxt = p[cur];
                if (st.find(nxt) != st.end())
                {
                    break;
                }
                assert(a < n + 1);
                v += c[nxt];
                st.insert(nxt);
                cur = nxt;
            }

            for (auto idx : st)
            {
                vis[idx] = true;
                cnt[idx] = st.size();
                sum[idx] = v;
            }
        }

        LL ans = func(1);
        for (int i = 2; i <= n; i++)
        {
            LL v = func(i);
            ans = max(ans, v);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3980
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main()
{
	cio;
	int a, b, c, k;

	cin >> a >> b >> c;
	cin >> k;

	int i = 0;

	while (a >= b)
	{
		b *= 2;
		i++;
	}

	while (b >= c)
	{
		c *= 2;
		i++;
	}

	if (i <= k)
		cout << "Yes";
	else
		cout << "No";
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 N;
  vector< int64 > T(5);
  cin >> N;
  cin >> T;
  int64 V = *min_element(begin(T), end(T));
  cout << 4 + (N + V - 1) / V << endl;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=1;i<=n;i++)
#define endl   "\n"







int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int  a,b,c;

    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;



    







}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static String[] nums = sc.nextLine().split(" ");

	static int N = Integer.parseInt(nums[0]);
	static int M = Integer.parseInt(nums[1]);
	static char[][] room = new char[N][M];
	static int D = Integer.parseInt(nums[2]);
	static int num = 0;
	public static void main(String[] args) {
		inputRoom();

			if ( M >= D) {
				setWE();
			}

			if ( N >= D) {
				setNS();
			}

		System.out.println(num);
		sc.close();

	}
	private static void setWE() {
		boolean canPut = true;

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M - D + 1; j++) {
				canPut = true;

				for(int k = 0; k < D; k++){
					if (Main.room[i][j + k] == '#') {
						canPut = false;
						break;
					}
				}

				if (canPut == true) {
					num++;
				}

			}
		}


	}

	private static void setNS() {
		boolean canPut = true;

		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N - D + 1; j++) {
				canPut = true;

				for(int k = 0; k < D; k++){
					if (Main.room[j + k][i] == '#') {
						canPut = false;
						break;
					}
				}

				if (canPut == true) {
					num++;
				}

			}
		}


	}


	private static void inputRoom() {
		String str_room = "";

			for (int i = 0; i < N; i++) {
					str_room = sc.nextLine();
					Main.room[i] = str_room.toCharArray();
			}

	}

}



Measured memory_bytes: 27708
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    vector<int> v(N, 0);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;

        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;

            A--;
            v[A]++;
        }
    }

    int ans = count(v.begin(), v.end(), 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int x, y, z, k;
vector<ll> a, b, c;


void solve() {
    
    vector<ll> ans;
    
    vector<ll> tmp;
    rep(i, x) rep(j, y) tmp.eb(a[i] + b[j]);
    sort(all(tmp), greater<ll>());
    // outa(tmp, x * y);
    
    sort(all(c), greater<ll>());
    rep(i, min(x * y, k)) rep(j, min(z, k)) ans.eb(tmp[i] + c[j]);
    sort(all(ans), greater<ll>());
    
    rep(i, k) out(ans[i]);
}

void init(int xx, vector<ll>& aa) {
    aa.resize(xx);
    rep(i, xx) cin >> aa[i];
    // sort(all(aa), greater<ll>());
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> x >> y >> z >> k;
    init(x, a);
    init(y, b);
    init(z, c);
    
    solve();
    
}


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

int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int a=0;
  rep(i, 3)
  {
    if(s[i]==t[i]){
      a++;
    }
  }
  cout << a;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {

	int N; cin >> N;
	vector<long long> A(N), X(N, 0);
	for (int i = 0; i < N; i++)cin >> A[i];
	long long sum = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)sum += A[i];
		else sum -= A[i];
	}
	X[0] =sum;
	long long x = sum/2;
	for (int i = 1; i < N; i++) {
		X[i] = 2 * (A[i-1]-x);
		x = A[i-1] - x;
	}
	for (int i = 0; i < N; i++)cout << X[i] <<" ";
}





Measured memory_bytes: 2816
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i

aaa = [ X / 500, A ].min
ccc = [ X / 50, C ].min

count = 0
(aaa+1).times do |a|
  bbb = [ (X-500*a) / 100, B ].min
  (bbb+1).times do |b|
    ccc = [ (X-500*a-100*b) / 50, C ].min
    (ccc+1).times do |c|
      if (500 * a) + (100 * b) + (50 * c) == X
        count += 1
      end
    end
  end
end

p count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,f=0;
  cin >> n;
  for(int i = 1; i < n + 1;i++)
  {
      int m = i * 1.08;
      if(m == n)
      {
          f = i;
          break;
      }
  }
  if(f > 0) cout << f << endl;
  else cout << ":(" << endl;;
  return 0;
}


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

int mod = 1000000007;

int main()
{
    string S, x, y, z;
    cin >> S;
    x = S;
    reverse(x.begin(), x.end());
    y = S.substr((S.size() + 2) / 2);
    z = y;
    reverse(z.begin(), z.end());

    cout << (S == x && y == z ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
int N,*H,max=0,c=0,co=0,s=0;

cin >> N;

H = (int*)malloc(sizeof(int) * N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    while(c < N){
        co = c;
        s=0;
        while(H[co] >= H[co+1] && co < N-1){
            s++;
            co++;
        }
        if(max < s){
            max = s;
        }
        if(max >= N-c) break;
        c++;
    }
    cout << max;
    return 0;

}

Measured memory_bytes: 640
import Control.Monad
import Control.Applicative
import Data.List

-- e.g.
-- 1
-- [a] <- map read . words <$> getline => [1] -> a == 1
-- 1
-- a <- readlLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'

main :: IO()
main = do
  c <- getChar
  let ans = case c of
              'A' -> 'T'
              'G' -> 'C'
              'T' -> 'A'
              'C' -> 'G'

  putStrLn [ans]


Measured memory_bytes: 380
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <stack>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int a[N+1];
	rep(i, N)
	{
		cin >> a[i];
	}
	int l[N], r[N];
	memset(l, 0, sizeof(l));
	memset(r, 0, sizeof(r));
	
	stack<int> s;
	s.push(0);
	for(int i = 0; i < N; i++)
	{
		while(!s.empty() && (a[s.top()] >= a[i]))
		{
			s.pop();
		}
		if (!s.empty())
		{
			l[i] = s.top()+1;
		}
		else
		{
			l[i] = 0;
		}
		
		s.push(i);
	}

	while(!s.empty())
	{
		s.pop();
	}
	a[N] = N+1;
	s.push(N);
	for(int i = N-1; i >= 0; i--)
	{
		while(!s.empty() && (a[s.top()] <= a[i]))
		{
			s.pop();
		}
		if (!s.empty())
		{
			r[i] = s.top();
		}
		else
		{
			r[i] = i+1;
		}
		
		s.push(i);
	}

	ll ans = 0;
	rep(i, N)
	{
		cout << i << "; l=" << l[i] << "; r=" << r[i] << endl;
		ans += 1ll * (i - l[i] + 1) * (r[i] - i + 1) * a[i];
	}

	cout << ans << endl;
	
	return 0;
}
#endif
const int N=200000+19;
int S[N],A[N],l[N],r[N];
int n,top;
ll res;
 
int main(){
	cin >> n;
	for(int i = 1; i < n+1; i++) 
	{
		cin >> A[i];
	}
	S[top=1]=0;
	for (int i=1;i<=n;i++){
		while (A[i]<A[S[top]]) top--;
		l[i]=S[top];
		S[++top]=i;
	}
	S[top=1]=n+1;
	for (int i=n;i>=1;i--){
		while (A[i]<A[S[top]]) top--;
		r[i]=S[top];
		S[++top]=i;
	}
	for(int i=1; i < n+1; i++){
		res+=1ll*A[i]*(i-l[i])*(r[i]-i);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	
	double sit_h=0,sit_m=0;
	
	sit_h+=360*((double)h/12);
	
	sit_m+=360*((double)m/60);
	
	sit_h+=(360/12)*((double)m/60);
	
	double sit=max(sit_h,sit_m)-min(sit_h,sit_m);
	if(sit>180)sit=360-sit;

	double ans=(a*a)+(b*b)-2*a*b*cos(sit/180*M_PI);
	cout << fixed << setprecision(20) << sqrt(ans) << endl;
	return 0;
}



Measured memory_bytes: 4224
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		HashMap<Integer, String> map = new HashMap<>();
		map.put(25, "Christmas");
		map.put(24, "Christmas Eve");
		map.put(23, "Christmas Eve Eve");
		map.put(22, "Christmas Eve Eve Eve");
		out.println(map.get(inint()));
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

}

Measured memory_bytes: 20820
(* O(n log n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let p = ref @@ -1
let xys = ref []
let _ =
  Array.sort (-) a_s;
  let i = ref 0 in while !p < 0 && !i < n do if a_s.(!i) >= 0 then p := !i; incr i done;
  if !p = -1 then p := n - 1
  else if !p = 0 then p := 1;
  for i = !p to n - 2 do
    xys := (a_s.(0), a_s.(i)) :: !xys;
    a_s.(0) <- a_s.(0) - a_s.(i)
  done;
  for i = 0 to !p - 1 do
    xys := (a_s.(n - 1), a_s.(i)) :: !xys;
    a_s.(n - 1) <- a_s.(n - 1) - a_s.(i)
  done;
  Printf.printf "%d\n" a_s.(n - 1);
  List.rev !xys |> List.iter @@ fun (x, y) -> Printf.printf "%d %d\n" x y

Measured memory_bytes: 13056
#include<iostream>

using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a > b)swap(a, b);
  if(a<= c && c <= b){
    cout << "Yes" <<endl;
  }
  else cout << "No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n,m;
    int x;
    int k;
	cin >> n>> m;
    int sw[m][n];
    int jou[m];
    int ans=0;
    bool flag;
    int nishin[n];
    fr(i,m){
      fr(j,n){
        sw[i][j]=0;
      }
    }
    fr(i,m){
      cin >> k;
      fr(j,k){
        cin >> x;
        
        sw[i][x-1]=1;
        
      }
    }
    int p[m];
    fr(i,m){
      cin>>p[i];
    }
    
    fr(i,int(pow(2,n))){
      int z = i;
      flag=true;
      fr(j,m){
       jou[j]=0;
      }
      
      fr(j,n){
        nishin[j]=z%2;
        z = z/2;
      }
      fr(j,n){
        fr(k,m){
          jou[k]+=nishin[j]*sw[k][j];

        }
      }
      fr(j,m){
        if(jou[j] % 2 != p[j])flag=false;
      }
      if(flag==true)ans+=1;
    }
      cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

inline int max(int a,int b){ return a>b?a:b; }

const int N=1e5+5;

int n,L[N],R[N],id[N],pre[N],suf[N],ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&L[i],&R[i]);
	for(int i=1;i<=n;++i) id[i]=i;
	std::sort(id+1,id+1+n,[](int a,int b){ return R[a]<R[b]; });
	for(int i=1;i<=n;++i) pre[i]=max(pre[i-1],L[id[i]]);
	for(int i=n;i>=1;--i) suf[i]=max(suf[i+1],L[id[i]]);
	for(int i=2;i<=n;++i){
		ans=max(ans,max(0,R[id[1]]-max(pre[i-1],suf[i+1])+1)+R[id[i]]-L[id[i]]+1);
		ans=max(ans,max(0,R[id[1]]-pre[i-1]+1)+max(0,R[id[i]]-suf[i]+1));
	}
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  // 明かりがついているか
  // 1なら点灯している、0なら消えている
  int light[N];
  for(int i = 0; i < N; i++){
    light[i] = 0;
  }
  light[0] = 1;
 
  // ボタンの情報
  int btn[N];
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    btn[i] = a;
  } 
  //次に押すボタン、最初はボタン1を押すので、初期値は1
  int next = 1;
  
  for(int i = 0; i < N; i++){
    // 明かりがついている場合
    if(light[next - 1] == 1){
      next = btn[next - 1];
      light[next-1] = 1;
      if(next == 2){
        cout << i + 1<< endl;
        exit(0);
      }
    // 明かりがついていない場合
    }else{
      next = btn[next - 1];
    }
  }
  cout << "-1" << endl;
}

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

using namespace std;


void solve() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << ' ' << x  << ' '<<y;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <cstdlib>
# include <stack>
 
using namespace std;
 
int main() {
    string t;
    stack<int> s;
    while (cin >> t) {
        if (t == "+") {
            int op1 = s.top(); s.pop();
            int op2 = s.top(); s.pop();
            int ans = op2 + op1;
            s.push(ans);
        }
        else if (t == "-") {
            int op1 = s.top(); s.pop();
            int op2 = s.top(); s.pop();
            int ans = op2 - op1;
            s.push(ans);
        }
        else if (t == "*") {
            int op1 = s.top(); s.pop();
            int op2 = s.top(); s.pop();
            int ans = op2 * op1;
            s.push(ans);
        }
        else {
            s.push(atoi(t.c_str()));
        }
    }
    cout << s.top() << endl;
    return 0;
}



Measured memory_bytes: 3216
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
maxa = max(a)
a_s = set(a)
s = set()
s1 = set()
same_s = set()
ans = 0
for i in a:
    if i in s1:
        same_s.add(i)
    if i not in s:
        s1.add(i)
        for j in range(i, maxa+1, i):
            s.add(j)
        ans += 1

print(ans - len(same_s))


Measured memory_bytes: 119612
#include <iostream>
using namespace std;
 int A[120];
    int N;
int main() {
  
    cin >> N;
    bool x = true;
    for(int i = 0;i<N;i++) cin >> A[i];
    for(int i = 0;i<N;i++){
      if(A[i] % 2==0){
        if(A[i] % 3 == 0||A[i] % 5 == 0 ){
        }else{
          x = false; 
          break;
        }
      }
    }
      if(x == true){
    cout << "APPROVED" << endl;
}else{
    cout << "DENIED" << endl;
  }
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int a, b, t;
    cin >> a >> b >> t;
    cout << t/a*b << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
int n,a[100100];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
bool solve(){
	int s=0;
	for(int i=1;i<=n;i++) s+=~a[i]&1;
	if(s&1) return 1;
	if(n-s>1) return 0;
	int g=0;
	for(int i=1;i<=n;i++){
		if(a[i]==1) return 0;
		g=gcd(g,a[i]&-2);
	}
	for(int i=1;i<=n;i++) a[i]/=g;
	return !solve();
}
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	if(solve()) puts("First");
	else puts("Second");
	return 0;
}


Measured memory_bytes: 768
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL long long
#define ll long long
#define LD double

#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
const ll N = 1e5 + 5, mod = 1e9 + 7;
ll x, y, n, k, out = 1;
vector<int> v[N];

void dfs(int u, int p = -1, ll cur = k) {
    out = (out * cur) % mod;

    ll ps = 0;
    for (int i = 0; i < v[u].size(); i++)
        if (v[u][i] != p) {
            dfs(v[u][i], u, k - 1 - ps - (p != -1));
            ps++;
        }
}

int main() {
    HabdModeActive

    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1);
    cout << out;


    return 0;
}

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int puni[101]{};
	puni[a]++;
	puni[b]--;
	puni[c]++;
	puni[d]--;
	for(int i = 1; i < 101; i++) puni[i] += puni[i - 1];
	int ans = 0;
	for(int i = 0; i < 101; i++) if(puni[i] == 2) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll rd(dl x)
{

        if((ll)x==x)
            return (ll)x;
        else
            return ((ll)x);
}


int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,k,i,j,l,u,v,x,y,a,b,c,d;
    cin >> n;
    vector<ll> V(n);
    CIN(V,0,n);
    ll counter=0;
    for(i=1;i<n-1;i++)
    {
        if((V[i]>V[i+1]and V[i] < V[i-1]) or(V[i]>V[i-1] and V[i] <V[i+1]))
            counter++;
    }
    cout << counter;
}
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    MOD = 1000000007
    N, *A = map(int, read().split())
    seq = [-1] * 3
    ans = 1
    try:
        for a in A:
            ans = ans * seq.count(a - 1) % MOD
            seq[seq.index(a - 1)] = a
        print(ans)
    except:
        print(0)
        
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14068
#include <stdio.h>


int main(void){
  int a, b;

  scanf("%d %d",&a,&b);

  int c = a + b;

  if(a % 3 == 0 || b % 3 == 0 || c % 3 == 0)
    printf("Possible\n");
  else
    printf("Impossible\n");

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int H, N, ans;
    scanf("%d %d", &H, &N);
    vector<int> A(N), B(N);
    REP(int,i,0,N){
        scanf("%d %d", &A.at(i), &B.at(i));
    }
    vector<int> dp(H+1);
    dp.at(0) = 0;
    REP(int,h,1,H+1){
        dp.at(h) = INT_MAX;
        REP(int,i,0,N){
            int prev = max(0, h-A.at(i));
            dp.at(h) = min(dp.at(h), dp.at(prev)+B.at(i));
        }
    }
    ans = dp.at(H);
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

template<typename T>
vector<T> sieve(T n) {
    vector<T> minf(n + 1, -1);
    minf[0] = 0;
    minf[1] = 1;
    for (T i = 2; i <= n; i++) {
        if (minf[i] != -1) continue;
        minf[i] = i;
        for (T j = 2 * i; j <= n; j += i) {
            if (minf[j] == -1) minf[j] = i;
        }
    }
    return minf;
}

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

    vector<int> minf = sieve(1000000);

    int n;
    cin >> n;

    bool is_pair = true;
    int all_g = 0;
    vector<int> used(1000001, n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (all_g == 0) all_g = a;
        else all_g = __gcd(all_g, a);

        if (!is_pair) continue;

        while (a > 1) {
            if (used[minf[a]] < i) {
                is_pair = false;
                break;
            }

            used[minf[a]] = i;
            a /= minf[a];
        }
    }
    cout << (is_pair ? "pairwise coprime" : (all_g == 1 ? "setwise coprime" : "not coprime")) << newl;

    return 0;
}

Measured memory_bytes: 11092
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class rec_lambda {
  F f;

public:
  rec_lambda(F &&f) : f(std::move(f)) {}
  template <class... Args> auto operator()(Args &&... args) const {
    return f(*this, std::forward<Args>(args)...);
  }
};
template <class F> auto make_rec(F &&f) { return rec_lambda<F>(std::move(f)); }
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}
constexpr char eoln = '\n';

} // namespace n91

#include <cassert>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u64 k = scan<u64>();
  const u64 n = 50;
  std::vector<u64> ans(n, n - 1);

  for (const usize i : rep(0, n)) {
    ans[i] += (n + 1) * (k / n);
  }
  for (const usize i : rep(0, k % n)) {
    ans[i] += n + 1;
  }
  for (auto &e : ans) {
    assert(e >= k);
    e -= k;
  }

  std::cout << n << eoln;
  for (const usize i : rep(0, n)) {
    if (i)
      std::cout << " ";
    std::cout << ans[i];
  }
  std::cout << eoln;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=1000+10,maxn=60000+10,inf=0x3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    ll ans1=1,ans2=-1;
    for(ll i=0;i<=40;i++)
    {
        for(ll j=0;j<=40;j++)
        {
            for(ll k=0;k<=300;k++)
            {
                for(ll l=0;l<=300;l++)
                {
                    if((i*a+j*b)*100+k*c+l*d>f)break;
                    if((i*a+j*b)*e<k*c+l*d)break;
                    ll te1=(i*a+j*b)*100+k*c+l*d;
                    ll te2=k*c+l*d;
                    if(te1*ans2<te2*ans1)
                    {
                        ans1=(i*a+j*b)*100+k*c+l*d;
                        ans2=k*c+l*d;
                    }
                }
            }
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}
/********************

********************/


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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) cout << a - 1 << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256