akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
////@formatter:on
//endregion


int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    make(int, n, m);
    if (n > m){
        swap(n, m);
    }
    cout << string(m, '0' + n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());

  cout << A.size() << endl;
}


Measured memory_bytes: 256
S=gets.chomp
gnum=0
pnum=0
point=0
S.each_char{|c|
    if pnum>=gnum
        # gu-
        if c=='p'
            point -= 1
        end
        gnum+=1
    else
        # pa-
        if c=='g'
            point +=1
        end
        pnum+=1
    end
}
puts point

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  scanf("%d%d",&x,&y);
  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
    if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
      printf("Yes\n");
      return 0;
    }
  }
  if (x == 4 || x == 6 || x == 9 || x == 11) {
    if (y == 4 || y == 6 || y == 9 || y == 11) {
      printf("Yes\n");
      return 0;
    }
  }
  if (x == 2 && y == 2) {
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
}

Measured memory_bytes: 256
n = int(input())
s = input()
L = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
     'P','Q','R','S','T','U','V','W','X','Y','Z']
ans=''
for i in range(len(s)):
     for l in range(len(L)):
         if s[i]==L[l]:
             ans += L[((l+n)%len(L))]
print(ans)                  
     

Measured memory_bytes: 42460
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 
 
int main() {
    int x;
    cin >> x;
    int a = x/500;
    x = x - a*500;
    int b = x/5;
    cout << a*1000 + b*5 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B;
	int asumisu;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	asumisu = A + B;
	if (asumisu < A - B) asumisu = A - B;
	if (asumisu < A * B) asumisu = A * B;
	printf("%d\n", asumisu);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int count,i,cc;
  char data[33];
  while(1){
    for(i=0;i<32;i++){
      data[i]='0';
    }
    scanf("%s",data);
    if(data[0]=='#') break;
    if(data[0]=='q'||data[0]=='w'||data[0]=='e'||data[0]=='r'||data[0]=='t'||data[0]=='a'||data[0]=='s'||data[0]=='g'||data[0]=='z'||data[0]=='x'||data[0]=='c'||data[0]=='v'||data[0]=='b'||data[0]=='d'||data[0]=='f'){
      cc=1;
    }else if(data[0]=='y'||data[0]=='u'||data[0]=='i'||data[0]=='o'||data[0]=='p'||data[0]=='h'||data[0]=='j'||data[0]=='k'||data[0]=='l'||data[0]=='n'||data[0]=='m'){
      cc=2;
    }
    count=0;
   
    for(i=1;i<32;i++){
      if(data[i]=='q'||data[i]=='w'||data[i]=='e'||data[i]=='r'||data[i]=='t'||data[i]=='a'||data[i]=='s'||data[i]=='g'||data[i]=='z'||data[i]=='x'||data[i]=='c'||data[i]=='v'||data[i]=='d'||data[i]=='b'||data[i]=='f'){ 
	if(cc==2){
	count++;
	cc=1;  
	}
      }else if(data[i]=='y'||data[i]=='u'||data[i]=='i'||data[i]=='o'||data[i]=='p'||data[i]=='h'||data[i]=='j'||data[i]=='k'||data[i]=='l'||data[i]=='n'||data[i]=='m'){
	if(cc==1){
	count++;
	cc=2;
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int visited[100005];
int color[100005];
vector<pair<int,int> > arr[100005];
int m;
void dfs(int n,int c)
{
    visited[n]++;
    c=(c+1)%m;
    //cout<<n<<endl;
    for(int i=0;i<arr[n].size();i++)
    {
        
        int k = arr[n][i].first;//cout<<k<<<<endl;
        int e = arr[n][i].second;
        //cout<<k<<' '<<e<<endl;
        if(!visited[k])
        {
            color[e]=c;
            dfs(k,c);
            c=(c+1)%m;
        }
    }
}
int main()
{
    int n;
    m=0;
    cin>>n;
    
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        arr[a].push_back(make_pair(b,i));
        arr[b].push_back(make_pair(a,i));
        int p = arr[a].size(),q=arr[b].size();
        m = max(m,max(p,q));
        
    }
    color[arr[1][0].second] = 1;
    visited[1]++;
    //for(int i=0;i<=n-1;i++)cout<<color[i]<<' ';cout<<endl;
    dfs(1,1);
    cout<<m<<endl;
    for(int i=0;i<n-1;i++)cout<<color[i]+1<<endl;
    
}

Measured memory_bytes: 7680
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
const int N=2e5+10;
struct point{
    int x,h;LL p;
}a[N];
bool cmp(point x,point y){
    return x.x<y.x;
}
int n,d,A;
LL ans;
int main(){
    scanf("%d%d%d",&n,&d,&A);
    d*=2;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].h);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        a[i].p+=a[i-1].p;
        a[i].h-=a[i].p*A;
        if(a[i].h<=0)continue;
        int times=(a[i].h+A-1)/A;
        a[i].p+=times;ans+=times;
        int L=i,R=n,p,now=a[i].x+d;
        while(L<=R){
            int mid=(L+R)>>1;
            if(a[mid].x<=now){
                p=mid;L=mid+1;
            }
            else R=mid-1;
        }
        a[p+1].p-=times;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a <= 5){
        printf("0\n");
    }else if(a <= 12){
        printf("%d\n", b/2);
    }else{
        printf("%d\n", b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define endl '\n'

int main() {
	int n;
	ll d;
	cin >> n >> d;
	d *= d;
	int ans = 0;
	while (n--) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    ll ans = 0;
    repe(i,2,(ll)sqrt(N) + 1){
        ll tmp = 0;
        while(N%i==0){
            N /= i;
            tmp++;
        }

        repe(i,1,50){
            if (tmp < i) break;
            tmp -= i;
            ans++;
        }
    }
    if (N > 1) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

double dp[3002];
double ar[3002];


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

    int n;
    cin >> n;

    for(int i=1;i<=n;i++)
    {
        cin >> ar[i];
    }

    dp[0] = 1.0;

    for(int i=1;i<=n;i++)
    {
        for(int j=i;j>=0;j--)
        {
            dp[j] = dp[j-1]*ar[i] + dp[j]*(1-ar[i]);
        }
    }

    double ans = 0.0;
    for(int i=0;i<=n;i++)
    {
        int j = n-i;
        if(i>j)
            ans+=dp[i];
    }

    cout << fixed << setprecision(10) << ans << endl;

    return 0;

}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n-1);
	for(auto &x:b) cin >> x;
	a[0] = b[0];
	a[1] = b[0];
	for(int i=1; i<n-1; ++i){
		a[i] = min(a[i], b[i]);
		a[i+1] = b[i];
	}
	int ans = 0;
	for(auto x:a) ans+=x;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll n;
    cin >>n;
    vector<ll>x(n);
    rep(i,n){
        cin>>x[i];
    }
    ll ans=10000000;
    ll sum=0;
    rep(i,101){
        sum=0;
        rep(l,n){
           sum+=pow(llabs((x[l]-i)),2); 
        }
       ans=min(ans,sum);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
static const int tx[] = {+0,+1,+0,-1};
static const int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-8;


map<vector<int>,int> dp;

int dfs(vector<int>& buns,int sum,int comb_i,vector<vector<int> >& all_combinations){
  if(comb_i >= all_combinations.size()) return sum;
  if(dp.find(buns) != dp.end()) return dp[buns];

  vector<int> prev = buns;
  bool isok = true;
  for(int weight = 1; weight <= 9; weight++){
    int use_count = all_combinations[comb_i][weight];
    buns[weight] -= use_count;
    if(buns[weight] < 0){
      isok = false;
      break;
    }
  }

  int res = 0;
  if(isok){
    res = max(sum + 1,dfs(buns,sum + 1,comb_i,all_combinations));
  }
  buns = prev;
  res = max(res,dfs(buns,sum,comb_i + 1,all_combinations));
  buns = prev;
  return (dp[buns] = max(res,dp[buns]));
}

void make_combinations(int weight,int sum,vector<int>& current,vector<vector<int> >& all_combinations){
  if(sum >= 10){
    if(sum == 10) all_combinations.push_back(current);
    return;
  }
  if(weight >= 10) return;

  for(int use_count = 0; use_count <= 10; use_count++){
    current[weight] = use_count;
    make_combinations(weight + 1,sum + weight * use_count,current,all_combinations);
    current[weight] = 0;
  }
}

int main(){
  int total_buns;
  
  vector<vector<int> > all_combinations;
  vector<int> current(11);
  make_combinations(1,0,current,all_combinations);

  while(~scanf("%d",&total_buns)){
    if(total_buns == 0) break;
    vector<int> buns(11);
    dp.clear();

    for(int i = 0; i < total_buns; i++){
      int weight;
      scanf("%d",&weight);
      buns[weight]++;
    }

    int greedy_sum = 0;
    for(int weight = 1; weight <= 5; weight++){
      if(weight == 5){
        int use_count = (buns[weight] / 2) * 2;
        greedy_sum += use_count / 2;
        buns[weight] -= use_count;
      }
      else{
        int use_count = min(buns[weight],buns[10 - weight]);
        greedy_sum += use_count;
        buns[weight] -= use_count;
        buns[10 - weight] -= use_count;
      }
    }

    printf("%d\n",greedy_sum + dfs(buns,0,0,all_combinations));
  }
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d;
  cin>>a;
  rep(i,a){
    cin>>b>>c>>d;
    b=b-c-d;
    if(b<0||b%2!=0){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}

lint dp[55][55][2600];//dp[a][b][c]...dp[a枚目までで][b枚使って][cにする]通り数

int main(void) {
	speed();
	int n, a; cin >> n >> a;
	vector<lint> d(n);
	for (int i = 0; i < 55; i++)for (int j = 0; j < 55; j++)for (int k = 0; k < 2600; k++) { dp[i][j][k] = 0; }
	dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int k = 0; k <= 54; k++) {
			for (int j = 0; j < 2600; j++) {
				dp[i][k][j] += dp[i - 1][k][j];
				if (!(j - d[i - 1] < 0)) {
					if (k != 0)
						dp[i][k][j] += dp[i - 1][k - 1][j - d[i - 1]];
				}
			}
		}
	}
	lint ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[n][i][i * a];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 65088
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  ll n;
  cin >> n;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  if(n % 2 == 0){
    ll sum = 0;
    ll a;
    a = n / 2;
    rep(i,a){
      sum += vec[i];
    }
    cout << sum * 2 - vec[0];
  }
  else{
    ll sum = 0;
    ll a;
    a = (n+1) / 2;
    rep(i,a){
      sum += vec[i];
    }
    cout << sum * 2 - vec[0] - vec[a-1];
  }
    
  return 0;
}



Measured memory_bytes: 4832
// https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_c
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod)
            x -= mod;
    }
    ModInt &operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0)
            x += mod;
        return *this;
    }
    ModInt &operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt &operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
    friend ostream &operator<<(ostream &s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream &operator>>(istream &s, ModInt<mod> &a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<(int)1e9 + 7>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    vector<bool> upd(n, false);
    REP(i, n) cin >> t[i];
    REP(i, n) cin >> a[i];
    if (t[n - 1] != a[0]) {
        cout << "0\n";
        return 0;
    }
    mint ans = 1;
    for (int i = 1; i < n - 1; i++) {
        if (t[i] == t[i - 1] && a[i] == a[i + 1]) {
            ans *= min(t[i], a[i]);
        } else if (t[i] > t[i - 1] && a[i] == a[i + 1] &&
                   a[i] < t[i]) { // h[i] == t[i]
            ans = 0;
        } else if (t[i] == t[i - 1] && a[i] > a[i + 1] &&
                   a[i] > t[i]) { // h[i] == a[i]
            ans = 0;
        } else if (t[i] > t[i - 1] && a[i] > a[i + 1] &&
                   a[i] != t[i]) { // h[i] == t[i] == a[i]
            ans = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int n; cin >> n;
    int d[100]; for (int i = 0; i < n; i++) cin >> d[i];

    int num[100] = {0};
    for (int i = 0; i < n; i++) num[d[i]]++;
    int count = 0;
    for (int i = 1; i <= 100; i++)
      if (num[i]) count++;
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Set<Integer> hash_set = new HashSet<Integer>();
    for (int i = 0; i < N; i++) {
       hash_set.add((Integer)sc.nextInt());
    }
    if(hash_set.size()  ==(Integer)N){
      System.out.print("YES");
    }else{
    System.out.print("NO");
    }
}  
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    int a = 700;
    for( int i = 0; i < 3; ++i ) {
        if( s[i] == 'o' ) a += 100;

    }
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *p;
  struct node *r;
  struct node *l;
  int key;
};
typedef struct node * Node;
Node root;
void insert(int v){
  Node y=NIL;
  Node x=root;
  Node c;
  c=malloc(sizeof(struct node));
  c->key=v;
  c->l=NIL;
  c->r=NIL;
  while(x!=NIL){
    y=x;
    if(c->key < x->key) x=x->l;
    else x=x->r;
  }
    c->p=y;
    if(y==NIL) root=c;
    else if(c->key < y->key) y->l=c;
    else y->r=c;
}
 
void inorder(Node w){
  if(w!=NIL){
    inorder(w->l);
    printf(" %d",w->key);
    inorder(w->r);
  }
}
void preorder(Node w){
  if(w!=NIL){
    printf(" %d",w->key);
    preorder(w->l);
    preorder(w->r);
  }
}
 
int main(){
  int i,k,a;
  char com[20];
 
  scanf("%d",&k);
 
  for(i=0;i<k;i++){
    scanf("%s",com);
 
  if(com[0]=='i'){
    scanf("%d",&a);
    insert(a);
  }
  else if(com[0]=='p'){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
  }
  }
  return 0;
}

Measured memory_bytes: 24040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int x;
	cin>>x;
	if(x)
		cout<<0;
	else
		cout<<1;
	return 0;
}

Measured memory_bytes: 3636
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }



