akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n, std::vector<long long> a, std::vector<long long> b) {
    // check
    // cout << N << endl;
    // rep(i, N + 1) {
    //     if (i > 0) cout << " ";
    //     cout << A[i];
    // }
    // cout << endl;
    // rep(i, N) {
    //     if (i > 0) cout << " ";
    //     cout << B[i];
    // }

    ll ans = 0;
    rep(i, n) {
        int temp = min(a[i], b[i]);
        ans += temp;
        b[i] -= temp;
        temp = min(a[i + 1], b[i]);
        ans += temp;
        a[i + 1] -= temp;
    }

    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N + 1);
    for (int i = 0; i < N + 1; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &B[i]);
    }
    func(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int t,n;
    for(int i=0; i<4; i++){
        cin >> t >> n;
        if(t==1)        cout << 6000 * n << endl;
        else if(t==2)   cout << 4000 * n << endl;
        else if(t==3)   cout << 3000 * n << endl;
        else if(t==4)   cout << 2000 * n << endl;
    }
}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,tot,point[200005],nxt[200005],head[200005];
ll f[100005][2];
void addedge(int x,int y)
{
	point[++tot]=y,nxt[tot]=head[x],head[x]=tot;
	point[++tot]=x,nxt[tot]=head[y],head[y]=tot;
}
void dfs(int x,int fa)
{
	f[x][0]=f[x][1]=1;//0 black
	for(int i=head[x];i;i=nxt[i])
	{
		int y=point[i];
		if(y==fa) continue;
		dfs(y,x);
		f[x][0]=(f[x][0]*f[y][1])%mod;
		f[x][1]=(f[x][1]*(f[y][0]+f[y][1]))%mod;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(x,y);
	}
	dfs(1,0);
	printf("%lld\n",(f[1][0]+f[1][1])%mod);
	return 0;
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define For(i,k,n) for(ll i=k;i<n;i++)
#define endl "\n"
#define ll long long int
using namespace std;
#define test int t; cin>>t; while(t--)
#define vi vector<int>
#define vl vector<ll>
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>

void dummy(){
    for(int i=0;i<23;i++);
}
void scanArr(ll a[],ll n){
    For(i,0,n)cin>>a[i];
}
void scanArr(int a[],int n){
    For(i,0,n)cin>>a[i];
}
void printl(){
  cout<<endl;
}
void dummy2(){
  For(i,0,10)cout<<"";
}
ll mexp(ll a,ll b){
  if(a==0) return 0;
  if (b==0) return 1;
  ll ans=1;
  while(b>0){
    if(b&1){
      ans*=a;b--;
    }
    else{
      a*=a;b=b>>1;
    }
  }
  return ans;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  
  //        ------Code Here------
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
	return 0;
}

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

using namespace std;

int main(void){
	unsigned int N, K;
	scanf("%d", &N);
	scanf("%d", &K);
	//printf("(N, K) = (%d, %d) \n", N, K);

	unsigned int h[N], count;

	count = 0;
	for(int i=0; i<N; i++){
		scanf("%d", &h[i]);
		if(h[i] >= K) count += 1;
	}
	printf("%d\n", count);

	


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define R register
#define ll long long
#define mp make_pair
#define pii pair<int, int>
using namespace std;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    int m1, d1, m2, d2;
    read(m1), read(d1), read(m2), read(d2);
    printf("%d\n", m2 != m1 && d2 == 1);
    return 0;
}

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

int n; string s;
bool used[1000000];
vector<int>O, I;
bool ok(int t) {
	if (I.size() < t || O.size() < t)return false;
	memset(used, 0, sizeof(used));
	rep(i, t)used[I[i]] = 1;
	rep(i, t)used[O[i]] = 1;
	int p = n - 1;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (used[p] || s[p] == 'O'))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	cin >> n >> s;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I.push_back(i);
		if (s[i] == 'O'&&O.size() < I.size())O.push_back(i);
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        sum += tmp;
    }
    int ans = sum - n;
    cout << ans;
    return 0;
}

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

int64_t f(int64_t x,int64_t y,int64_t minimum){
  
  if(x%minimum==0 && y%minimum==0){
    return x*y/minimum;
  }
  
  return f(x,y,minimum-1);
  
}
  
  
  
