akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n-1);
  REP(i,n-1) cin >> a[i];
  
  int ans = 0, mx = 0;
  REP(i,n-2){
    ans += min(a[i],a[i+1]);
  }

  cout << ans+a[0]+a.back() << endl;

  return 0;
}

Measured memory_bytes: 256
a = input()

if a[-1] == "2" or a[-1] == "4" or a[-1] == "5" or a[-1] == "7" or a[-1] == "9":
  print("hon")
elif a[-1] == "0" or a[-1] == "1" or a[-1] == "6" or a[-1] == "8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e14
#define dd double
#define MOD 1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl cout<<endl
#define fill(a,val) memset(a,val,sizeof(a))
#define mp make_pair
#define endl "\n"
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){ll res=1;x=x%MOD;while(y>0){if(y&1)res = (res*x)%MOD;y = y>>1;x = (x*x)%MOD;}return res%MOD;}  
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){if(low>high)return;ll mid=(low+high)/2;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
signed main()
{
    fastio();   
    ll K;
    cin>>K;
    ll ar[1000005]={};
    for(ll i=3;i<1000005;i+=3)
    {
        ar[i]=-1;
    }
    for(ll i=5;i<=1000004;i+=5)
        ar[i]=-1;
    ll ans=0;
    for(ll i=1;i<=K;i++)
    {
        if(ar[i]!=-1)
            ans+=i;
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 11452
#include<stdio.h>
int main()
{
    int a,b,area,perimeter;
    scanf("%d %d", &a, &b);
    if(a >= 1 && a <= 100 && b >= 1 && b <=100)
       {
           area = a*b;
           perimeter = 2*(a+b);
           printf("%d %d\n",area,perimeter);
       }
return 0;

}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
char x; cin>>x; x++; out(x);  

  return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

string S;
int a[20] = {};
int j = 0;

int main()
{
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C')
		{
			a[j]++;
		}
		else
		{
			j++;
		}
	}
	int ma = 0;

	for (int i = 0; i < 20; i++)
	{
		ma = max(ma, a[i]);
	}
	cout << ma << endl;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 202055;
const int M = 1211;

void solve() {
    int n;
    cin >> n;
    
    cout << n*(n+1)/2;

}

int main() {
    ios_base::sync_with_stdio(false);


    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
EW=0
ans=99999999999999999999999999999999

N=int(input())
S=input()

for i in range(N):
    if i==0:
        pass
    elif S[i]=="E":
        EW+=1
if ans>EW:
    ans=EW

for j in range(1,N):
    if S[j]=="E":
        EW-=1
    if S[j-1]=="W":
        EW+=1

    if ans>EW:
        ans=EW
print(ans)


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

int main() {
  
  int N, Y, count, a, b;
  cin >> N >> Y;
  
  bool z = false;
  
  for(int i = 0; i <= N; i++){
    
    for(int j = 0; j <= N; j++){
      
      if(Y == 9000 * i + 4000 * j + 1000 * N && N - i - j >= 0){
        //cout << 9000 * i + 4000 * j + 1000 * N << endl;
        a = i;
        b = j;
        z = true;
        break;
      }
      if(z){
        break;
      }
    }
  }
      
    if(z){
      cout << a << " " << b << " " << N - a - b << endl;
    }
    else{
      cout << "-1" << " " << "-1" << " " << "-1" << endl;
    }
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string S;
	cin >> S;
	int ans=0, res=0;
	rep(i,3){
		if(S[i]=='R') res++;
		else res=0;
		ans=max(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
// 大小関係

#include <iostream>
using namespace std;

int main()
{
    int a, b;

    cin >> a >> b;

    if (a > b)
        cout << "a > b\n";
    else if (a < b)
        cout << "a < b\n";
    else
        cout << "a == b\n";
    return 0;
}



Measured memory_bytes: 3080
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
c.append(0)

i=0
l=[]
for j in b:
  while c[i]>j:
    i+=1
  l.append(i)
b.append(0)
s=0
cnt=0
i=0
for j in a:
  while b[i]>j:
    s+=l[i]
    i+=1
  cnt+=s
print(cnt)

Measured memory_bytes: 103764
import string
import sys

a = string.ascii_lowercase
key = str.maketrans(a, a[1:] + a[:1])

for s in sys.stdin:
    for i in range(1, 27):
        s = s.translate(key)
        if 'the' in s or 'this' in s or 'that' in s:
            break
    print(s, end="")

Measured memory_bytes: 8008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dfs(int N,ll X,vector<ll> a){
    if(N == 0) return 1;
    if(X == 1) return 0;
    if(X > 1 && X <= a[N]/2) return dfs(N-1,X-1,a);
    if(X == a[N]/2+1) return dfs(N-1,a[N-1],a)+1;
    if(X > a[N]/2+1 && X < a[N]) return dfs(N-1,a[N-1],a)+dfs(N-1,X-a[N]/2-1,a)+1;
    if(X == a[N]) return dfs(N-1,a[N],a)*2+1;
}

int main(){
    int N; cin >> N;
    ll X; cin >> X;
    vector<ll> a(N+1);
    a[0] = 1;
    rep(i,N){
        a[i+1] = a[i]*2+3;
    }
    ll ans = dfs(N,X,a);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N, cnt, L[105];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> L[i];
	sort(L + 1, L + 1 + N);
	for (int i = 1; i <= N; i++)
		for (int j = i + 1; j <= N; j++)
			for (int k = j + 1; k <= N; k++)
				if (L[i] != L[j] && L[j] != L[k] && L[i] + L[j] > L[k]) cnt++;
	cout << cnt << '\n';
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint l, r;
  cin >> l >> r;
  r = min(r, l + 5000);
  lint mini = 2019LL;
  rep1 (i, l, r) {
    rep1 (j, i + 1, r) {
      mini = min(mini, ((lint)i * (lint)j) % 2019LL);
    }
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a*100+b*10+c)%4==0) 
    {
        cout<<"YES";
    }
    else 
    {
        cout<<"NO";
    }
    return 0;
} 

Measured memory_bytes: 256
// 2020-09-16 22:51:35
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n, m;
  cin >> n >> m;
  vector<P> q(m);
  rep(i, m) cin >> q[i].second >> q[i].first;
  sort(ALL(q));
  int c = 0, ans = 0;
  for (auto [b, a] : q) {
    if (c < a) {
      ans++;
      c = b - 1;
    }
  }
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3996
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int i,k=0;
	char a[1000],b[1000];
	scanf("%s",&a);
	int n=strlen(a);
	for(i=0;i<n;i++){
		if(a[i]=='0') b[k++]='0';
		else if(a[i]=='1') b[k++]='1';
		else if(a[i]=='B') 
		{
			if(k==0) continue;
			else k--;
		}
	}
	for(i=0;i<k;i++) printf("%c",b[i]);
	printf("\n");
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define Max(x,y) ((x) > (y) ? (x) : (y))
#define Min(x,y) ((x) < (y) ? (x) : (y))
#define mod 1000000007
#define N 100010
using namespace std;
inline int read(){
	int x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

int n,ans;
int num[N];

int main(){
	n = read();
	for(int i = 1;i <= n;i++){
		int x = read();
		num[x]++; num[x+1]++;
		if(x > 0) num[x-1]++;
	}
	for(int i = 0;i <= 100000;i++)
		ans = Max(ans,num[i]);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 200005;
int N;
string road;

int move_fast(int s,int t){
    if(s == t) return 0;
    int step = 0;
    while(s +1 != t && s+2 != t){
        if(road[s+1] == '#' && road[s+2] == '#'){
            return -1;
        }
        else if(road[s+2] != '#'){
            s += 2;
        }
        else{
            s+=1;
        }
        step++;
    }
    return step+1;
}
int move_good(int s,int t){
    int step = 0;
    while(s <= t){
        if(road[s-1] == '.' && road[s+1] == '.'){
            road[s] = '#';
            return s;
        }

        if(road[s+1] == '#' && road[s+2] == '#'){
            return -1;
        }
        else if(road[s+1] != '#'){
            s++;
        }
        else{
            s += 2;
        }
    }

    if(s > t) return -1;

    return s;

}

int main()
{
    int A,B,C,D;
    cin >> N >> A >> B >> C >> D >> road;

    if(C > D){
        swap(C,D);
        swap(A,B);
    }

    road = " "+road;

    int amin = 0,bmin = 0,amax = 0,bmax  = 0;
    if(A < B){
        bmin = move_fast(B,D);
        amin = move_fast(A,C);
    }
    else{
        A = move_good(A,C);
        if(A == -1){
            bmin = -1;
        }
        else{
            bmin = move_fast(B,D);
            amin = move_fast(A,C);
        }
    }

    if(amin == -1 || bmin == -1 || amax == -1 || bmax == -1) printf("No\n");
    else printf("Yes\n");

    return 0;
}

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

int main() {
  vector<int64_t> lucas(87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  int number;
  cin >> number;
  for (int i = 2; i <= number; i++) {
    lucas.at(i) = lucas.at(i - 1) + lucas.at(i - 2);
  }
  cout << lucas.at(number) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string S;
  cin >> S;
  string T;
  cin >> T;
  T += S;
  cout << T << '\n';
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    ll kawanai = 1000;
    ll kabu = 0;
    ll mon = 1000;
    REP(i,N-1){
        if(kawanai >= mon + kabu*A[i]){
            kabu = 0;
            mon = kawanai;
        }else{
            kawanai = mon + kabu*A[i];
        }
        kabu += mon/A[i];
        mon = mon%A[i];
    }
    mon += kabu*A[N-1];
    cout << max(mon,kawanai) << "\n";
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    
    char S[N][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cin >> S[i][j];
        }
    }
    
    int ans=0;
    
    for(int A=0; A<N; A++){
        int good=1;
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(S[(i+A)%N][j]!=S[(j+A)%N][i]){
                    good=0;
                }
            }
        }
        
        if(good==1){
            ans+=N;
        }

    }
    

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


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000

using namespace std;

#define MAXN 100001
vector<int> dp(MAXN, INF);

int main(){
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n)cin>>a[i];

  rep(i, n)*lower_bound(dp.begin(), dp.end(), a[i]) = a[i];

  auto it = lower_bound(dp.begin(), dp.end(), INF);
  cout<<distance(dp.begin(), it)<<endl;

// rep(i, n)cout<<dp[i]<<' ';

  return 0;
}



Measured memory_bytes: 3624
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,k,c = map(int, input().split())
    s = input().rstrip()
    left = [0]*n
    day = 0
    temp = 0
    while day < n:
        if s[day] == 'o':
            temp += 1
            left[day] = temp
            for i in range(c):
                if day+i+1 < n:
                    left[day+i+1] = temp
            day += c
        else:
            left[day] = temp
        day += 1

    right = [0]*n
    day = n-1
    temp = 0
    while 0 <= day:
        if s[day] == 'o':
            temp += 1
            right[day] = temp
            for i in range(c):
                if day-i-1 >= 0:
                    right[day-i-1] = temp
            day -= c
        else:
            right[day] = temp
        day -= 1

    res = []
    for i in range(n):
        if s[i] == 'o':
            if i-c-1 < 0:
                pre = 0
            else:
                pre = left[i-c-1]
            if i+c+1 >= n:
                pos = 0
            else:
                pos = right[i+c+1]
            if pre + pos == k-1:
                res.append(i+1)
    for i in range(len(res)):
        if i-1>=0:
            l = res[i-1]
        else:
            l = -1000000
        if i+1<len(res):
            r = res[i+1]
        else:
            r = 10000000
        if res[i]-l>c and r-res[i] > c:
            print(res[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 30508
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int alicePoints = 0;
        int bobPoints = 0;
        int n = Integer.parseInt(sc.nextLine());
        String[] a = sc.nextLine().split(" ");

        Integer[] aInt = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            aInt[i] = Integer.parseInt(a[i]);
        }
        Arrays.sort(aInt, Comparator.reverseOrder());
        for (int tursCount = 0; tursCount < n; tursCount++) {
            if (tursCount % 2 == 0) {
                alicePoints = alicePoints + aInt[tursCount];
            } else {
                bobPoints = bobPoints + aInt[tursCount];
            }
        }
        System.out.println(alicePoints - bobPoints);
    }
}

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

using namespace std;
int n,i,x;
int a[200005];
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        x^=a[i];
    }
    for(i=1;i<=n;i++)
        cout<<(x^a[i])<<' ';
    return 0;
}


Measured memory_bytes: 4356
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int tmp = partition(a, 0, n-1);
        for (int i = 0; i < n; i++) {
            if (i != 0)
                System.out.print(" ");
            if (i == tmp)
                System.out.print("[" + a[i] + "]");
            else
                System.out.print(a[i]);
        }
        System.out.println();
    }

    static int partition(int[] A, int p, int r) {
        int x = A[r];
        int i = p-1;

        for (int j = p; j < r; j++) {
            if (A[j] <= x) {
                i = i+1;
                int tmp = A[j];
                A[j] = A[i];
                A[i] = tmp;
            }
        }
        int tmp = A[r];
        A[r] = A[i+1];
        A[i+1] = tmp;

        return i+1;
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 58604
#include<cstdio>
int count[200005];
int a[200005];
long long pow2[200005][2];
long long mod[2], org[2];
int ans[200005];

int popCount(int u){
    int res = 0;
    while(u!=0){
        res += u%2;
        u /= 2;
    }
    return res;
}

void preWork(int n){
    count[0] = 0;
    for(int i = 1; i <= n; i++){
        int u = i, cnt = 0;
        while(u){
            u %= popCount(u);
            cnt++;
        }
        count[i] = cnt;
    }
}

void setUp(int n,int cnt1){
    mod[0] = cnt1-1; mod[1] = cnt1+1;
    if(mod[0]!=0) pow2[0][0] = 1%mod[0]; 
    if(mod[1]!=0) pow2[0][1] = 1%mod[1];
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 2; j++){
            if(mod[j]<=0) continue;
            pow2[i][j] = pow2[i-1][j]*2ll%mod[j];
        }
    }
    org[0] = 0, org[1] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 2; j++){
            if(mod[j]<=0) continue;
            long long cur = pow2[n-i][j];
            if(a[i]!=0) org[j] = (org[j]+cur)%mod[j];
        }
    }
}