ll N;
vector<ll> a;
int main() {

	cin >> N;

	a.resize(N);
	rep(i, N)
		cin >> a[i];


	ll sumkind = 0;

	sort(a.begin(), a.end());

	if (a[N - 1] > a[0] + 1) { cout << "No" << endl; return 0; }


	sumkind += a[N-1];


	if (a[0] != a[N - 1]) {
		ll index = 0;
		while (a[index] == a[0]) { sumkind--; index += 1; }

		if (sumkind <= 0 || (N - index) < 2 * (sumkind)) {
			cout << "No" << endl;
			
		}

		else {
			cout << "Yes" << endl;
			
		}

	}

	if (a[0] == a[N - 1]) {

		if (N == sumkind + 1 || N >= 2 * sumkind) {
			cout << "Yes" << endl;
			
		}
		else {
			cout << "No" << endl;
			
		}

	}

	

	return 0;
}


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

  int main(){
    int N;
    cin >> N;
    int l,r;
    int A=0;
    for (int i=0;i<N;i++){
      cin >> l >> r;
      A+=r-l+1;
    }
    cout << A << endl;
  }


Measured memory_bytes: 256
import math


def cosine_theorem(A: int, B: int, theta: float)->float:
    return math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(theta))


def clock_angle(hour: int, minute: int)->float:
    long_rad = (math.pi / 360) * (hour * 60 + minute)
    short_rad = (math.pi / 30) * minute
    diff_rad = abs(long_rad - short_rad)

    while diff_rad > 2*math.pi:
        diff_rad -= 2*math.pi

    return diff_rad


