akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[1000], b[1000];
signed main(){
  int n, m, x, y;
  scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
  rep(i,n)scanf("%lld", &a[i]);
  rep(i,m)scanf("%lld", &b[i]);
  sort(a, a+n);sort(b, b+m);
  int mn = a[n-1], mx = b[0];
  int ans = 0;
  // printf("%lld %lld\n", mn, mx);
  repi(i,mn+1,mx+1){
    if(x < i and i <= y)ans = 1;
  }
  printf("%s\n", ans ? "No War" : "War");
	return 0;
}








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

int main() {
  long long H, N, x = 0;
  cin >> H >> N;
  string a = "Yes";
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (long long i = 0; i < N; i++) {
    x += A.at(i);
  }
  if (x < H) {
    a = "No";
  }
  cout << a << endl;
}

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

using namespace std;

const int INF = 1000000000;

void Main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N, vector<int>(N, INF));
    vector<pair<pair<int, int>, int>> edges;
    for (int i = 0; i < M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        graph[a][b] = c;
        graph[b][a] = c;
        edges.push_back(make_pair(make_pair(a, b), c));
    }
    for (int i = 0; i < N; ++i) {
        graph[i][i] = 0;
    }

    vector<vector<int>> minPath = graph;
    for (int k = 0; k < N; ++k) {
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                minPath[i][j] = min(minPath[i][j], minPath[i][k] + minPath[k][j]);
            }
        }
    }

    int ans = 0;
    for (auto e : edges) {
        int a = e.first.first;
        int b = e.first.second;
        int c = e.second;
        bool found = false;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                if (minPath[i][j] == minPath[i][a] + c + minPath[b][j]) {
                    found = true;
                }
            }
        }
        if (!found) {
            ++ans;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


void solve(long long N){
    vector<vector<ll>> cnt(10, vector<ll>(10));
    for (ll i = 1; i <= N; i++) {
        string s = to_string(i);
        cnt[s.front()-'0'][s.back()-'0']++;
    }
    ll ret=0;
    for (ll i = 0; i <= 9; i++) {
        for (ll j = 0; j <= 9; j++) {
            ret += cnt[i][j]*cnt[j][i];
        }
    }
    cout << ret << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
num = $stdin.gets.chomp.to_i
max_id  = -1
max_num = -1 
1.upto( num ){
	list = $stdin.gets.chomp.split( /\s/ ).map{ |e| e.to_i }
	#p list
	if max_num < list[ 1 ]
		max_id  = list[ 0 ]
		max_num = list[ 1 ]
	elsif max_num == list[ 1 ]
		if max_id > list[ 0 ]
			max_id = list[ 0 ]
		end
	end
}
puts "#{max_id} #{max_num}"


Measured memory_bytes: 6100
// #include <iostream>
#include <stdio.h>
// #include <cmath>

using namespace std;


int main(void){
    
    for(int i = 1; i < 10; i++ ){
        for(int j = 1; j < 10; j++ ){
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}


Measured memory_bytes: 2656
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

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

const int N = 100005;
const int mod = 998244353;

int res;
int f[N], g[N];
int prd[N * 3], inv[N * 3];

int C(int n, int k) {
	if (k < 0) return n < 0;
	return 1LL * prd[n] * inv[n - k] % mod * inv[k] % mod; 
}

int pw(int x, int y) {
	if (!y) return 1;
	int ret = pw(x, y >> 1); ret = 1LL * ret * ret % mod;
	if (y & 1) ret = 1LL * ret * x % mod; return ret;
}

void solve(int n, int m, string a, string b, string c, string d) {
	int cntc, cntd;
	cntc = cntd = 0;
	for (int i = 1; i <= m; ++i) {
		cntc += c[i] == '1', cntd += d[i] == '1';
	}
	f[1] = g[n] = 1;
	int cnta, cntb;
	cnta = cntb = 0;
	for (int i = 1; i < n; ++i) {
		cnta += a[i] == '1', cntb += b[i] == '1';
		f[i + 1] = C(cnta + cntb + cntc - 1, cntc - 1);
	}
	cnta = cntb = 0;
	for (int i = n; i > 1; --i) {
		cnta += a[i] == '1', cntb += b[i] == '1';
		g[i - 1] = C(cnta + cntb + cntd - 1, cntd - 1);
	}
	int sum = 0, cur = 1;
	for (int i = n; i >= 1; --i) {
		int cnt = 0;
		cnt += a[i] == '1', cnt += b[i] == '1';
		if (!cnt) continue;
		cur = cur * cnt % mod;
		sum = (sum + 1LL * cur * f[i]) % mod;
	}
	for (int i = n; i >= 1; --i) {
		int cnt = 0;
		cnt += a[i] == '1', cnt += b[i] == '1';
		if (!cnt) continue;
		res = (res + 1LL * sum * g[i]) % mod;
		sum = (sum - 1LL * cnt * f[i]) % mod;
		if (sum < 0) sum += mod;
		sum = 1LL * sum * pw(cnt, mod - 2) % mod;
	}
}

int main() {
	ios::sync_with_stdio(false);
	prd[0] = inv[0] = 1;
	for (int i = 1; i < 3 * N; ++i) {
		prd[i] = 1LL * i * prd[i - 1] % mod;
		inv[i] = pw(prd[i], mod - 2);
	}
	int n, m;
	string a, b, c, d;
	cin >> n >> m;
	cin >> a >> b >> c >> d;
	bool have = 0;
	a = " " + a, b = " " + b, c = " " + c, d = " " + d; 
	for (int i = 1; i <= n; ++i) {
		have |= a[i] == '1' || b[i] == '1';
	}
	for (int i = 1; i <= m; ++i) {
		have |= c[i] == '1' || d[i] == '1';
	}
	if (!have) {
		cout << 1; return 0;
	}
	solve(n, m, a, b, c, d);
	solve(m, n, c, d, a, b);
	cout << res; 
}

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

using namespace std;

const int ASIZE = 26;

void inc(char& c) {
  if (c == 'z')
    c = 'a';
  else
    ++c;
}

void try_set_a(char& c, int& k) {
  if (c == 'a')
    return;

  int need = 'z' - c + 1;
  if (k < need)
    return;
  k -= need;
  c = 'a';
}

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

  string s;
  int k;
  cin >> s >> k;

  int n = s.length();
  for (int i = 0; i < n; ++i)
    try_set_a(s[i], k);

  if (k > 0) {
    k %= ASIZE;
    while (k) {
      inc(s[n - 1]);
      --k;
    }
  }

  cout << s << endl;

  return 0;
}


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

using namespace std;

const int INF = 0x3f3f3f3f;

int n, m;
int w[100021], v[100021];
int sv;
int dp[121][100021];
int ans;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &w[i], &v[i]);
        sv += v[i];
    }
    for (int i = 1; i <= sv; ++i) {
        if (i == v[1]) {
            dp[1][i] = w[1];
            ans = v[1];
            continue;
        }
        dp[1][i] = INF;
    }
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j <= sv; ++j) {
            if (j < v[i]) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            if (dp[i][j] <= m)
                ans = j;
        }
    }
    // for (int i = 1; i <= n; ++i) {
    //     for (int j = 1; j <= sv; ++j) {
    //         printf("%d ", dp[i][j]);
    //     }
    //     printf("\n");
    // }
    printf("%d\n", ans);
    return 0;
}

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

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    ll n, k;
    cin >> n >> k;
    cout << modpow(k, n) << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