int main(){
    int n;
    scanf("%d",&n);
    preWork(n);
    int cnt1 = 0;
    for(int i = 1; i <= n; i++){
        scanf("%1d",&a[i]);
        if(a[i]==1) cnt1++;
    }
    setUp(n,cnt1);
    //printf("ok\n");
    for(int i = 1; i <= n; i++){
        if(a[i]==0){
            long long cur = org[1];
            cur += pow2[n-i][1];
            if(cur>=mod[1]) cur -= mod[1];
            //printf("i = %d, cur = %lld\n",i,cur);
            ans[i] = 1+count[cur];
        }
        else{
            if(cnt1==1) ans[i] = 0;
            else{
                long long cur = org[0];
                cur -= pow2[n-i][0];
                if(cur<0) cur += mod[0];
                //printf("i = %d, cur = %lld\n",i,cur);
                ans[i] = 1+count[cur];
            }
        }
    }
    for(int i = 1; i <= n; i++) printf("%d\n",ans[i]);
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 212345;
struct RMQStatic {
  int *a;
  int dp_min[20][MAX_N]; // [i][j] := answer index of start_pos == j, len == 2^i
  int dp_max[20][MAX_N];

  int log2(int b) {return 31 - __builtin_clz(b);}

  // O(NlogN)
  void build(int* a, int N) {
    this->a = a;
    int M = log2(N) + 1;
    REP(i, N) dp_min[0][i] = i;
    REP(i, N) dp_max[0][i] = i;
    for (int i = 1, len = 1; i < M; i++, len <<= 1) {
      for (int j = 0; j + len < N; j++) {
        {
          int s = dp_min[i - 1][j];
          int t = dp_min[i - 1][j + len];
          dp_min[i][j] = a[s] <= a[t] ? s : t;
        }
        {
          int s = dp_max[i - 1][j];
          int t = dp_max[i - 1][j + len];
          dp_max[i][j] = a[s] >= a[t] ? s : t;
        }
      }
    }
  }

  // O(1)
  // [from..to]の間で最小の値の添字を返す。複数ある場合は一番最初のを返す
  int query(int from, int to, int type) {
    int k = log2(to - from + 1);
    if (type == 0) {
      int s = dp_min[k][from];
      int t = dp_min[k][to - (1 << k) + 1];
      return a[s] <= a[t] ? s : t;
    } else {
      int s = dp_max[k][from];
      int t = dp_max[k][to - (1 << k) + 1];
      return a[s] >= a[t] ? s : t;
    }
  }
};

RMQStatic rmq;
int A[MAX_N];

int main2() {
  int N = nextInt();
  int K = nextInt();
  vector<int> isSorted(N);
  REP(i, N) A[i] = nextInt();

  {
    deque<int> s;
    for (int i = 0; i < N; i++) {
      if (i - K >= 0 && s.size() > 0 && s.front() == A[i-K]) {
        s.pop_front();
      }
      while (s.size() > 0 && s.back() > A[i])
        s.pop_back();
      s.push_back(A[i]);
      if ((int)s.size() == K) {
        isSorted[i-K+1] = true;
      }
    }
  }

  rmq.build(A, N);

  int ans = N - K + 1;
  int id = 0;
  for (int i = 0; i + K <= N; i++) {
    if (isSorted[i])
      id++;
    else if (i + K <= N-1) {
      if (A[i] < A[rmq.query(i+1, i+K-1, 0)] &&
        A[i+K] > A[rmq.query(i+1, i+K-1, 1)]
      ) ans--;
    }
  }

  if (id >= 2) ans -= id-1;
  cout << ans << endl;
  return 0;
}

int main() {
#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 33884
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let in_x: usize = read();
    let in_y: usize = read();
    let in_a: usize = read();
    let in_b: usize = read();
    let in_c: usize = read();
    let mut in_p: Vec<i64> = Vec::new();
    let mut in_q: Vec<i64> = Vec::new();
    let mut in_r: Vec<i64> = Vec::new();

    for _ in 0..in_a {
        in_p.push(read());
    }

    for _ in 0..in_b {
        in_q.push(read());
    }

    for _ in 0..in_c {
        in_r.push(read());
    }

    in_p.sort_by_key(|&x| -x);
    in_q.sort_by_key(|&x| -x);
    in_r.sort_by_key(|&x| -x);

    let mut apples = Vec::new();

    for i in 0..in_x {
        apples.push(in_p[i]);
    }

    for i in 0..in_y {
        apples.push(in_q[i]);
    }

    apples.sort();

    for i in 0..apples.len() {
        if i >= in_r.len() {
            break;
        } else if apples[i] >= in_r[i] {
            break;
        }

        apples[i] = in_r[i];
    }

    println!("{}", apples.iter().fold(0, |s, x| s + x));
}


Measured memory_bytes: 12540
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int l, r;
    cin>>l>>r;
    (r*2>=l)?cout<<0<<endl:cout<<l-(r*2)<<endl;
    
    return 0;
}

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

