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


using namespace std;


const int MAXN = 3000 + 23;









int n, a[MAXN];
vector<int> g[MAXN];
bitset<MAXN> mark;

void inp();
void dfs(int, int = -1);

int main() {
    inp();
    for (int i = 0; i < n; i++) {
        mark.reset();
        dfs(i);
        if (mark[i])
            cout << i + 1 << ' ';
    }
    return 0;
}
void inp() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[--u].push_back(--v), g[v].push_back(u);
    }
}
void dfs(int v, int p) {
    for (auto u : g[v]) if (u != p) dfs(u, v);
    for (auto u : g[v]) if (!mark[u] && a[v] > a[u]) mark[v] = true;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  int N;

  cin>>N;

  long long a[100001];

  long long left[100001];

  long long right[100001];

  left[0]=0;

  right[N+1]=0;

  for(int i=1;i<=N;i++){

    cin>>a[i];

    left[i]=__gcd(a[i],left[i-1]);

  }

  for(int i=N;i>=1;i--){

    right[i]=__gcd(a[i],right[i+1]);

  }

  long long maxx=0;

  for(int i=1;i<=N;i++){
    maxx=max(__gcd(left[i-1],right[i+1]),maxx);

  }

  cout<<maxx<<endl;

  return 0;

}


Measured memory_bytes: 2560
x, y = map(int, input().split())
res = 0
if x == 1:
    res += 300000
elif x == 2:
    res += 200000
elif x == 3:
    res += 100000
if y == 1:
    res += 300000
elif y == 2:
    res += 200000
elif y == 3:
    res += 100000
if x == 1 and y == 1:
    res += 400000
print(res)



Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define INF 10000000000
#define M 1000000007
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
 
int main() {
	long N;
	long T[200001];
	long A[200001];
	long ans = 0;
	long t = 1, a = 1;
	long b;
	long x, y;
	long i, j;
	
	scanf("%ld", &N);
	for(i=1;i<=N;i++) {
		scanf("%ld %ld", &T[i], &A[i]);
		x = t; y = a;
		t = T[i]; a = A[i];
		b = max(max(x/t, y/a), 2);
		while(x > t || y > a) {
			t = T[i] * b;
			a = A[i] * b;
			b++;
		}
	}
	
	printf("%ld\n", t + a);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, Z, W;
vector<ll> v;

int main(){
  cin >> N >> Z >> W;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  ll ret = abs(W - v[N-1]);
  if(N>=2){
    ret = max(ret, abs(v[N-1] - v[N-2]));
  }

  cout << ret << endl;
  
  return 0;
}

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

fn main() {
    input! {
        n: usize,
        a: [i64; n]
    }

    let mut sum = vec![0;n+1];
    for i in 0..n {
        sum[i+1] = sum[i] + a[i];
    }

    let counted = count(&sum);
    let mut cnt = 0u64;
    for (_, &v) in counted.iter() {
        cnt += v as u64 * (v as u64 - 1) / 2;
    }
    println!("{}", cnt);
}

#[allow(dead_code)]
fn count<T: Eq + std::hash::Hash + Clone>(slice: &[T]) -> std::collections::HashMap<T, usize> {
    let mut hmap = std::collections::HashMap::new();
    for item in slice {
        *hmap.entry(item.clone()).or_insert(0) += 1;
    }
    hmap
}

Measured memory_bytes: 19220
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>

#define MAX 1000000
#define NIL -1

using namespace std;

class Node{
  public:
	int location;
	int p,l,r;
	Node(){}
};

class Point{
  public:
	int id,x,y;
	Point() {}
	Point(int id, int x, int y): id(id),x(x),y(y){}
	bool operator < (const Point &p) const{
		return id < p.id;
	}
	
	void print(){
		printf("%d\n",id);
	}
};

int N;
int np;
Point P[MAX];
Node T[MAX];

bool lessX(const Point &p1, const Point &p2) {return p1.x<p2.x;}
bool lessY(const Point &p1, const Point &p2) {return p1.y<p2.y;}

int makeKDTree(int l, int r, int depth){
	if(!(l<r)) return NIL;
	int mid=(l+r)/2;
	int t=np++;
	
	if(depth%2==0){
		sort(P+l,P+r,lessX);
	}
	else{
		sort(P+l,P+r,lessY);
	}
	T[t].location=mid;
	T[t].l=makeKDTree(l,mid,depth+1);
	T[t].r=makeKDTree(mid+1,r,depth+1);
	
	return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
	int x=P[T[v].location].x;
	int y=P[T[v].location].y;
	
	if(sx<=x&&x<=tx&&sy<=y&&y<=ty){
		ans.push_back(P[T[v].location]);
	}
	
	if(depth%2==0){
		if(T[v].l!=NIL){
			if(sx<=x) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(x<=tx) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
	else{
		if(T[v].l!=NIL){
			if(sy<=y) find(T[v].l,sx,tx,sy,ty,depth+1,ans);
		}
		if(T[v].r!=NIL){
			if(y<=ty) find(T[v].r,sx,tx,sy,ty,depth+1,ans);
		}
	}
}

int main(){
	int x,y;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l=T[i].r=T[i].p=NIL;
	}
	np=0;
	
	int root=makeKDTree(0,N,0);
	
	int q;
	scanf("%d",&q);
	int sx,tx,sy,ty;
	vector<Point> ans;
	for(int i=0;i<q;i++){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		for(int j=0;j<ans.size();j++){
			ans[j].print();
		}
		printf("\n");
	}
}

Measured memory_bytes: 16508
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <vector>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, x[10], y[10], cnt = 0;
  ld sum = 0;
  vector<int> vec;

  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> x[i] >> y[i];
  }
  for (int i = 0; i < n; ++i) vec.push_back(i);
  do
  {
    ++cnt;
    for (int j = 0; j < n - 1; ++j) {
      sum += sqrtl(powl(x[vec[j]] - x[vec[j + 1]], 2) + powl(y[vec[j]] - y[vec[j + 1]], 2));
    }
  } while (next_permutation(vec.begin(), vec.end()));
  cout << fixed << setprecision(15) << sum / cnt;
}


