akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

long long powerm(long long x, unsigned long long y, long long p) 
{ 
    long long res = 1;
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
long long modinverse(long long a, long long b)
{
    long long b0 = b, t, q;
    long long x0 = 0, x1 = 1;
    if (b == 1) return 1;
    while (a > 1) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0) x1 += b0;
    return x1;
}

	int fac[1000003];
	int ifac[1000003];
signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int mo=1000003;
	int q;
	fac[0]=1;
	for(int i=1;i<1000003;++i)
		fac[i]=(i*fac[i-1])%mo;
	for(int i=0;i<1000003;++i)
	{
		ifac[i]=modinverse(fac[i],mo);
	}
	cin>>q;
	while(q)
	{
		--q;
		int x,d,n;
		cin>>x>>d>>n;
		// cout<<x<<endl;
		if(x==0){
			cout<<0<<"\n";
			continue;
		}
		if(d==0)
		{
			cout<<powerm(x,n,mo)<<"\n";
			continue;
		}
		int ans=powerm(d,n,mo);
		if(((x*powerm(d,mo-2,mo))%(mo)+n-1)<mo)
			ans*=fac[((x*powerm(d,mo-2,mo))%(mo)+n-1)];
		else
			ans*=0;
		ans%=mo;
		if(((x*powerm(d,mo-2,mo))%(mo)-1)>=0)
			ans*=ifac[((x*powerm(d,mo-2,mo))%(mo)-1)];
		ans%=mo;
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 16512
from collections import Counter
N,A,B = map(int,input().split())
src = list(map(int,input().split()))
src.sort(reverse=True)

ave = sum(src[:A]) / A
print(ave)

counter = Counter(src)
cnt = counter[src[0]]

ncr = [[1]]
for n in range(1,N+1):
    ncr.append([1])
    for r in range(1,n):
        ncr[n].append(ncr[n-1][r-1] + ncr[n-1][r])
    ncr[n].append(1)

if cnt < A:
    last = src[A-1]
    n = counter[last]
    r = src[:A].count(last)
    print(ncr[n][r])
elif cnt == A:
    print(1)
else:
    ans = 0
    for r in range(A, min(B,cnt)+1):
        ans += ncr[cnt][r]
    print(ans)


Measured memory_bytes: 3444
n = input()
n_keta = len(n)

if n_keta % 2 == 0:
    total = 0
    for i in range(n_keta // 2):
        total += 10 ** (2*i) * 9
else:
    total = 0
    for i in range(n_keta//2):
        total += 10 ** (2*i) * 9
    total += int(n) - 10 ** (n_keta-1) + 1
print(total)


Measured memory_bytes: 2940
#include<iostream>

#include<cstdio>
#include<math.h>
#include<float.h>
using namespace std;
#define equals(a,b) fabs((a)-(b))<DBL_EPSILON*fmax(1,fmax(fabs(a),fabs(b)))
class Point{
    public:
        double x,y;
        Point(double x=0,double y=0):x(x),y(y){}

        Point operator + (Point p){return Point(x+p.x,y+p.y);}
        Point operator - (Point p){return Point(x-p.x,y-p.y);}
        Point operator * (double a){return Point(a*x,a*y);}
        Point operator / (double a){return Point(x/a,y/a);}
            
        double norm(){return x*x+y*y;}
        double abs(){return sqrt(norm());}    
        
        bool operator < (const Point &p)const{
            return x!=p.x?x<p.x:y<p.y;
        }
        bool operator == (const Point &p)const{
            return equals(x,p.x)&&equals(y,p.y);
        }
};
typedef Point Vector;
struct Segment{
    Point p1,p2;
};
typedef Segment Line;
double dot(Vector a,Vector b){//内積
    return a.x*b.x+a.y*b.y;
}
Point project(Segment s,Point p){ //射影　p377
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/base.norm();
    return s.p1+base*r;
}
Point reflect(Segment s,Point p){
    return p+(project(s,p)-p)*2.0;
}
int main(){
    int q;
    Point p1,p2;
    scanf("%lf %lf %lf %lf",&p1.x,&p1.y,&p2.x,&p2.y);
    Segment s;
    s.p1=p1;  s.p2=p2;
    cin>>q;
    Point p,pp;
    for(int i=0;i<q;i++){
        cin>>p.x>>p.y;
        pp=reflect(s,p);
        printf("%.10f %.10f\n",pp.x,pp.y);
    }
    return 0;
}



Measured memory_bytes: 3276
A,B,C,K=map(int, input().split())
if A >= K:
  print(1*K)
else:
  K=K-A
  if B >= K:
    print(1*A)
  else:
    K=K-B
    if C >= K:
      print(1*A+(-1)*K)
    else:
      print(1*A+(-1)*C)

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

int main()
{
    int a,b,c,x,i,s,j,k,l,cnt=0;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>x;
    for (i = 0; i <= a; ++i)
    {
        for (j = 0; j <= b; ++j)
        {
            for (k = 0; k <= c; ++k)
            {
                l = (i*500) + (j*100) + (k*50);
                if(l == x)
                    cnt++;
                else if (l>x)
                {
                    break;
                }
            }
        }
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 51;
const int LG = 20;

int n, m;
vector<int>g[N];
int depth[N];
int anc[N][LG+1];
map<pair<int,int>,int>edges;
ll edge_mask[N];

void dfs(int u, int p){
    anc[u][0] = p;
    for(int v:g[u]){
        if(v != p){
            depth[v] = depth[u] + 1;
            dfs(v, u);
        }
    }
}

void pre(){
    FOR(i,1,LG){
        FOR(j,1,n){
            anc[j][i] = anc[anc[j][i-1]][i-1];
        }
    }
}

int lca(int a, int b){
    if(depth[a] < depth[b]){
        swap(a, b);
    }
    int d = depth[a] - depth[b];
    FOR(i,0,LG){
        if(d & (1<<i)){
            a = anc[a][i];
        }
    }
    if(a == b){
        return a;
    }
    ROF(i,LG,0){
        if(anc[a][i] != anc[b][i]){
            a = anc[a][i];
            b = anc[b][i];
        }
    }
    return anc[a][0];
}

ll dp[N][(1<<LG)];

ll solve(int i, int mask){
    if(i == n){
        return (mask == (1LL<<m) - 1);
    }
    if(dp[i][mask] != -1){
        return dp[i][mask];
    }
    int new_mask = mask | edge_mask[i];
    return dp[i][mask] = solve(i+1, new_mask) + solve(i+1, mask);
}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    cin >> n;
    int u, v;
    FOR(i,1,n-1){
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
        if(u > v){
            swap(u, v);
        }
        edges[mp(u,v)] = i;
    }
    dfs(1,0);
    pre();
    cin >> m;
    FOR(i,0,m-1){
        cin >> u >> v;
        int l = lca(u, v);
        //cout << u << " " << v << " " << l << endl;
        int p;
        while(u != l){
            p = anc[u][0];
            edge_mask[edges[mp(min(u, p), max(u, p))]] |= (1LL<<i);
            u = anc[u][0];
        }
        while(v != l){
            //cout << v << endl;
            p = anc[v][0];
            //cout << p << endl;
            edge_mask[edges[mp(min(v, p), max(v, p))]] |= (1LL<<i);
            v = anc[v][0];
        }
    }
    /*FOR(i,1,n-1){
        cout << edge_mask[i] << endl;
    }*/
    memset(dp,-1,sizeof(dp));
    cout << solve(1, 0);

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 418048
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key, find_by_order

#define ll long long
#define pi pair<int, int>
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD =  1e9 + 7;
vector<int> arr[mxn];
int n, m, k, q;
string s, t;

void solve(){
    cin >> s;
    int foo = 0;
    for (char ch : s) {
        foo += (int) (ch - '0');
    }
    cout << ((foo % 9 == 0) ? "Yes" : "No") << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}


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

using namespace std;

typedef long long ll;

const int maxN = 2e5 + 1;

ll pw[maxN];

int ciclos(int x){
	if(x == 0) return 0;
	int bits = __builtin_popcount(x);
	return 1 + ciclos(x % bits);
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	reverse(s.begin(), s.end());
	int unos = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1') unos++;
	}
	ll mod = unos + 1;
	if(unos - 1 > 0) mod *= (unos - 1);
	pw[0] = 1;
	for(int i = 1; i < n; i++) pw[i] = (pw[i - 1] * 2) % mod;
	ll tot = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '1'){
			tot = (tot + pw[i]) % mod;
		}
	}

	for(int i = n - 1; i >= 0; i--){
		if(s[i] == '1'){
			if(unos == 1){
				cout << 0 << '\n';
			}else{
				int queda = (tot - pw[i] + mod) % (unos - 1);
				cout << 1 + ciclos(queda) << '\n';
			}
		}else{
			int queda = (tot + pw[i]) % (unos + 1);
			cout << 1 + ciclos(queda) << '\n';
		}
	}
}


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

struct UnionFind{
    vector<int> parent;
    vector<int> rank;
    UnionFind(int n):rank(n,0),parent(n){
        rep(i,n) parent[i]=i;
    }

    int find(int x){
        if (parent[x] == x) return x;
        else return find(parent[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x==y) return;
        else if(rank[x]<rank[y]) parent[x]=y;
        else{
            parent[y]=x;
            if (rank[x]==rank[y]){
                rank[x]+=1;
            }
        }
    }
};




int main(){
    int v,e;
    cin >> v >> e;
    //tuple<int,int,int> edge();
    vector<tuple<int,int,int>> edge(e);
    UnionFind uf(v);
    
    rep(i,e){
        int s,t,w;
        cin >> s >> t >> w;
        //tuple<int,int,int> temp = make_tuple(w,s,t);
        tuple<int,int,int> temp(w,s,t);
        edge[i]=temp;
    }
    sort(edge.begin(),edge.end());
    /*
    rep(i,e){
        cout << get<0>(edge[i])<<" " <<  get<1>(edge[i]) <<" "<< get<2>(edge[i]) << endl;
    }
    */
    int res=0;
    rep(i,e){
        int s,t,w;
        w = get<0>(edge[i]);
        s = get<1>(edge[i]); t = get<2>(edge[i]);
        if(uf.find(s)==uf.find(t))continue;
        uf.unite(s,t);
        res+=w;
    }

    cout << res << endl;


}


Measured memory_bytes: 4108
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll N;
  cin>>N;

  ll ans=0;
  for(int A=1;A<=N;A++){
    for(int j=1;A*j<N;j++) ans++;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define mid (l + r >> 1)
#define ls (k << 1)
#define rs (k << 1 | 1)
using namespace std;

const int maxn = 200010;
int n, m, tag, a[maxn], cnt[600010];
struct node { int s, tag; } t[maxn * 20];

void maintain(int k, int l, int r) {
	t[k].s = t[k].tag ? r - l + 1 : t[ls].s + t[rs].s;
}

void add(int k, int l, int r, int ql, int qr, int v) {
	if (l >= ql && r <= qr) { t[k].tag += v, maintain(k, l, r); return; }
	if (mid >= ql) add(ls, l, mid, ql, qr, v);
	if (mid < qr) add(rs, mid + 1, r, ql, qr, v);
	maintain(k, l, r);
}

int sum(int k, int l, int r, int ql, int qr) {
	if (t[k].tag) return min(r, qr) - max(l, ql) + 1;
	if (l >= ql && r <= qr) return t[k].s;
	int s = 0;
	if (mid >= ql) s += sum(ls, l, mid, ql, qr);
	if (mid < qr) s += sum(rs, mid + 1, r, ql, qr);
	return s;
}

void modify(int x, int v) {
	add(1, 1, n + m + m, x - cnt[x] + 1, x, v);
}

void ins(int x, int v) {
	if (x > tag && x <= tag + n) modify(x, -1);
	cnt[x] += v;
	if (x > tag && x <= tag + n) modify(x, 1);
}

int main() {
	scanf("%d %d", &n, &m), tag = m;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]), ins(a[i] += m, 1);
	}
	for (int i = 1, p, x; i <= m; i++) {
		scanf("%d %d", &p, &x);
		ins(a[p], -1), ins(a[p] = x + tag, 1);
		printf("%d\n", n - sum(1, 1, n + m + m, tag + 1, tag + n));
	}
	return 0;
}

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

int main()
{
  int N, K, x, sum = 0;

  cin >> N >> K;

  for (int i = 0; i < N; i++)
  {
    cin >> x;
    sum += 2 * min(K - x, x);
  }

  cout << sum << endl;
}

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

int main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  for(int i = 0; i < n; i++){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

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

int main(){
  int x, cnt=0;
  cin >> x;
  for(int i=0; x>=400; i++){
    x-=200;
    cnt++;
  }
  cout << 9-cnt << endl;

  return 0;
}

Measured memory_bytes: 3636
l, r = map(int,input().split())

li = []

if r - l > 2018:
    ans = 0
else:
    for i in range(l,r):
        for j in range(i + 1,r + 1):
            li.append((i * j) % 2019)
    ans = min(li)

print(ans)

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

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

  ll A=1900*M+100*(N-M);

  for(int i=0;i<M;i++)A*=2;
  ll ans= A;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
#define white 0
#define balck -1
#define grey 1
using namespace std;

int a[110][110],n;
int color[110];
int t=0;
int ts[105],te[105];

void dfsinit()
{
    for(int i=1;i<=100;i++)
        color[i]=white;
}

void dfsvisit(int u)
{
    color[u]=grey;
    ts[u]=++t;  //搜索
    for(int j=1;j<=n;j++)  //搜索?点
    {
        if(color[j]==white && a[u][j]==1)
        {
           dfsvisit(j);  //深搜
        }
    }
    te[u]=++t;
    color[u]=balck;
}

void dfs()
{
    dfsinit();
    for(int i=1;i<=n;i++)
    {
        if(color[i]==white)
            dfsvisit(i);
    }
}

int main()
{
   int key,d,x;
   t=0;
   memset(a,0,sizeof(a));
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
       scanf("%d%d",&key,&d);
       for(int j=1;j<=d;j++)
       {
        scanf("%d",&x);
        a[key][x]=1;
       }
   }

   dfs();
   for(int i=1;i<=n;i++)
   {
       printf("%d %d %d\n",i,ts[i],te[i]);
   }
   return 0;
}

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

int main()
{
    long long n;
    cin >> n;
    if(n%2==1)
    {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    long long t = 10;
    while(n/t > 0)
    {
        ans += n / t;
        t *= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())

type1 = type2 = type3 = 0

ans = 0
while n > 0:
    s = input()
    ans += s.count("AB")

    if s[0] == "B" and s[-1] == "A":
        type3 += 1
    elif s[-1] == "A":
        type1 += 1
    elif s[0] == "B":
        type2 += 1

    n -= 1

ans += min(type1, type2)

if type3 > 0:
    if type1 == type2 == 0:
        ans += type3 - 1
    else:
        ans += type3

print(ans)


Measured memory_bytes: 3064
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String date = "";

		try {
			scanner = new Scanner(System.in);
			date = scanner.next();
			SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy/MM/dd");
			Date uDate = sdFormat.parse(date);
			Date tDate = sdFormat.parse("2019/04/30");

			int diff = tDate.compareTo(uDate);
			if (diff == 0) {
				System.out.println("Heisei");
			} else if (diff > 0) {
				System.out.println("Heisei");
			} else {
				System.out.println("TBD");
			}

		} catch (ParseException e) {
			e.printStackTrace();
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			BigDecimal[] wkKane = new BigDecimal[numN];
			String[] wkNaiyo = new String[numN];

			BigDecimal[] wkRes = new BigDecimal[numN];
			BigDecimal rate = new BigDecimal("380000.0");
			for (int i = 0; i < numN; i++) {
				wkKane[i] = new BigDecimal(scanner.next());
				wkNaiyo[i] = scanner.next();
				if (wkNaiyo[i].equals("BTC")) {
					wkRes[i] = wkKane[i].multiply(rate);
				} else {
					wkRes[i] = wkKane[i];
				}

			}

			BigDecimal res = BigDecimal.ZERO;
			for (int i = 0; i < wkRes.length; i++) {
				res = res.add(wkRes[i]);
			}

			System.out.println(res.setScale(4, RoundingMode.HALF_UP));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22612
var
  n,i,j,m,k,ans,x,y:longint;
  a:array[0..100005] of longint;
begin
  readln(n);
  for i:=1 to n do begin read(a[i]); ans:=ans+a[i]; end;
  readln(m);
  for i:=1 to m do
  begin
    readln(x,y);
    writeln(ans-a[x]+y);
  end;
end.


Measured memory_bytes: 128
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var x = nexts(n);
  var ans = 1, id = 1, rem = 0;
  for(var i = 0; i < n; i++){
    rem++;
    ans = mul(ans,rem);
    if(x[i] < id){
      rem--;
    }else{
      id += 2;
    }
  }
  return ans;
}

Measured memory_bytes: 44836
import cmath
pi = cmath.pi

def expD(t):
  nexp, pexp = {}, {}
  while t != 0:
    pexp[t] = cmath.exp(2j*pi/t)
    nexp[t] = cmath.exp(-2j*pi/t)
    t //= 2
  return nexp, pexp
def powerlimit(x):
  a = 1
  while a < x:
    a *= 2
  return a

N, M = map(int, input().split())
A = list(map(int, input().split()))
m = max(A)
X = [0 for i in range(m+1)]
for i in A:
  X[i] += 1
limit = powerlimit(2*(m+1))
X = X[:] + [0 for _ in range(limit-m-1)]

nexp, pexp = expD(limit)

def fft(f, n):
  hn = n//2
  if n == 1:
    return f
  elif n == 2:
    return [f[0] + f[1], f[0] - f[1]]
  else:
    f0 = [f[2*_] for _ in range(hn)]
    f1 = [f[2*_+1] for _ in range(hn)]
    f0 = fft(f0, hn)
    f1 = fft(f1, hn)
    grow = 1
    fund = nexp[n]
    for i in range(hn):
      right = grow * f1[i]
      f[i] = f0[i] + right
      f[i+hn] = f0[i] - right
      grow *= fund
    return f
def ifft(f, n):
  hn = n//2
  if n == 1:
    return f
  elif n == 2:
    return [f[0] + f[1], f[0] - f[1]]
  else:
    f0 = [f[2*_] for _ in range(hn)]
    f1 = [f[2*_+1] for _ in range(hn)]
    f0 = ifft(f0, hn)
    f1 = ifft(f1, hn)
    grow = 1
    fund = pexp[n]
    for i in range(hn):
      right = grow * f1[i]
      f[i] = f0[i] + right
      f[i+hn] = f0[i] - right
      grow *= fund
    return f
  
F = fft(X, limit)
V = [F[i]*F[i] for i in range(limit)]
E = ifft(V, limit)
for i in range(limit):
  E[i] = int(0.5+E[i].real/limit)
cnt = 0
S = 0
point = limit - 1

while cnt < M:
  Ep = E[point]
  if Ep != 0:
    if cnt + Ep > M:
      S += (M - cnt) * point
      cnt = M
    else:
      S += point * Ep
      cnt += Ep
  point -= 1
print(S)


Measured memory_bytes: 138656
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
	if(l >= r)
	{
		return;
	}
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	//printf("----%d\n", m);
	rec(l, m);
	rec(m+1, r);
	post.push_back(root);
}

void solve()
{
	pos = 0;
	rec(0, pre.size());
//	for(int i = 0; i < n; i++)
//	{
//		if(i)
//		{
//			printf(" ");
//		}
//		printf("%d", post[i]);
//	}
//	printf("\n");
}


int main()
{
	int n;
	scanf("%d", &n);
	int d;
	for(int i = 0; i < n; i++)
	{	
		scanf("%d", &d);
		pre.push_back(d);
	}
	for(int i = 0; i < n; i++)
	{	
		scanf("%d", &d);
		in.push_back(d);
	}
	solve();
	
	for(int i = 0; i < n; i++)
	{
		if(i)
		{
			printf(" ");
		}
		printf("%d", post[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2808
from bisect import bisect_left as bl
from itertools import accumulate
INF = 10 ** 20

def get_score(acc, head, end):
  sec_head = acc[head - 1]
  sec_end = acc[end]
  sec_sum = sec_end - sec_head
  cut = bl(acc, sec_head + sec_sum // 2) - 1
  score = INF
  reta, retb = None, None
  for i in range(cut - 1, cut + 2):
    if head <= i < end: 
      a = acc[i] - sec_head
      b = sec_end - acc[i]
      if score > abs(a - b):
        score = abs(a - b)
        reta, retb = a, b
  return (reta, retb)

n = int(input())
acc = [0]
acc += accumulate(map(int, input().split()))

ans = INF
for i in range(2, n - 1):
  p, q = get_score(acc, 1, i)
  r, s = get_score(acc, i + 1, n)
  if not None in (p, q, r, s):
    ans = min(ans, max(p, q, r, s) - min(p, q, r, s))
print(ans)

Measured memory_bytes: 26996
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int l[n];
  l[0]=2;
  l[1]=1;
  if(n==0||n==1){
    cout<<n;
    return 0;
  }
  for(int i=2;i<n+1;++i){
    l[i]=l[i-1]+l[i-2];
  }
  cout<<l[n];
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define ll long long 
int n,m,k;
ll d[150][9];
ll p[8]={1,1,2,3,5,8,13,21};
int main()
{
    std::cin>>n>>m>>k;
    d[0][0]=1;
    for (int i=1; i<=n; ++i)
        for (int j=0; j<m;++j)
            d[i][j]=(d[i-1][j]*p[j]*p[m-j-1]+(j>0)*d[i-1][j-1]*p[j-1]*p[m-j-1]+(j<m-1)*d[i-1][j+1]*p[j]*p[m-j-2])%1000000007;
    std::cout<<d[n][k-1];
}


Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <stack>
#define pb push_back
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll exp(ll t,ll x){if(x==0) return 1;if(x==1) return t;if(x%2==1) return (t*exp((t*t)%mod,x/2))%mod;if(x%2==0) return exp((t*t)%mod,x/2);} 
ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){return u<b?u:bsum(u/b,b)+u%b;}
ll prival(ll u,ll p){int cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
bool isprime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
void YAY(void){cout<<"YES"<<endl;}
void NAY(void){cout<<"NO"<<endl;}
int n;
int cc[111111];
int ind, rr=0;
int main(void)
{
	int i, j;
	cin>>n;
	for(i=1 ; i<=n ; i++)
	{
		int x;
		scanf("%d",&x);
		cc[x]++;
		cc[x+1]++;
		cc[x+2]++;
	}
	for(i=0 ; i<=111110 ; i++)
	{
		if(rr<cc[i])
		{
			ind=i-1;
			rr=cc[i];
		}
	}
	cout<<rr;	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

int main(){
  int a,b;
  cin >> a >> b;

  if(0<a && a<10 && 0<b && b<10)
    cout << a*b << endl;
  else
    cout << -1 << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    multiset<ll> M;

    REP(i, N){
        ll a;
        cin >> a;
        if(i == 0){
            M.insert(a);
            continue;
        }

        // 最小のものと同じかそれよりも小さいときは追加
        if(a <= *M.begin()){
            M.insert(a);
            continue;
        }

        // a以上で最小のものを探す
        auto it = M.lower_bound(a);
        // aより小さいもので一番大きいものを消して塗り替え
        it--;
        M.erase(it);
        M.insert(a);
        
    }

    cout << M.size() << endl;
    return 0;
}

Measured memory_bytes: 8128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i -g;
        while( j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt ++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }
    
    for (int i = G.size()-1; i>= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    cnt = 0;
    
    shellSort(A, n);
    
    cout << G.size() << endl;
    for (int i = G.size() -1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) printf("%d\n", A[i]);
    
    return 0;
}


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

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

    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    int ans = 1e9;
    for(int i = -100; i <= 100; i++){
        int cost = 0;
        for(int j = 0; j < n; j++){
            int tmp = A[j] - i;
            cost += tmp * tmp;
        }
        ans = min(ans, cost);
    }

    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 998244353;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	long inf = LMAX / 2 - MAX;

	void doIt() {
		long N = sc.nextLong() - 1;
		LinkedList<Integer> stack = new LinkedList<>();
		while(N >= 0) {
			stack.push((int)(N % 26));
			N -= 26;
			if(N < 0) break;
			N /= 26;
		}
		while(!stack.isEmpty()) {
			int c = stack.pollFirst();
			System.out.print((char)(c + 'a'));
		}
	}

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


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

int main(){
    int a;
    cin >> a ;
    bool frag = false;
    if(a%10==7){
        frag = true;
    }else if((a%100 - a%10)== 70){
        frag = true;
    }else if((a - a%100)==700){
        frag = true;
    }

    if(frag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int s[100] = {};
int main() {
	int a, b, k;
	cin >> a >> b >> k;
	if (b - a <= 2 * k - 2) {
		FOR(j, a, b + 1)cout << j << endl;
	}
	else {
		FOR(j, a, a + k)cout << j << endl;
		FOR(j, b - k + 1,b + 1)cout << j << endl;
	}
}



Measured memory_bytes: 256
def _calc_today_max_v2(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)
    bad_2nd_values = [Ci[contest] * (today + 2 - last_day[contest]) for contest in range(26)]
    total_bad_2nd_value = sum(bad_2nd_values)

    max_value = -99999999999999999
    max_context = 0
    for contest_1st in range(26):
        contest_1st_value = Sdi[today][contest_1st]
        bad_1st_value = today_total_bad_value - today_bad_values[contest_1st]
        if today == D - 1:
            today_value = contest_1st_value - bad_1st_value
            if max_value < today_value:
                max_value = today_value
                max_context = contest_1st
        else:
            for contest_2nd in range(26):
                contest_2nd_value = Sdi[today + 1][contest_2nd]
                bad_2nd_value = total_bad_2nd_value - today_bad_values[contest_1st] - bad_2nd_values[contest_2nd]
                today_value = contest_1st_value + contest_2nd_value - bad_1st_value - bad_2nd_value
                if max_value < today_value:
                    max_value = today_value
                    max_context = contest_1st
    return max_context


def _calc_today_max(today, D, Ci, Sdi, last_day):
    today_bad_values = [Ci[contest] * (today + 1 - last_day[contest]) for contest in range(26)]
    today_total_bad_value = sum(today_bad_values)

    max_value = -99999999999999999
    max_context = 0
    for contest in range(26):
        today_contest_value = Sdi[today][contest]
        today_bad_value = today_total_bad_value - today_bad_values[contest]
        today_value = today_contest_value - today_bad_value
        if max_value < today_value:
            max_value = today_value
            max_context = contest

    return max_context


def _main(D, Ci, Sdi):
    last_day = [0] * 26
    for today in range(D):
        max_contest = _calc_today_max_v2(today, D, Ci, Sdi, last_day)
        print(max_contest + 1)
        last_day[max_contest] = today + 1


def _execute():
    D = int(input())
    Ci = list(map(int, input().split()))
    Sdi = []
    for i in range(D):
        Sdi.append(list(map(int, input().split())))
    _main(D, Ci, Sdi)


if __name__ == "__main__":
    _execute()


Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
struct node{
	long long a,b;
};
vector<node>f[131100];
vector<pair<int,int> >ch[131100];
int n;
long long l=0,r=0,mid,ans=0,mn[131100];
bool cmp_a(node x,node y){
	return x.a<y.a;
}
bool cmp_b(node x,node y){
	return x.b<y.b;
}
void merge(vector<node> &ls,vector<node> &rs,vector<node> &u){
	if(ls.size()>rs.size()) swap(ls,rs);
	sort(ls.begin(),ls.end(),cmp_b);
	sort(rs.begin(),rs.end(),cmp_a);
	mn[0]=rs[0].b;
	for(int i=1,end=rs.size();i<end;i++) mn[i]=min(mn[i-1],rs[i].b);
	for(int i=0,j=rs.size()-1;i<ls.size();i++){
		while(j>=0&&ls[i].b+rs[j].a>mid) j--;
		if(j>=0) u.push_back((node){ls[i].a,mn[j]});
	}
	sort(ls.begin(),ls.end(),cmp_a);
	sort(rs.begin(),rs.end(),cmp_b);
	mn[0]=rs[0].a;
	for(int i=1,end=rs.size();i<end;i++) mn[i]=min(mn[i-1],rs[i].a);
	for(int i=0,j=rs.size()-1;i<ls.size();i++){
		while(j>=0&&ls[i].a+rs[j].b>mid) j--;
		if(j>=0) u.push_back((node){mn[j],ls[i].b});
	}
}
void dfs(int u){
	if(f[u].size()) f[u].clear();
	if(ch[u].empty()){
		f[u].push_back((node){0,0});
		return;
	}
	int ls=ch[u][0].first,rs=ch[u][1].first;
	dfs(ls),dfs(rs);
	for(int i=0;i<f[ls].size();i++){
		f[ls][i].a+=ch[u][0].second;
		f[ls][i].b+=ch[u][0].second;
	}
	for(int i=0;i<f[rs].size();i++){
		f[rs][i].a+=ch[u][1].second;
		f[rs][i].b+=ch[u][1].second;
	}
	merge(f[ls],f[rs],f[u]);
	f[ls].clear();
	f[rs].clear();
}
int main(){
	scanf("%d",&n);
	for(int i=2,fa,w;i<=n;i++){
		scanf("%d %d",&fa,&w);
		ch[fa].push_back(make_pair(i,w));
		r+=w;
	}
	while(l<r){
		mid=(l+r)>>1;
		dfs(1);
		if(f[1].size()) r=mid,ans=mid;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 28792
#include<bits/stdc++.h>
#define ll long long int
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace std;
ll expo(ll a,ll b,ll m = mod){
	ll res = 1;
	while(b){
		if(b&1)
			res = (res*a)%mod;
		b = (b*b)%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	while(b>0){
		ll r = a%b;
		a = b; b = r;
	}
	return a;
}
//for(int i=0;i<n;i++)
int main()
{
	 
   boost
   #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	int t=1;
// 	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    int ans[n+1];
	    int s = sqrt(n);
	    
	    memset(ans,0,sizeof(ans));
	    for(int i=1;i<=s;i++){
	        for(int j=1;j<=s;j++){
	            for(int k=1;k<=s;k++){
	                int sum = i*i + j*j + k*k + i*j + j*k + k*i;
	                if(sum<=n)
	                ans[sum]++;
	            }
	        }
	    }
	    for(int i=1;i<=n;i++)
	    cout<<ans[i]<<"\n";
	}
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
using namespace std;
int main(){
	int sc[5];
	int sm = 0;
	for(int i = 0;i < 5;i++){
		cin >> sc[i];
		if(sc[i] < 40){sc[i] = 40;}
		sm += sc[i];	
	}
	cout << sm/5 << endl;
	return 0;
}


Measured memory_bytes: 3096
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int P = 998244353;
int pot(int a,int w){
  int r = 1;
  while(w){
    if(w & 1)r = r * a % P;
    a = a * a % P;
    w/=2;
  }
  return r;
}
int mul(int a,int b){
  return a * b % P;
}
void add(int &a,int b){
  a += b;
  if(a >= P)
    a -= P;
}
void sub(int &a,int b){
  a -= b;
  if(a < 0)
    a += P;
}
vector<int> licz(vector<int> a, vector<int> b, int n){
  if(n == 1){
    return {mul(b[0], pot(a[0], P-2))};
  }
  vector<int> a1(n/2),b1(n/2);
  R(i,n/2){
    a1[i] = a[i*2];
    add(a1[i], a[i*2+1]);
    b1[i] = b[i*2];
    add(b1[i], b[i*2+1]);
  }
  vector<int> r1 = licz(a1,b1,n/2);
  vector<int> a2(n/2),b2(n/2);
  R(i,n/2){
    a2[i] = a[i*2];
    sub(a2[i], a[i*2+1]);
    b2[i] = b[i*2];
    sub(b2[i], b[i*2+1]);
  }
  vector<int> r2 = licz(a2,b2,n/2);
  vector<int> res(n);
  R(i,n/2){
    res[i*2] = mul(r1[i] + r2[i],(P+1)/2);
    res[i*2+1] = mul(r1[i] + P - r2[i], (P+1)/2);
  }
  return res;
}
int n;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  vector<int> a(1 << n);
  int sum = 0;
  R(i,1 << n){
    cin >> a[i];
    sum += a[i];
  }
  int odw = pot(sum, P-2);
  R(i,1 << n){
    a[i] = mul(a[i], odw);
  }
  add(a[0], P-1);
  vector<int> b(1 << n, P - 1);
  b[0] = (1 << n) - 1;
  vector<int> res = licz(a,b,1 << n);
  int pom = res[0];
  R(i,1 << n){
    sub(res[i],pom);
    cout << res[i] << "\n";
  }
}


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

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

  if(n%2==1){
    cout << 0 << endl;
    return 0;
  }

  long long ans = 0;
  long long div = 10;
  while(div<=n){
    ans += n/div;
    div *= 5;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        int x,y;
        cin>>x>>y;

        if(y>=x)printf("unsafe\n");
        else{
            printf("safe\n");
        }

        //printf("Case %d: ",++te);
    }
    return 0;
}






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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1000000000;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll count = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    while (a[i] % 2 == 0) {
      count++;
      a[i] /= 2;
    }
  }
  cout << count << endl;
}


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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    map<ll,int> cnt;
    for(ll i = 2; i*i <= n; i++){
        while(n%i == 0){
            n /= i;
            cnt[i]++;
        }
    }
    if(n > 1)   cnt[n]++;
    int ans = 0;
    for(auto p : cnt){
        int x = p.second;
        for(int i = 0;; i++){
            if(i*(i+1)/2 > x){
                ans += i-1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String result = (Math.abs(x - a) <= Math.abs(x - b)) ? "A" : "B";
        System.out.println(result);
    }

}

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

#define MAX_M 20
#define MAX_N 100000

int N,M;
int cnt[MAX_N+1][MAX_M];

int memo[1<<MAX_M];
int csum[1<<MAX_M];

inline int cntToy(int toy, int begin, int end){
	//printf("cntToy(%d,%d,%d)=%d\n",toy+1, begin, end,cnt[end][toy] - cnt[begin][toy]);
	return cnt[end][toy] - cnt[begin-1][toy];
}

inline int cntToyAll(int toy){
	return cnt[N][toy];
}

int dp(const int bits, const int n){
	if(bits == 0) return 0;
	if(csum[bits] != 0) return memo[bits];
	csum[bits] = n;
	int best = 1<<21;
	for(int toy=0; toy<M; ++toy){
		const int toyBit = (1<<toy);
		if( toyBit & bits ){
			const int b = bits^toyBit;
			const int x = dp(b, n - cntToyAll(toy));
			const int begin = csum[b]+1;
			const int y = x + (cntToyAll(toy) - cntToy(toy, begin, n));
			best = min(best,y);
		}
	}
	//printf("n=%d memo[#%x]=%d\n",n, bits, best);
	return memo[bits] = best;
}

int main(){
	cin >> N >> M;
	for(int i=1; i<=N; ++i){
		for(int j=0; j<M; ++j){
			cnt[i][j] = cnt[i-1][j];
		}
		int t;
		cin >> t;
		cnt[i][t-1]++;
	}
	cout << dp((1<<M)-1, N) << endl;
}


Measured memory_bytes: 18984
// AOJ Vol3-0383 Heat Strokes
// 2018.12.22

//#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int A, B, X;
	int c, ans;

	scanf("%d%d%d", &A, &B, &X);
	if (A >= 2 * B) ans = ((X - 1) / 500 + 1) * B;
	else {
		ans = X / 1000 * A;
		c = X % 1000;
		if (c) {
			if (c <= 500 && B < A) ans += B;
			else ans += A;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

int solvekoch(int n, vector<double> p1,vector<double> p2) {
	if (n == 0) {
		return 0;
	}

	vector<double> s{ p1[0]+(p2[0] - p1[0]) / 3, p1[1]+(p2[1] - p1[1]) / 3 };
	vector<double> t{ p1[0]+(p2[0] - p1[0]) / 3 * 2,p1[1]+(p2[1] - p1[1]) / 3 * 2 };

	double cos6 = cos(60.0 / 180 * 3.14159265354);
	double sin6 = sin(60.0 / 180 * 3.14159265354);
	vector<double> u{ s[0]+cos6*(t[0]-s[0])-sin6*(t[1]-s[1]), s[1]+sin6*(t[0]-s[0])+cos6*(t[1]-s[1]) };

//	cout << fixed << setprecision(7) << p1[0] << " " << p1[1] << endl;
	solvekoch(n - 1, p1, s);
	cout << fixed << setprecision(7) << s[0] << " " << s[1] << endl;
	solvekoch(n - 1, s, u);
	cout << u[0] << " " << u[1] << endl;
	solvekoch(n - 1, u, t);
	cout << t[0] << " " << t[1] << endl;
	solvekoch(n - 1, t, p2);
//	cout << p2[0] << " " << p2[1] << endl;

	return 0;
}

int main() {

	int n;
	cin >> n;

	vector<double> p1{ 0,0 };
	vector<double> p2{ 100,0 };

	cout << 0 << " " << 0 << endl;
	solvekoch(n, p1, p2);
	cout << 100 << " " << 0 << endl;

}


Measured memory_bytes: 3244
from math import factorial
N = int(input())
A = list(map(int,input().split()))
L = []
D = {}
ans = 0
L.append(0)
for i in range(len(A)) :
    L.append(L[-1]+A[i])
for j in range(len(L)) :
    if L[j] not in D :
        D[L[j]] = 1
    else :
        D[L[j]] += 1
V = list(D.values())
for k in range(len(V)) :
    if V[k] >= 2 :
        c = factorial(V[k])//(factorial(2)*factorial(V[k]-2))
        ans += c
print(ans)


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

int n, a[101];
int solve(bool even, int pos){
	int sm = 0;
	if(pos==n){
		if(even) return 1;
		return 0;
		}
	if(even){
		return pow(3, n-pos);
		}
	int p = 1, q = 2;
	if(a[pos]%2) swap(p, q);
	sm += p*solve(1, pos+1);
	sm += q*solve(0, pos+1);
	return sm;
	}

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<solve(0, 0)<<'\n';
	}


Measured memory_bytes: 384
using System;
using System.Linq;

namespace arc082_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = new int[100010];
            for (int i = 0; i < n; i++) a[x[i]]++;
            int max = a[0] + a[1] + a[2];
            int now = a[0] + a[1] + a[2];
            for (int i = 3; i < 100010; i++)
            {
                now -= a[i - 3]; now += a[i];
                max = Math.Max(max, now);
            }
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 18528
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;

int main() {
    int h, n; cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    if (h <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 640