d = [0] * n
f = [0] * n
M = [[0]*n for _ in xrange(n)]
color = [0] * n
tt = 0
WHITE = 0
GRAY = 1
BLACK = 2

def dfs_visit(u):
    global tt
    color[u] = GRAY
    tt += 1
    d[u] = tt
    for v in xrange(n):
        if M[u][v] == 0:
            continue
        if color[v] == WHITE:
            dfs_visit(v)
    color[u] = BLACK
    tt += 1
    f[u] = tt
    return 0

def dfs():
    for u in xrange(n):
        if color[u] == WHITE:
            dfs_visit(u)
    for u in xrange(n):
        print "{} {} {}".format(u+1, d[u], f[u])
    return 0

def main():
    for i in xrange(n):
        a = map(int, raw_input().split())
        u = a[0]-1
        k = a[1]
        for j in xrange(k):
            v = a[j+2] -  1
            M[u][v] = 1
    
    dfs()
    return 0

main()

Measured memory_bytes: 6484
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MM 1000000007
using namespace std;

int main()
{
	int n;
	cin>>n;
	
	int a[n],b[n],c[n];
	
	for (int i=0;i<n;i++)
	cin>>a[i];
	
	for (int i=0;i<n;i++)
	cin>>b[i];
	
	for (int i=0;i<n-1;i++)
	cin>>c[i];
	
	int ans=0;
	for (int i=0;i<n;i++)
	{
		ans+=(b[a[i]-1]);
		if (i!=0)
		{
			if (a[i]-a[i-1]==1)
			{
				ans+=(c[a[i-1]-1]);
			}
		}
		
	}
	
	cout<<ans;
	
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b, c, max, min;

	scanf("%d%d%d", &a, &b, &c);
	max = a;
	if (max < b)
		max = b;
	if (max < c)
		max = c;
	min = a;
	if (min > b)
		min = b;
	if (min > c)
		min = c;
	printf("%d\n", max - min);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  set<string> st;
  rep(i,n) st.insert(s[i]);
  cout << st.size() << endl;
}