Measured memory_bytes: 3852
/*
Author : N_o_o_B
Created : April 22 2020 21:58:11 
*/
#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;

    ll a,b;
    cin >> a >> b;
    if(a*b<=0){
        cout << "Zero" << endl;
        return 0;
    }
    if((b-a+1)%2){
        cout << ((a<0) ? "Negative":"Positive") << endl;
    }
    else{
        cout << "Positive" << endl;
    }


    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define rep(i,a,b)  for (int i = a; i < b; ++i)
#define rrep(i,z,a) for (int i = z; i >= a; --i)
#define rep0(n)     for(int i = 0 ; i < n; ++i )
#define rep1(n)     for(int i = 1 ; i <= n; ++i )
#define pb          push_back
#define sd(x)       scanf("%d",&x)
#define tc          int test;cin>>test; while(test--)
#define all(v)      v.begin(),v.end()
#define ff          first
#define ss          second
#define mp          make_pair
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl        "\n"
#define spc         " "
#define mem0(a)     memset(a,0,sizeof(a))
#define extime      cout << endl << endl << "____"<<(float)clock() / CLOCKS_PER_SEC << "s____";
#define MAXN        1000006
#define mod         2000000014
//#define ll          long long int
//typedef vector<ll>  vll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
void OJ()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int spf[1000008], used[1000008];
void sieve()
{
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++)

    // marking smallest prime factor for every
    // number to be itself.
    spf[i] = i;

  // separately marking spf for every even
  // number as 2
  for (int i = 4; i < MAXN; i += 2)
    spf[i] = 2;

  for (int i = 3; i * i < MAXN; i++)
  {
    // checking if i is prime
    if (spf[i] == i)
    {
      // marking SPF for all numbers divisible by i
      for (int j = i * i; j < MAXN; j += i)

        // marking spf[j] if it is not
        // previously marked
        if (spf[j] == j)
          spf[j] = i;
    }
  }
}

int solve()
{
  int n, z = 0;
  cin >> n;
  int a[n];
  rep0(n)cin >> a[i], z = __gcd(z, a[i]);
  if (z != 1)return cout << "not coprime", 0;
  rep0(n)
  {
    int x = a[i];

    while (x != 1)
    {
      int t = spf[x];
      while (x % t == 0 && x != 1)x /= spf[x];
      used[t]++;
      if (used[t] > 1)
      {
        if (z == 1)return cout << "setwise coprime", 0;
        else return cout << "not coprime", 0;
      }
    }
  }
  cout << "pairwise coprime";
  return 0;
}
signed main()
{
  OJ();
  sieve();
  IOS
  //tc
  solve();
  //extime
  return 0;
}

Measured memory_bytes: 19828
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