pair<int,int>a[214514];
int ans[214514];
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].first;
    }
    for(int j=0;j<n;j++){
        a[j].second=j;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
    	if(i<n/2)ans[a[i].second]=a[n/2].first;
    	else ans[a[i].second]=a[n/2-1].first;
    }
    for(int i=0;i<n;i++){
    	cout<<ans[i]<<endl;
    }			
}


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

mt19937_64 mt(4329702433LL);

const ll INF = 1e2;

const ld eps = 1e-10;

int get_rank(vector<vector<ld>> mat) {
	const int n = mat.size();
	int pos = 0;
	for (int i = 0; i < n; i++) {
		int it = pos;
		for (int j = pos; j < n; j++) {
			if (abs(mat[j][i]) > abs(mat[it][i])) it = j;
		}
		if (it != pos) swap(mat[pos], mat[it]);
		if (abs(mat[pos][i]) < eps) continue;
		for (int j = pos + 1; j < n; j++) {
			ld v = mat[j][i] / mat[pos][i];
			mat[j][i] = 0;
			for (int k = i + 1; k < n; k++) {
				mat[j][k] -= mat[pos][k] * v;
			}
		}
		++pos;
	}
	return pos;
}

int max_matching(const vector<vector<int>>& G) {
	const int n = G.size();
	vector<vector<ld>> mat(n, vector<ld>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) if (G[i][j]) {
			ll e = mt() % INF + 1;
			if (mt() % 2) e = -e;
			mat[i][j] = e;
			mat[j][i] = -e;
		}
	}
	return get_rank(move(mat));
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N, M;
	cin >> N >> M;
	vector<vector<int>> pos(N);
	for (int i = 0; i < M; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int v;
			cin >> v; --v;
			pos[v].push_back(i);
		}
	}
	vector<int> fl(M);
	int res = 0, ad = 0;
	for (int i = 0; i < N; i++) {
		if (pos[i].size() == 1) {
			if (fl[pos[i][0]] == 0) {
				fl[pos[i][0]] = 1;
				++ad;
			}
		}
		else if (pos[i].size() == 0) {
			++res;
		}
	}
	vector<vector<int>> G(M + ad, vector<int>(M + ad));
	for (int i = 0, j = M; i < M; i++) if (fl[i]) {
		G[j][i] = G[i][j] = 1;
		++j;
	}
	for (int i = 0; i < N; i++) {
		if (pos[i].size() == 2) {
			int u = pos[i][0], v = pos[i][1];
			G[u][v] = G[v][u] = 1;
		}
	}
	res += max_matching(G) / 2;
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 11820
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    // cout << ((n>3 && (!(n%7) || !(n%4) || !((n%7)%4)))? "Yes" : "No") << endl;

    for ( int cake_i = 0; cake_i <= n/4; cake_i++) {
        for (int donut_i = 0; donut_i <= n/7; donut_i++) {
            if  (n == cake_i * 4 + donut_i * 7 ){
                cout << "Yes" <<endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

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

  int sum = 0;
  rep(i,N.length()) {
    sum += N[i] - '0';
    sum %= 9;
  }

  cout << (sum == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h> 
#include <cstdio>
#include <string>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> c(n, 0);
    vector<int> v(n, 0);
    int g = 0, w = 0;
    int t;
    string r;
    for(int i = 0; i < m; i++){
        cin >> t >> r;
        if(r == "WA"){
            if(c[t-1] == 0){
                v[t-1] += 1;
            } 
        }
        else{
            if(c[t-1] == 0){
                c[t-1] += 1;
                g++;
                w += v[t-1];
            }
        }
    }
    cout << g << " " << w;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3

from pprint import pprint
import heapq
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N, M, source = map(int, input().split())
adj_list = [[] for v in range(N)]
for _ in range(M):
    u, v, w = map(int, input().split())
    adj_list[u].append([v, w])
# pprint(adj_list)


def dijkstra(n_nodes, adj_list, source):
    dist = [0 if v == source else INF for v in range(n_nodes)]
    priority_queue = [[dist[source], source]]

    while priority_queue:
        current_distance, current = heapq.heappop(priority_queue)
        if current_distance > dist[current]:
            continue
        for neighbor, distance in adj_list[current]:
            if current_distance + distance < dist[neighbor]:
                dist[neighbor] = current_distance + distance
                heapq.heappush(priority_queue, [dist[neighbor], neighbor])

    return dist


dist = dijkstra(N, adj_list, source)

for v in range(N):
    if dist[v] == INF:
        print('INF')
    else:
        print(dist[v])



Measured memory_bytes: 98992
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#define ll long long
using namespace std;

int main(){
    int x;
    bool flag=true;
    cin>>x;
    if(x<=3){
        cout<<x<<endl;
        return 0;
    }
    while(flag){
        for(int j=2; j<sqrt(x+1); j++){
            if(x%j==0){
                flag=true;
                //cout<<x<<" ";
                //cout<<"if"<<endl;
                break;
            }else{
                //cout<<x<<" ";
                //cout<<"else"<<endl;
                flag=false;
            }
        }
        //cout<<x<<endl;
        x=x+1;
    }
    cout<<x-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        a: [u64; n]
    }
    let mut left = vec![0u64;n+1];
    let mut right = vec![0u64;n+1];
    for i in 0..n {
        let j = n-1-i;
        left[i+1] = std::cmp::max(left[i], a[i]);
        right[j] = std::cmp::max(right[j+1], a[j]);
    }

    for i in 0..n {
        println!("{}", std::cmp::max(left[i], right[i+1]));
    }
}


Measured memory_bytes: 11772
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		while(s.find("this")==-1 && s.find("that")==-1 && s.find("the")==-1){
			for(int i=0; i<s.length(); i++){
				if(s[i]>='a' && s[i]<'z')
					s[i]++;
				else if(s[i]=='z')
					s[i]='a';
			}
		}
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 3060
#include <iostream>

unsigned short calculate_num_monitor (const unsigned short* num_tree_all, const unsigned short* num_range)
{
	// variable for this function
	register unsigned short num_tree_monitored;
	register unsigned short num_monitor;

	num_tree_monitored = (unsigned short)(2) * *num_range + (unsigned short)(1);
	num_monitor        = *num_tree_all / num_tree_monitored;

	if ( (*num_tree_all % num_tree_monitored) != 0 ) { num_monitor += (unsigned short)(1); }

	return num_monitor;
}

int main (void)
{
	// variables for main process
	register unsigned short N;
	register unsigned short D;

	// STEP.01
	// read out the given data
	std::cin >> N >> D;

	// STEP.02
	// output the answer of this task
	std::cout << calculate_num_monitor (&N, &D) << std::endl;

	// STEP.END
	return EXIT_SUCCESS;
}

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

int main() {
    long long x, y; cin >> x >> y;
    long long ans = 1LL<<60;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            long long res = i + j;
            long long xx = x * (i ? -1 : 1);
            long long yy = y * (j ? -1 : 1);
            if (xx <= yy) ans = min(ans, res + yy - xx);
        }
    }
    cout << ans << endl;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll a; cin >> a;
ll ans = 0;
ll x = 7 % a;
REP(i,a){
  if(x==0){
    ans = i+1;
    break;
  }
  x = (10*x+7) % a;
}
if(ans==0) cout << -1;
else cout << ans;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}
double calc_sunuke(ll num) {
	return (double)num / (double)sumdig(num);

}

int main() {

	int N;
	string s;
	vector<int> leftcnt(26, 0), rightcnt(26,0);

	cin >> N >> s;
	//char i = 'a'; 97

	int ans = 0;
	rep(i, 0, N-1) {
		string left = s.substr(0, i + 1);
		string right = s.substr(i + 1, N - (i + 1));
		int ta = 0;
		rep(j, 0, left.length()) {
			leftcnt[left[j]-97] += 1;
		}
		rep(j, 0, right.length()) {
			rightcnt[right[j]-97] += 1;
		}

		rep(j, 0, 26) {
			if (leftcnt[j] > 0 && rightcnt[j] > 0) {
				ta += 1;
			}
		}
		ans = max(ans, ta);
		rep(j, 0, 26) {
			rightcnt[j] =0;
			leftcnt[j] = 0;
		}
		
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int x,y;
	cin >> x >> y;
	int k = 0;
	if(x <= 3)
	{
		k = (4 - x) * 100000;
	}
	if(y <= 3)
	{
		k += (4 - y) * 100000;
	}
	if(x + y == 2)
	{
		k += 400000;
	}
	cout << k << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int gate[] = new int[n + 2];
        Arrays.fill(gate, 0);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            gate[a]++;
            gate[b + 1]--;
        }
        int ans = 0;
        int cnt = 0;
        for (int i = 0; i < n + 2; i++) {
            cnt += gate[i];
            if (cnt == m) {
                ans++;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 66260
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
vector <pair<int,int> > arr;
bool comp(pair<int,int> x,pair<int,int> y)
{
	if(x.second<y.second)
	{
		return true;
	}
	return false;
}
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		arr.pb(mp(a,b));
	}
	sort(arr.begin(),arr.end(),comp);
	int x;
	int cnt=0;
	int now=0;
	for(x=0;x<arr.size();x++)
	{
		if(now+arr[x].first<=arr[x].second)
		{
			now+=arr[x].first;
		}
		else
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 2420
#include<iostream>
using namespace std;
int main(){
	int n,sum=0,w[1001],ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		sum++;
		cin>>w[i];
		if(sum%2==1 && w[i]%2==1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include<cstdio>

using namespace std;
long long memo[35][110];
int N, ansnum;
int num[110] = { 0 };

long long solve(int sum, int depth,bool IsFirst) {
	if (sum<0 || sum>20)return 0;

	if (depth >= N - 1) {
		if (sum == ansnum)return 1;
		return 0;
	}

	if (memo[sum][depth] >= 0)return memo[sum][depth];

	if(IsFirst)return memo[sum][depth] = solve(sum + num[depth], depth + 1,false);
	return memo[sum][depth] = solve(sum + num[depth], depth + 1,false) + solve(sum - num[depth], depth + 1,false);
}

int main(void) {
	for (int i = 0; i<35; i++) {
		for (int j = 0; j<110; j++) {
			memo[i][j] = -1;
		}
	}
	scanf("%d", &N);
	for (int i = 0; i<N - 1; i++) {
		scanf("%d", &num[i]);
	}
	scanf("%d", &ansnum);

	printf("%lld\n", solve(0, 0,true));

	return 0;
}

Measured memory_bytes: 1056
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}

bool sosu(ll p){
    bool ans = true;
    double psqrtd = pow(p, 0.5);
    ll psqrt = psqrtd;
    for(ll i = 2; i <= psqrt; i++){
        if(p%i==0)ans = false;
    }
    if(p==1)ans = false;
    return ans;
}



int main(void){
    string s;
    cin >> s;
    ll n = s.length();
    for(ll i=0;i<n;i++){
    if(i%2==1){
        if(s.at(i)=='R'){
            cout << "No" << endl;
            break;
        }
    }
    if(i%2==0){
        if(s.at(i)=='L'){
            cout << "No" << endl;
            break;
        }
    }
    if(i==n-1)cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;


// const INF: i64 = 1_000_000_000;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n = sc.read();
    let mut ls: Vec<i64> = Vec::new();
    let mut rs: Vec<i64> = Vec::new();
    for _ in 0..n {
        ls.push(sc.read());
        rs.push(sc.read());
    }

    ls.push(0);
    rs.push(0);
    let n = n + 1;

    let mut big_l = (0..n).collect::<Vec<usize>>(); big_l.sort_by_key(|&i| -(ls[i]));
    let mut small_r = (0..n).collect::<Vec<usize>>(); small_r.sort_by_key(|&i| rs[i]);
    let mut used = vec![false; n];
    // println!("{:?}", big_l);
    let mut ans = 0i64;
    for k in 0..n {
        let i = big_l[k];
        let j = small_r[k];
        if ls[i] <= rs[j] || used[i] || used[j] {
            break;
        }
        used[i] = true;
        used[j] = true;
        ans += 2 * (ls[i] - rs[j]);
    }
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 10492
import math

inn = [int(x) for x in input().split()]
aa = []
bb = []
for i in range(inn[0]):
    tmp = [int(x) for x in input().split()]
    aa.append(tmp[0])
    bb.append(tmp[1])

maxaa = max(aa)
ba = [x for x in bb if x > maxaa]
sumba = sum(ba)
lenba = len(ba)
if sumba == inn[1]:
    print(lenba)
    exit()
elif sumba > inn[1]:
    count = lenba
    tot = sumba
    for b in sorted(ba):
        tot -= b
        if tot < inn[1]:
            print(count)
            exit()
        count -= 1
else:
    count = lenba + math.ceil((inn[1]-sumba)/max(aa))
    print(count)


Measured memory_bytes: 11788
N = int(input())
A = [int(x) for x in input().split()]

x, y, z = A[0], A[1], 0
for i in range(2, N):
    if i % 2 == 0:
        z = z + A[i]
        y = max(y, x)
        x = x + A[i]
    else:
        z = max(y, z)
        y = y + A[i]
        x = x

if N % 2 == 0:
    print(max(x, y))
else:
    print(max(y, z))


Measured memory_bytes: 31528
#include<stdio.h>
int main(void)
{

int x,h,m,s;

 scanf("%d",&x);
 
 h=x/3600;

 m=(x%3600)/60;
 
 s=(x%3600)%60;


printf("%d:%d:%d\n",h,m,s);

return 0;
}


Measured memory_bytes: 2672
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <iterator>
using namespace std;

void func_a() {
	int A, B, C;
	cin >> A >> B >> C;
	int ans = (A - B) > C ? 0 : C - (A - B);
	cout << ans << endl;
}

int main()
{
	func_a();
	return 0;
}

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

string cipher(string const& s, int& p, bool rev);
string str(string const& s, int& p, bool rev);
string letter(string const& s, int& p, bool rev, int cnt);

string cipher(string const& s, int& p, bool rev) {
    string res;
    while(p < s.size() && s[p] != ']') {
        res += str(s, p, rev);
    }
    return res;
}

string str(string const& s, int& p, bool rev) {
    string res;
    if(s[p] == '[') {
        res = cipher(s, ++p, !rev);
        reverse(res.begin(), res.end());
        ++p;
    } else {
        res = letter(s, p, rev, 0);
    }
    return res;
}

string letter(string const& s, int& p, bool rev, int cnt) {
    if(s[p] == '+') {
        return letter(s, ++p, rev, cnt+1);
    } else if(s[p] == '-') {
        return letter(s, ++p, rev, cnt-1);
    } else {
        string res;
        if(s[p] == '?') {
            res += 'A';
            ++p;
        } else {
            int off = s[p] - 'A' + cnt;
            while(off < 0) {
                off += 26;
            }
            res += 'A' + (off % 26);
            ++p;
        }
        return res;
    }
}

int main() {
    string s;
    while(cin >> s, s != ".") {
        int p = 0;
        cout << cipher(s, p, false) << endl;
    }
}


Measured memory_bytes: 3212
n,m = map(int,input().split())
if m > 0:
    li = [int(input()) for i in range(m)]
else:
    li = [0]

#連続する壊れていない階段の数を求める
li_new = [-1]*(m+1)
li_new[0] = li[0]
for i in range(1,m):
    li_new[i] = li[i] - (li[i-1]+1)
li_new[m] = n - li[m-1]
#print(li_new)

#必用な部分までのフィボナッチ数をリストに保存
fib = [0] * (max(max(li_new)+2,3))
fib[0] = 0
fib[1] = 1
fib[2] = 1
for i in range(3,max(li_new)+2):
    fib[i] = fib[i-2] + fib[i-1]
#print(fib)

#連続する壊れていない階段の数ごとのフィボナッチ数の積
ans = 1
if m > 0:
    for i in li_new:
        ans *= fib[i]
else:
    ans = fib[n+1]
print(ans%1000000007)

Measured memory_bytes: 460020
#include <iostream>
#include <vector>
#include <map>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> A(N);
   for (int i=0; i<N; i++){
      std::cin >> A.at(i);
   }

   std::map<int, long long int> mp;
   for (int i=0; i<N; i++){
      mp[A.at(i)]++;
   }

   long long int sum = 0;
   for (auto x : mp){
      sum = sum + x.second * (x.second-1) /2;
   }

   for (int i=0; i<N; i++){
      int n = mp[A.at(i)];
      std::cout << sum-(n-1) << std::endl;
   }
}



Measured memory_bytes: 11840
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

struct fenwick
{
	int n;
	unordered_map<int, int> F;

	fenwick()
	{
		n = inf;
		F.rehash(200000 * 17);
		//F.max_load_factor();
	}

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 81392
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n,ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


void solve() {
	int a, b; cin >> a >> b;
	cout << 2 * b -a << endl;
}



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))

ans = 0

for i in A:
    if i%4 == 0:
        ans += 2
    elif i%2 == 0:
        ans += 1

if ans >= N - int(N%2==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
def check(p):
    curw = 0
    trucknum = k
    can = True
    for i in range(n):
        w = package[i]
        if w > p:
            can = False
            break
        if curw+w <= p:
            curw += w
        elif curw+w > p:
            trucknum -= 1
            curw = w
        if i == n-1 and curw > 0:
            trucknum -= 1
        if trucknum < 0:
            can = False
            break
    return can

n,k = map(int,input().split())
package = []
for _ in range(n):
    package.append(int(input()))

M = sum(package)
m = 0
while True:
    if m+1 == M:
        break
    mid = (m+M)//2
    if check(mid):
        M = mid
    else:
        m = mid
print(M)




Measured memory_bytes: 9560
#!/usr/bin/env python3
#AGC24 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
if a[0] != 0:
    print(-1)
    quit()
for i in range(1,n):
    if a[i] - a[i-1] > 1:
        print(-1)
        quit()
ans = 0
for i in range(1,n):
    if a[i] == a[i-1] and a[i] > 0:
        ans += a[i]
    elif a[i] == a[i-1] + 1:
        ans += 1
    elif a[i] < a[i-1]:
        ans += a[i]
print(ans)


Measured memory_bytes: 51804
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 60;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


int n;
int mem[N][10],used[N][10];

int dfs(int idx,int carry){
  if((n>>idx) == 0) return carry == 0;
  if(used[idx][carry]++) return mem[idx][carry];

  //1 0 
  int res = 0;
  {
    int f = max(0LL,(1+0+carry) - (n>>idx&1));
    int ncarry = (f+1)/2;
    res += dfs(idx+1,ncarry);
    res %= mod;
  }
  
  // 1 1
  {
    int f = max(0LL,(1+1+carry) - (n>>idx&1));
    int ncarry = (f+1)/2;
    res += dfs(idx+1,ncarry);
    res %= mod;
  }

  //0 0
  {
    int f = max(0LL,(0+0+carry) - (n>>idx&1));
    int ncarry = (f+1)/2;
    res += dfs(idx+1,ncarry);
    res %= mod;
  }
  
  return mem[idx][carry] = res;
}

signed main(){
  cin>>n;
  int ans = dfs(0,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
string s;

int main(void){
    
    scanf("%d", &N);
    cin >> s;
    
    int ans = 0, num = 0;
    for(int i = 0; i < N; ++i){
        num += (s[i] == 'I') ? 1 : -1;
        ans = max(ans, num);
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int a,b,c;
int32_t main() {
	cin>>a>>b>>c;
	if(a==b && b==c)
		if(a&1)
		cout<<0;
		else cout<<-1;
	else
	{
		int ans=0;
		int ta,tb,tc;
		while(a%2==0 && b%2==0 && c%2==0)
		{
			ans++;
			ta=(b+c)/2;
			tb=(a+c)/2;
			tc=(a+b)/2;
			a=ta;b=tb;c=tc;
		}
		cout<<ans;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
// void read(__int128 &x)
// {
//     x = 0;
//     char ch;
//     int flag = 1;
//     while ((ch = getchar()))
//     {
//         if (ch == '-') flag = -1;
//         if (ch >= '0' && ch <= '9') break;
//     }
//     x = ch - '0';
//     while ((ch = getchar()) >= '0' && ch <= '9')
//     {
//         x = x * 10 + ch - '0';
//     }
//     x *= flag;
// }

// void out(__int128 x)
// {
//     if (x < 0)
//     {
//         x = -x;
//         putchar('-');
//     }
//     if (x >= 10) out(x / 10);
//     putchar(x % 10 + '0');
// }


// ll b[300005];
// int n, k;
// ll a[300005];

// int res;
// bool check(int cnt)
// {

//     for(int i = 0; i < cnt; i++)
//     {
//         a[i] = b[i];
//     }

//     int pos = cnt;
//     for(int i = cnt; i < cnt * k; i++)
//     {
//         while(b[pos] < (2 * a[i - cnt] ) && pos < n)
//         {
//             pos++;
//         }
//         if(pos >= n)
//             return 0;
//         a[i] = b[pos];
//         pos++;
//     }
//     return 1;
// }



int a, b, c, n;
const int M = 1e5 + 100;
string s[M];
char ans[M];

void dfs(int i, int a, int b, int c)
{
    if (i == n)
    {
        cout << "Yes\n";
        for (int i = 0; i < n; i++)
            cout << ans[i] << "\n";
        exit(0);
    }
    if (s[i] == "AB")
    {
        if (a) ans[i] = 'B', dfs(i + 1, a - 1, b + 1, c);
        if (b) ans[i] = 'A', dfs(i + 1, a + 1, b - 1, c);
    }
    if (s[i] == "BC")
    {
        if (b) ans[i] = 'C', dfs(i + 1, a, b - 1, c + 1);
        if (c) ans[i] = 'B', dfs(i + 1, a, b + 1, c - 1);
    }
    if (s[i] == "AC")
    {
        if (a) ans[i] = 'C', dfs(i + 1, a - 1, b, c + 1);
        if (c) ans[i] = 'A', dfs(i + 1, a + 1, b, c - 1);
    }
}

int main()
{


    cin >> n >> a >> b >> c;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    dfs(0, a, b, c);
    cout << "No";
}


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

public class Main {

	public static void main(String[] args) {
		Main ans = new Main();
		System.out.printf("%.10f\n",ans.solve());
	}

	private double solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double [] array = new double[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextDouble();
		}

		double [][] dp = new double[3001][3001];

		dp[0][0]=1.0;
		for(int i=1;i<=N;i++){
			Arrays.fill(dp[i], -1);
		}

		return solve(array, dp, N, (N+1)/2);
 
	}

	private double solve(double[] array, double [][]dp, int i, int x) {

		if (x==0) return 1.0;
		if (i==0) return 0;

		if(dp[i][x]>-0.9) return dp[i][x];
		 
		dp[i][x] = ((1-array[i])* solve(array, dp, i-1, x)) + (array[i]* solve(array, dp, i-1, x-1)); 
		//System.out.printf("dp[%d][%d]: %d\n", i, x, dp[i][x]);
		
		return dp[i][x];
	}

}

Measured memory_bytes: 119344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] v = cin.ArrayInt(n);
			double d = 2.0;
			double ans = 0;
			
			Array.Sort(v);
			var vv = v.Reverse().ToList();
			for (int i = 0; i < n; i++) {
				ans += vv[i] / d;
				if (i < n - 2) {
					d *= 2;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13268
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"
flag = False
for i in range(N-1):
    if H[i+1] - H[i] > 0:
        flag = False
        pass
    elif H[i+1] - H[i] == 0:
        #flag = True
        pass
    elif H[i+1] - H[i] == -1 and flag == False:
        H[i] -= 1
        flag = True
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 14224