Measured memory_bytes: 25168
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const int BIG=1e7;
const int maxNN=1e6;

int N;
vector<vector<int>> d(maxNN);
vector<int> dp(maxNN);
vector<bool> used(maxNN);

int dfs(int x){
    if(dp.at(x)!=0) return dp.at(x);
    if(used.at(x)) return BIG;
    used.at(x)=true;
    int p=d.at(x).size();
    if(p==0) return dp.at(x)=1;
    
    
    int memo=0;
    for(int i=0;i<p;i++){
        memo=max(memo,dfs(d.at(x).at(i)));
    }
    return dp.at(x)=memo+1;
}

int main(){
    cin>>N;
    //cout<<dp.size()<<endl;

    
    for(int i=0;i<N;i++){
        int memory=0;
        for(int j=0;j<N-1;j++){
            int x,y;
            y=i;
            cin>>x;
            
            x--;
            if(x>y) swap(x,y);
            //cout<<x<<' '<<y<<' '<<x*N+y<<endl;
            d.at(memory).push_back(x*N+y);
            //if(j!=0)son.at(x*N+y)=true;
            memory=x*N+y;
        }
    }
    d.at(0).erase(unique(d.at(0).begin(), d.at(0).end()), d.at(0).end());

    /*for(int i=0;i<N*N;i++){
        if(d.at(i).size()!=0){
            cout<<endl<<i<<':';
        for(int j=0;j<d.at(i).size();j++) cout<<d.at(i).at(j)<<' ';}
    }*/

    int ans=dfs(0);
    if(ans>=BIG) cout<<-1<<endl;
    else cout<<ans-1<<endl;
}