ll ga, sa, ba;
ll gb, sb, bb;

ll dp1[5010];
ll dp2[5010*5010];

void go(ll dp[], int n, ll w, ll p) {
  REP(i, n) {
    if(i + w > n) break;
    if(dp[i] < 0) continue;
    dp[i+w] = max(dp[i+w], dp[i] + p);
  }
}

int main(void) {
  int n;
  cin >> n;
  cin >> ga >> sa >> ba;
  cin >> gb >> sb >> bb;
  memset(dp1, -1, sizeof dp1);
  dp1[0] = 0;
  go(dp1, n, ga, gb);
  go(dp1, n, sa, sb);
  go(dp1, n, ba, bb);
  go(dp1, n, 1, 1);
  assert(dp1[n] < 5010*5010);

  memset(dp2, -1, sizeof dp2);
  dp2[0] = 0;
  go(dp2, dp1[n], gb, ga);
  go(dp2, dp1[n], sb, sa);
  go(dp2, dp1[n], bb, ba);
  go(dp2, dp1[n], 1, 1);
  cout << dp2[dp1[n]] << endl;
  
  return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

//二次元配列
//vector<vector<int>> A(N, vector<int>(M));

using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> p(M);
  vector<int> k(M);
  vector<vector<int>> s(M,vector<int>());

  rep(i,M){
    cin >> k.at(i);
    rep(j,k.at(i)){
      int buffer;
      cin >> buffer;
      s.at(i).push_back(buffer);
    }
  }

  rep(i,M){
    cin >> p.at(i);
  }

  //bit全探索
  int sum=0;

  for(int bit = 0;bit < (1<<N);++bit){
    bool flag = 1;
    for(int i = 0;i < M;i++){
      int count = 0;

      for(int j = 0;j < k.at(i);j++){
        if(bit & (1 << (s.at(i).at(j)-1))){
          count++;
        }
      }

      if(count%2 != p.at(i)){
        flag = 0;
      }
    }
    if(flag)sum++;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#abc121 c
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])

ans=0
for yen,kosu in ab:
    if m==0:
        break
    x=min(kosu,m)
    m-=x
    ans+=yen*x
print(ans)

Measured memory_bytes: 29028
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
		ce("Yes")
	}else{
		ce("No")
	}

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<stack>
#define pii std::pair<int,int>
using namespace std;

vector<int> edge[2005];
pair<int,int> e[2005];
bool vis[2005];
int cnt;