def colon(A: int, B: int, H: int, M: int)->float:
    theta = clock_angle(H, M)
    # print('theta =', theta)
    return cosine_theorem(A, B, theta)


if __name__ == "__main__":
    A, B, H, M = map(int, input().split())
    ans = colon(A, B, H, M)
    print(ans)


Measured memory_bytes: 9472
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;

const int inf=1e9,mod=1e9+7,N=2e5+5;

void solve(){
	int a,b,k;
	cin>>a>>b>>k;
	int r=k;
	set<int>s;
	for(int i=a;r && i<=b;r--,++i){
		s.insert(i);
	}
	for(int i=b;k && i>=a;k--,i--){
		s.insert(i);
	}
	for(auto i:s)cout<<i<<'\n';
}

int main(){
 	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3616
fn main() {
    proconio::input! {
        x: usize,
    }
    let ans = match x {
        400..=599 => 8,
        600..=799 => 7,
        800..=999 => 6,
        1000..=1199 => 5,
        1200..=1399 => 4,
        1400..=1599 => 3,
        1600..=1799 => 2,
        1800..=1999 => 1,
        _ => unreachable!(),
    };
    println!("{}", ans);
}


Measured memory_bytes: 2072
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void)            
            {


int n,d,res=0;
scanf("%d%d",&n,&d);

long int x[n],y[n] ;
 double z = 0;
for (int i = 0; i <n; i++)
 {

scanf("%li%li",&x[i],&y[i]);

 }    
for (int i1 = 0; i1 < n; i1++)
   {
z= sqrt( (x[i1]*x[i1]) + (y[i1]*y[i1]) );


if ( z <= d)
    {

res++;

    }  



   }



printf("%d",res);


return 0;



            }