Measured memory_bytes: 43520
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

int main()
{
	int n; cin >> n;
	ll ans = 0;
	vector<int> l(n);
	for(int i = 0; i<n; i++)
		cin >> l[i];
	sort(l.begin(), l.end());
	
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++){
			int aux, x;
			aux = l[i] + l[j];
			//x = lower_bound(l.begin(), l.end(), aux);
			x = (lower_bound(l.begin(), l.end(), aux) - l.begin())-1;
			//cout << x << " " << j << endl;
			ans += (x - j);
			//cout << ans << endl;
		}
	}
	cout << ans << endl;
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;

  void init() {
    scanf("%lld", &N);
  }

  void solve() {
    printf("%lld\n", (N*(N-1)/2));
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

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

int main(){
    int n, m, l, i;
    cin >> n;
    int t[n], t_ori[n];
    int ans = 0;
    i = 0;
    while(i < n) {
        cin >> t[i];
        t_ori[i] = t[i];
        i++;
    }
    cin >> m;
    int p[m], x[m];
    i = 0;
    for (int j = 0; j < m; j++) {
        cin >> p[i] >> x[i];
        i++;
    }

    for (int i = 0; i < m; i++) {
        t[p[i] - 1] = x[i];
        for (int j = 0; j < n; j++) {
            ans += t[j];
        }
        t[p[i] - 1] = t_ori[p[i] - 1];
        cout << ans << '\n';
        ans = 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    IOS

    int n;
    cin>>n;
    int arr[n];

    for(int i=0;i<n;i++)
        cin>>arr[i];

    sort(arr,arr+n,greater<int>());

    ll sum=arr[0];

    if(n%2==0)
    {
        for(int i=1;i<=(n-2)/2;i++)
            sum+=2*arr[i];
    }
    else
    {
        for(int i=1;i<=(n-2)/2;i++)
            sum+=2*arr[i];
        sum+=arr[((n-2)/2)+1];
    }

    cout<<sum;

    return 0;
}


Measured memory_bytes: 4396
#include <iostream>

using namespace std;

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

    int num_of_odd = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 1)
            ++num_of_odd;
    }

    cout << double(num_of_odd) / (double)n << '\n';
}


