akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long min = (long) 1e18;
		long maxdiff = - (long) 1e18;
		int cnt = 0;
		for(int i=0;i<N;i++){
			min = Math.Min(A[i], min);
			if(A[i] - min >= maxdiff){
				if(A[i] - min > maxdiff){
					maxdiff = A[i] - min;
					cnt = 1;
				} else {
					cnt++;
				}
			}
		}
		
		Console.WriteLine(cnt);
		
		
	}
	int N;
	long T;
	long[] A;
	public Sol(){
		var d = ria();
		N = d[0]; T = d[1];
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 20832
import math

k = int(input())
ans = 0

for i in range(1, k+1):
    for j in range(i, k+1):
        g_2 = math.gcd(i, j)
        for k in range(j, k+1):
            g_3 = math.gcd(g_2, k)
            if i==j and j==k:
                ans += g_3
            elif i==j or j==k or k==i:
                ans += g_3 * 3
            else:
                ans += g_3 * 6

print(ans)

Measured memory_bytes: 9176
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        for(int i = 1; i < 6; i++) {
            int a = sc.nextInt();
            if (a == 0) {
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 35584
N, M = map(int, input().split())
H = list(map(int, input().split()))

r = [1] * len(H)
a = []
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] >= H[B - 1]:
        r[B - 1] = 0
    if H[B - 1] >= H[A - 1]:
        r[A - 1] = 0

print(r.count(1))


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

int main(){
    ll n,A,B;
    cin>>n>>A>>B;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll l=0,r=1e9+1;
    while(r-l>1){
        ll mid=(l+r)/2,cnt=0;
        rep(i,n){
            ll x=max(0LL,a[i]-mid*B);
            ll plus=x/(A-B);
            if(x%(A-B)!=0)plus++;
            cnt+=plus;
        }
        if(cnt>mid)l=mid;
        else r=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 4048
// ALDS_1_3_B.cpp
// Queue

#include <iostream>
#include <queue>
using namespace std;

int main()
{
    int n;
    int q;
    queue<string> names;
    queue<int> times;
    int time_sum = 0;
    cin >> n >> q;
    int time;
    string name;
    while (n--) {
        cin >> name >> time;
        names.push(name);
        times.push(time);
    }
    while (!times.empty()) {
        time = times.front();
        times.pop();
        name = names.front();
        names.pop();
        if (time > q) {
            times.push(time - q);
            names.push(name);
            time_sum += q;
        }
        else {
            time_sum += time;
            cout << name << " " << time_sum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5768
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, i, *a;
	cin >> n;
	a = new int[n];
	for (i = 0; i < n; i++) cin >> a[i];
	 
	int q, o;
	cin >> q;
	while (q--)
	{
		cin >> o;
		cout << lower_bound(a, a + n, o) - a << endl;
	}
	return 0;
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w,A;
    cin >> h >> w;
    int64_t c[10][10], csum = 0;

    for (size_t i = 0; i < 10; i++)
    {
        for (size_t j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }

    for (size_t k = 0; k < 10; k++)
    {
        for (size_t j = 0; j < 10; j++)
        {
            for (size_t i = 0; i < 10; i++)
            {
                c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
            }
            
        }
        
    }
    
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cin >> A;
            if(A >= 0){
            csum += c[A][1];
            }
        }
    }
    cout << csum << endl;

    
}

Measured memory_bytes: 256
# _*_ coding:utf-8 _*_
#  AtcoderBeginnersContest085-A
#  https://beta.atcoder.jp/contests/abc085/tasks/abc085_a

def change2018(s):
	replaceStr=s.replace("2017","2018")
	return replaceStr


if __name__ == '__main__':
	problemStr=input()
	answerStr=change2018(problemStr)
	print(answerStr)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
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(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  string S; cin >> S;
  int a = 0, b = 0;
  REP(i, N){
    if(S[i] == ')'){
      if(b == 0){
        a++;
      }else{
        b--;
      }
    }else{
      b++;
    }
  }
  REP(i, a){
    S = "(" + S;
  }
  REP(i, b){
    S = S + ")";
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n;
map<P,ll> dp;

bool func(string x){
	for (int i = 0; i < x.size(); i++){
		string y = x;
		if(i>0){
			char tmp = y[i];
			y[i] = y[i-1];
			y[i-1] = tmp;
		}
		if(y.find("AGC")!=string::npos) return false;
	}
	return true;
}

ll dfs(P p){
	if(dp.count(p)>0) return dp[p];
	if(p.first==n) return 1;

	ll res = 0;
	string t = "AGCT";
	for (int j = 0; j < 4; j++){
		string x = p.second+t[j];
		if(func(x)){
			string y = p.second.substr(1,2) + t[j];
			res += dfs(P(p.first+1,y));
			res %= mod;
		}
	}
	dp[p] = res;
	return res;
}

int main()
{
	cin>>n;
	cout<<dfs(P(0,"TTT"))<<endl;
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

        int ans = 0;
        if ((n-1) % (k-1) == 0) {
            ans = (n-1) / (k-1);
        } else {
            ans = (n-1) / (k-1) + 1;
        }

        System.out.println(ans);
    }
}


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

using ll = long long;
const ll inf = 1e18 + 5;

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


	int n, W;
	cin >> n >> W;
 	vector<ll> weight(n), value(n);
 	for (int i = 0; i < n; i++)
 		cin >> weight[i] >> value[i];

 	int sum_value = 0;
 	for (auto x : value) 
 		sum_value += x;
 	// dp[i] - munimum total weight of items with total value exaclyt i
 	vector<ll> dp(sum_value + 1, inf);
 	dp[0] = 0;

 	for (int i = 0; i < n; i++) {

 		for (int cur_value = sum_value - value[i]; cur_value >= 0; cur_value--){
 			dp[cur_value + value[i]] = min(dp[cur_value + value[i]], dp[cur_value] + weight[i]);
 		}
 	}

 	ll ans = 0;
 	for (int i = 0; i <= sum_value; i++)
 		if (dp[i] <= W)
 			ans = max(ans, (ll)i);

 	cout << ans << endl;
}

Measured memory_bytes: 1024
a,b,c = map(int, input().split())
k = int(input())
 
i = 0
while a >= b:
  b = b * 2
  i += 1

j = 0
while b >= c:
  c = c * 2
  j += 1
  
if i + j <= k:
  print('Yes')
else:
  print('No')

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

ll n,arr[100005],dp[100005];

int main()
{
    cin>>n;
    for(ll i=0;i<n;i++) cin>>arr[i];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>
#include <unordered_map>
typedef long long LL;

int main()
{
    LL x, y;
    std::cin >> x >> y;

    bool ans = false;

     if(4 *x >= y && y >= 2 *x && y % 2 == 0)
    {
        ans = true;
    }

    if(ans)
    {
        std::cout << "Yes";
    }else {
        std::cout << "No";
    }

    return EXIT_SUCCESS;
}


Measured memory_bytes: 3164
#include<stdio.h>
int main() {
	int i,j;
	int n;
	int s[100005];
	int s2[100005];
	int result = 0;
	scanf("%d", &n);
	for (i = 0; i <= 100002; i++) {
		s[i] = 0;
		s2[i] = 0;
	}
	for (i = 0; i < n; i++) {
		scanf("%d",&s[i]);
	}

	for (i = 0; i < n; i++) {
		if (s[i] <= 100000) {
			s2[s[i]]++;
		}
		else {
			s2[100001]++;
		}
	}

	for (i = 1; i < 100001; i++) {
		if (s2[i] > i) {
			result = result + s2[i]-i;
		}
		else if (s2[i] < i) {
			result = result + s2[i];
		}
	}
	result = result + s2[100001];
	printf("%d",result);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int a[100000];
int ct[20]={};
int s[20][100001]={};

int dp[1<<20];

int main()
{
    int n,m;
    cin >>n >>m;
    rep(i,n)
    {
        cin >>a[i];
        --a[i];
        ++ct[a[i]];
    }

    rep(i,m)rep(j,n) s[i][j+1] = s[i][j]+(a[j]==i);
    
    fill(dp,dp+(1<<20),n);
    dp[0]=0;
    rep(i,1<<m)
    {
        int st=0;
        rep(j,m)if(i>>j&1) st+=ct[j];

        rep(j,m)if(!(i>>j&1))
        {
            int num = s[j][st+ct[j]] - s[j][st];
            int nx = i|(1<<j);
            dp[nx] = min(dp[nx],dp[i]+(ct[j]-num));
        }
    }

    cout << dp[(1<<m)-1] << endl;
    return 0;
}

Measured memory_bytes: 15368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 59; //MAX 9223372036854775807
ll ans = INF;

int main()
{
ll n, c;
cin >> n >> c;
ll d[c][c] = {};
rep(i, c) rep(j, c)
{
    cin >> d[i][j];
}
vector<ll> v[3];
rep(i, n) rep(j, n)
{
    ll a;
    cin >> a;
    v[(i + j + 2) % 3].push_back(a);
}

vector<vector<ll>> chh(3, vector<ll>(c,0) );
rep(i, 3) rep(j, c)
{
    rep(k, v[i].size())
    {
        chh[i][j] += d[v[i][k]-1][j];
    }
}
rep(i, c) rep(j, c) rep(k, c)
{
    if (i == j || j == k || k == i)
        continue;
    ans = min(ans, chh[0][i] + chh[1][j] + chh[2][k]);
}

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


Measured memory_bytes: 2608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];
		for(int i = 0 ; i < 3 ; i++) {
			for(int j = 0 ; j < 3 ; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int[] x = new int[3];
		int[] y = new int[3];
		x[0] = 0;
		for(int i = 0 ; i < 3 ; i++) y[i] = a[0][i];
		x[1] = a[1][0] - y[0];
		x[2] = a[2][0] - y[0];
		for(int i = 0 ; i < 3 ; i++) {
			for(int j = 0 ; j < 3 ; j++) {
				if(a[i][j] != x[i] + y[j]) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;
int a, b, c, d, x;

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

	if (n%2) {
		cout << n * 2 << endl;
	}
	else {
		cout << n << endl;
	}

	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  int a, b, l;
  string s;

  cin >> a >> b;
  if(b%a == 0) cout << a+b << endl;
  else cout << b-a << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string S){
    int n=S.size();
    VVi dp(2,Vi(n,0));
    dp[0][0]=1;
    dp[1][1]=1;
    REP(i,1,n){
        if(S[i-1]!=S[i]) dp[0][i]=dp[0][i-1]+1;
        chmax(dp[0][i],dp[1][i-1]+1);
        if(i>1){
            dp[1][i]=dp[0][i-2]+1;
        }
    }
    cout<<max(dp[0][n-1],dp[1][n-1])<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 5252
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
const int N = 1000 + 5;
int a[N];
int b[N];
int vis[29];
int main()
{
   int n;
   string s;
   while(cin >> n)
   {
       cin >> s;
       int ans = 0;
       for(int  i = 1; i <= n-2; i++)
       {
           int now = 0;
           memset(vis,0,sizeof(vis));
           for(int j = 0; j <= i; j++)
           {
               int c = s[j] - 'a';
               if(vis[c]) continue;
               else vis[c] = 1;
               for(int k = i+1; k < n; k++)
               {
                   if(s[j] == s[k])
                   {
                       now += 1;
                       break;
                   }
               }
           }
           ans = max(ans,now);
       }
       printf("%d\n",ans);
   }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {

	public void watch() {

		Scanner sc = new Scanner(System.in);

		int S = sc.nextInt();

		int h = S / 60 / 60;

		int m = (S - h * 60 * 60) / 60;

		int s = S - (h * 60 * 60 + m * 60);

		System.out.println(h + ":" + m + ":" + s);

	}

	public static void main(String[] args) {

		new Main().watch();

	}

}

Measured memory_bytes: 26312
#include<stdio.h>
 int main(void){
     int m,f,r;
     while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1){
            break;
        }
        if(m==-1||f==-1){
            printf("F\n");
        }
        else if(80<=m+f){
            printf("A\n");
        }
        else if(65<=m+f&&m+f<80){
            printf("B\n");
        }
        else if(50<=m+f&&m+f<65){
            printf("C\n");
        }
        else if(30<=m+f&&m+f<50&&50<=r){
            printf("C\n");
        }
        else if(30<=m+f&&m+f<50){
            printf("D\n");
        }
        else{
        printf("F\n");
        }
     }
    return 0;
 }

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x7fffffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define ff first
#define ss second
#define EPS 1e-8
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
const int MOD=100000007;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string>) { cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
/////////////////// FUNCTIONS ////////////////////////////////////
template<class T>
T maxx(T a, T b) {return a>b?a:b;}
template<typename T, typename... Args>
T maxx(T a, T b, Args... args){return maxx(a>b?a:b, args...);}
ll mexp(ll x, ll n, ll m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
template<class T>
T minn(T a, T b) {return a<b?a:b;}
template<typename T, typename... Args>
T minn(T a, T b, Args... args){return minn(a>b?a:b, args...);}
bool ispow2(ll x){ return x && (!(x&(x-1))); }
ld pow(ld a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0);   cout<<fixed; cerr<<fixed;
  cout<<setprecision(8); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	int n; cin>>n;
	if(n%3==0) cout<<n/3<<'\n';
	else if(n%3==1) cout<<(n-1)/3<<'\n';
	else cout<<(n-2)/3<<'\n';

	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
  return 0;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using namespace atcoder;

using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep (i, n) {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    rep (i, q) {
        int t, a, b;
        cin >> t >> a >> b;
        if (t == 0) fw.add(a, b);
        else cout << fw.sum(a, b) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 8216
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( stdin.hasNextLine() ) {

	    final String input = stdin.nextLine();

	    final ArrayList<Integer> indicesOfJ = getIndicesOf( 'J', input );
	    int jCount = 0;
	    for ( int i : indicesOfJ ) {
		if ( input.startsWith( "JOI", i ) ){
		    jCount++;
		}			
	    }

	    final ArrayList<Integer> indicesOfI = getIndicesOf( 'I', input );
	    int iCount = 0;
	    for ( int i : indicesOfI ) {
		if ( input.startsWith( "IOI", i ) ) {
		    iCount++;
		}
	    }
	    System.out.println( jCount );
	    System.out.println( iCount );
	}	
    }

    public static ArrayList<Integer> getIndicesOf( char ch, String input ) {
	final ArrayList<Integer> indices = new ArrayList<Integer>();

	for ( int i = 0; i < input.length(); i++ ) {
	    if ( input.charAt( i ) == ch ) {
		indices.add( i );
	    }
	}
	
	return indices;
    }    
}

Measured memory_bytes: 18948
#include <cstdio>
#include <algorithm>

int main() {

	int a[6];
	int i;
	int ans = 0;

	for (i = 0; i < 4; ++i) scanf("%d",&a[i]);

	std::sort(a, a + 4);
	ans += a[3] + a[2] + a[1];

	scanf("%d%d", &a[4], &a[5]);
	a[4] >= a[5] ? ans += a[4] : ans += a[5];

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


Measured memory_bytes: 2744
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using T = ll;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;



int main(){
   int n, x, t;
   cin >> n >> x >> t;
   int res = (n + x - 1) / x * t;
   cout << res << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>

int A[101][101];

void chain(int n, int *x){
  int i, j, k, l;
  
  for(i=1; i<n+1; i++)
    A[i][i] = 0;
    
  for(i=2; i<n+1; i++){
    for(j=1; j<n-i+2; j++){
      l = i+j-1;
      A[j][l] = 100000000;
      for(k=j; k<l; k++){
        if(A[j][l] > A[j][k]+A[k+1][l]+x[j-1]*x[k]*x[l])
          A[j][l] = A[j][k]+A[k+1][l]+x[j-1]*x[k]*x[l];
      }
    }
  }
}

int main(){
  int i,n;
  int x[101];
  
  scanf("%d", &n);
  
  for(i=1; i<n+1; i++)
    scanf("%d%d", &x[i-1], &x[i]);
    
  chain(n, x);
  printf("%d\n", A[1][n]);
  
  return 0;
}

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

int main(){
  vector<int> a(3);
  for(int i=0;i<3;i++)
    cin >> a.at(i);
  sort(a.begin(),a.end());
  
  cout << a.at(2)*10+a.at(1)+a.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(a>=k)
    {
        cout<<k<<endl;
    }
    else{
        sum+=a;
        k=k-sum-b;
        if(k<=0)
            cout<<sum<<endl;
        else{
            for(int i=0;i<c;i++){
                sum=sum-1;
                k=k-1;
                if(k<=0)
                    break;
            }
            cout<<sum<<endl;
        }

    }
}

Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextLong();
    long M = sc.nextLong();
    
    long x = (M - N * 2) / 4;
    
    System.out.println(x > 0 ? (N + x) : (Math.min(N, M / 2)));
    
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21200
N, M = map(int, input().split())
Broken = set([])
for _ in range(M):
    broken = int(input())
    Broken.add(broken)

DP = [0] * (N+1)
DP[0] = 1

for i in range(1, N+1):
    if i in Broken:
        continue
    DP[i] = DP[i-1] + DP[i-2]
    DP[i] %= 10**9 + 7
print(DP[N])

Measured memory_bytes: 11884
n, a, b, c, d = map(int, input().split())
s = list(input())
ans = 0
A = c
B = d
cntS = [0 for i in range(len(s))]
if s[0] == "#":
    cntS[0] = 1
for i in range(len(s)):
    if s[i] == "#":
        cntS[i] = cntS[i - 1] + 1

cnt = 0
ans = "Yes"
for i in range(b - 1, B):
    if cntS[i] >= 2:
        ans = "No"
        break

for i in range(a - 1, A):
    if cntS[i] >= 2:
        ans = "No"
        break

if s[A - 1] == "#" or s[B - 1] == "#":
    ans = "No"

if A < a or B < b:
    ans = "No"

if a < b < B < A:
    key = 1
    if (s[b - 2] == "#" or s[b] == "#") and ans == "Yes":
        for i in range(b, B):
            if s[i - 1] == "." and s[i + 1] == "." and s[i] == ".":
                s[i] = "#"
                cntS[i] = 1
                key = 0
        if key:
            ans = "No"

    if ans == "Yes":
        for i in range(a - 1, A):
            if cntS[i] >= 2:
                ans = "No"

print(ans)

Measured memory_bytes: 61552
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

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

  sort(a.begin(), a.end(), [](int l, int r) { return l > r; });
  int ab[] = {0, 0};
  for (int i = 0; i < N; ++i) {
    ab[i & 1] += a[i];
  }

  cout << ab[0] - ab[1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int dif(vector<string> s,vector<string> t){
	int n = s.size();
	int res = 0;
	rep(i, n)
	{
		rep(j,n){
			if(s[i][j] != t[i][j])
				res++;
		}
	}
	return res;
}

vector<string> r(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[j][n - i - 1] = s[i][j];
		}
	}
	return temp;
}
vector<string> l(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[n-j-1][i] = s[i][j];
		}
	}
	return temp;
}

int main(){
	int n;
	cin >> n;
	vector<int> b(n+1,inf);
	rep(i, n - 1) cin >> b[i+1];
	int ans = 0;
	rep(i, n){
		ans += min(b[i], b[i + 1]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,k,a[N],b[N];
ll ans;

int main(){
    read2i(n,k);
    lp(i,1,n){
        read2i(a[i],b[i]);
        if(((a[i] ^ k) & k) == (a[i] ^ k)) ans += b[i];
    }

    int curr = 0;
    lpd(j,30,0) if((k>>j)&1){
        ll sum = 0;
        lp(i,1,n) if((((a[i]>>j<<j) ^ curr) & curr) == ((a[i]>>j<<j) ^ curr))
            sum += b[i];
        ans = max(ans, sum);
        curr += 1<<j;
    }
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var N, K, cond int
	fmt.Scan(&N, &K)
	if N%2 != 0 {
		cond = N/2 + 1
	} else {
		cond = N / 2
	}
	if cond >= K {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
import std.stdio;
import std.string;
import std.algorithm;

void main() {
  int n;
  readf(" %d", &n);
  int[] a = new int[n - 1];
  int[] b = new int[n - 1];
  int[][] g = new int[][n];
  foreach (i; 0..n-1) {
    readf(" %d %d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
    g[a[i]] ~= i;
    g[b[i]] ~= i;
  }
  int d = 0;
  foreach (i; 0..n) d = max(d, cast(int)g[i].length);
  int[] ans = new int[n - 1];
  void dfs(int u, int p, int c) {
    foreach (i; g[u]) {
      int v = u ^ a[i] ^ b[i];
      if (v == p) continue;
      ans[i] = c;
      c = (c + 1) % d;
      dfs(v, u, c);
    }
  }
  dfs(0, -1, 0);
  writeln(d);
  foreach (i; 0..n-1) {
    writeln(ans[i] + 1);
  }
}


Measured memory_bytes: 9852
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d,e,f,i,g[101],h=1200,j,clo1,clo2,ans,h1,h2,m1,m2,t,m,n,x=0,k,y=0,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s1,s2,s3,s4,s5,s6;
    cin>>h1>>m1>>h2>>m2>>k;
    clo1 = h1*60+m1;
    clo2 = h2*60+m2;
    ans = clo2-clo1-k;
    if(ans<=0){
        cout<<0;
    }
    else{
        cout<<ans;
    }
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

class Program
{
    static string S, T;

    public static void Main(string[] args)
    {
        S = Input.NextString();
        T = Input.NextString();

        var CountS = new List<int>[26];
        var CountT = new List<int>[26];

        foreach (var i in Enumerable.Range(0, 26))
        {
            CountS[i] = new List<int>();
            CountT[i] = new List<int>();
        }
        for (int i = 0; i < S.Length; i++)
        {
            CountS[S[i] - 'a'].Add(i);
            CountT[T[i] - 'a'].Add(i);
        }

        var comp = new Comp();

        Array.Sort(CountS, comp);
        Array.Sort(CountT, comp);

        for (int i = 0; i < 26; i++)
        {
            var f = AEquals(CountS[i], CountT[i]);
            if (!f)
            {
                Console.WriteLine("No");
                return;
            }

        }

        Console.WriteLine("Yes");
        return;
    }

    static bool AEquals(List<int> x, List<int> y)
    {
        if (x.Count != y.Count)
            return false;

        for (int i = 0; i < x.Count; i++)
        {
            if (x[i] != y[i])
                return false;
        }

        return true;
    }

    class Comp : IComparer<List<int>>
    {
        public int Compare(List<int> x, List<int> y)
        {
            int ix = 0;
            int iy = 0;

            while (true)
            {
                if (x.Count <= ix && y.Count <= iy)
                    return 0;
                if (x.Count <= ix)
                    return 1;
                if (y.Count <= iy)
                    return -1;

                var cx = x[ix++];
                var cy = y[iy++];
                if (cx != cy)
                    return cx - cy;
            }
        }
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 19680
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include<queue>
#include<map>
using namespace std;
int a[100005];
int b[100005];
int main(){
	int A,B,m;
	int mina=100005;
	int minb=100005;
	cin>>A>>B>>m;
	for(int i=1;i<=A;i++){
		scanf("%d",&a[i]);
		mina=min(mina,a[i]);
	}
	for(int i=1;i<=B;i++){
		scanf("%d",&b[i]);
		minb=min(minb,b[i]);
	}
	long long minn=mina+minb;
	for(int i=1;i<=m;i++){
		int ai,bi;
		int c;
		scanf("%d %d %d",&ai,&bi,&c);
		minn=min(minn,(long long)a[ai]+b[bi]-c);
	}
	cout<<minn<<endl;
	return 0;
} 

Measured memory_bytes: 1024
S = str(input())
T = str(input())


ans = len(T)
for i in range(0,len(S)-len(T)+1):
  
  count = 0

  for j in range(0,len(T)):
    
    if S[i+j] == T[j]:
      count = count + 1
    else:
      count = count
  
  tmp = len(T)-count
  
  if ans > tmp:
    ans = tmp
  else:
    ans = ans

print(ans)    

Measured memory_bytes: 9116
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

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

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

  ll m,k;
  std::cin>>m>>k;

  if(m==0){
    if(k==0)std::cout<<"0 0\n";
    else std::cout<<-1<<"\n";
    return 0;
  }

  if(m==1){
    if(k==0)std::cout<<"0 0 1 1\n";
    else std::cout<<-1<<"\n";
    return 0;
  }

  if(k>=(1ll<<m)){
    std::cout<<-1<<"\n";
    return 0;
  }

  for(ll i=(1ll<<m)-1;i>=0;i--)if(i!=k)std::cout<<i<<" ";
  std::cout<<k<<" ";
  rep(i,0,1ll<<m)if(i!=k)std::cout<<i<<" ";
  std::cout<<k<<"\n";

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	static int F => int.Parse(Str);
	static long FL => long.Parse(Str);
	static int[] G => Strs.Select(int.Parse).ToArray();
	static decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	static long[] GL => Strs.Select(long.Parse).ToArray();
	static string Str => ReadLine();
	static string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	static int N;
	void Solve()
	{
		var I = G;
		N = I[0];
		WriteLine(ToString(Calc(Get(), Get(), I[1] - 1)));
	}
	static int[] Get() => G.Select(i => i - 1).ToArray();
	static string ToString(int[] p) => string.Join(" ", p.Select(i => i + 1));
	static int[] Calc(int[] p, int[] q, int K)
	{
		if (K == 0) return p;
		if (K == 1) return q;
		if (K < 6) return Calc(q, Mult(q, Inv(p)), K - 1);
		int[] ip = Inv(p), iq = Inv(q), x = Mult(q, ip, iq, p), y = Mult(ip, q, p, iq);
		switch (K % 6)
		{
			case 0: return Mult(Pow(x, K / 6), q, p, iq, Pow(y, K / 6 - 1));
			case 1: return Mult(Pow(x, K / 6), q, Pow(y, K / 6));
			case 2: return Mult(Pow(x, K / 6), q, ip, Pow(y, K / 6));
			case 3: return Mult(Pow(x, K / 6), q, ip, iq, Pow(y, K / 6));
			case 4: return Mult(Pow(x, K / 6 + 1), iq, Pow(y, K / 6));
			default: return Mult(Pow(x, K / 6 + 1), p, iq, Pow(y, K / 6));
		}
	}
	static int[] Inv(int[] a)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[a[i]] = i;
		return c;
	}
	static int[] Mult(int[] a, int[] b)
	{
		var c = new int[N];
		for (var i = 0; i < N; i++) c[i] = a[b[i]];
		return c;
	}
	static int[] Mult(params int[][] a)
	{
		if (a.Length == 0) return MakeArray(N, i => i);
		var x = a[0];
		for (var i = 1; i < a.Length; i++) x = Mult(x, a[i]);
		return x;
	}
	static int[] Pow(int[] a, int b)
	{
		var p = MakeArray(N, i => i);
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = Mult(p, x);
			b >>= 1;
			x = Mult(x, x);
		}
		return p;
	}
}


Measured memory_bytes: 45484
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int  , int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back


vector<int> arr;
vector<vector<pii>> num;
int tpa[100005];
void upd(int ind , int val)
{   
    if(val == ind)return;
    if(val > ind)
    {
        if(val < num[ind][1].F || num[ind][1].F == -1)
        {
            num[ind][1].S = num[ind][1].F;
            num[ind][1].F = val;
        }
        else if(num[ind][1].S == -1 || val < num[ind][1].S)num[ind][1].S = val;
    }

    else
    {
        if(num[ind][0].F == -1 || num[ind][0].F < val)
        {
            num[ind][0].S = num[ind][0].F;
            num[ind][0].F = val;
        }
        else if(num[ind][0].S == -1 || val > num[ind][0].S)num[ind][0].S = val;
    }
}
void merge(int l , int r)
{   
    int mid = l + (r-l)/2;

    int left = l;int right = mid+1;

    while(left <= mid && right <=r+1)
    {
        while(right <= r && arr[right] < arr[left])right++;

        if(right <= r)upd(arr[left] , arr[right]);
        if(right +1 <=r)upd(arr[left] , arr[right+1]);
        if(right-1 >=mid+1)upd(arr[left] , arr[right-1]);
        if(right-2 >=mid+1)upd(arr[left] , arr[right-2]);
        if(right-3 >=mid+1)upd(arr[left] , arr[right-3]);
        left++;
    }

    
    int cnt = 0;
    left = l;right = mid+1;
    while(left <= mid && right <= r)
    {
        if(arr[left] <= arr[right])tpa[cnt++] = arr[left++];
        else tpa[cnt++] = arr[right++];
    }

    while(left <= mid)tpa[cnt++] = arr[left++];
    while(right <= r)tpa[cnt++] = arr[right++];

    for(int i = l;i <=r;i++)arr[i] = tpa[i-l];
}

void msort(int l , int r)
{
    if(l >= r)return;
    int mid = l + (r-l)/2;
    msort(l , mid);
    msort(mid+1 , r);
    merge(l , r);
}
int main()
{   
    fastio;
    
    int n ;cin>>n;
    vector<int> org(n);
    arr.resize(n);
    num.resize(n , vector<pii>(2 , mpi(-1 , -1)));
    for(int i = 0 ;i<n;i++)
    {
        int u;cin>>u;
        org[i] = u;
        arr[u-1] = i;
    }

    msort(0 , n-1);
    ll ans = 0;

    // for(int i = 0 ; i<n;i++)
    // {
    //     cout<<arr[i]<<" ";
    // }
    // cout<<endl;
    for(int i = 0 ;i <n;i++)
    {  
        pii p1 = num[i][0];
        pii p2 = num[i][1];

        // cout<<p1.F<<" "<<p1.S<<endl;
        // cout<<p2.F<<" "<<p2.S<<endl;

        if(p2.F != -1)
        {
            int rs = n-p2.F;
            if(p2.S != -1)rs = p2.S - p2.F;
            
            int ls = i+1;
            if(p1.F != -1)ls = i-p1.F;

            // cout<<org[i]<<" "<<ls<<" "<<rs<<"\n";
            ans += (ll)(org[i])*ls*rs;
        }

        if(p1.F != -1)
        {
            int rs = n-i;
            if(p2.F != -1)rs = p2.F - i;
            int ls = p1.F+1;
            if(p1.S != -1)ls = p1.F - p1.S;

            ans += (ll)(org[i])*ls*rs;
            // cout<<org[i]<<" "<<ls<<" "<<rs<<"\n";
        }
    }

    cout<<ans<<endl; 
    

return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
int main (void){
long int N = 0;
long int a,b;
long int c=0;
long int d =0;
int br[200100];
scanf("%d",&N);

for(a=1;a<N+1;a++){
scanf("%d",&b);
br[a] = b;
}
for(long int e=1;e<N+1;e++){

if(br[e] == e-c){
    d++;

}else if(br[e] != e-c){
    c++;
}
}
  
if(N<=c){
    printf("-1");
}else if(N>c){
    printf("%d",c);

}
return 0;
}


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

int main(){

    long long int n,Y;
    cin >> n >> Y;
    //cout << Y << endl;

    for(int x =0;x <= n;x++){
        for(int y = 0;y <= n;y++){

            int z = n-x-y;
            //cout << z << endl;
            if(z < 0){
                
            }else{
                long long int sum = 10000*x+5000*y+1000*z;
                //cout << z << " " << sum <<endl;
                if(sum == Y){
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>

int main()
{
    int a[3];

    scanf("%d%d%d",&a[0],&a[1],&a[2]);

    std::sort(a,a+3);

    if((a[0]==a[1] && a[1]!=a[2]) || (a[0]!=a[1] && a[1]==a[2]))
        printf("Yes");
    else
        printf("No");

    return 0;
}


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

int main(){
  int n; cin>>n;
  vector<vector<int>> tree(n);
  vector<pair<int,int>> vp;
  for(int i=0;i<n-1;i++){
    int a,b; cin>>a>>b; 
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
    vp.emplace_back(a,b);
  }
  int k=0;
  vector<bool> vis(n,false);
  vector<int> log(n,-1);
  map<pair<int,int>,int> I;
  queue<int> que;
  que.push(0);
  vis[0]=true;
  while(!que.empty()){
    int x=que.front(); que.pop();
    if(k<tree[x].size()) k=tree[x].size();
    int cur=1;
    for(auto &v:tree[x]){
      if(vis[v]) continue;
      vis[v]=true;
      que.push(v);
      if(log[x]==cur) cur++;
      log[v]=I[make_pair(x,v)]=I[make_pair(v,x)]=cur;
      cur++;
    }
  }cout<<k<<endl;
  for(auto v:vp){
    cout<<I[v]<<endl;
  }
} 

Measured memory_bytes: 19700