akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;


int main()
{
	int i, j, k, l, m, X, Y,sum,flag;
	sum = 1;
	bool ans[1001] = {};
	for (i = 2; i <= 31; i++) {
		j = i*i;
		while (j <= 1000) {
			ans[j] = 1;
j*=i;
		}
	}
	cin >> X;
	for (i = 0; i <= X; i++) {
		if (ans[i]) {
			sum = i;
		}
	}
	cout << sum << endl;

}



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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);

    for (int h=0; h<H; h++){
        cin >> a.at(h);
    }

    vector<string> b(H+2, "");
    for (int h=0; h<H+2; h++){
        for (int w=0; w<W+2; w++){
            b.at(h) += '#';
        }
    }

    for (int h=0; h<H; h++){
        for (int w=0; w<W; w++){
            b[h+1][w+1] = a[h][w];
        }
    }

    for (int h=0; h<H+2; h++){
        cout << b.at(h) << endl;
    }
}

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

vector<vector<int>> v;
vector<int> ans;
map<P, int> w;

void dfs(int x, int p=-1, int len=0) {
    rep(i, v[x].size()) {
        int to = v[x][i];
        if (to == p) continue;
        len ^= w[{x,to}];
        ans[to] = len;
        dfs(v[x][i], x, len);
        len ^= w[{x,to}];
    }
}

void solve() {
    int n;
    cin >> n;
    v.resize(n);
    rep(i,n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        v[a].push_back(b);
        v[b].push_back(a);
        w[{a,b}] = c & 1;
        w[{b,a}] = c & 1;
    }

    ans = vector<int>(n);
    ans[0] = 0;
    dfs(0);
    rep(i,n) cout << ans[i] << endl;

    return;
}

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


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