Measured memory_bytes: 256
H ,N = [int(i) for i in input().split()]
AB = []
for _ in range(N):
    AB.append([int(i) for i in input().split(' ')])
 
MAX = 0
for a, b in AB:
    MAX = a if MAX < a else MAX
 
DP = [10**10] * (H+MAX)
DP[0] = 0
for i in range(H):
    for a,b in AB:
        if DP[i] != 10**10:
            DP[i+a] = min(DP[i+a],DP[i] + b)
 
print(min(DP[H:]))

Measured memory_bytes: 42220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {

  string s;
  cin >> s;
  if(s.at(1) == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3600
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# d = 2 ** N - 1について
# 1 xor 2 xor... xor dは
# 各桁にフラグが2 * (N - 1)本ずつ立っている（つまり0になる）
# なのでXを抜くとXを構成する部分についてフラグが抜けてXができる

M, K = getNM()

if M == 0 and K == 0:
    print(0, 0)

elif M == 1 and K == 0:
    print(0, 0, 1, 1)

elif M >= 2 and K < 2 ** M:
    ans = []
    for n in range(2 ** M):
        if n != K:
            ans.append(n)
    print(*ans, K, *ans[::-1], K)
    
else:
    print(-1)

Measured memory_bytes: 108464
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; int a[N]; int ma = 0, mi = inf;
  if(N==2){
    int a, b; cin >> a >> b;
    if(a!=1 || b!=1){
      cout << "Impossible" << endl;
    }
    else cout << "Possible" << endl;
    return 0;
  }
  rep(i, N){
    cin >> a[i]; ma = max(ma, a[i]); mi = min(mi, a[i]);
  }
  if(ma==1){
    cout << "Impossible" << endl; return 0;
  }
  if(mi!=(ma+1)/2){
    cout << "Impossible" << endl; return 0;
  }
  int cnt[N] = {};
  rep(i, N){
    cnt[a[i]]++;
  }
  if(ma%2==0){
    if(cnt[mi]!=1){
      cout << "Impossible" << endl; return 0;
    }
  }
  else{
    if(cnt[mi]!=2){
      cout << "Impossible" << endl; return 0;
    }
  }
  for(int i=mi+1; i<=ma; i++){
    if(cnt[i]<2){
      cout << "Impossible" << endl; return 0;
    }
  }
  cout << "Possible" << endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int vis[N],n,k=1,ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x==k)
			k++;
		else
			ans++;
	}
	printf("%d\n",(ans==n?-1:ans));
	return 0;
}