Measured memory_bytes: 5224
#include <stdio.h>
	int main(void){
		int i,n,min=1000000,max=-1000000,a;
		double sum=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&a);
			if(a<min){
				min=a;
			}
			if(max<a){
				max=a;
			}
			sum+=a;
		}
		printf("%d %d %.0lf\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<ll> a(n); rep(i,n) cin >> a[i];

    map<ll,ll> mp;

    rep(i,n){
        a[i] -= i;
        mp[a[i]]++;
    }

    ll ans = 0;
    rep(i,n){
        ans += mp[- a[i] - i*2];
    }
    
    cout << ans << endl;

}
    

Measured memory_bytes: 27336
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
	while(1){
		ll m,n; cin >> m >> n;
		if(n+m == 0) break;
		vl c(m),x(n);
		rep(i,n) cin >> x[i];
		rep(i,m) cin >> c[i];
		vvl dp(m+1,vl(300,linf));
		dp[0][128] = 0;
		rep(i,m){
			rep(j,256){
				if(dp[i][j] == linf) continue;
				rep(k,n){
					ll nxt = min(255LL, max(0LL, j+x[k]));
					chmin(dp[i+1][nxt], dp[i][j] + (nxt-c[i]) * (nxt-c[i]));
				}
			}
		}
		ll ans = linf;
		rep(i,256) chmin(ans, dp[m][i]);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 50608
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int mo=998244353;
const int N=405;
int n,a[N],b[N];
int fac[N],inv[N],pa[N];
int S1,S2,ans,tr[N];
int f[N][N][N];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
void init(){
	fac[0]=1;
	For(i,1,N-1) fac[i]=1ll*fac[i-1]*i%mo;
	For(i,0,N-1) inv[i]=power(fac[i],mo-2);
}
int main(){
	scanf("%d",&n);
	init();
	For(i,1,n) scanf("%d%d",&a[i],&b[i]);
	S1=S2=0;
	f[0][0][0]=mo-1;
	For(i,1,n){
		For(j,0,S1) For(k,0,S2)
			f[i][j][k]=f[i-1][j][k];
		tr[0]=1;
		For(j,1,b[i]-1) tr[j]=1ll*tr[j-1]*a[i]%mo;
		For(j,0,b[i]-1) tr[j]=1ll*tr[j]*inv[j]%mo;
		For(j,0,S1) For(k,0,S2) For(v,0,b[i]-1)
			f[i][j+v][k+a[i]]=(f[i][j+v][k+a[i]]+mo-1ll*f[i-1][j][k]*tr[v]%mo)%mo;		
		S1+=b[i]-1; S2+=a[i];
	}
	int ans=0;
	For(i,0,S1) For(j,1,S2){
		int val=1ll*f[n][i][j]*fac[i]%mo;
		val=1ll*val*power(j,mo-1-i)%mo;
		ans=(ans+1ll*val*S2%mo*power(j,mo-2))%mo;
	}
	printf("%d\n",ans);
}
/*
For(S \in T) -1^(|S|-1)
	For(x[i] in S)
		
*/

Measured memory_bytes: 256256
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int s;
    double w,h;
    char c;
    while(cin>>s>>c>>w>>c>>h){
        if(25.0<=w/(h*h))cout<<s<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

int main (){
	string s;
	cin >> s;
	ll cnt=0,len;
	rep (i,s.size()){
		if (s[i]=='A'){
			len = i;
			break;
		}
	}
	ll ans,max1 = -1;
	for (ll i = len;i < s.size();i++){
		cnt++;
		if (s[i]=='Z'){
			max1 = max(max1,cnt);
		}

	}
	cout << max1 << endl;
}




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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &v: a) cin >> v;
    int h = -1, an = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= h) an++;
        h = max(h, a[i]);
    }
    cout << an << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

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

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

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