void dfs(int n,int k)
{
    vis[n]=1;cnt++;
    if(k==0) 
		return;
    for(int i=0;i<edge[n].size();i++)
        if(!vis[edge[n][i]]) 
			dfs(edge[n][i],k-1);
}
int main(){
    int n,k;cin>>n>>k;
    for(int i=1;i<=n-1;i++)
	{
        int a,b;
		cin>>a>>b;
        e[i].first=a;
		e[i].second=b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    int ans=n;
    if(k&1)
	{
        for(int i=1;i<=n-1;i++)
		{
            cnt=0;
            memset(vis,0,sizeof vis);
            vis[e[i].second]=1;
            dfs(e[i].first,k/2);
            dfs(e[i].second,k/2);
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }
	else
	{
        for(int i=1;i<=n;i++)
		{
            cnt=0;
            memset(vis,0,sizeof vis);
            dfs(i,k/2);
            int tmp=n-cnt;
            ans=min(tmp,ans);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int>E[100];

int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	int i;

	for(i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		E[a].push_back(b);
		E[b].push_back(a);
	}

	for(i=1;i<=N;i++){
	cout<<E[i].size()<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [0]*n
for i in range(n):
    x[i] = list(map(int,input().split()))

d0 = [0]*n
d1 = [0]*n
for i,[x,y] in enumerate(x) :
    d0[i] = x-y
    d1[i] = x+y
print(max(max(d0)-min(d0), max(d1)-min(d1)))

Measured memory_bytes: 61164
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a, b;
  string op;
  while(1)
  {
    cin >> a >> op >> b;
    if(op == "?") break;
    if(op == "+") cout << a+b << endl;
    if(op == "-") cout << a-b << endl;
    if(op == "*") cout << a*b << endl;
    if(op == "/") cout << a/b << endl;
  }
  return 0;
}


Measured memory_bytes: 3140
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = if N % 2 == 0 {
        (1..26).map((|i| N / (2 * 5i64.pow(i)))).sum::<i64>()
    } else {
        0
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
n = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(n):
    min_j = i
    for j in range(i, n):
        if A[j] < A[min_j]:
            min_j = j
    if i != min_j:
        A[i], A[min_j] = A[min_j], A[i]
        cnt += 1
print(*A)
print(cnt)



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

typedef long long ll;
typedef long double lxd;
typedef vector<ll> vll ;
 
#define INF 1e10 ;
#define mem(dp,a) memset(dp,a,sizeof dp)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) ;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define fo(i,n,x) for (ll i=x;i<=n  ;i++)
#define mp(a,b) push_back(make_pair(a,b))
#define pb(x) push_back(x)
#define make_graph(a,b) adj[a].pb(b) ; adj[b].pb(a);
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t; cin>>t; label: while(t--)
#define fls fflush(stdout)
#define F first
#define S second

main(){
    ll n ;
    cin>>n  ;
    while(n){
        ll x = n % 10 ;
        if(x == 7){
            cout<<"Yes"; return 0 ;
        }
        n /= 10 ;
    }
    cout<<"No";
}

Measured memory_bytes: 3604
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}


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

using namespace std;

int main() {
  int sum = 0;
  string n;
  cin >> n;

  for (unsigned i=0; i < n.size(); i++) {
    sum += n[i] - 48;
  }
  if (sum % 9 == 0) {
    cout << "Yes\n";
  }
  else {
    cout << "No\n";
  }
}

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

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        q.push(tmp);
    }
    for(int i=0; i<m; i++){
        int tmp=q.top();q.pop();
        tmp/=2;
        q.push(tmp);
    }
    ll sum=0;
    while(!q.empty()){
        sum+=q.top();q.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll n;
	cin>>n;
	vector<ll> v(n);
	rep(i,n) cin>>v[i];
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			for(ll k=j+1;k<n;k++)
			{
				ll tmp[3]={v[i],v[j],v[k]};
				set<ll> st;
				st.insert(v[i]);st.insert(v[j]);st.insert(v[k]);
				if(st.size()<3) continue;
				sort(tmp,tmp+3);
				if(tmp[0]+tmp[1]>tmp[2]) ans++;
			}
		}
	}	
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



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

int main() {
	int n;
	cin >> n;
	vector<int> v(n,0);
	int s=0;
	for(int i=0;i<n;i++)
	{
		cin >> v.at(i);
	}
	for(int i=0;i<n;i++)
	{
		int c;
		cin >> c;
		s += max(0,v.at(i) - c);
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 10005
#define ll long long
#define endl '\n'

using namespace std;

int main()
{
	ll num[100005];
	set<int> v;
	int n,m,tmp;
	cin >> n >> m;
    int ttt=0;
	for(int i=0;i<m;++i){
		cin >> tmp;
		if(v.find(tmp)==v.end())
			v.insert(tmp),++ttt;
	}
	v.insert(100000000);
	auto p=v.begin();
	num[0]=1;

	if(*p==1)
		num[1]=0,++p;
	else
		num[1]=1;

	for(int i=2;i<=n;++i){
		num[i]=(num[i-1]+num[i-2])%1000000007;
		if(*p==i)
			num[i]=0,++p;
	}
	cout << num[n] << endl;

	return 0;
}

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

const int MAX = 100010;
const long long INF = 1e18;
int n;
struct edge {
    long long cost;
    int to;
};
vector<edge> G[MAX];
vector<long long> D(MAX);

void dijkstra(int s){
    for(int i = 0; i < n; i++){
        D[i] = INF;
    }
    D[s] = 0;

    priority_queue<P, vector<P>, greater<P>> q;
    q.push({0, s});
    while(!q.empty()){
        P p = q.top();
        q.pop();
        int now = p.second;
        for(int i = 0; i < G[now].size(); i++){
            edge e = G[now][i];
            if(D[e.to] > D[now] + e.cost){
                D[e.to] = D[now] + e.cost;
                q.push({D[e.to], e.to});
            }
        }
    }
}

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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({c, b});
        G[b].push_back({c, a});
    }

    int q, k;
    cin >> q >> k;

    k--;
    dijkstra(k);

    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << D[x] + D[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

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

struct Position {
  int x;
  int y;
};

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> map(H);
  for (size_t i = 0; i < H; i++) {
    cin >> map[i];
  }

  if (map[0][0] != '.' || map[H - 1][W - 1] != '.') {
    cout << -1 << endl;
    return 0;
  }

  vector<vector<int>> dist(H, vector<int>(W, -1));
  dist[0][0] = 0;
  queue<Position> queue;
  queue.push(Position{0, 0});
  while (!queue.empty()) {
    Position p = queue.front(); queue.pop();
    for (size_t i = 0; i < 4; i++) {
      int x = p.x + dx[i];
      int y = p.y + dy[i];
      if (x >= 0 && y >= 0 && x < W && y < H &&
          map[y][x] == '.' && dist[y][x] < 0) {
        dist[y][x] = dist[p.y][p.x] + 1;
        queue.push(Position{x, y});
      }
    }
  }
  if (dist[H - 1][W - 1] < 0) {
    cout << -1 << endl;
    return 0;
  }

  int score = 0;
  for (size_t i = 0; i < H; i++) {
    for (size_t j = 0; j < W; j++) {
      if (map[i][j] == '.') {
        score++;
      }
    }
  }
  cout << (score - dist[H - 1][W - 1] - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
n, W = map(int, input().split())
obj = [list(map(int, input().split())) for _ in range(n)]
DP = [[0]*2*W for _ in range(n+1)]

for i in range(1, n+1):
    for w in range(W+1):
        weight, value = obj[i-1]
        DP[i][w] = max(DP[i-1][w], DP[i][w])
        if w + weight <= W:
            DP[i][w + weight] = max(DP[i - 1][w] + value, DP[i][w + weight])

ans = max(DP[n])
print(ans)


Measured memory_bytes: 192792
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    char s[10];
    scanf("%s", s);
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        printf("Yes\n");
    else if (s[0] == s[2] && s[2] != s[1] && s[1] == s[3])
        printf("Yes\n");
    else if (s[0] == s[3] && s[3] != s[1] && s[1] == s[2])
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < w; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26124
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		string s[51];
		REP(i,0,n) {
			string tmps;
			cin>>tmps;
			s[i]+=tmps[0];
			REP(j,1,(int)tmps.size()){
				char c=tmps[j-1];
				if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
					s[i]+=tmps[j];
				}
			}
		}
		sort(s,s+n);
		int k=0;
		bool flag=false;
		REP(i,0,n-1){
			if(s[i]==s[i+1]) {
				flag=true;
				break;
			}
			int mn=min<int>(s[i].size(),s[i+1].size());
			REP(j,0,mn){
				if(s[i][j]!=s[i+1][j])	{
					k=max(k,j+1);
					break;
				}
				if(j==mn-1)	k=max(k,mn+1);
			}
		}
		p(flag?-1:k);
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int a, b;
    char op;
    cin >> a >> op >> b;
    cout << (op=='+'?a+b:a-b) << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 45;
int n,a[MAXN][MAXN];
ll f[MAXN][MAXN][MAXN][MAXN],g[MAXN][MAXN][MAXN][MAXN];
char str[MAXN];
inline ll getf(int i, int j, int k, int l);
inline ll getg(int i, int j, int k, int l);

int main()
{
	cin >> n;
	for(int i = 1; i<=2*n; i++)
	{
		cin >> str+1;
	    for(int j = 1; j<=2*n; j++)
		    a[i][j] = str[j]-'0';
	}
	memset(f,-1,sizeof(f)), memset(g,-1,sizeof(g));
	ll ans = 0;
	for(int i = 2; i<=2*n; i++)
		ans += getg(2,i-1,i+1,2*n)*a[1][i];
	cout << ans << endl;
	return 0;
}

inline ll getf(int i, int j, int k, int l)
{
	if(f[i][j][k][l]>=0)
	    return f[i][j][k][l];
	if(k<=j)
		return f[i][j][k][l] = 0;
	if(i>j||k>l)
		return f[i][j][k][l] = i>j&&k>l;
	f[i][j][k][l] = 0;
	for(int p = i; p<=j; p++)
		for(int q = k; q<=l; q++)
			f[i][j][k][l] += getg(i,p-1,p+1,j)*getg(k,q-1,q+1,l)*a[p][q];
	//cout << "f " << i << " " << j << " " << k << " " << l << " " << f[i][j][k][l] << endl;
	return f[i][j][k][l];
}
inline ll getg(int i, int j, int k, int l)
{
	if(g[i][j][k][l]>=0)
	    return g[i][j][k][l];
	if(k<=j)
	    return g[i][j][k][l] = 0;
	if(i>j||k>l)
		return g[i][j][k][l] = i>j&&k>l;
	g[i][j][k][l] = 0;
	for(int p = i; p<=j; p++)
	    for(int q = k; q<=l; q++)
	    	g[i][j][k][l] += getf(i,p,q,l)*getg(p+1,j,k,q-1);
	//cout << "g " << i << " " << j << " " << k << " " << l << " " << g[i][j][k][l] << endl;
	return g[i][j][k][l];
}

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

int main()
{
    string s;
    cin >> s;
    int size = s.size();
    vector<int> c_num(size, 0);
    vector<int> rl_num;

    int p = 0;
    while (p < size)
    {
        int num = 0;
        if (s[p] == 'R')
        {
            while (p < size && s[p] == 'R')
            {
                num += 1;
                p += 1;
            }
            rl_num.push_back(num);
            continue;
        }

        if (s[p] == 'L')
        {
            while (p < size && s[p] == 'L')
            {
                num += 1;
                p += 1;
            }
            rl_num.push_back(num);
            continue;
        }
    }
    int index = 0;
    for (auto i = 0; i < rl_num.size(); i += 2)
    {
        if(rl_num[i] % 2 == 0){
            c_num[index + rl_num[i] - 1] += rl_num[i] / 2;
            c_num[index + rl_num[i]] += rl_num[i] / 2;
        }else{
            c_num[index + rl_num[i] - 1] += (rl_num[i] + 1) / 2;
            c_num[index + rl_num[i]] += rl_num[i] / 2;
        }

        if(rl_num[i+1] % 2 == 0){
            c_num[index + rl_num[i] - 1] += rl_num[i + 1] / 2;
            c_num[index + rl_num[i]] += rl_num[i + 1] / 2;
        }else{
            c_num[index + rl_num[i]] += (rl_num[i + 1] + 1) / 2;
            c_num[index + rl_num[i] - 1] += rl_num[i + 1] / 2;            
        }

        index += rl_num[i] + rl_num[i + 1];
    }
    for (auto i = 0; i < size; i++)
    {
        cout << c_num[i] << " ";
    }

    cout << endl;

    
}

Measured memory_bytes: 1528
#include<iostream>
#include<cstdlib>
using namespace std;
#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(int argc, char const *argv[])
{
    int H, *A;
    A = (int *)malloc(sizeof(int)*MAX);

    cin >> H;
    for(int i=1; i<=H; i++) cin >> A[i];
    
    for(int i=1; i<=H; i++){
        cout << "node " << i <<": key = " << A[i] << ", ";
        if(parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
string ch="URDL";

int h,w;
int si,sj,dir;
char t[10][10];
int cnt=0;
vector<char> ans;

bool inField(int y,int x){
  if(y<0||x<0)return false;
  if(y>=h||x>=w)return false;
  return true;
}

bool solve(int y,int x,int dir,int depth=0){
  if(depth==cnt)return true;
  
  for(int i=0;i<4;i++){
    if((i+2)%4==dir)continue;
    int k,ny,nx;
    for(k=0;;k++){
      ny=y+dy[i]*k;
      nx=x+dx[i]*k;
      if(!inField(ny,nx))break;
      if(t[ny][nx]=='o')break;
    }
    if(!inField(ny,nx))continue;
    t[ny][nx]='.';
    if(solve(ny,nx,i,depth+1)){
      ans.push_back(ch[i]);
      return true;
    }
    t[ny][nx]='o';
  }
  return false;
}

int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>t[i][j];
      if(t[i][j]=='o'){
        cnt++;
      }else if(t[i][j]=='U'){
        si=i,sj=j,dir=0;
      }else if(t[i][j]=='R'){
        si=i,sj=j,dir=1;
      }else if(t[i][j]=='D'){
        si=i,sj=j,dir=2;
      }else if(t[i][j]=='L'){
        si=i,sj=j,dir=3;
      }
    }
  }
  solve(si,sj,dir);
  reverse(ans.begin(),ans.end());
  for(int i=0;i<(int)ans.size();i++)cout<<ans[i];
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;i++)
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)

int main(void){
    fast_io();

    ll n;
    cin >> n;
    vll v(n);
    rep(i,n)cin >> v[i];
    
    vll memo(100001,0);
    rep(i,(int)v.size()){
        memo[v[i]]++;
    }
    
    ll sum = accumulate(v.begin(),v.end(),0LL);
    ll q;
    cin >> q;
    vll c(q);
    vll b(q);
    rep(i,q) cin >> b[i] >> c[i];

    rep(i,q){
        sum += (c[i] - b[i]) * memo[b[i]];
        const ll temp = memo[b[i]];
        memo[b[i]] = 0;
        memo[c[i]] += temp;
        cout << sum << "\n";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6032
n, *a = map(int, open(0).read().split())
a.sort(reverse=True)
ans = a[0]
if n%2 == 0:
    for i in range(1, n//2):
        ans += a[i] * 2
else:
    for i in range(1, int(n/2)):
        ans += a[i] * 2
    ans += a[i+1]

print(ans)
    

Measured memory_bytes: 31620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
//积水问题
char map[20010];
int isfinish(int x)
{
	int up=0,down=0,len,i,flag=1;
	len=strlen(map);
	for(i=x;i<=len-1;i++)
	{
		
		if(map[i]=='\\')
		{
			down++;
			flag=0;
		}
		if(map[i]=='/')
		{
			up++;
			if(flag==1)
				return 0;
		}
		if(up>down)
			return 0;
	}
	
	
	return 1;
}
int main()
{
	int stack[20010],i,j=0,len,puddle[10010]={0},total=0,top=0,flag=1;
	scanf("%s",map);
	len=strlen(map);
	for(i=0;i<=len-1;i++)
	{

		if(map[i]=='\\')
		{
			top++;
			stack[top]=i;
		}
		if(map[i]=='/' && top!=0)
		{
			if(flag==1)
			{
				flag=0;
				j++;
			}
			puddle[j]+=i-stack[top];
			total+=i-stack[top];
			top--;
			if(top==0)
				flag=1;
			if(flag==0)
				flag=isfinish(i+1);
		}

	}
	printf("%d\n%d",total,j);
	for(i=1;i<=j;i++)
		printf(" %d",puddle[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n)*((n)+1)>>1)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;

const ll MAXN = 1e5+5, MAXM=105, oo=1e15;
ll dp[MAXM][MAXN], c[MAXM], w[MAXN];
int n, W;

ll f(int i, int sum){
    if(sum < 0) return oo;
    if(i<0){
        if(sum==0) return 0;
        return oo;
    }
    if(~dp[i][sum]) return dp[i][sum];
    return dp[i][sum] = min(f(i-1, sum-c[i]) + w[i], f(i-1, sum));
}


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



    cin >> n >> W;
    for (int i=0; i<n; i++)
            cin >> w[i] >> c[i];

    memset(dp, -1, sizeof dp);
    for (int i=0; i<MAXN; i++){
        f(n-1, i);
    }
    ll ans=0;
    for (int i=0; i<MAXM; i++)
        for (int j=0; j<MAXN; j++)
            if(~dp[i][j] && dp[i][j] <= W)
                ans = max(ans, (ll)j);

    cout << ans << "\n";
    return 0;
}

/*
1
9 3
111100000
 */

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}


int main() {
    int n,m; cin >> n >> m;
    vector<vector<char>> v;v.assign(n,vector<char>());
    for(int i = 0;i < n;i++){
        string s; cin >> s;
        if(s.find('#') != string::npos){
            for(int j = 0;j < m;j++){
                v[i].push_back(s[j]);
            }
        }else{
            i--;
            n--;
        }
    }
    
    for(int i = v[0].size()-1;i >= 0;i--){
        int cnt = 0;
        if(v[0][i] == '.'){
            for(int j = 0;j < n;j++){
                if(v[j][i]=='.'){
                    cnt++;
                }
            }
        }
        if(n == cnt){
            for(int j = 0;j < n;j++){
                v[j].erase(v[j].begin()+i);
            }
        }
    }
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < v[i].size();j++){
            cout << v[i][j];
        }
        cout << endl;
    }
}




Measured memory_bytes: 3624
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    p = LI()
    t = LI()
    ans = float("inf")
    for i in range(n+1):
        x0 = t[0]*i
        m0 = p[0]*i
        for j in range(n+1):
            x1 = x0+t[1]*j
            m1 = m0+p[1]*j
            for k in range(n+1):
                x2 = x1+t[2]*k
                m2 = m1+p[2]*k
                rest = max(0,math.ceil((n-x2)/t[3]))
                m3 = m2+p[3]*rest
                if m3 < ans:
                    ans = m3
    print(ans)
    return

#B
def B():
    def f(n):
        if n < 4:
            return 1
        m = n
        res = 1
        i = 2
        while i**2 <= n:
            if m%i == 0:
                if m//i != i:
                    res *= m//i
                res *= i
            i += 1
        return res
    MA = 100000
    d = [0]*(MA+1)
    for i in range(12,MA+1):
        if not d[i]:
            if f(i) >= (i<<1):
                j = i
                while j <= MA:
                    d[j] = 1
                    j += i
    for i in range(MA):
        d[i+1] += d[i]
    q = I()
    for i in range(q):
        print(d[I()])
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#G
def G():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()



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

using namespace std;

int main(){
	int n,t,tmp,small,pro,count;
	vector<int>a;
	cin >> n >> t;
	for(int i=0;i<n;i++){
		cin >>tmp;
		a.push_back(tmp);
	}
	count =0;
	pro =0;
	small =a[0];
	for(int i=1;i<n;i++){
		if(small<a[i]){
			if(pro<(a[i]-small)){
				count =1;
				pro = a[i]-small;
			}else if(pro==(a[i]-small)){
				count +=1;
			}
		}else if(small>a[i]){
			small = a[i];
		}
	}
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 892
N, T = [int(s) for s in input().split(' ')]
AB = sorted([tuple(int(s) for s in input().split(' ')) for _ in range(N)])

dp = [0] * T  # remainder max
ans = 0
for a, b in AB:
  for t, v in enumerate(dp):
    if t >= a:
      dp[t - a] = max(dp[t - a], v + b)
    else:
      ans = max(ans, v + b)
print(ans)
  
  

Measured memory_bytes: 47736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn],first=0,second=0;

int main()
{
	int n;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>a[i];
		if(a[i]>=first) {
			second=first;
			first = a[i];
		}
		else if(a[i]>=second){
			second = a[i];
		}
	}
	for(int i = 0;i<n;i++){
		if(a[i]==first) cout<<second<<endl;
		else cout<<first<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
int n, m;
long long a;
multiset<int, greater<int>> prices;
int32_t main()
{
    cin >> n >> m;
    assert(n <= 100000);
    int cnt = 0;
    while(cin >> a)
    {
        prices.insert(a);
        assert(n <= 1000000000);
        cnt++;
    }
    assert(cnt == n);
    for(int i = 0; i < m; i++)
    {
        int largest = *prices.begin();
        prices.erase(prices.begin());
        prices.insert(largest / 2);
    }
    int ans = 0;
    for(auto x : prices)
        ans += x;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  int answer;
  if (A+B >= A-B) answer = A+B;
    else answer = A-B;
  if (A*B > answer) answer =A*B;
  cout << answer << endl;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	SORT(a);

	LL alice = 0, bob = 0;
	for (int i = n-1; i >= 0; i -= 2) {
		alice += a[i];
	}
	for (int i = n-2; i >= 0; i -= 2) {
		bob += a[i];
	}

	cout << alice - bob << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()

a, b = int(s[:2]), int(s[2:])
if 0 < a < 13 and 0 < b < 13:
    print('AMBIGUOUS')
elif 0 < a < 13:
    print('MMYY')
elif 0 < b < 13:
    print('YYMM')
else:
    print("NA")


Measured memory_bytes: 9088
#include<cstdio>
#include<cmath>

double sqr(double x){
  return x*x;
}

int distance_sqr(int D, int *X, int *Y){
  double s=0;
  for(int i=0;i<D; i++){
    s+=sqr(X[i]-Y[i]);
  }
  return s;
}

int main(){
  int N, D;
  scanf("%d %d",&N, &D);
  int X[10][10];
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      scanf("%d", &X[i][j]);
    }
  }
  //for(int i=0; i<N; i++){
  //  for(int j=0; j<D; j++){
  //    printf("%d ", X[i][j]);
  //  }
  //  printf("\n");
  //}
  
  int c=0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      int XX[10], YY[10];
      for(int h=0; h<D; h++){
        XX[h]=X[i][h];
        YY[h]=X[j][h];
      }
      // printf("X[%d]----X[%d] distance %d\n",i,j,distance_sqr(D,XX,YY));
      for(int k=0; k<10000; k++){
        if(sqr(k)==distance_sqr(D,XX,YY)){
          c++;
          break;
        }
      }
    }
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 128
N=int(input())
if N <=2:
    print(N)
elif N <4:
    print(2)
elif N <8:
    print(4)
elif N < 16:
    print(8)
elif N < 32:
    print(16)
elif N < 64:
    print(32)
else:
    print(64)


Measured memory_bytes: 2940