Measured memory_bytes: 384
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

#互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

# aの逆元(mod M)を求める（aとMは互いに素であることが前提）
def mod_inv(a,M=mod):
    x = extgcd(a,M)[0]
    return (M+x%M)%M

#a!をmodしつつ求める
def fact(a,M=mod):
    ans = 1
    for i in range(2,a+1):
        ans = ans*i
        ans = ans%M
    return ans


p = I()
a = III()

beki = [[1]*p for _ in range(p)]
for i in range(p):
    for j in range(1,p):
        beki[i][j] = beki[i][j-1]*(-i)
        beki[i][j] = beki[i][j]%p

fact_inv = [0]*p
for i in range(p):
    fact_inv[i] = mod_inv(fact(i,p),p)

pfact = fact(p-1,p)

ans = [0]*p
for j in range(p):
    if a[j]==0:
        continue
    else:
        ans[0] += 1
        for i in range(p):
            ans[i] -= pfact*fact_inv[i]*fact_inv[p-1-i]*beki[j][p-1-i]
            ans[i] %= p

print(*ans)

Measured memory_bytes: 116188
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, a, b, c);
    print(((a * 100 + b * 10 + c) % 4 == 0) ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 256
n,m=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(n)]
cd=[list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    t=[]
    for j in range(m):
        t.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
    k=min(t)
    for j in range(m):
        if k==(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])):
            print(j+1)
            break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,a,b,v[2010];