using namespace std;

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

    long long a, b, c, d, lcm;
    cin >> a >> b >> c >> d;
    lcm = c * d / __gcd(c, d);

    cout << (b - a + 1) - ((b / c - (a - 1) / c) + (b / d - (a - 1) / d) - (b / lcm - (a - 1) / lcm)) << '\n';

    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    char a;
    cin >> a;
    cout << char(a + 1);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k) cout << ":(";
  else cout << "Yay!";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll n, m, x, y;
	cin >> n >> m;
	vector<ll> a, b, c, d;
	rep(i, n) {
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	rep(i, m) {
		cin >> x >> y;
		c.push_back(x);
		d.push_back(y);
	}
	rep(i, n) {
		ll ans = 1, minm;
		rep(j, m) {
			ll man = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (j == 0)minm = man;
			else {
				if (minm > man) {
					minm = man;
					ans = j + 1;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,l,apple[205],pp=1,sum=0,min=101;
	cin>>n>>l;
	for(int p=1;p<=n;p++)
	{
		apple[p]=pp+l-1;
		pp++;
		sum+=apple[p];
	}
	for(int i=1;i<=n;i++)
	{
		if(apple[i]==0)
		{
			cout<<sum;
			return 0;
		}
		if(abs(apple[i])<abs(min))
			min=apple[i];			
	}		
	cout<<sum-min;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn upper_bound(v: &Vec<(usize, usize)>, x: &usize) -> usize {
    use std::cmp::Ordering;

    let mut l = 0;
    let mut h = v.len();
    while h > l {
        let m = l + (h - l) / 2;
        match v[m].0.cmp(x) {
            Ordering::Less | Ordering::Equal => {
                l = m + 1;
            }
            Ordering::Greater => {
                h = m;
            }
        }
    }
    l
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();

    // input
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let d: usize = read(&mut stdin_lock, &mut buf, b' ');
    let a: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut xhv = vec![(0usize, 0usize); n];
    for i in 0..n {
        xhv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        xhv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    xhv.sort();

    let mut counts = vec![0; xhv.len() + 1];
    let mut count = 0;
    for i in 0..xhv.len() {
        count -= counts[i];
        let (x, h) = xhv[i];
        if count * a < h {
            let c = ((h - (count * a)) + a - 1) / a;
            count += c;
            counts[upper_bound(&xhv, &(x + 2 * d))] += c;
        }
    }
    println!("{}", counts.iter().sum::<usize>());
}


Measured memory_bytes: 12540
<?php
list($n, $m, $v, $p) = ints();
$a = ints();
rsort($a);
$ok = 0;
$ng = $n;
while(abs($ok - $ng) > 1){
    $mid = intdiv($ok + $ng, 2);
    if(isOK($mid)){
        $ok = $mid;
    }else{
        $ng = $mid;
    }
}
echo $ok + 1;
function isOK($k){
    global $a, $m, $v, $n, $p;
    $minusable = ($n-$v) * $m;
    $over = 0;
    for($i = $k-1; $i >= $p-1; $i--){
        $o = $a[$i] - $a[$k];
        if($o > $m){
            return false;
        }
        $over += $o; 
    }
    return $over<=$minusable;
}

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define repa(i, a, b) for (auto i = (a); i <= (b); i++)
#define repd(i, a, b) for (auto i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define zero(a)  memset((a), 0, sizeof (a))
#define sz(x) (int)(x).size()
#define debug(x) cout << (x) << "\n";
#define mp make_pair
#define pb push_back

constexpr auto inf = numeric_limits<int>().max();
constexpr auto llinf = numeric_limits<ll>().max();

template<typename ForwardIterator>
void dump(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << *it << " ";
	}
	cout << "\n";
}

template<typename ForwardIterator>
void dump_map(ForwardIterator st, ForwardIterator en) {
	for (auto it = st; it != en; it++) {
		cout << (*it).first << ":" << (*it).second << " ";
	}
	cout << "\n";
}

void solve() {
  int x, y;
  cin >> x >> y;
  if (y % 2 != 0) {
    cout << "No";
  } else {
    auto b = y / 2 - x;
    auto a = x - b;
    if (a >= 0 && b >= 0) {
      cout << "Yes";
    } else{
      cout << "No";
    }
  }
	cout << "\n";
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#define N_ 101000
#define pii pair<int,int>
using namespace std;
int n, Q;
struct point {
	int a, b;
	bool operator<(const point &p)const {
		return a < p.a;
	}
}w[N_];
int p[N_];
int X[3*N_], CX, S[3*N_];
struct Range {
	int b, e;
}V[N_];
int CV, vis[N_];
vector<int>G[3 * N_], F[3 * N_];
int BIT[3 * N_], Res[3 * N_];
void Add(int a, int b) {
	while (a <= CX) {
		BIT[a] += b;
		a += (a&-a);
	}
}
int Sum(int a) {
	int r = 0;
	while (a) {
		r += BIT[a];
		a -= (a&-a);
	}
	return r;
}
int Calc(int a) {
	int t = lower_bound(X + 1, X + CX + 1, a) - X;
	return Res[t - 1];
}
int main() {
	int i;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d%d",&w[i].a,&w[i].b);
		X[++CX] = w[i].a;
		X[++CX] = w[i].b;
	}
	for (i = 1; i <= n+1; i++) {
		scanf("%d", &p[i]);
		X[++CX] = p[i];
	}
	sort(X + 1, X + CX + 1);
	CX = unique(X + 1, X + CX + 1) - (X + 1);
	for (i = 1; i <= n; i++) {
		w[i].a = lower_bound(X + 1, X + CX + 1, w[i].a) - X;
		w[i].b = lower_bound(X + 1, X + CX + 1, w[i].b) - X;
		S[w[i].a]++;
		if (w[i].b < w[i].a) {
			G[w[i].a - 1].push_back(CV);
			F[w[i].b].push_back(CV);
			V[CV++] = { w[i].b,w[i].a - 1 };
		}
	}
	for (i = 1; i <= n + 1; i++) {
		p[i] = lower_bound(X + 1, X + CX + 1, p[i]) - X;
		S[p[i]]--;
	}
	int s = 0;
	for (i = 1; i <= CX; i++) {
		s += S[i];
		Add(i, S[i]);
	}
	scanf("%d", &Q);
	priority_queue<pii>PQ;
	int chk = 0, res = n;
	for (i = CX; i >= 1; i--) {
		for (auto &t : G[i]) {
			PQ.push({ -V[t].b, t });
		}
		while (Sum(i) < -1) {
			if (PQ.empty()) {
				chk = 1;
				break;
			}
			int x = PQ.top().second;
			Add(V[x].b, 1);
			Add(V[x].e + 1, -1);
			vis[x] = 1;
			res--;
			PQ.pop();
		}
	}
	Res[0] = res;
	while (!PQ.empty())PQ.pop();
	for (i = 1; i <= CX; i++) {
		for (auto &t : F[i]) {
			if (vis[t])continue;
			PQ.push({ V[t].e, t });
		}
		while (Sum(i) < 0) {
			if (PQ.empty()) {
				if (!chk)chk = i + 1;
				break;
			}
			int x = PQ.top().second;
			Add(V[x].b, 1);
			Add(V[x].e + 1, -1);
			res--;
			PQ.pop();
		}
		Res[i] = res;
	}
	for (i = chk - 1; i <= CX; i++)Res[i] = -1e9;
	while (Q--) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%d\n",max(max(Calc(a) + 1, Calc(b)),-1));
		
	}
	return 0;
}

Measured memory_bytes: 29304
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

Int gcd(Int n, Int m) {
    Int a = max(n , m);
    Int b = min(n , m);
    return b == 0 ? a : gcd(b, a % b);
}

int main() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    Int B = b - (b / c) - (b / d);
    Int add = (c * d) / gcd(c, d);
    B += b / add;
    //cout << b << " "  << b / c <<  " "  << b / d << " " << b / (c * d) << endl;
    a--;
    Int A = a - (a / c) - (a / d);
    A += a / add;
    //cout << A <<  " " << B << endl;
    dump(B - A);
    return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

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

    for (int i = 0; i < N-1; ++i) {
        if(H[i]<=H[i+1]) continue;
        else H[i+1]++;
        if(H[i]>H[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int C = sc.nextInt();
        final int nMax = 100000;
        LinkedList<int[]>[] dic = new LinkedList[C+1];
        for(int i=0;i<=C;i++) dic[i] = new LinkedList<>();
        for(int i=1;i<=N;i++){
            int s = sc.nextInt();
            int t = sc.nextInt();
            int c = sc.nextInt();
            dic[c].add(new int[]{s,t});
        }
        int[] res = new int[nMax+5];
        for(int i=1;i<=C;i++){
            if(dic[i].size()==0) continue;
            int[] cur = new int[nMax+5];
            while(dic[i].size()>0){
                int[] temp = dic[i].remove();
                cur[temp[0]]++;
                cur[temp[1]+1]--;
            }
            for(int j=1;j<nMax+5;j++) cur[j] = cur[j-1]+cur[j];
            for(int j=1;j<nMax+5;j++){
                if(cur[j]>0) res[j]++;
            }
        }
        int ans = 0;
        for(int j=1;j<nMax+5;j++) ans = Math.max(ans, res[j]);
        System.out.println(ans);
    }
}


Measured memory_bytes: 98340
// AOJ DPL_1_D Longest Increasing Subsequence
// 2018.4.26 bal4u

#include <stdio.h>
#include <stdlib.h>

#define SIZE 100002

int size;      /* the number of data */
int S[SIZE];   /* data array */
int len;       /* the length of LIS */
int L[SIZE];   /* LIS */

int LIS()
{
  int k;
  int lo, hi, mid;

  if (size <= 0) return 0;

  L[0] = S[0];
  len = 1;
  for (k = 1; k < size; k++) {
    if (L[len-1] < S[k]) { L[len++] = S[k]; continue; }
    lo = 0;
    hi = len;
    while (lo < hi) {
      mid = (lo + hi)/2;
      if (L[mid] < S[k]) lo = mid + 1;
      else               hi = mid;
    }
    if (lo < len) L[lo] = S[k];
    else       L[len++] = S[k];
  }
  return len;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int i;

	size = in();
	for (i = 0; i < size; i++) S[i] = in();
	printf("%d\n", LIS());
	return 0;
}



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

main() {
    int a,b,c; cin >> a >> b >> c;
    cout << (a+b)*c/2 << endl;

    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

void solve() {
    int N;
    cin >> N;
    mint ans = 0;
    for (int i = N / 3; i >= 1; i--) {
        ans += C(N - i * 3 + i - 1, i - 1);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3696
N, Q = map(int, input().split())
S = input()
t = [0] * N
for i in range(N - 1):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
#define tabs(a, b) ((a<b) ? (b-a) : (a-b))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
void faster(){
   	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ull INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
 
ll n, a[MAXN];

void solve(){
	cin >> n;

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

	sort(a, a + n);

	ll cnt = 0;

	for(ll i = 0, L = 0; i < n; ++i){
		L += a[i] * 2;
		if(a[i + 1] > L)
			cnt = 0;
		else
			cnt++;
	}

	cout << cnt;
}
 
int main(){
 
	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int main(void) {
    int x, a;
    cin >> x >> a;
    if (x < a) cout << "0" << endl;
    else cout << "10" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int main(int argc, char* argv[]) {
  unsigned long n, a, b;
  cin >> n >> a >> b;
  const unsigned long d = n / (a + b);
  const unsigned long m = n % (a + b);
  cout << a * d + std::min(a, m);
  return 0;
}


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

int ans=0,n;

int main(){
  int i,sum,now;
  while(1){
    cin >> n;
    if(n==0)break;
    ans = 0;
    for(i=1;i<n;i++){
      now = i;
      sum = 0;
      while(sum<n)sum+=now++;
      if(sum==n)ans++;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3000
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  string N;int K;cin>>N>>K;
  REP(i,0,K){
    if(N.at(i)!='1'){
      print(N.at(i))
      return 0;
    }
  }
  print('1')
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int r,b,w,g;cin>>r>>b>>w>>g;
	cout<<r+b+w+g<<endl;
	return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main (){
    int N, P; cin >> N >> P;
    vector<ll> dp(N+1);
    //dp[i]: i番目までで条件を満たす選び方の数
    dp[0] = !P; // P=0なら何も取らない場合
    for(int i=0; i<N; i++){
        int a; cin >> a;
        if(a%2==0) dp[i+1] = 2 * dp[i];
        else dp[i+1] = pow(2, i); //  dp[i] + pow(2, i) - dp[i]
    }
    cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  int A[9];
  REP(i,0,9)cin>>A[i];
  int N;cin>>N;
  int b[N];
  REP(i,0,N)cin>>b[i];
  bool Ab[9];
  REP(i,0,9)Ab[i]=false;
  REP(i,0,9){
    REP(j,0,N){
      if(A[i]==b[j]){
        Ab[i]=true;
      }
    }
  }
  if((Ab[0]&&Ab[1]&&Ab[2])||(Ab[3]&&Ab[4]&&Ab[5])||(Ab[6]&&Ab[7]&&Ab[8])||
  (Ab[0]&&Ab[3]&&Ab[6])||(Ab[1]&&Ab[4]&&Ab[7])||(Ab[2]&&Ab[5]&&Ab[8])||
  (Ab[0]&&Ab[4]&&Ab[8])||(Ab[2]&&Ab[4]&&Ab[6]))print("Yes")
  else print("No")
}

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

#define rep(i,n) for(long long i = 0; i < n; i++)

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

const ll INF = ll(1e18) + 1;
const int intINF = 1e9 * 2 + 3;
//--------------------------------------------------

ulli gcd(ulli a, ulli b) {return (b <= 0) ? a : gcd(b, a % b);}
ulli lcm(ulli a, ulli b) {return a * b / gcd(a, b);}

bool isPrime(int n)
{
	if (n <= 3)return n > 1;
	if (n % 2 == 0)return false;
	if (n % 3 == 0)return false;
	for (int i = 5; i * i < n; i += 6) {
		if (n % i == 0 || n % (i + 2) == 0) { return false; }
	}
	return true;
}
//---------------------------------------------------



void Main()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}


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

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

//Greedy, Greedy.
public class Main{

	int n, INF = 1<<29, M = 50000;
	int[] c;

	int f(int x){
		int res = 0, k = n-1;
		while(x>0&&k>=0){
			res += x/c[k];
			x%=c[k--];
		}
		return x==0?res:INF;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		for(int T=1;;T++){
			n = sc.nextInt();
			if(n==0)break;
			c = new int[n];
			for(int i=0;i<n;i++)c[i]=sc.nextInt();
			int[] dp = new int[M];
			Arrays.fill(dp, INF);
			dp[0] = 0;
			boolean f1 = true, f2 = true;
			for(int x=1;x<M&&f1;x++){
				for(int i=0;i<n;i++){
					if(x-c[i]>=0)dp[x] = Math.min(dp[x], dp[x-c[i]]+1);
				}
				if(dp[x]==INF)f1 = false;
				if(dp[x]<f(x))f2 = false;
			}
			System.out.println("Case #"+T+": "+(!f1?"Cannot pay some amount":!f2?"Cannot use greedy algorithm":"OK"));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  vector<int> v(3);
  for (int i = 0; i < 3; i++) {
    cin >> v[i];
  }
  sort(v.rbegin(), v.rend());
  cout << 10 * v[0] + v[1] + v[2] << endl;
}


Measured memory_bytes: 256
def resolve():
    n, m, q = map(int, input().split())
    queue = []
    for i in range(q):
        queue.append(list(map(int, input().split())))
    ans = 0
    import itertools
    l = itertools.combinations(range(1, n + m), n)
    for i in l:
        a = [x - y for y, x in enumerate(i)]
        x = 0
        for j in queue:
            if a[j[1] - 1] - a[j[0] - 1] == j[2]:
                x += j[3]
        ans = max(ans, x)
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9216
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
int a,b;

string ans = "";
 
void solve(){
	int maxi = max(a,b);
	int mini = min(a,b);
	ans = string(maxi,mini+0x30);
}
 
int main(){
	cin>>a>>b;

	solve();

	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long c[1005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int t=i;
		for(int j=2;j<=i;j++)
			while(t%j==0){
				t/=j;
				c[j]++;
			}
	}
	long long a=1;
	for(int i=2;i<=n;i++)
		a=a*(c[i]+1)%1000000007;
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
/*Stay true to yourself, yet always be open to learn. Work hard, and never give up on your dreams, 
even when nobody else believes they can come true but you. These are not cliches but real tools you 
need no matter what you do in life to stay focused on your path.
*/

 /*Pppppppp    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HH     HH     UU      UU
   pp    pp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pppppppp    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   pp          UU      UU     CC          CC           HH     HH     UU      UU
   pp          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
   */

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    float n ,d;
    cin >> n >> d;
    d = 2*d +1;
    cout<<ceil(n/d);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<functional>
#include<cstring>

using namespace std;
typedef long long ll;
int N=1<<17;
ll dat[1<<18];
int id[1<<18];
int n,r,l;
int d[1000001],t[1000001],x[1000001];
int timel[100001];

void init(){
	memset(dat,0,sizeof(dat));
	for(int i=N;i<N*2;i++)id[i]=i-N;
}

void update(int k,ll a){
	k+=N-1;
	dat[k]+=a;
	while(k>0){
		k=(k-1)/2;
		if(dat[k*2+1]>=dat[k*2+2]){
			dat[k]=dat[k*2+1];
			id[k]=id[k*2+1];
		}else{
			dat[k]=dat[k*2+2];
			id[k]=id[k*2+2];
		}
	}
}

int main(void){
	scanf("%d%d%d",&n,&r,&l);
	for(int i=0;i<r;i++)scanf("%d%d%d",&d[i],&t[i],&x[i]);
	int nt=0;
	init();
	for(int i=0;i<r;i++){
		timel[id[0]]+=t[i]-nt;
		nt=t[i];
		update(d[i],x[i]);
	}
	timel[id[0]]+=l-nt;
	int sum=0,rid=0;
	for(int i=0;i<n;i++){
		if(sum<timel[i])sum=timel[i],rid=i;
	}
	printf("%d\n",rid+1);
	return 0;
}

Measured memory_bytes: 16116
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    a = L[i]
    for j in range(i,N):
        b = L[j]
        for k in range(j,N):
            c = L[k]
            if abs(a-b)<c and c<a+b and a!=b and b!=c and c!=a:
                ans += 1
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

ll p[333] = {0};
ll pw[333] = {1};
ll dp[301][301][301] = {0};

signed main(void){
  int i, j, k;
  p[0] = 1; p[1] = 1;
  rep1(i, 333){
    p[i] = (ll)i * p[i - 1];
    p[i] %= mod;
  }
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    if(n > m){ puts("0"); return 0; }
    if(n == m){ printf("%lld\n", p[n - 1]); return 0; }

    // n < m, m - n日余る
    rep1(i, 333){
      pw[i] = pw[i - 1] * n;
      pw[i] %= mod;
    }
    dp[0][0][0] = 1;
    //dp[進捗][日数][街kまで題意]
    rep(j, m){
      //m日目の行動
      //遊ぶ
      per(i, n)per(k, n)if(i > k){
        dp[i][j + 1][k] += dp[i][j][k] * (ll)(i - k);
        dp[i][j + 1][k] %= mod;
      }
      //進める
      per(i, n)per(k, n){
        dp[i + 1][j + 1][k] += dp[i][j][k] * (ll)(n - i - 1);
        dp[i + 1][j + 1][k] %= mod;
      }
      //セーブ
      per(i, n)per(k, n){
        dp[i][j + 1][i] += dp[i][j][k] * (k + 1);
        dp[i][j + 1][i] %= mod;
      }
    }
    ll res = dp[n - 1][m][n - 1];
    //ll res = 0;
    //rep(k, n + 1)res = (res + dp[n][m][k]) % mod;

    /*rep(j, m + 1)rep(i, n + 1)rep(k, n + 1)if(dp[i][j][k] != 0){
      pri3(i, j, k);
      pri(dp[i][j][k]);
      kabe;
    }*/
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 212608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int H, W;
    cin >> H >> W;
    map<int, int> mp;
    multiset<int> st;
    for(int i = 0; i < W; ++i)  mp[i] = i;
    for(int i = 0; i < W; ++i)  st.insert(0);
    for(int i = 0; i < H; ++i){
        int A, B;
        cin >> A >> B;
        --A;
        auto it = mp.lower_bound(A);
        int R = -1;
        while(it != mp.end() && it->first <= B){
            chmax(R, it->second);
            st.erase(st.find(it->first - it->second));
            it = mp.erase(it);
        }
        if(R != -1 && B < W){
            mp[B] = R;
            st.insert(B - R);
        }
        if(st.size())   cout << *st.begin() + i + 1 << '\n';
        else    cout << -1 << '\n';
    }
}

Measured memory_bytes: 22312
import fractions


def args():
    N, MA, MB = list(map(int, input().split()))

    A, B, C = [], [], []
    for i in range(N):
        a, b, c = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        C.append(c)

    # print(N, MA, MB)
    # print(A)
    # print(B)
    # print(C)

    return N, MA, MB, A, B, C

def solve(N, MA, MB, A, B, C):
    def recur(i, a, b):
        if not MEMO[i][a][b] is None:
            return MEMO[i][a][b]

        if not i < N:
            if 0 < a and 0 < b:
                g = fractions.gcd(a, b)
                if (MA, MB) == (a / g, b / g):
                    return 0
            return float("inf")

        res = min(recur(i + 1, a, b) + 0, recur(i + 1, a + A[i], b + B[i]) + C[i])
        MEMO[i][a][b] = res
        return res

    x, y, z = N + 1, 10 * N + 1, 10 * N + 1
    MEMO = [[[None] * z for _ in range(y)] for _ in range(x)]

    ans = recur(0, 0, 0)

    return ans


if __name__ == '__main__':
    res = solve(*args())

    print(-1) if res == float("inf") else print(res)


Measured memory_bytes: 128600
from bisect import bisect_left, bisect_right
n = int(input())
a, b, c = [sorted(list(map(int, input().split()))) for i in range(3)]
ans = 0
for i in range(n):
  j = bisect_left(a, b[i])
  k = bisect_right(c, b[i])
  ans += j*(n-k)
print(ans)

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

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


	if (n == 100) {
		n++;
	}
	int num = 1;
	for (int i = 0; i < d; i++) {
		num *= 100;
	}
	int ans = num * n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, M =map(int, input().split())
H_tree = [0] + [int(n) for n in input().split()]
GOOD_Tree = [0] + [1 for n in range(N)]
 
for i in range(M):
  A, B = map(int, input().split())
  if H_tree[A]<=H_tree[B]:GOOD_Tree[A] = 0
  if H_tree[A]>=H_tree[B]:GOOD_Tree[B] = 0
print(sum(GOOD_Tree))

Measured memory_bytes: 20000
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int bitcount (uint16_t a)
{
    a = (a & 0x5555) + (a >> 1 & 0x5555);
    a = (a & 0x3333) + (a >> 2 & 0x3333);
    a = (a & 0x0f0f) + (a >> 4 & 0x0f0f);
    a = (a & 0x00ff) + (a >> 8 & 0x00ff);
    return a;
}

int main (int argc, char const *argv[])
{
    int64_t N, M, k[10], p[10];
    uint16_t s[10] = {0};
    int64_t tmp, ans = 0;

    scanf("%"PRId64"%"PRId64, &N, &M);
    for (int i = 0; i < M; i++) {
        scanf("%"PRId64, &k[i]);
        for (int j = 0; j < k[i]; j++) {
            scanf("%"PRId64, &tmp);
            s[i] |= (1 << (tmp - 1));
        }
    }
    for (int i = 0; i < M; i++) {
        scanf("%"PRId64, &p[i]);
    }

    for (uint16_t i = 0; i <= (0x3FF >> (10 - N)); i++) {
        tmp = 0;
        for (int j = 0; j < M; j++) {
            if (((bitcount(s[j] & i) % 2)) == p[j]) tmp++;
        }
        if (tmp == M) ans++;
    }

    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // std::ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    // cout.tie(nullptr);
    return 0;
}();

int knapSack(vi &weg, vi &value, int n, int w,int tval, vector<vector<lli>> &dp)
{
    //dp[idx][val] = it will store the min weght to require to get this value;
    dp[0][0] = 0;
    for (int idx = 1; idx <= n; idx++)
    {
        dp[idx][0] = 0; // by not thaking any object thus obtaning 0 value;
        for (int val = 1; val <= tval; val++)
        {
            dp[idx][val] = dp[idx - 1][val]; //not taking current object;

            if (val >= value[idx-1])
                dp[idx][val] = min(dp[idx][val], dp[idx - 1][val - value[idx-1]] + weg[idx-1]);
        }
    }

    for (int val = tval; val >= 0; val--)
        if (dp[n][val] <= w)
            return val;
}

int solve()
{
    int n, w;
    scanf("%d%d", &n, &w);
    vi weg(n, 0), val(n, 0);
    int tval = 0;
    loop(n)
    {
        scanf("%d",&weg[i]);
        scanf("%d",&val[i]);
        tval += val[i];
    }

    vector<vector<lli>> dp(n + 1, vector<lli>(tval + 1, 1e9));
    return knapSack(weg, val, n, w, tval, dp);
}

int main()
{

    printf("%d\n", solve());
    return 0;
}

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

using namespace std;

int main()
{
  long long N, K;
  cin >> N >> K;
  vector<long long> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  cout << (N-1 + K-1-1) / (K-1) << endl;
  
}


Measured memory_bytes: 1152
from itertools import combinations
N = int(input())
S = list(input().strip())
d = {}
for c in S:
  if c in d.keys():
    d[c] += 1
  else:
    d[c] = 1
ans = 0
for n in d.values():
  ans = (ans+n+ans*n)%(10**9+7)
print(ans) 



Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int v[3];
    cin >> v[0] >> v[1] >> v[2];

    vector<int> even;
    vector<int> odd;
    for (int i = 0; i < 3; i++) {
        if (v[i] % 2) odd.push_back(i);
        else         even.push_back(i);
    }

    int d = 0;
    if (odd.size() == 2) {
        v[odd[0]]++;
        v[odd[1]]++;
        d = 1;
    } else if (even.size() == 2) {
        v[even[0]]++;
        v[even[1]]++;
        d = 1;
    }
    sort(begin(v), end(v));

    cout << d + (v[2]-v[0])/2 + (v[2]-v[1])/2 << endl;

    return 0;
}


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

const int MOD = 1e9 + 7;

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    mint combination(long long n) {
        mint result(n);
        for(int i = 2; i <= x; i++) {
            result *= (n - i + 1);
            result /= i;
        }
        return result;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};


int n,a,b;
mint result;
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    cin >> n >> a >> b;
    cout << mint(2).pow(n) - 1 - mint(a).combination(n) - mint(b).combination(n);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9+7;
ll ans;
ll n,k;
const ll maxin = 1e5+5;
vll g[maxin];

void dfs(int s, int t){
    ll cnt = k-1;
    if(t != -1) cnt--;
    for(auto p:g[s]){
        if (p==t) continue;
        ans *= cnt;
        ans%=mod;
        cnt--;
        dfs(p,s);
    }

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

    cin>>n>>k;
    REP(i,n-1){
        ll u,v; cin >>u>>v;
        u--; v--;
        g[u].push_back(v); g[v].push_back(u);
    }
    ans = k;
    dfs(0,-1);
    cout << ans << endl;
    
    return 0;
}

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

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
using namespace std;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int N; cin >> N;
    int ans = 0;
    rep(i, 1, N) {
        int a = i, c=0;
        while(a > 0) { a /= 10; c++; }
        if (c%2 == 1) ans++;
    }
    END(ans);

}


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

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	if(a==b)cout<<"Draw";
	else if(a==1)cout<<"Alice";
	else if(b==1)cout<<"Bob";
	else if(a>b)cout<<"Alice";
	else cout<<"Bob";
}

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll power(ll x,ll y){
	ll re=1;
	while(y>0){
		if(y%2)re=re*x%hell;
		x=x*x%hell;
		y=y/2;
	}
	return re;
}
int main(){
	ll n,k;cin>>n>>k;
	ll dp[k+1]={0};
	for(ll i=k;i>=1;i--){
		ll x=k/i;
		dp[i]=power(x,n);
		for(ll j=2*i;j<=k;j+=i){
			dp[i]=(dp[i]-dp[j]+hell)%hell;
		}
	}
	ll sum=0;
	for(ll i=1;i<=k;i++){
		//cout<<dp[i]<<" ";
		sum=(i*dp[i]%hell+sum)%hell;
	}
	cout<<sum<<endl;
}


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

int main(){
  ll X;
  cin >> X;
  
  ll total = 100;
  ll cnt = 0;
  while(total < X){
    total += total*0.01;
    cnt++;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
string a,b;
int dp[3005][3005];
int LCS(int i,int j){
    if(i == sz(a) or j == sz(b))
        return 0;
    if(dp[i][j] != -1)return dp[i][j];
    int &ans = dp[i][j];
    if(a[i] == b[j])
        return ans = LCS(i + 1,j + 1) + 1;
    return ans = max(LCS(i + 1, j), LCS(i, j + 1));

}
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    cls(dp, -1);
    cin >> a >> b;
    dp[sz(a)][sz(b)] = 0;
    for(int i = sz(a) - 1; i >= 0; i--)
        for(int j = sz(b) - 1; j >= 0; j--){
            if(a[i] == b[j])
                dp[i][j] = dp[i + 1][j + 1] + 1;
            else
            dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
        }

    //reconstruir
    int i = 0, j = 0;
    string ans = "";
    while(i < sz(a) and j < sz(b)){
        if(a[i] == b[j]){
            ans += a[i];
            i++;
            j++;
        }else 
        if(dp[i + 1][j] > dp[i][j + 1])
            i++;
        else
            j++;
    }
    cout << ans << '\n';
    return 0;
}   

Measured memory_bytes: 35584
#include <stdio.h>

int main(){
	int N,a[100],i,A,B,C,D,j,n,m,b[100][2];
	scanf("%d",&N);
	
	for(i=0;i<100;i++){
		a[i]=0;
		b[i][0]=0;
		b[i][1]=i;
	}
	for(i=0;i<(N*(N-1))/2;i++){
		scanf("%d %d %d %d",&A,&B,&C,&D);
		if(C>D){
			a[A-1]+=3;
		}else if(D>C){
			a[B-1]+=3;
		}else if(D==C){
			a[A-1]+=1;
			a[B-1]+=1; 
		}
	}
	for(i=0;i<N;i++){
		b[i][0]=a[i];
		//printf(" %d\n",a[i]);
	}
	
	for(j=0;j<N;j++){
		for(i=0;i<N-1;i++){
			if(b[i][0]<=b[i+1][0]){
				n=b[i][0];
				m=b[i][1];
				b[i][0]=b[i+1][0];
				b[i][1]=b[i+1][1];
				b[i+1][0]=n;
				b[i+1][1]=m;
			}
		}
	}
	//for(i=0;i<N;i++){
	//	printf(" %d  %d\n",b[i][0],b[i][1]);
	//}
	for(i=0;i<N;i++){
		a[b[i][1]]=i+1;
		if(i!=0&&b[i-1][0]==b[i][0]){
			a[b[i][1]]=a[b[i-1][1]];
		}
			
	}
	for(i=0;i<N;i++){
		printf("%d\n",a[i]);
	}
		
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<ll> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 
    
    int main(){
        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif  

        fast;
        string s;
        cin>>s;
        if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes";
        else cout<<"No";
        return 0;  
    }       
 
 
    //keep it simple stupid



Measured memory_bytes: 3652