int main() {
  int64_t A,B;
  cin>>A>>B;
  int64_t C=min(A,B);
  cout<<f(A,B,C)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  while (true) {
    double q;
    cin >> q;
    if (q == -1.)
      break;

    double x = q / 2;
    while (0.00001 * q <= abs(pow(x, 3) - q))
      x -= (pow(x, 3) - q) / (3 * x * x);

    printf("%.10lf\n", x);
  }
}


Measured memory_bytes: 3332
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.N) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

N, M = map(int, input().split())
P = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(N):
    P[i] -= 1
for _ in range(M):
    x, y = map(int, input().split())
    x-=1
    y-=1
    UF.union(x, y)

print(sum(UF.same(i,p) for i,p in enumerate(P)))

Measured memory_bytes: 13812
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define N 212345
using namespace std;
int main()
{
    long long res,n,sum;
    res=0;sum=0;
    cin>>n;
    if(n==0)
    {
        printf("0\n");
        return 0;
    }
    sum=(n/11)*2;
    n%=11;
    if(n>0&&n<=6)sum++;
    else if(n>6)sum+=2;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;

template<class T> bool ckmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template <typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template <typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template <class X, class Y>
std::ostream & operator << (std::ostream & os, std::pair <X, Y> const& p) {
    return os << p.first << " " << p.second;
}

template <class Ch, class Tr, class Container>
std::basic_ostream <Ch, Tr> & operator << (std::basic_ostream <Ch, Tr>& os, Container const& x) {
    bool first = true;
    for(auto& y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CMultipleClocks {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vl T(n);
        in >> T;
        ll res = accumulate(all(T), T[0], [&](ll x, ll y) {
            return lcm(x, y);
        });
        out << res << '\n';
	}

	void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
	CMultipleClocks solver;
    solver.setup();
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3628
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
const int mod = 1000000007;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
using namespace std;
int main() {
	ll n, h,a[100010],b[100010];
	cin >> n >> h;
	rep(i, n)cin >> a[i] >> b[i];
	sort(a, a + n); sort(b, b + n);
	int ct = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (h <= 0) { h = 0; break; }
		if (b[i] < a[n - 1])break;
		h -= b[i];
		++ct;
	}
	if(h>0)cout<<(h/a[n-1])+ct+(h%a[n-1]==0?0:1)<<endl;
	else cout << ct << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string A, B;
int N;

int main(void){
	//IO("test.in", "test.out");
	cin >> A >> B;
	N = stoi(A + B);
	if((int)sqrt(N) * (int)sqrt(N) == N) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main()
{
    int bc, rc;
    map<string, int> MB, MR;
    string s;

    cin >> bc;
    for (int i=0; i < bc; i++) {
        cin >> s;
        if (MB.count(s) > 0) {
            MB[s]++;
        } else {
            MB[s] = 1;
        }
    }

    cin >> rc;
    for (int i=0; i < rc; i++) {
        cin >> s;
        if (MR.count(s) > 0) {
            MR[s]++;
        } else {
            MR[s] = 1;
        }
    }

    int max = 0;
    map<string, int>::iterator it = MB.begin();
    while (it != MB.end())
    {
        string w = it->first;
        int wc_in_b = it->second;
        int wc_in_r = 0;
        if (MR.count(w) > 0) {
            wc_in_r = MR[w];
        } 
        int diff = wc_in_b - wc_in_r;
        if (max < diff) {
            max = diff;
        }
        it++;
    }
    cout << max << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

ll n,m,x, tmp;
V<V<int> > v;
ll cost[12];

bool check(V<int> &s) {
	bool ans = true;
	REP(i,m) {
		if(s[i] < x) {
			ans = false;
		}
	}
	/*
	if(!ans) {
		REP(j,m) {
			cout << s[j] << " ";
		}
		cout<< endl;
	}
	*/
	return ans;
}

ll solve(int i, int c, V<int> o) {
	V<int> n1;
	V<int> n2;
	REP(j,m) {
		n1.push_back(o[j]+v[i][j]);
		n2.push_back(o[j]);
	}
	if(i == n-1) {
		ll a1 = 100000000, a2 = 100000000;
		if(check(n1)) a1 = c + cost[i];
		if(check(n2)) a2 = c;
		return min(a1, a2);
	}
	return min(solve(i+1, c+cost[i], n1), solve(i+1, c, n2));
}

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

	REP(i,n) {
		V<int> v2;
		cin >> cost[i];

		REP(j,m) {
			cin >> tmp;
			v2.push_back(tmp);
		}
		v.push_back(v2);
	}

	V<int> tt(m);
	ll ans = solve(0, 0, tt);
	if(ans >= 100000000) cout << -1 << endl;
	else cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________
	string s;
	cin >> s;
	map<char, int>m;
	zip(i, 0, s.size())
	{
		m[s[i]]++;
	}
	zip(i, 0, s.size() - 1)
	{
		if (s[i] == s[i + 1])
		{
			cout << i + 1 << " " << i + 2 << en;
			return 0;
		}
	}
	zip(i, 0, s.size() - 2)
	{
		if (s[i] == s[i + 2])
		{
			cout << i + 1 << " " << i + 3 << en;
			return 0;
		}
	}
	cout << -1 << " " << -1 << en;



	return 0;
}



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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<set>
#include<cmath>
using namespace std;

int main()
{
  int N, K, input, temp, moto, min, keta, ans, fin, kakunin;
  bool flag = false;
  int toridashi(int N, int keta);
  set<int> S;
  
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    cin >> input;
    S.insert(input);
  }
  int i;
  for(i = N; i < 10*N; i++){
    flag = false;
    int mlog = log10(i);
    for(int j = 0; j < mlog+1 ; j++){
      temp = toridashi(i, j);
      if(S.count(temp)){
        flag = true;
        break;
      }
    }
    if(flag == false) break;
  }
  cout << i << endl;
  
  return 0;
}


int toridashi(int i, int keta)
{
  for(int j = 0; j < keta; j++) i /= 10;
  return i % 10;
}

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

#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<pair<int, int>> q(n);
    for (int i = 0; i < n; i++) {
        q[i] = {a[i], i};
    }
    sort(q.rbegin(), q.rend());

    vector<vector<long>> d(n + 1, vector<long>(n + 1, LLONG_MIN));
    d[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= i; j++) {
            if (d[i][j] == LLONG_MIN) continue;
            {
                //left
                d[i + 1][j + 1] = max(d[i + 1][j + 1],
                                      d[i][j] +
                                      (long) q[i].first * abs(q[i].second - j)
                );
            }
            {
                //right
                d[i + 1][j] = max(d[i + 1][j],
                                  d[i][j] +
                                  (long) q[i].first * abs(q[i].second - (n - 1 - (i - j)))
                );
            }
        }
    }
    long res = 0;
    for (int j = 0; j <= n; j++) {
        res = max(res, d[n][j]);
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 34540
#include <stdio.h>
#include <string>
#include<iostream>
using namespace std;
int main()
{
    // 入力
    int N;
    cin>>N;
    int d[N];
    for(int i=0;i<N;i++){
    	cin>>d[i];
    }

    int next_diameter=0;
    int next_i=0;
    int base_diameter=200;
    bool next_found=false;
    bool loop_continue=true;
    int tower_height=0;
    while(loop_continue){
	    for(int i=0;i<N;i++){
			if(d[i]<base_diameter) {
				if(d[i]>next_diameter){
					next_diameter=d[i];
					next_i=i;
					next_found=true;
					//cout<<d[i]<<endl;
				}
			}
		}
		if(next_found){
			tower_height++;
			next_found=false;
			base_diameter=next_diameter;
			next_diameter=0;
			d[next_i]=0;
		} else{
			loop_continue=false;
		}

	}
	cout<<tower_height<<endl;
    return 0;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    
    rep(h,H) {
        rep(w,W) {
            if (w+1<=A && h+1<=B) {
                cout << 1;
            }
            else if (w+1>A && h+1>B) {
                cout << 1;
            }
            else {
                cout << 0;
            }
        }
        cout << endl;
    }
}


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

int main(){


    ll N,K; cin>>N>>K;
    vector<ll> H(N);

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

    sort(H.begin(), H.end(), greater<>());
    ll sum=0;
    for (int i = K; i < N; ++i) {
        sum += H[i];
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
//作者:中国江苏南京丁天行
using namespace std;
int n;
ll f[100005],s[100005],ans,sum;
int c[100005],a[100005];
int main(){
    scanf("%d",&n);
    c[1]=1;
    scanf("%d",a+1);
    for(int i=2;i<=n;++i){
        char in;
        scanf(" %c%d",&in,a+i);
        if(in=='+')c[i]=1;
        else c[i]=-1;
    }
    for(int i=n;i;--i)s[i]=abs(a[i])+s[i+1];
    c[n+1]=-1;
    ans=-orz*n;
    for(int i=1;i<=n;++i){
        if(c[i]==-1){
            ll add=a[i];
            int k=i+1;
            while(c[k]==1)add+=a[k++];
            ans=max(ans,sum-add+s[k]);
        }
        sum+=a[i]*c[i];
    }
    ans=max(ans,sum);
    printf("%lld\n",ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,t;
	int x,h;
	int i;
	double max;
	cin>>n>>t;
	max=-1;
	for(i=0;i<n;i++){
		cin>>x>>h;
		if(max<(double)h*t/x) max=(double)h*t/x;
	}
	printf("%lf\n",max);
	return 0;
}


Measured memory_bytes: 3220
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int ain = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		int aout = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		int bin = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		int bout = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		int cin = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		int cout = sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
		
		int a = aout - ain;
		int b = bout - bin;
		int c = cout - cin;
		
		System.out.println(a / 3600 + " " + (a % 3600) / 60 + " " + ((a % 3600) % 60));
		System.out.println(b / 3600 + " " + (b % 3600) / 60 + " " + ((b % 3600) % 60));
		System.out.println(c / 3600 + " " + (c % 3600) / 60 + " " + ((c % 3600) % 60));
	}
}

Measured memory_bytes: 26192
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>
#include <stack>
using namespace std;
typedef long long ll;
#define T int t_;Read(t_);while(t_--)
#define dight(chr) (chr>='0'&&chr<='9')
#define alpha(chr) (chr>='a'&&chr<='z')
#define INF (0x3f3f3f3f)
#define maxn (100005)
#define maxm (10005)
#define mod 1000000007
#define ull unsigned long long
#define repne(x,y,i) for(int i=(x);i<(y);++i)
#define repe(x,y,i) for(int i=(x);i<=(y);++i)
#define repde(x,y,i) for(int i=(x);i>=(y);--i)
#define repdne(x,y,i) for(int i=(x);i>(y);--i)
#define ri register int
inline void Read(int &n){char chr=getchar(),sign=1;for(;!dight(chr);chr=getchar())if(chr=='-')sign=-1;
    for(n=0;dight(chr);chr=getchar())n=n*10+chr-'0';n*=sign;}
inline void Read(ll &n){char chr=getchar(),sign=1;for(;!dight(chr);chr=getchar())if
    (chr=='-')sign=-1;
    for(n=0;dight(chr);chr=getchar())n=n*10+chr-'0';n*=sign;}
int a[105];
int main()
{
   // freopen("a.in","r",stdin);
  //  freopen("b.out","w",stdout);
    int n,x,ans=0;
    Read(n),Read(x);
    repe(1,n,i) Read(a[i]);
    sort(a+1,a+n+1);
    repe(1,n,i){
        x -= a[i];
        if(x<0)break;
        ++ans;
    }
    if(x > 0) --ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AtCoder Regular Contest 067
// C - Factors of Factorial

#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#define MAX_N 1000
#define MOD ((ll)1e9 + 7)
using namespace std;
typedef long long int ll;


int N;
bool is_not_prime[MAX_N + 1];
vector<int> primes;
map<int, int> factors;
ll ans;


int main() {

  int n;

  scanf("%d", &N);

  memset(is_not_prime, 0, sizeof(is_not_prime));
  for (int i = 2; i <= N; i++) {
    if (is_not_prime[i]) {
      continue;
    }
    primes.push_back(i);
    for (int j = 1; i * j <= N; j++) {
      is_not_prime[i * j] = true;
    }
  }

  for (int i = 2; i <= N; i++) {
    n = i;
    for (int j = 0; j < (int)primes.size(); j++) {
      while (n % primes[j] == 0) {
        factors[primes[j]] = factors[primes[j]] + 1;
        n /= primes[j];
      }
    }
  }

  ans = 1;
  for (auto itr = factors.begin(); itr != factors.end(); itr++) {
    ans *= itr->second + 1;
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;

}




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

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

  int totalE=0;
  int totalW=0;
  int e=0;
  int w=0;
  for(int i=0;i<n;i++)
    if(s[i]=='E')totalE++;
    else totalW++;

  int ans=1e9;


  for(int i=0;i<n;i++){
    int ne=e;
    int nw=w;
    
    if(s[i]=='E')ne++;
    else nw++;

    int c=w + (totalE-ne);

    ans=min(ans,c);
    e=ne;
    w=nw;
  }

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


Measured memory_bytes: 900
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();
			long n = cin.Long();
			long ans = n * (n - 1) / 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: 11092
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


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

	long long n, m, i, j, k, x, y, xx, yy, ans, cc, nn, mm;
	cin >> n >> m;
	vector<long long> a(n), b(n), c(n), d(m), e(m), f(m);
	set<long long> sx = { -1000000100, 0, 1000000100, 1000000200 };
	set<long long> sy = { -1000000100, 0, 1000000100, 1000000200 };

	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
		sx.insert(a[i]);
		sx.insert(b[i]);
		sy.insert(c[i]);
	}

	for (i = 0; i < m; i++) {
		cin >> d[i] >> e[i] >> f[i];
		sx.insert(d[i]);
		sy.insert(e[i]);
		sy.insert(f[i]);
	}

	map<long long, long long> xid, yid;
	cc = 0;
	for (auto p : sx) xid[p] = cc++;
	cc = 0;
	for (auto p : sy) yid[p] = cc++;

	nn = yid.size(); 
	mm = xid.size();
	vector<long long> xsize(mm, 0), ysize(nn, 0);
	vector<long long> px, py;
	for (auto p : sx) px.push_back(p);
	for (auto p : sy) py.push_back(p);
	for (i = 0; i < mm - 1; i++) xsize[i] = px[i + 1] - px[i];
	for (i = 0; i < nn - 1; i++) ysize[i] = py[i + 1] - py[i];

	vector<vector<bool>> up(nn, vector<bool>(mm, true));
	vector<vector<bool>> down(nn, vector<bool>(mm, true));
	vector<vector<bool>> left(nn, vector<bool>(mm, true));
	vector<vector<bool>> right(nn, vector<bool>(mm, true));


	for (i = 0; i < nn; i++) {
		left[i][0] = false;
		right[i][mm - 1] = false;
	}
	for (i = 0; i < mm; i++) {
		down[0][i] = false;
		up[nn - 1][i] = false;
	}

	for (i = 0; i < n; i++) {
		x = xid[a[i]];
		xx = xid[b[i]];
		y = yid[c[i]];

		for (j = x; j < xx; j++) {
			down[y][j] = false;
			up[y - 1][j] = false;
		}
	}

	for (i = 0; i < m; i++) {
		x = xid[d[i]];
		y = yid[e[i]];
		yy = yid[f[i]];

		for (j = y; j < yy; j++) {
			right[j][x - 1] = false;
			left[j][x] = false;
		}
	}

	vector<vector<bool>> visited(nn, vector<bool>(mm, false));
	x = yid[0]; y = xid[0];
	queue<pair<long long, long long>> q;

	visited[x][y] = true;
	q.push({ x, y });

	while (!q.empty()) {
		x = q.front().first;
		y = q.front().second;
		q.pop();

		vector<pair<long long, long long>> v;
		if (right[x][y]) v.push_back({ x, y + 1 });
		if (left[x][y]) v.push_back({ x, y - 1 });
		if (down[x][y]) v.push_back({ x - 1, y });
		if (up[x][y]) v.push_back({ x + 1, y });

		for (auto p : v) {
			xx = p.first; yy = p.second;

			if (visited[xx][yy]) continue;
			visited[xx][yy] = true;
			q.push({ xx, yy });
		}
	}

	if (visited[0][0]) {
		cout << "INF\n";
	}
	else {
		ans = 0;
		for (i = 0; i < nn - 1; i++) {
			for (j = 0; j < mm - 1; j++) {
				if (visited[i][j]) {
					ans += (long long)ysize[i] * xsize[j];
					//cout << ans << "\n";
				}
			}
		}
		cout << ans << "\n";
	}


	return 0;
}



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

#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;

int dfs(int x,int y);
int dx[] = {0,-1,0,1,0};

int w,h;
string g[21];

int main(){
    while(cin >> w >> h,w) {
        rep(i,h){
            cin >> g[i];
        }
        rep(y,h) {
            rep(x,w){
                if(g[y][x] == '@') {
                    int cnt = dfs(x,y);
                    cout << cnt << endl;
                }
            }
        }
    }
    return 0;

}

int dfs(int x,int y){
    g[y][x] = '#';
    int cnt = 1;
    rep(i,4){
        int nx = x + dx[i], ny = y + dx[i + 1];
        if(nx >= 0 && ny >= 0 && nx < w && ny < h && g[ny][nx] == '.') {
            cnt += dfs(nx,ny);
        }
    }
    return cnt;
}



Measured memory_bytes: 3180
#include <iostream>
#include <string>

using namespace std;

int main(){
	int joi=0,ioi=0;
	string str;
	while(cin>>str){
		joi=ioi=0;
	for(int i=0;i<str.size()-2;i++){
		if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I')joi++;
		else if(str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I')ioi++;
	}
	cout<<joi<<endl;
	cout<<ioi<<endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll; 
 
int N;
const int MAX_N = 100000;
ll A[MAX_N];

int gcd(int a, int b) {
    int large = max(a, b);
    int small = min(a, b);
    if (small == 0) return large;
    else return gcd(small, large % small);
}

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

    ll L[MAX_N+1];
    L[0] = 0;
    for (int i = 0; i < N - 1; i++) L[i+1] = gcd(L[i], A[i]);

    ll R[MAX_N+1];
    R[N+1] = 0;
    for (int i = N; i >= 0; i--) R[i] = gcd(R[i+1], A[i]);

    int ans = 0;
    for (int i = 0; i < N; i++){
        ans = max(ans, gcd(L[i], R[i+1]));
    }

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int x, y;
	cin >> x >> y;
	cout << (-1 <= x - y && x - y <= 1 ? "Brown" : "Alice") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define N 200020
#define int long long
#define inf 1e9
using namespace std;

int n,cnt,ans;
int root[N];

double bessie[N];

struct node{
	int p2,p5;
}num[N];

int calc(int x,int y,int s=0){
	while(x%y==0)s++,x/=y;
	return s;
}

bool operator<(node x,node y){
	if(x.p2!=y.p2)return x.p2>y.p2;
	else return x.p5>y.p5;
}

int getrk(int x){
	int l=0,r=n+1;
	while(r-l>1){
		int mid=(l+r)>>1;
		if(num[mid].p2>=x)l=mid;
		else r=mid;
//		printf("get %lld %lld %lld %lld\n",l,r,mid,x);
	}
	return l;
}

struct TREE{
	int val,ls,rs;
}tree[N*20];

#define L(x) tree[x].ls
#define R(x) tree[x].rs
#define mid ((l+r)>>1)
#define lson L(x),l,mid
#define rson R(x),mid+1,r

void update(int x){
	tree[x].val=tree[L(x)].val+tree[R(x)].val;
}

void build(int &x,int l,int r,int s){
	if(s<l||s>r)return;
	tree[++cnt]=tree[x],x=cnt;
//	printf("run: %lld %lld %lld %lld\n",x,l,r,s);
	if(!(l^r)){tree[x].val++;return;}
	build(lson,s),build(rson,s);
	update(x);
}

int query(int x,int l,int r,int s){
//	printf("%lld %lld %lld %lld\n",x,l,r,s);
//	system("pause");
	if(!(l^r))return tree[x].val;
	if(s>mid)return query(rson,s);
	else return tree[R(x)].val+query(lson,s);
}

void init(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&bessie[i]);
		bessie[i]=llround(bessie[i]*inf);
//		printf("%lf\n",bessie[i]);
	}
	for(int i=1;i<=n;i++){
		num[i].p2=calc(bessie[i],2),num[i].p5=calc(bessie[i],5);
	}
	sort(num+1,num+1+n);
	for(int i=1;i<=n;i++){
		root[i]=root[i-1];
		build(root[i],1,30,num[i].p5+1);
//		printf("root: %lld %lld %lld %lld\n",i,root[i],num[i].p2,num[i].p5);
	}
//	printf("xxx\n");
	for(int i=1;i<=n;i++){
		int pos=getrk(18-num[i].p2);
//		printf("fuckljx %lld\n",pos);
		int now=query(root[pos],1,30,19-num[i].p5);
		if((num[i].p2<<1)>=18&&(num[i].p5<<1)>=18)now--;
		ans+=now;
	}
	printf("%lld\n",ans>>1);
}

#undef int

int main(){
	init();
}

Measured memory_bytes: 38136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main(int argc, char* argv[])
{
  int N, K;
  std::cin >> N >> K;

  std::vector< int > vl(N, 0);
  for (int i = 0; i < N; i++) {
    std::cin >> vl[i];
  }

  std::sort(vl.begin(), vl.end(), std::greater< int >());
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += vl[i];
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vecint h(n);
  for(auto&& e:h)cin>>e;
  constexpr int INF = 1000000000;
  vecint dp(n, INF);
  dp[0] = 0;
  for(auto&& i:irange(1,n)) {
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    if (i >= 2) {
      dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }
  cout<<dp.back()<<endl;
  return 0;
}


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

int main(){
	int A, B, C, D, P;

	cin>>A>>B>>C>>D>>P;

	if(P >= C) {
		if(P*A > B + D * (P - C)){
			cout<< B + D * (P - C) <<endl;
		} else {
			cout<< P * A <<endl;
		}
	} else{
		if(B > A * P){
			cout<<A * P<<endl;
		} else {
			cout<< B<<endl;
		}
		
	}

	return 0;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int n,k,s,cnt;
void a(int q,int p,int f){
  if(f==k){
    if(s==q) cnt++;
  }else for(int i=p+1;i<=n;i++)a(i+q,i,f+1);
}

int main(){
  while(1){
    cin>>n>>k>>s;
   if(n+k+s==0) break;
   cnt=0;
   for(int i=1;i<=n;i++) a(i,i,1);
   cout<<cnt<<endl;
  }
     return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int N,i;
    int s=0;
    double k;
    scanf("%d",&N);
    for (i=1;i<=N;i++)
    {
        if (i%2!=0)
        {
            s++;
        }
        else
        {
            k=0.5;
        }
    }
    k=1.0*s/N;
    printf("%.10f\n",k);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n,a;
    cin>>n;
    vector<ll> c(n);
    vector<ll> d(n+1,0);
    rep(i,n) {
        cin>>a;
        a--;
        c[a]++;
        d[c[a]]++;
    }
    vector<ll> S(n+1,0);
    for (int i = 1; i < n+1; ++i) S[i] = S[i-1] + d[i];
    for (long long K = 1; K <= n; ++K) {
        long long low = 0, high = n+1;
        while (high - low > 1) {
            long long x = (low + high) / 2;
            if (S[x] >= K * x) low = x;
            else high = x;
        }
        cout << low << endl;
    }    
    return 0;
}

Measured memory_bytes: 7936
#include<cstdio>
const static int MOD = 1000000007;

int main(){
	int N, K;
	scanf("%d %d", &N, &K);
	long long ans = 0;
	for (long long i = K; i <= N+1; ++i){
		ans = (ans + i*(N+1 - i) + 1) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<bool> good(N, true);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (H[a] >= H[b]) good[b] = false;
    if (H[b] >= H[a]) good[a] = false;
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (good[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3736
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4020
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
s = input()
kaku = 0
kaigai = 0
for i,t in enumerate(s):
    if t == 'a':
        if kaku < a+b:
            res = 'Yes'
            kaku += 1
        else:
            res = 'No'
    elif t == 'b':
        if kaku < a+b and kaigai < b:
            res = 'Yes'
            kaku += 1
            kaigai += 1
        else:
            res = 'No'
    else:
        res = 'No'
    print(res)


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

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

  int n, m;
  cin >> n >> m;

  vector<string> a(n), b(m);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }

  string ans = "No";
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool check = true;
      for (int x = 0; x < m; x++) {
        for (int y = 0; y < m; y++) {
          char pa = a[i + x][j + y];
          char pb = b[x][y];

          if (pa != pb) {
            check = false;
            break;
          }
        }

        if (!check) break;
      }

      if (check) {
        ans = "Yes";
        i = n;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, k; cin >> n >> k;
    map<int, ll> num;
    // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
    for (int i = 1; i <= n; ++i) num[i%k]++;

    long long res = 0;
    for (int a = 0; a < k; ++a) {
        int b = (k-a) % k;
        int c = (k-a) % k;
        if ((b+c) % k != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 6528
#include<iostream>
#define MAX_SIZE 1000000

using namespace std;

int main(void){
	
	int a,d,n,temp;
	bool is_prime[MAX_SIZE+1];
	
	
	for(int i=0;i<=MAX_SIZE;i++){
		is_prime[i]=true;
	}
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=MAX_SIZE;i++){
		if(is_prime[i]){
			for(int j=2*i;j<=MAX_SIZE;j=j+i){
				is_prime[j]=false;
			}
		}
	}

	while(1){
		
		cin>>a>>d>>n;
		
		if(a==0 && d==0 && n==0){
			break;
		}
		for(int i=0,cnt=0;i<=MAX_SIZE;i++){
			temp=a+i*d;
		
			if(is_prime[temp]){
				cnt++;
				if(cnt==n){
					cout<<temp<<endl;
				}
			}
			if(cnt==n){
				break;
			}
		}
	}
}

Measured memory_bytes: 0
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
f = [0] * 100001
s = sum(a)
for v in a:
    f[v] += 1

q = ni()
for z in range(q):
    b, c = na()
    s += (c-b) * f[b]
    f[c] += f[b]
    f[b] = 0
    print(s)


Measured memory_bytes: 85300
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    int k;
    cin>>s>>k;
    rep(i,k){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
}


Measured memory_bytes: 256
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N, K = input_int()

if N>K:
    temp=N%K
    print(min(temp, abs(K-temp)) )
else:
    print(min(N, abs(K-N)) )

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

bool solve() {
    string N;
    cin >> N;
    int a = 0;
    for ( char c : N ) {
        a += (int)(c -'0');
        a %= 9;
    }
    return a == 0;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3684
#include <cstdio> 
#include <cstdlib> 
#include <numeric>
#include <cmath> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
using namespace std; 
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  

typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 

vector<string>generate(){
  vector<string> ret;
  rep(i,26){
    rep(j,26){
      rep(k,26){
	ret.push_back(string(1,'a'+i)+string(1,'a'+j)+string(1,'a'+k));
      }
    }
  }
  return ret;
}

main(){
  int p=0;
  vector<string> all = generate();
  string last=string(1,'a');
  string beg=last;
  set<string> S;
  while(true){
    string query=beg+all[p++]+last;
    printf("?%s\n",query.c_str());fflush(stdout);
    char buf[3];
    scanf("%s",buf);
    string tmp = string(buf);
    if (S.find(tmp) != S.end() || tmp[0] != last[0]){
      printf("!OUT\n");fflush(stdout);
      break;
    }
    S.insert(tmp);
    beg =string(1,tmp[tmp.size()-1]);
  }
  return false;
}

Measured memory_bytes: 0
N=int(input())
W=list(map(int,input().split()))

val=10**9
for i in range(N):
    if abs(sum(W[:i+1])-sum(W[i+1:])<val):
        val=abs(sum(W[:i+1])-sum(W[i+1:]))
        
        
print(val)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),K=in();
	if(K>=N){
		out(0);
		return 0;
	}
	auto H=vecin<ll>(N);
	sort(ALL(H),greater<ll>());

	out(accumulate(H.begin()+K,H.end(),0LL));

	return 0;
}

Measured memory_bytes: 1792