int main(){
	cin >> n >> a >> b;
	REP(i,0,n) cin >> v[i];
	
	cout << max(abs(b-v[n-1]), abs((n==1?0:v[n-1]-v[n-2]))) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define fin for(i=0;i<n;i++)
#define vec vector<ll>
#define pb push_back
#define vecit vector<ll>::iterator
#define vecp vector<pair<ll,ll> >
#define vecpit vector<pair<ll,ll> >::iterator
#define mapp map<ll,ll>
#define mapr map<ll,pair<ll,ll> >
#define maprit map<ll,pair<ll,ll> >::iterator
#define mapit map<ll,ll>::iterator
#define mod1 1000000007
#define INF 1000000000000000000
#define twodp vector<vector<ll> >dp(n+1,vec (k+1,0));
using namespace std;
int main()
{
    ll n,i,j,k,l;
    cin>>n>>k;
    twodp
    vec v;
    fin
    {
        cin>>j;
        v.pb(j);
    }
    for(i=0;i<=n;i++)
    {
        dp[i][0]=1;
    }
    for(i=1;i<=n;i++)
    {
        vec p;
        p.pb(1);
        for(l=1;l<=k;l++)
        {
            p.pb((dp[i-1][l]+p[l-1])%mod1);
        }
        for(j=1;j<=k;j++)
        {
            if(j<=v[i-1])
            {
                dp[i][j]=p[j];
            }
            else
            {
                dp[i][j]=(p[j]-p[j-v[i-1]-1]+mod1)%mod1;
            }
        }
    }
   /* for(i=0;i<=n;i++)
    {
        for(j=0;j<=k;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<"\n";
   }
*/


    cout<<dp[n][k];



}


Measured memory_bytes: 84316