int main() {
	int n;
	string s;
	set<string> st;
	cin >> n;

	REP(i,n) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
	
}



Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    string s;
    cin>>s;
    if(n>=3200)
    {
        cout<<s<<endl;
    }else
    {
        cout<<"red"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
p = a+b
q = c*2
if p <= q :
    ans = a*x+b*y
else :
    ans = min(x,y)*q
    if x < y :
        ans += (y-x)*min(b,q)
    else :
        ans += (x-y)*min(a,p)
print(ans)


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


bool fun(int x, unordered_map<int, int> &m){
    
    if(x%2==0){
       if(m[2]==0){
            m[2] = 1;
            while(x%2==0){
                x = x/2;
            }
        }else{
            return false;
        }
        
    }
    
    for(int i = 3;i<=sqrt(x);i+=2){
        if(x%i==0){
            if(m[i]==0){
                m[i] = 1;
                
                while(x%i==0){
                    x = x/i;
                }


            }else{
                return false;
            }

        }
    }
    
    if(x > 2){
        if(m[x] == 0){
            m[x] = 1;
        }else{
            return false;
        }
    }
    return true;
}

int main(){
        
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        int n;
        cin>>n;
        unordered_map<int, int> m;
        int arr[n];
        bool res = true;
        for(int i = 0;i<n;i++){
            cin>>arr[i];
        }

        for(int i = 0;i<n;i++){
            if(!fun(arr[i], m))
            {
                res = false;
                break;
            }    
        }

        if(res){
            cout<<"pairwise coprime";
            return 0;
        }else{
            int g = arr[0];
            for(int i = 1;i<n;i++){
                
                g = __gcd(g, arr[i]);
            }

                if( g == 1 ){
                    cout<<"setwise coprime";
                    return 0;
                }
        }
        cout<<"not coprime";

        return 0;
}

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

int main() 
{
   vector<int> X(5);
   for (int i = 0; i < 5; i++)
      cin >> X.at(i);

   vector<int> Y(5, 0);
   for (int i = 0; i < 5; i++)
   {
      for (int j = 0; j < 5; j++)
      {
         if (i == j)
            Y.at(i) += X.at(j);
         else
         {
            if (X.at(j) % 10 == 0)
               Y.at(i) += X.at(j);
            else
               Y.at(i) += (X.at(j) / 10 + 1) * 10;
         }
      }
   }
   cout << min(min(min(min(Y.at(0), Y.at(1)), Y.at(2)), Y.at(3)), Y.at(4)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    vint cnt(K);
    for(int i=1;i<=N;i++) cnt[i%K]++;

    int ans=0;
    for(int a=0;a<K;a++){
        int b=(K-a)%K;
        int c=(K-a)%K;
        if((b+c)%K==0) ans+=cnt[a]*cnt[b]*cnt[c];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
'''
選択ソート
'''

n = int(input())
a = list(map(int,input().split()))

cnt = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if a[j] < a[minj]:
            minj = j
    if a[i] != a[minj]:
        cnt += 1
    tmp = a[i]
    a[i] = a[minj]
    a[minj] = tmp

print(' '.join(map(str,a)))
print(cnt)



Measured memory_bytes: 5604
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
[トポロジカルソート]
⇒入次数0の頂点からスタートし、その番号を1とする.
　1から出ている有向辺をすべて削除
  入次数0になった頂点の番号を2とし、2から出ている有向辺をすべて削除
  入次数0になった頂点の番号を3とし、...を繰り返す

常に入次数が0になった頂点を選択してその1つ前を親とするため、
出来上がったグラフの各頂点の親は、そのグラフで最も近い親(距離1)
つまり、後から足されたM本の辺ではない
よって、トポロジカルソートによって得られるグラフが元の木である.
"""
n,m = LI()

edges = [[] for _ in range(n)]
cnt = [[0,i] for i in range(n)]
for _ in range(n-1+m):
    a,b = LI()
    edges[a-1].append(b-1)
    cnt[b-1][0] += 1


ans = [None]*n
que = deque()
for i in range(n):
    if cnt[i][0] == 0:
        que.append(cnt[i][1])
        ans[cnt[i][1]] = 0
        while que:
            v = que.popleft()
            for i in edges[v]:
                cnt[i][0] -= 1
                if cnt[i][0] == 0:
                    que.append(i)
                    ans[i] = v+1
        break
for i in ans:
    print(i)


Measured memory_bytes: 70832
#include <bits/stdc++.h>
#define debug(x) std::cerr<<"L: "<<__LINE__<<" f("<<__FUNCTION__<<") Var: "<<#x<<" Val: "<<x<<"\n";
typedef long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() { debug(clock()); }
inline int read() {static char c; static int x; int flag = 1; while (c = getchar(), !isdigit(c)) if (c == '-') flag = -1; x = c - '0'; while (c = getchar(), isdigit(c))x = (x << 1) + (x << 3) + c - '0'; return x * flag;}
inline char achar() {static char c; while (c = getchar(), !isalpha(c)); return c;}

struct horo {
	int v, id;
	friend bool operator<(const horo&lhs, const horo&rhs) {return lhs.v < rhs.v;};
} ns[(1 << 19)];
std::map<int, int> hash;
int n, first[(1 << 19)], second[(1 << 19)];

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif

	n = (1 << read());
	for (int i = 0; i < n; ++i) {
		ns[i].id = i;
		ns[i].v = read();
	}
	std::sort(ns, ns + n);
	for (int i = 0; i < n; ++i)
		first[ns[i].id] = i;
	memset(second, -1, sizeof second);
	for (int i = 0; i < n; ++i) {
		for (int k = 0; k < 20; ++k)
			if (i & (1 << k)) {
				int sub = (i & ~(1 << k));
				if (first[sub] == first[i] && second[sub] == second[i]) continue;
				if (first[sub] <= second[i]) continue;
				sub = first[sub] == first[i] ? second[sub] : first[sub];
				if (sub > first[i])
					second[i] = first[i], first[i] = sub;
				else if (sub > second[i])
					second[i] = sub;
				// assert(first[i] > second[i]);
			}
	}
	int ans = 0;
	for (int i = 1; i < n; ++i)
		printf("%d\n", ans = std::max(ans, ns[first[i]].v + ns[second[i]].v));
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region macro
using vi=vector<int>;
using vs=vector<string>;
using ii=pair<int,int>;
#define INF (1<<64)-1
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#pragma endregion
// variables
int n,k,c;string s;
vector<ii> l,r;
vi ans;
void solve(){
  // write code here
  cin>>n>>k>>c;
  cin>>s;
  l.resize(n);
  r.resize(n);
  int idx=-c-1,cnt=0;
  for(int i=0;i<n;++i){
    if(s[i]=='o'&&i>idx+c){
      cnt++;
      idx=i;
    }
    l[i]=mp(cnt,idx);
  }
  idx=n+c,cnt=0;
  for(int i=n-1;i>=0;--i){
    if(s[i]=='o'&&i<idx-c){
      cnt++;
      idx=i;
    }
    r[i]=mp(cnt,idx);
  }
  for(int i=0;i<n;++i){
    //judge if the condition would be met when s[i] was 'x'
    if(s[i]=='o'){
      int days=0;
      if(i>0)days+=l[i-1].fi;
      if(i<n-1)days+=r[i+1].fi;
      if(i>0&&i<n-1){
        if(r[i+1].se-l[i-1].se<=c)days--;
      }
      if(days<k)ans.pb(i+1);
    }
  }
  for(int v:ans)cout<<v<<'\n';
}
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}

Measured memory_bytes: 9608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  int res=0;
  while(true) {
    bool exist_odd=false;
    rep(i,n) {
      if(a[i]%2!=0) exist_odd=true;
    }
    if(exist_odd) break;
    rep(i,n) a[i]/=2;
    ++res;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;
const li inf = 1e15;

li solve(vector<li>& xs, li n, li m) {
    vector<vector<li>> dp(n + 1, vector<li>(m + 1, -inf));
    dp[0][0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= m; ++j) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + 1 <= m) {
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + xs[i]);
            }
        }
    }
    return dp[n][m];
}

int main() {
    li n, m;
    cin >> n >> m;
    vector<li> xs(n), ys(n), zs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> ys[i] >> zs[i];
    }

    li ans = -inf;

    for (int mask = 0; mask < 8; ++mask) {
        vector<li> relax;
        for (int i = 0; i < n; ++i) {
            li xsig = (mask & (1 << 0)) ? 1 : -1;
            li ysig = (mask & (1 << 1)) ? 1 : -1;
            li zsig = (mask & (1 << 2)) ? 1 : -1;
            li v = xs[i] * xsig + ys[i] * ysig + zs[i] * zsig;
            relax.push_back(v);
        }
        ans = max(ans, solve(relax, n, m));
    }

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


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() % 10;
        String ans = "hon";
        if(n==3) {
            ans = "bon";
        }
        else if(n==0 || n==1 || n==6 || n==8) {
            ans = "pon";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=8000005,INF=1<<29;

bool is_prime[MAX+1];

void sieve(int n,int cnt){
    int p=0;
    for(int i=0;i<n;i++) is_prime[i]=false;
    for(int i=n;i<MAX;i++) is_prime[i]=true;
    
    for(int i=n;p<cnt;i++){
        if(is_prime[i]){
            p++;
            is_prime[i]=false;
            for(int j=2*i;j<MAX;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int M,N;cin>>M>>N;
        if(M+N==0) break;
        sieve(M,N);
        
        for(int i=M;;i++){
            if(is_prime[i]){
                cout<<i<<endl;
                break;
            }
        }
    }
    
}



Measured memory_bytes: 10928
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pl;
#define pi pair<int,int>
#define MM 1000000000
#define MOD MM+7
#define initial_value -1
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,-1,0,1,1,1,-1,-1};
struct edge{ll to,cost;};
int H,W,D,a,Q,L,R;
int ans = 0;
int px[90009],py[90009],dist[90009];
int main(){
    cin >> H >> W >> D;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a;
            px[a] = i;
            py[a] = j;
        }
    }
    for(int i = D+1; i <= H*W; i++){
        dist[i] = dist[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D]);
    }
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> L >> R;
        cout << dist[R]-dist[L] << endl;
    }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define show(a) for(auto el:a)cout<<el<<" "
#define ff first
#define ss second
#define pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
      ll n,i,j,k,x,y,z;
      ll c=0;
      cin>>n;
      ll a[n];
      fr(i,0,n)
      cin>>a[i];
      if(n<3)
      {
         c=0;
      }
      else
      for(i=0;i<n-2;i++)
      {
          for(j=i+1;j<n-1;j++)
          {
              for(k=j+1;k<n;k++)
              {
                  x=a[i];
                  y=a[j];
                  z=a[k];
                  if(x!=y && y!=z && z!=x)
                  {
                      if(x+y>z)
                      {
                          if(y+z>x)
                          {
                              if(z+x>y)
                              {
                                  c++;
                              }
                          }
                      }
                  }
              }
          }
      }
      cout<<c<<"\n";
        
        

    
     return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    int main(){
        long long int a;
        cin>>a;
        for(int i=1;;i++){
            if(i*i>a){
            cout<<(i-1)*(i-1)<<endl;
            return 0;
            }
        }
    }


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 最大値 */
	private static final int MAX = 100_000;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] count = new int[MAX];
			count[0] = 0;
			IntStream.range(1, MAX).forEach(i -> count[i] = count[i - 1] + (isPalindromic(i) ? 1 : 0));
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			System.out.println(count[b] - count[a - 1]);
		}
	}

	/**
	 * 入力数字の10進数表現は回文かどうかを計算
	 * 
	 * @param n 入力数字
	 * @return 入力数字の10進数表現は回文かどうか
	 */
	private static boolean isPalindromic(int n) {
		char[] s = String.valueOf(n).toCharArray();
		for (int i = 0; i < s.length / 2; i++) {
			if (s[i] != s[s.length - 1 - i]) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 35448
h, w = gets.split.map(&:to_i)
a = []
h.times do |i|
  s = gets.chomp
  a.push(s) if s.count('.') != w
end
(w - 1).downto(0) do |i|
  f = true
  a.each do |x|
    f = false if x[i] != '.'
  end
  if f
    a.each do |x|
      x[i] = ''
    end
  end
end
puts a

Measured memory_bytes: 1788