akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int nn;

void solve(string s, int c, int n) {
	if(n == nn) {cout << s << endl; return;}
	rep(i, c) {
		string t = s;
		t += 'a' + i;
		solve(t, c, n+1);
	}
	string t = s;
	t += 'a' + c;
	solve(t, c+1, n+1);
	return;
}

int main() {
//	cout << fixed << setprecision(15);
	cin >> nn;
	string s = "";
	solve(s, 0, 0);
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,ans;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        cin>>a>>b;
        ans+=b-a+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pi = pair<int, int>;
using vi = vector<int>;
using vii = vector<pi>;
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(0); cin.tie(NULL);
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x)sz(a))
#define present(t, x) (t.find(x) != t.end())
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define forall(it, a) for(decltype((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define what_is(x) cerr << #x << " is " << (x) << endl;
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) \
	for(long blockTime=(long)NULL;(blockTime==(long)NULL?(blockTime=clock())!=(long)NULL:false); \
	debug("%s:%.4fs\n",(d),(double)(clock()-blockTime)/CLOCKS_PER_SEC))
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1); // pi
const ld EPS = 1e-9; // epsilon
#define eb emplace_back
#define ef emplace_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int imin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int imax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

//time__("program time")

void solve(){

}

int main(){

	fast_io;
	//solve();
	int n;
	cin >> n;

	uint64_t ans;
	if(n%2 == 0){
		cout << n << "\n";
	}else{
		ans = 2*n;
		cout << ans << "\n";
	}

return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    vector<int> button;
    for (int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        a--;
        button.push_back(a);
    }

    int now = 0, c = 0;
    for (;;)
    {
        if (now == 1)
        {
            printf("%d\n", c);
            break;
        }

        if (c >= n)
        {
            printf("-1\n");
            break;
        }
        c++;
        now = button[now];
    }
}


Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main() {
	int n,a;
	cin >> n;
	int cnt = 0;
	int m = 1000001;
	for (int i = 0;i < n;i++) {
		cin >> a;
		if (m > a) {
			cnt++;
			m = a;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int dt[n];
		rep(i,n)cin>>dt[i];
		sort(dt,dt+n);
		int res=0,ans=0;
		rep(i,n){
			res+=dt[i];
			ans+=res;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
n = int(input())
for i in range(n):
    y,m,d = map(int,input().split())
    only_dai = (1000 - y + 1) // 3 * 10 * 20
    dai_shou = ((1000 - y - 1) - (1000 - y + 1) // 3) * (20 * 5 + 19 * 5)
    if y % 3 == 0:
        hanpa_m = (10 - m) * 20
    else:
        hanpa_m = (10 - m) * 20 - (10 - m + 1) // 2
    if m % 2 == 0 and y % 3 != 0:
        hanpa_d = 19 - d
    else:
        hanpa_d = 20 - d
    ans = only_dai + dai_shou + hanpa_m + hanpa_d + 1
    print(ans)


Measured memory_bytes: 5592
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<double,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int x,y,X,Y;cin >> x >> y >> X >> Y;
    int a = X - x;int b = Y - y;
    cout << X - b << " " << Y + a << " " << x - b << " " << y + a << endl;

}


Measured memory_bytes: 256
program prob1
    implicit none
    integer(8)::N, i, j, maxf, count, ans, fc, ec
    integer, allocatable::h(:), m(:)
    read(*,*) N
    allocate(h(N))
    allocate(m(N))
    read(*,*) h
    maxf = maxval(h)
    ans = 0

    do while(maxf /= 0)
        count = 0
        do i = 1, N-1
            if(h(i) == 0 .and. h(i+1) > 0) then
                if(count == 0)then
                    fc = i
                end if
                ec = i
                count = count + 1
            end if
        end do
        count = count + 1

        if(sum(h(1:fc)) == 0) then
            count = count -1
        end if
        ans = ans + count

        do i = 1, N
            if(h(i) > 0) then
                h(i) = h(i) - 1
            end if
        end do

        maxf  = maxval(h)
    end do

    write(*,*) ans

    deallocate(h)
    deallocate(m)
    stop
end program prob1

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf LLONG_MAX/10000000
#define INF LLONG_MAX/3
#define P pair<int,int>
using namespace std;
signed main(){
	int n,t;
	cin>>n>>t;
	int ans=INF;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(b<=t)ans=min(ans,a);
	}
	if(ans==INF)cout<<"TLE"<<endl;
	else cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
def check(S, T):
    tbl = {}
    inv = {}
    for i in range(len(S)):
        if S[i] in tbl and tbl[S[i]] != T[i]:
            return False
        if T[i] in inv and inv[T[i]] != S[i]:
            return False
        tbl[S[i]] = T[i]
        inv[T[i]] = S[i]
    return True


def main():
    S = input()
    T = input()
    if check(S, T):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 41840
import sys
input = sys.stdin.readline

N,M,C = map(int,input().split())
Bm = list(map(int,input().split()))
rtn=0
for i in range(N):
  Aim = list(map(int,input().split()))
  chk = C
  for j in range(M):
    chk += Aim[j]*Bm[j]
  if chk > 0:
    rtn+=1
print(rtn)


Measured memory_bytes: 3060
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	set<string> ST;
	cin >> N;

	rep(i, N) {
		string S;
		cin >> S;
		ST.insert(S);
	}

	co(ST.size());

	Would you please return 0;
}

Measured memory_bytes: 19140
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > A(N+2);
  int sum  = 0;
  A[0]=0;
  A[N+1] = 0;
  for (int i=1; i<=N; i++){
    scanf("%d", &A[i]);
  }
  for (int i=0; i<=N; i++){
    sum += abs(A[i]-A[i+1]);
  }
  //printf("sum=%d\n", sum);
  for (int i=1; i<=N; i++){
    printf("%d\n", sum-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]));
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int x = 0;
    for(int i = 0; i < n; i++) x += a[i];
    bool ans = true;
    for(int i = 0; i < m; i++){
        if(a[i] * (4*m) < x) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   
void solve(){
    int n,k,c;
    string s;
    cin >> n >> k >> c >> s;
    s = '#'+s;
    vector<int>suf(2*n+5),pre(n+5);
    FOR(i,1,n+1){
        if(s[i] == 'x')pre[i] = pre[i-1];
        else pre[i] = max(pre[i-1],1+pre[max(0LL,i-c-1)]);
    }
    RFOR(i,n,0){
        if(s[i] == 'x')suf[i] = suf[i+1];
        else suf[i] = 1+suf[i+c+1];
    }
    vector<int>ans;
    int checker = 0,it = 0;
    FOR(i,1,n+1){
        if(s[i] == 'o'){
            while(checker+1 < i){
                ++checker;
                if(s[checker] == 'o')it = checker;
            }
            if(!it){
                if(suf[i+1] < k)ans.pb(i);
                continue;
            }
            int lo = 1,hi = it;
            while(lo < hi){
                int mid = (lo+hi)/2;
                if(pre[mid] == pre[it])hi = mid;
                else lo = mid+1;
            }
            if(pre[lo]+suf[max(i+1,lo+c+1)] >= k || i-lo < c)continue;
            ans.pb(i);
            //cout << it << "\n";
        }
    }
    for(auto &x:ans)cout << x << "\n";
}

signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 8520
/*
Author : N_o_o_B
Created : January 12 2020 17:34:27 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n,m;
    cin >> n >> m;
    vi penalties(n);
    vi first_ac(n,-1);
    int cnt = 0;
    int pen = 0;
    fori(i,m){
        int p;string s;
        cin >> p >> s;
        p--;
        if(s=="WA" and first_ac[p]==-1){
            penalties[p]++;
        }
        if(s=="AC" and first_ac[p]==-1){
            first_ac[p]=i;
            cnt++;
            pen += penalties[p];
        }
    }
    cout << cnt << " " << pen << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int N;
pair<int, int> A[105], B[105];
bool paired[105];

int main(void) {
    scanf("%d", &N);
    REP(i, 0, N) {
    	int a, b;
    	scanf("%d %d", &a, &b);
    	A[i] = make_pair(a, b);
    }

    REP(i, 0, N) {
    	int c, d;
    	scanf("%d %d", &c, &d);
    	B[i] = make_pair(c, d);
    }
    sort(A, A+N);
    sort(B, B+N);

    REP(i, 0, N) {
    	int j = 0;
    	int idx = -1;
    	int maxy = -1;
    	while (A[j].first < B[i].first && j < N) {
    		if (A[j].second < B[i].second && paired[j] == false && A[j].second > maxy) {
    			maxy = A[j].second;
    			idx = j;
    		}
    		j++;
    	}
    	if (idx != -1) {
    		paired[idx] = true;
    	} 
    }

    REP(i, 0, N) if (paired[i]) ans++;
  
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>

using namespace std;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for (int i = 0; i < m; ++i) {
        ans *= 2;
    }
    cout << ans * (1900 * m + 100 * (n - m)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve()
{
    int K, A, B;
    cin >> K >> A >> B;
    int ans = 0;
    for (int i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            ans = 1;
            break;
        }
    }
    if (ans) cout << "OK";
    else cout << "NG";

}

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


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

int n_=1<<19;

class segtree{
public:
	int dp[1<<20];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=n_-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=n_){
		if(b<=l || r<=a)return 2e9;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

segtree seg[2];

int n,q;
int a[200005],b[200005];
set<int> s;

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		seg[0].update(i,a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		seg[1].update(i,b[i]);
	}
	scanf("%d",&q);
	bool flag=false;
	for(int i=0;i<q;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		y--;
		if(x==1){
			s.insert(y);
			seg[0].update(y,z);
		}
		if(x==2){
			s.insert(y);
			seg[1].update(y,z);
		}
		if(x==3){
			printf("%d\n",seg[0].query(y,z));
		}
		if(x==4){
			printf("%d\n",seg[1].query(y,z));
		}
		if(x==5 || x==6){
			int side=x-5;
			if(!flag){
				for(int i=0;i<n;i++){
					seg[side].update(i,seg[1-side].query(i,i+1));
				}
				flag=true;
			}else{
				for(set<int>::iterator it=s.begin();it!=s.end();it++){
					seg[side].update(*it,seg[1-side].query(*it,(*it)+1));
				}
			}
			s.clear();
		}
	}
	return 0;
}

Measured memory_bytes: 12936
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			ans+=a[i]*a[j];
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
	int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int gram;
	vector<int> ans;
	while(cin>>gram){
		for(int i=9;i>=0;i--){
			if(gram >= weight[i]){
				ans.push_back(i);
				gram -= weight[i];
			}
		}
		
		for(int i=ans.size()-1;i>=0;i--){
			cout<<weight[ ans[i] ];
			if(i != 0) cout<<' ';
		}
		cout<<endl;  
		ans.clear();
	}
	return 0;
}

Measured memory_bytes: 1216
package main

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

func main() {
	bio := bufio.NewReader(os.Stdin)
	raw1, err := bio.ReadBytes('\n')
	if err != nil {
		panic(err)
	}
	num, err := strconv.Atoi(string(raw1[:(len(raw1) - 1)]))
	if err != nil {
		panic(err)
	}
	raw2, err := bio.ReadBytes('\n')
	if err != nil {
		panic(err)
	}
	elemsStr := strings.Split(string(raw2[:(len(raw2)-1)]), " ")
	elems := make([]int, num)
	for i := 0; i < len(elemsStr); i++ {
		x, err := strconv.Atoi(elemsStr[i])
		if err != nil {
			panic(err)
		}
		elems[i] = x
	}

	for i := 0; i < len(elems); i++ {
		elem := elems[i]
		j := i
		for ; j > 0; j-- {
			if elems[j-1] > elem {
				elems[j] = elems[j-1]
			} else {
				break
			}
		}
		elems[j] = elem
		printElems(elems)
	}
}

func printElems(elems []int) {
	res := make([]string, len(elems))
	for i, n := range elems {
		res[i] = strconv.Itoa(n)
	}
	fmt.Println(strings.Join(res, " "))
}



Measured memory_bytes: 1416
# n = gets.chomp.to_i
d = []
cnt = 0
list = {}

n, k = gets.chomp.split(" ").map(&:to_i)

n.times do |i|
  list[i+1]=0
end

k.times do |i|
  d[i] = gets.chomp.to_i
  a = []
  a = gets.chomp.split(" ").map(&:to_i)
  a.each do |v|
    list[v]+=1
  end
end

n.times do |i|
  cnt+=1 if list[i+1]==0
end

puts cnt

Measured memory_bytes: 14368
from sys import stdin


def main():
    N = int(stdin.readline())
    A = [int(input()) for _ in range(N)]

    new_A = sorted(A, reverse=True)
    max_A = new_A.pop(0)
    next_max_A = new_A.pop(0)

    for a in A:
        if max_A == a:
            print(next_max_A)
        else:
            print(max_A)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14108
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    
    int left=0,right=0;
    ll sum=0;
    ll ans=0;
    while(left<n){
        while(right<n && (sum^a[right])==(sum+a[right])){
            sum+=a[right];
            right++;
        }
        ans+=(right-left);
        if(left==right) right++;
        else sum-=a[left];
        left++;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n);
    v_inputrep(a, n);
    sort(a.begin(), a.end(), greater<int>());
    int sum = accumulate(a.begin(), a.end(), 0);

    bool flag = true;
    double norm = sum / (double)(4 * m);

    for(int i = 0 ; i < m ; i++){
      if(a.at(i) < norm){
          flag = false;
      }
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }


}

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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    string o, e;
    cin >> o >> e;

    ll size_o = o.size();
    ll size_e = e.size();
    for (int i = 0; i < min(size_o,size_e); ++i) {
        cout << o.at(i) << e.at(i);
    }

    if (size_o != size_e) {
        cout << o.at(o.size()-1);
    }
    cout << endl;

    return 0;
}


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

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define watch(x);       cout << "\n" <<  #x << " is: " << x << "\n";
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd(a,b)
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        int a[n];
        loop(i,0,n-1)
        {
            cin>>a[i];
        }
        ll money=1000;
        int j=0;
        loop(i,0,n-2)
        {
            if(a[i+1]>a[i])
                continue;
            else
            {
                ll stocks=money/a[j];
                money=(money-(stocks*a[j]))+stocks*a[i];
                j=i+1;
            }
        }
        if(j!=n-1)
        {
            ll stocks=money/a[j];
                money=(money-(stocks*a[j]))+(stocks*a[n-1]);
        }
        cout<<money;
        //nl;
    }
    return 0;
}


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

using namespace std;

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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a+b == 15) cout << "+" << endl;
	else if (a*b == 15) cout << "*" << endl;
	else cout << "x" << endl;
	return 0;
}

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

int n,m;
int x[222];
int cp[222];

void rshu(){
	int i;
	for( i = 0; i < n; i++ ){
		cp[2*i] = x[i];
		cp[2*i+1] = x[n+i];
	}
	for( i = 0; i < 2*n; i++ )
		x[i] = cp[i];
}
void cut( int input ){
	int i;
	for( i = 0; i < 2*n; i++ ){
		cp[ (i-input+2*n)%(2*n) ] = x[i];
	}
	for( i = 0; i < 2*n; i++ ){
		x[i] = cp[i];
	}
}

int main(){
	int i;
	int input;
	
	cin >> n >> m;
	for( i = 0; i < 2*n; i++ ){
		x[i] = i+1;
	}
	
	for( i = 0; i < m; i++ ){
		cin >> input;
		if( input == 0 )
			rshu();
		else
			cut(input);
	}
	for( i = 0; i < 2*n; i++ ){
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
n,m = gets.chop.split(" ").map(&:to_i)
array = Array.new(n, Array.new(2))
n.times do |i|
    array[i] = gets.split(" ").map(&:to_i)
end
array.sort! {|a,b| a[0] <=> b[0]}
sum = 0
array.each do |a|
    m -= a[1]
    sum += a[1] * a[0]
    if m<0 then sum -= m.abs * a[0]; break end
end
puts sum

Measured memory_bytes: 10360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) cin >> a[i];
    int m = 0;
    for(int i = n-1; i >= 0; i--) {
        b[i] = a[i];
        for(int j = 2; j*(i+1)-1 <= n-1; j++) {
            b[i] += b[j*(i+1)-1];
            b[i] %= 2;
        }
        if(b[i] == 1) m++;
    }
    cout << m << endl;
    rep(i,n) if(b[i] == 1) cout << i+1 << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define full(c) c.begin(), c.end()
#define vector2d(name, type, h, w, init) vector<vector<type>> name(h, vector<type>(w, init))
typedef signed long long int ll;
typedef unsigned long long int ull;
const int PRIME=1000000007;
using namespace std;

int main(){
  ll n,ca,ct;
  cin>>n;
  cin>>ct>>ca;
  n--;
  while(n--){
    //cout<<ct<<ca<<endl;
    ll a,t,m,mt,ma;
    cin>>t>>a;
    mt=ct/t;
    if(ct%t!=0) mt++;
    ma=ca/a;
    if(ca%a!=0) ma++;
    m=max(mt, ma);
    ct=t*m;
    ca=a*m;
  }
  cout<<ca+ct<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" 
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll t;
  cin>>t;
  if(t%1000)
  {
    deb(((t/1000)+1)*1000-t)
  }
  else
    deb(0)
}

Measured memory_bytes: 3652
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A&lang=jp
# Graph: python3
#  2018.12.05 yonezawa

import sys
input = sys.stdin.readline

class node:
    def __init__(self):
        n = self.n = int(input())
        self.cnt = 0
        self.start = [-1] * n
        self.end = [-1] * n
        self.pos = [1] * n
        self.nmap = [[0 for i in range(n)] for i in range(n)]

        for _ in range(n):
            l = list(map(int,input().split()))
            a = l[0] - 1
            for i in l[2:]:
                self.nmap[a][i-1] = 1
    def printMap(self):
        for i in self.nmap:
            print (*i)

    def printResult(self):
        for i in range(self.n):
            print(i+1,self.start[i],self.end[i])

    def dfs(self,u):
        self.cnt += 1
        self.start[u] = self.cnt
        self.pos[u] = 0
        for i in range(self.n):
            if self.nmap[u][i] == 1 and self.pos[i] == 1:    
                self.dfs(i)
        self.cnt += 1
        self.end[u] = self.cnt
                
def main():
    a = node()
    for i in range(a.n):
        if a.pos[i] == 1:
            a.dfs(i)
    a.printResult()

if __name__ == '__main__':
    main()



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

int main() {
int N;
  cin >> N;
  int result = 0;
  vector<int> A(N);
  vector<int> B(1000000);
  for(int a = 0;a < N;a++){
    cin >> A[a];
    B[A[a] - 1]++;
  }
  
  for(int a = 1;a <= 1000000;a++){
    if(B[a - 1] > 0){
      for(int b = 2 * a;b <= 1000000;b += a){
        B[b - 1] = 0;
      }
      
    }
    
  }
  for(int a = 1;a <= 1000000;a++){
   if(B[a-1] == 1){
     result++; 
   }
    
  }
  
  cout << result;
 
}

Measured memory_bytes: 8008
#C問題
N = int(input())
A = []
B = list(map(int,input().split()))
for i in range(N-1):
    if i == 0:
        A.append(B[0])
        A.append(B[0])
    else:
        if B[i] >= A[-1]:
            A.append(B[i])
        else:
            A[-1] = B[i]
            A.append(B[i])
            
            
print(sum(A))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int max = 0;
        for(int i = 0; i < N; i++){
            int a = sc.nextInt();
            sum += a;
            if(a > max) max = a;
        }
        if(max < sum - max) System.out.println("Yes");
        else System.out.println("No");

        sc.close();
    }

}


Measured memory_bytes: 23124
//29
#include<iostream>

using namespace std;

int main(){
  int n,t,h,l;
  cin>>n>>t>>h>>l;
  int nt[100],ht[100];
  for(int i=0;i<n;i++){
    cin>>nt[i]>>ht[i];
  }
  int p;
  int c=0;
  for(p=0;p<n;p=(p+1)%n){
    if(nt[p]==0&&ht[p]==0)break;
    if(nt[p]){
      c+=10;
      t++;
      nt[p]--;
    }else{
      c+=100;
      ht[p]--;
    }
    if(t>l){
      break;
    }
    if(c>=90){
      t-=(c-90)/10;
      nt[p]+=(c-90)/10;
      if(t<0)break;
      c=0;
    }
  }
  cout<<p+1<<endl;
  return 0;
}

Measured memory_bytes: 1164
n = int(input())
a = list(map(int, input().split()))

while True:
    if len(a) == 1:
        break
    a.sort()
    for i in range(len(a)-1, 0, -1):
        a[i] %= a[0]
        if a[i] == 0:
            del a[i]
print(a[0])

Measured memory_bytes: 62704
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s,t;
    std::cin >> s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}


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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e7 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n;

bool read() {
    if (scanf("%d", &n) != 1)
        return false;

    return true;
}

void solve() {
    map<int, int> mp;

    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++mp[x];
    }

    int ans = 0;

    for (auto i : mp)
        if (i.first <= i.second)
            ans += i.second - i.first;
        else
            ans += i.second;

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

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

    while (read())
        solve();

    return 0;
}


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

int main(){
  int64_t N; cin >> N;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  vector<pair<int64_t, int64_t>> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY[i].first >> MY[i].second;
  }
  sort(MY.begin(), MY.end());
  int64_t ans=1;
  int64_t nowf=MY[0].first;
  int64_t nows=MY[0].second;
  for(int i=1;i<N;i++){
    if(MY[i].first-nowf>=MY[i].second+nows){
      ans++;
      nowf=MY[i].first;
      nows=MY[i].second;
    }
    else if(nowf+nows>=MY[i].first+MY[i].second){
        nowf=MY[i].first;
        nows=MY[i].second;
      }
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,a[N];
long long ans;
map <int,int> m;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=m[a[i]-i];
		m[-a[i]-i]++;
	}

	cout<<ans;
}


Measured memory_bytes: 21448
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,x[4005],BB[4005],WW[4005],BW[4005][4005],WB[4005][4005];
ll dp[4005][4005];
char c[4005];
vector<ll>b,w;
ll d(ll x,ll y){
    if(x < 0 || y < 0)return 99999999999999LL;
    if(x == 0 && y == 0)return 0;
    return dp[x][y];
}
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    
    for(int i=1; i<=2 * n; i++){
        cin >> c[i] >> x[i];
        if(c[i] == 'B')b.pb(i);
        else w.pb(i);
    }
    for(int i=0; i<b.size(); i++)
        for(int j=i+1; j<b.size(); j++)
            if(x[b[i]] > x[b[j]])BB[x[b[j]]]++;
    for(int i=0; i<w.size(); i++)
        for(int j=i+1; j<w.size(); j++)
            if(x[w[i]] > x[w[j]])WW[x[w[j]]]++;
    for(int i=0; i<w.size(); i++)
        for(int j=0; j<b.size(); j++)
            if(w[i] < b[j])BW[x[b[j]]][x[w[i]]]++;
    for(int i=0; i<b.size(); i++)
        for(int j=0; j<w.size(); j++)
            if(b[i] < w[j])WB[x[w[j]]][x[b[i]]]++;
    for(int i=1; i<=n; i++)
        for(int j=n; j>=0; j--)
            BW[i][j] += BW[i][j + 1],
            WB[i][j] += WB[i][j + 1];
            
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++){
            dp[i][j] = min(d(i - 1 , j) + BB[i] + BW[i][j + 1] , d(i , j - 1) + WW[j] + WB[j][i + 1]);
        }
    
    cout << dp[n][n] << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 190080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());

		long[] A = new long[N + 1];
		long S = 0;
		for (int i = 1; i <= N; i++) {
			A[i] = Long.parseLong(sc.next());
			S += A[i];
		}
		sc.close();
		S /= 2;

		long x1 = S;
		for (int j = 2; j <= N - 1; j += 2) {
			x1 -= A[j];
		}
		System.out.print(x1 * 2 + " ");

		long x = x1;
		for (int i = 2; i <= N; i++) {
			x = A[i - 1] - x;
			System.out.print(x * 2 + " ");
		}
		System.out.println();

	}
}


Measured memory_bytes: 49512
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        while (s > 0) {
            String a = sc.next();
            if (map.containsKey(a)) {
                map.put(a, map.get(a) + 1);
            } else {
                map.put(a, 1);
            }
            s--;
        }
        System.out.println("AC x " + map.getOrDefault("AC", 0));
        System.out.println("WA x " + map.getOrDefault("WA", 0));
        System.out.println("TLE x " + map.getOrDefault("TLE", 0));
        System.out.println("RE x " + map.getOrDefault("RE", 0));
    }
}

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

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

	int M, D; cin >> M >> D;
	int count = 0;
	for (int m = 1; m <= M; ++m)
	{
		for (int d = 1; d <= D; ++d)
		{
			int d1 = d % 10;
			int d10 = (d / 10) % 10;
			if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
				++count;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[200005],R[200005];
void make(){
	F[0] = 1;
	for(int i=1;i<200005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<200005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
ll n,a,b,c;
int main(){
	cin>>n>>a>>b>>c; make();
	ll ans = 0;
	for(int i=0;i<n;i++){
		ll up = modpow(a,n)*modpow(b,i)%mod*C(n+i-1,i)%mod;
		up = up*modpow(modpow(a+b,n+i),mod-2)%mod; //cout<<up<<endl;
		up = up*(n+i)%mod*100LL%mod*modpow(a+b,mod-2)%mod;
		ans += up;
		up = modpow(b,n)*modpow(a,i)%mod*C(n+i-1,i)%mod;
		up = up*modpow(modpow(a+b,n+i),mod-2)%mod;
		up = up*(n+i)%mod*100LL%mod*modpow(a+b,mod-2)%mod;
		ans += up;
	}
	cout << (ans%mod+mod)%mod << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
#define mp make_pair
#define pb push_back
#define debug(x) cerr << #x << " = " << x << " "
void solve(int n, int a, int b)
{
  if (a + b - 1 > n)
    {
      puts("-1"); return;
    }
  int lower_bound = (n + (a-1))/a;
  if (b < lower_bound)
    {
      puts("-1"); return;
    }
  vector<int> ans;
  int tmp = n-a;
  for (int i = 0, cur = 1; i < a; ++i)
    {
      int len = min(tmp, b-1);
      tmp -= len;
      ++len;
      cur += len;
      for (int i = 1; i <= len; ++i) ans.pb(cur - i);
    }
  assert(ans.size() == n);
  for (int i = 0; i < n; ++i)
    printf("%d%c", ans[i], " \n"[i+1==n]);
}
int main()
{
  int n, a, b;
  while (~scanf("%d %d %d", &n, &a, &b)) solve(n, a, b);

}
	 


Measured memory_bytes: 3440
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC096_B_Maximum_Sum
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			/*int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int c = int.Parse(input[2]);*/
			
			List<int> numbers = new List<int>();

			for (int i = 0; i < 3; i++) {
				numbers.Add(int.Parse(input[i]));
			}
			int k = int.Parse(Console.ReadLine());

			int maxNumberIndex = numbers.IndexOf(numbers.Max());
			for (int i = 0; i < k; i++)
			{
				numbers[maxNumberIndex] *= 2;
			}
			
			Console.WriteLine(numbers[0] + numbers[1] + numbers[2]);
		}
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

map<ll, ll> memo;
ll calc(ll n, ll digit) {
  if (n == digit * 10 - 1 && memo.count(n)) { return memo[n]; }
  ll ret = 0;
  int d = n / digit;
  if (digit == 1) {
    if (d >= 6) { ret--; }
    if (d >= 4) { ret--; }
    ret += d + 1;
  } else {
    if (n / digit == 0) { return calc(n, digit / 10); }
    if (d == 4) {
      ret = 4 * calc(digit - 1, digit / 10);
    } else if (d == 6) {
      ret = 5 * calc(digit - 1, digit / 10);
    } else {
      if (d >= 6) { d -= 2; }
      else if (d >= 4) { d -= 1; }
      ret = d * calc(digit - 1, digit / 10);
      ret += calc(n % digit, digit / 10);
    }
  }
  if (n == digit * 10 - 1) { memo[n] = ret; }
  return ret;
}

int main() {
  ll n;
  while (scanf("%lld", &n), n) {
    ll left = n;
    ll right = 10000000000LL;
    while (left != right) {
      ll mid = (left + right) / 2;
      if (calc(mid, 1000000000) - 1 < n) {
        left = mid + 1;
      } else {
        right = mid;
      }
    }
    printf("%lld\n", left);
  }
}

Measured memory_bytes: 928
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int maxX = X,minY = Y;
    rep(i,0,N){
        int a;
        cin >> a;
        maxX = max(maxX, a);
    }
    rep(i,0,M){
        int b;
        cin >> b;
        minY = min(minY, b);
    }
    
    if(maxX < minY){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }
}

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

int main() 
{ 
    long long count = 0;
    double sum = 0;
    int n, k;
    cin >> n >> k;
    vector<double> a(n);
    for(int i =0 ;i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double x = (double)sum/(4*k);
    for(int i = 0; i < n; i++) {
        if(a[i] >= x) {
            count++;
        }
    }
    if(count >= k) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        System.out.println(a/b);
        System.out.println(a%b);
        System.out.println(String.format("%.5f",(double)(a)/(double)(b)));
   }
}


Measured memory_bytes: 26584
// use std::collections::HashMap;
// use std::collections::HashSet;


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.read();
    let m: i64 = sc.read();
    let mut ps = Vec::new();
    for _ in 0..n {
        let p: i64 = sc.read();
        ps.push(p - 1);
    }
    let ps = ps;

    let mut uf = Vec::new();
    for _ in 0..n {
        uf.push(-1)
    }

    for _ in 0..m {
        let mut x: i64 = sc.read();
        let mut y: i64 = sc.read();
        x -= 1;
        y -= 1;

        while uf[x as usize] >= 0 { x = uf[x as usize]; }
        while uf[y as usize] >= 0 { y = uf[y as usize]; }
        if x != y {
            if uf[x as usize] < uf[y as usize] {
                uf[x as usize] += uf[y as usize];
                uf[y as usize] = x;
            } else {
                uf[y as usize] += uf[x as usize];
                uf[x as usize] = y;
            }
        }
        // xs.push(x);
        // ys.push(y);
    }

    let mut ans = 0;
    for i in 0..n {
        let mut x = i;
        let mut y = ps[i as usize];
        while uf[x as usize] >= 0 { x = uf[x as usize]; }
        while uf[y as usize] >= 0 { y = uf[y as usize]; }
        if x == y {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

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

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

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

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


Measured memory_bytes: 6396
n=int(input())
l=list(map(int,input().split()))
flag=1
for i in l:
    if i%2==0:
        if i%3==0 or i%5==0:
            continue
        else:
            flag=0
            break
if flag==0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 2940