akhauriyash/Code-Regression huggingface dataset:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log,floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a,b,c = MAP()

k = INT()

z = 0

for i in range(100):
    if(b>a):
        break
    b*=2
    z+=1

for i in range(1000):
    if(c>b):
        break
    c*=2
    z+=1
# print(z)
if(z<=k):
    print("Yes")
else:
    print("No")



# temp = floor(log(a/b, 2))+1
# if(temp>0):
#     b=b*(2**temp)
#
# temp1 = floor(log(b/c, 2))+1
# # print(temp, b, temp1)
# if(temp+temp1<=k):
#     print("Yes")
# else:
#     print("No")

Measured memory_bytes: 68240
#include<stdio.h>
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
Tree tree[1000000];
#define NIL -1
int main()
{
  int i,id,j,n,k,c[100000],depth=0,num;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].parent=NIL;
    tree[i].left=NIL;
    tree[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c[j]);
      if(j==0){
	tree[c[0]].parent=id;
        tree[id].left=c[0];
      }
      else{
        tree[c[j]].parent=id;
        tree[c[j-1]].right=c[j];
      }
    }
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,tree[i].parent);
    num=i;
    while(tree[num].parent!=NIL){
      depth++;
      num=tree[num].parent;
    }
    printf("depth = %d,",depth);
    depth=0;
    if(tree[i].parent==NIL && tree[i].left==NIL){
       printf(" root, []\n");
    }
    else if(tree[i].parent==NIL && tree[i].left!=NIL){
      printf(" root, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(tree[i].left!=NIL){
      printf(" internal node, [%d",tree[i].left);
      for(j=tree[tree[i].left].right;j!=NIL;j=tree[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    
    else{
      printf(" leaf, []\n");
    }
    
  }
  return 0;
}

Measured memory_bytes: 2172
def get_score (taKa,cp,score):
    result = 0
    if taKa == "r" and cp == "s":
        result = score[taKa]
    if taKa == "s" and cp == "p":
        result = score[taKa]
    if taKa == "p" and cp == "r":
        result = score[taKa]
    return result
    

N , K = map(int,input().split())
scR,scS,scP = map(int,input().split())
score = {"r":scR,"s":scS,"p":scP}
word = input()
dp = [[0]*3  for i in range(N)]
hand = ["r","s","p"]
result  = [0]*3
for i in range(N):
    for j in range(3):
        result[j] = get_score(hand[j],word[i],score)

    if i < K:
        for j in range(3):
            dp[i][j] = result[j]
    else:
        dp[i][0] = max(dp[i-K][1]+result[0],dp[i-K][2]+result[0])
        dp[i][1] = max(dp[i-K][0]+result[1],dp[i-K][2]+result[1])
        dp[i][2] = max(dp[i-K][0]+result[2],dp[i-K][1]+result[2])
result = [0]*K
for i in range(N-K,N):
    result[N-K-i] = max(dp[i])

print(sum(result))
    
    




Measured memory_bytes: 22848
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	ll S;
	cin >> S;
	bool flag=true;
	ll c, q, r;
	if(S==1e18){
	    ll ans=1e9;
	    cout << 0 << ' ' << 0 << ' ' << ans << ' ' << 0 << ' ' << 0 << ' ' << ans << endl;
	    return 0;
	}
	for(c=min(S, (ll)1e9); flag; --c){
	    q=S/c, r=S%c;
	    flag=(1+q>1e9);
	}
	++c;
	cout << 0 << ' ' << 0 << ' ';
	cout << 1+q << ' ' << c-r << ' ';
	cout << 1 << ' ' << c << endl;
	
	return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
list_S = list(S)

if (len(S) == 1):
    if (S == T):
        print('Yes')
    else:
        print('No')
    
    exit()


def rotate_str(strr):
    n = len(strr)
    rv = strr[1:] + strr[0]
    
    return(rv)


for i in range(len(S)):
    S = rotate_str(S)
    
    if (S == T):
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int p { get; set; }
    public int c { get; set; }
}

public class Hello
{
    public static int h, w;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        h = int.Parse(line[0]);
        w = int.Parse(line[1]);
        var m = int.Parse(line[2]);
        var rs = new P[h];
        for (int i = 0; i < h; i++) rs[i] = new P { p = i };
        var cs = new P[w];
        for (int i = 0; i < w; i++) cs[i] = new P { p = i };
        var hs = new HashSet<long>();
        var rmax = 0; var cmax = 0;
        for (int i = 0; i < m; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var x = int.Parse(line[0]) - 1;
            var y = int.Parse(line[1]) - 1;
            rs[x].c++;
            rmax = Max(rmax, rs[x].c);
            cs[y].c++;
            cmax = Max(cmax, cs[y].c);
            hs.Add(x * 1000000 + y);
        }
        getAns(rs, cs, hs, rmax, cmax);
    }
    static void getAns(P[] rs, P[] cs, HashSet<long> hs, int rmax, int cmax)
    {
        var rs2 = rs.Where(z => z.c == rmax).ToArray();
        var cs2 = cs.Where(z => z.c == cmax).ToArray();
        foreach (var x in rs2)
            foreach (var y in cs2)
            {
                var t = x.p * 1000000 + y.p;
                if (!hs.Contains(t)) { Console.WriteLine(rmax + cmax); return; }
            }
        Console.WriteLine(rmax + cmax - 1);
    }
}


Measured memory_bytes: 89264
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 344444;
int n,a[N];
bool ck(int mid){
	int now=0;
	rep(i,1,n)
		if(i&1)now+=a[i];
		else{
			if(now>=mid)now=max(now-a[i],0);else now-=a[i];
		}
	return now>=mid;
}
int main() {
	read(n);rep(i,1,n)read(a[i]);
	if(n%2==0){
		int x=0,y=0;
		rep(i,1,n)if(i&1)x+=a[i];else y+=a[i];
		printf("%d %d\n",max(x,y),min(x,y));return 0;
	}
	int res=0,l=0,r=0;rep(i,1,n)r+=a[i];
	while(l<=r){
		int mid=(l+r)>>1;
		if(ck(mid))res=mid,l=mid+1;else r=mid-1;
	}
	rep(i,1,n)if(i%2==0)res+=a[i];int qaq=-res;rep(i,1,n)qaq+=a[i];
	printf("%d %d\n",res,qaq);
	return 0;
}


Measured memory_bytes: 1536
// https://atcoder.jp/contests/abc066/tasks/arc077_b
#include <bits/stdc++.h>
using namespace std;
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int MOD = 1000000007;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};
mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
mint operator+(mint a, mint b) {
    int x = a.n + b.n;
    return x - (x >= MOD) * MOD;
}
mint operator-(mint a, mint b) {
    int x = a.n - b.n;
    return x + (x < 0) * MOD;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
istream &operator>>(istream &i, mint &a) { return i >> a.n; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
    for (int i = I_.size(); i <= n; i++) {
        I_.push_back(I_[MOD % i] * (MOD - MOD / i));
        F_.push_back(F_[i - 1] * i);
        R_.push_back(R_[i - 1] * I_[i]);
    }
}

mint I(int n) {
    check_fact(abs(n));
    return n >= 0 ? I_[n] : -I_[n];
}
mint F(int n) {
    check_fact(n);
    return n < 0 ? 0 : F_[n];
}
mint R(int n) {
    check_fact(n);
    return n < 0 ? 0 : R_[n];
}
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n + 1);
    set<int> t, u;
    int d = -1;
    REP(i, n + 1) {
        cin >> v[i];
        if (t.count(v[i]) > 0) {
            d = v[i];
        }
        t.insert(v[i]);
    }
    int l = -1, r = -1;
    REP(i, n + 1) {
        if (v[i] == d) {
            if (l < 0) {
                l = i;
            } else {
                r = i;
            }
        }
    }

    cout << n << endl;
    FOR(i, 2, n + 1) { cout << C(n + 1, i) - C(l - 1 + n - r + 1, i - 1) << "\n"; }
    cout << "1\n";

    return 0;
}


Measured memory_bytes: 7664
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 3e3 + 2;
lli dp[N][N], n, m;
string s, t;

void solve(){
    cin >> s >> t;
    n = s.size(), m = t.size();
    memset(dp, 0, sizeof dp);
    NA(i,1,n+1){
        NA(j,1,m+1){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1]==t[j-1]){
                remax(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
    }
    string res = "";
    if(!dp[n][m]){
        cout << res;
        return;
    }
    lli i = n, j = m;
    while(i>0 && j>0){
        if(dp[i][j] == dp[i-1][j-1] + 1 && s[i-1]==t[j-1]) res += s[i-1], --i, --j;
        else if(dp[i][j-1]==dp[i][j]) --j;
        else --i;
    }
    reverse(all(res));
    cout << res ;
    return;
}
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;

}


Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if(N == M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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

int main(void){
    long long a,b,k ;
    cin >> a >> b >> k ;
    if (a>k){
        a=a-k ;
    } else {
        if (b>k-a){
            b=b-k+a ;
        } else {
            b=0 ;
        }
        a=0 ;
    }
    cout << a << " "<< b << endl ;
}

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

int main(){
	int H,W,h,w,ans=0;
	cin>>H>>W;
	cin>>h>>w;
	int A[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			A[i][j]=0;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<W;j++){
			A[i][j]=1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<w;j++){
			A[i][j]=1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(A[i][j]==0){ans++;}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet


fun f(n: Long): Long {
    return if (n%2==0L) {
        n / 2
    } else {
        3*n + 1
    }
}

fun solve(s: Long): Long? {
    val set = HashSet<Long>()
    var n = s

    set.add(s)
    var i = 2L
    while (true) {
        n = f(n)

        if (set.contains(n))
            return i

        set.add(n)
        i++
    }
}


fun main(args: Array<String>) {
    val s = readLine()!!.toLong()

    println(solve(s))
}

Measured memory_bytes: 31780
#include "bits/stdc++.h"
using namespace std;

int main() {
	string A,B;
	cin >> A >> B;
	if (A[0] > B[0]) {
		for (int n = 0 ;n<A[0]-'0';++n) {
			cout << B;
		}
	}
	else {
		for (int n = 0; n < B[0]-'0'; ++n) {
			cout << A;
		}
	}
	return 0;
}

Measured memory_bytes: 3504
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  complex<int32_t> p1(x1, y1), p2(x2, y2);
  complex<int32_t> d12 = p2 - p1;
  const complex<int32_t> I(0, 1);
  const complex<int32_t> d14 = d12 * I;
  complex<int32_t> p4 = p1 + d14;
  complex<int32_t> p3 = p2 + d14;
  cout << p3.real() << " " << p3.imag() << " " << p4.real() << " " << p4.imag() << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
//↓Union-Find Tree
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
//↑Union-Find Tree
int main(){
	int N,K,L;
	cin>>N>>K>>L;
	UnionFind U(N),V(N);
	for(int i=0;i<K;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		U.unionSet(a,b);
	}
	for(int i=0;i<L;i++){
		int a,b;
		cin>>a>>b;
		a--,b--;
		V.unionSet(a,b);
	}
	vpint vec;
	pint P[SIZE];
	for(int i=0;i<N;i++){
		P[i]=pint(U.root(i),V.root(i));
		vec.pb(P[i]);
	}
	sort(vec.begin(),vec.end());	//sortされたvector<pair<int,int>>
	for(int i=0;i<N;i++){
		//upper_bound(P[i])-lower_bound(P[i])はvec中に存在するP[i]の数になります
		cout<<upper_bound(vec.begin(),vec.end(),P[i])-lower_bound(vec.begin(),vec.end(),P[i])<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 5492
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int k,x;
	cin>>k>>x;
	for (int i = (x-k+1) ; i <= (x+k-1) ; i++){
		cout<<i<<endl;
	}
	
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
#define ALL(v) v.begin(), v.end()


ll t[100010];
ll h[100010];

ll root(ll x){
    if(t[x]==x){
        return x;
    }else{
        return t[x]=root(t[x]);
    }
}

int main(){
    ll N,M;
    cin>>N>>M;
    
    vector<ll> H(N+1);
    vector<bool> f(N+1);
    REP1(i,N){
        cin>>H[i];
        f[i]=true;
    }
    
    REP(i,M){
        ll a,b;
        cin>>a>>b;
        if(H[a]>H[b]){
            f[b]=false;
        }else if(H[a]<H[b]){
            f[a]=false;
        }else{
            f[b]=false;
            f[a]=false;
        }
    }
    ll cnt=0;
    REP1(i,N){
        if(f[i]==true){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
    
    // REP(i,N){
    //     t[i]=i;//t.push_back(i);
    //     h[i]=0;//h.push_back(0);
    // }
    // REP(ttttt,Q){
    //     ll q;
    //     cin>>q;
    //     if(q==0){
    //         ll a,z;
    //         cin>>a>>z;
    //         ll mi=min(root(a),root(z));
    //         ll ma=max(root(a),root(z));
    //         if(a!=z){
    //             if(h[mi]==h[ma]){
    //                 t[ma]=mi;
    //                 h[mi]++;
    //             }else if(h[mi]>h[ma]){
    //                 t[ma]=mi;
    //             }else{
    //                 t[mi]=ma;
    //             }
    //         }
    //     }else{
    //         ll a,z;
    //         cin>>a>>z;
    //         cout<<(root(a)==root(z)?"Yes":"No")<<endl;
    //     }
    // }
    // REP(i,N){
    //     sl(i,":",t[i],h[i]);
    // }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,co;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>s>>a;
      for(int i=0;i<Size(s);i+=a){
        co+=s[i];
      }
      Cout(co);
     

       
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int n; cin >> n;
    vector<int> a(n);

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

    sort(ALL(a));
    int mid = n / 2;

    cout << a[mid] - a[mid-1] << endl;
    return 0;
}


Measured memory_bytes: 640
# print('input >>')
X = int(input())

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)  

# print('-----output-----')

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

int main() {
  vector<int> A(9);
  for (int i = 0; i < 9; i++) cin >> A.at(i);
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> B.at(i);

  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < N; j++) {
      if (A.at(i) == B.at(j)) A.at(i) = 0;
    }
  }

  if (A.at(0) + A.at(1) + A.at(2) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(3) + A.at(4) + A.at(5) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(6) + A.at(7) + A.at(8) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(0) + A.at(3) + A.at(6) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(1) + A.at(4) + A.at(7) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(2) + A.at(5) + A.at(8) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(0) + A.at(4) + A.at(8) == 0) return cout << "Yes" << "\n", 0;
  if (A.at(2) + A.at(4) + A.at(6) == 0) return cout << "Yes" << "\n", 0;

  cout << "No" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}
map<ll,ll> mp;
///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
        ++mp[p];
          //cout << p << " ";
}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;

int main()
{
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a;
    for(ll i=0;i<n;++i){
        ll val;cin>>val;
        a.push_back(val);
    }
    ll c = 1;
    for(int i=0;i<n;++i){
        if(a[i]==c){
            c++;
        }
    }
    if(c==1){cout<<-1<<'\n';return 0;}
    cout<<n-c+1<<'\n';
    return 0;
}


Measured memory_bytes: 2420
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int N;
int arr[MAXN];
int cnt;
vector<int> G;

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

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

void work(){
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&arr[i]);
    cnt=0;
    shellSort(arr,N);
    printf("%d\n",G.size());
    for(int i=G.size()-1;i>=0;i--){
        printf("%d",G[i]);
        if(i) printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i=0;i<N;i++) printf("%d\n",arr[i]);
}

int main(){
    work();
    return 0;
}



Measured memory_bytes: 7116
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    xor_all = A[0]
    
    for i in range(1, N):
        xor_all ^= A[i]

    for i in range(N):
        if i != N - 1:
            print(A[i]^xor_all, end=" ")
        else:
            print(A[i]^xor_all)

if __name__ == "__main__":
    main()

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

const int INF = 1e9;

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


Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		int w = si(), n = si();
		int[] ary = new int[w];
		for (int i = 0; i < w; i++)
			ary[i]=i+1;
		for (int i = 0; i < n; i++) {
			String[] cons = scan.next().split(",");
			int p = Integer.parseInt(cons[0])-1, q = Integer.parseInt(cons[1])-1;
			int tmp = ary[p];
			ary[p] = ary[q];
			ary[q] = tmp;
		}
		for (int i = 0; i < w ; i++)
			out.println(ary[i]);
		out.flush();
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    ios
    ll n,k;
    cin>>n>>k;

    ll a[100005],dp[100005]={0};

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

    dp[0]=a[0];
    for(int i=1;i<n;i++)
    dp[i]=dp[i-1]+a[i];

    map<ll,ll> m;

    for(int i=0;i<n;i++)
    dp[i]%=k;
    
    ll ans=0;

    for(int i=0;i<n;i++)
    {
        if(m.find(dp[i])==m.end())
        m[dp[i]]=1;
        else
        m[dp[i]]++;

        if(dp[i]==0)
        ans+=m[dp[i]];
        else if(dp[i]!=0)
        ans+=(m[dp[i]]-1);

        //cout<<ans<<endl;
    }

    cout<<ans;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		int H = 0;
		int W = 0;
		int N = 0;
		int black = 0;
		
		Scanner input = new Scanner(System.in);
		
		H = input.nextInt();
		W = input.nextInt();
		N = input.nextInt();
		
		if(H > W) {
			for(int i = 1; i < H + 1; i++) {
				black += H;
				if(black >= N) {
					System.out.println(i);
					break;
				}
			}
		}else {
			for(int i = 1; i < W + 1; i++) {
				black += W;
				if(black >= N) {
					System.out.println(i);
					break;
				}
			}
		}
      	input.close();
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

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

	ll A, P;
	ll ans = 0;

	cin >> A >> P;

	ans = (3 * A + P) / 2;

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

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int count = 0;
    if(b-a <= k)
    {
        count++;
    }
    if(c-a <= k)
    {
        count++;
    }
    if(d-a <= k)
    {
        count++;
    }
    if(e-a <= k)
    {
        count++;
    }
    if(c-b <= k)
    {
        count++;
    }
    if(d-b <= k)
    {
        count++;
    }
    if(e-b <= k)
    {
        count++;
    }
    if(d-c <= k)
    {
        count++;
    }
    if(e-c <= k)
    {
        count++;
    }
    if(e-d <= k)
    {
        count++;
    }
if(count == 10)
{
    cout << "Yay!" << endl;
}
else
{
    cout << ":(" << endl;
}
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200006
using namespace std;
map<int,int>g;
int n,x,c[N],p[36];
int main()
{
	scanf("%d",&n);p[0]=1;
	for(int i=1;i<=n;i++)scanf("%d",&c[i]),g[c[i]]++;
	sort(c+1,c+n+1);
	for(int i=1;i<=30;i++)p[i]=p[i-1]<<1;
	for(int i=30,j=n;i>=1&&j>=1;i--){
		while(c[j]<p[i-1])i--;
		for(;c[j]>=p[i-1]&&j>=1;j--){
			if(g[c[j]]<=0)continue;g[c[j]]--;
			if(g[p[i]-c[j]]>0)g[p[i]-c[j]]--,x++;
		}
	}
	printf("%d\n",x);
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define endl "\n"
    #define sz(x) (int)(x).size()
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    ll mod =(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) return 1;
    	if (p == 2 || (p & 1)) return mult(x, binpow(x, p - 1));
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    // bool check(ll x){}
    ll binsearch(ll l,ll r)
    {
        while(l<r)
        {
            ll mid=(l+r)/2;
            // if(check(mid))r=mid;
            // else l=mid+1;
        }
        return l;
    }
    const ll man=(ll)1005;
    vector<ll>adj[man];
    bool vis[man][man];
    ll d[man],depth[man],par[man];
    void addedge(ll u,ll v){adj[u].pb(v);adj[v].pb(u);}
    ll dx[4]={1,-1,0,0};ll dy[4]={0,0,1,-1};
/*........................................................................................................................*/

signed main()/*Check flow...question galat mat padhna */
{
    fast;   
    ll a[12];
    a[0]=1;
    f(i,1,12)a[i]=a[i-1]*26;
    ll b[12]={0};
    ll n;
    cin>>n;
    for(ll i=0;i<12;i++)
    {
        if(n>=a[i])
        {
            n-=a[i];
            b[i]++;
        }
    }
    for(ll i=11;i>=0;i--)
    {
        while(n>=a[i])
        {
            b[i]++;
            n-=a[i];
        }
    }
    string s;
    For(i,12)
    {
        if(b[i])
        {
            s+=(char)('a'+b[i]-1);
        }
    }
    reverse(all(s));
    cout<<s<<endl;
}      


Measured memory_bytes: 3708
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

nd0 = sum(a)

for i in reversed(range(n)):
    monster = a[i+1]
    yusha = b[i]
    if monster > yusha:
        b[i] = 0
        a[i+1] = monster - yusha
    else:
        b[i] = yusha - monster
        a[i+1] = 0
    yusha = b[i]
    monster = a[i]
    if monster > yusha:
        b[i] = 0
        a[i] = monster - yusha
    else:
        b[i] = yusha - monster
        a[i] = 0
        
ndend = sum(a)
print(nd0-ndend)
    

Measured memory_bytes: 82148
#include <iostream>
#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];
    bool ok = 1;
    int count = 0;
  	int i = 0;

    for(int i=0;ok;i++){
      ok = 0;
        for(int j=n-1;j>i;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                ok = 1;
                count++;
            }
        }
    }
    
    for(int i=0;i<n;i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl << count << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[5];
int main() {
    scanf("%s",s);
    if(s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';
    printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}


int raise(int a,int b,int m)
{
  int an = 1;

  while(b>0)
  {
    if(b%2!=0) an = ((an%m) * (a%m))%m;
    b/=2;
    a = ((a%m) *(a%m))%m;
  }
  return an;
}
int dp[2];

int process(int a)
{
  int an =0 ;
  while(a>0)
  {
    int cn =0 ;
    for(int i=0;i<=32;i++)
    {
      if((a>>i)&1) cn++;
    }
    an ++ ;
    a%=cn;  
  }
  return an;
}
void solve()
{
  
  int n;
  cin >> n;

  string s;
  cin >> s;
  
  int cn=0;
  
  forf(i,0,n)
  {
    if(s[i]=='1') cn++;
  }
   
   forf(j,0,n)
   {
     if(cn>1) dp[0] += (raise(2,n-j-1,cn-1) * (s[j]-'0'))%(cn-1) , dp[0]%=(cn-1);
     if(cn<n) dp[1] += (raise(2,n-j-1,cn+1) * (s[j]-'0'))%(cn+1) , dp[1]%=(cn+1);
   } 

   forf(i,0,n)
   {
    if(s[i]=='0')
    {
      int an = dp[1];
      an = an + raise(2,n-i-1,cn+1);
      an%=cn+1;
      
      cout<<process(an)+1<<"\n";

    }else
    {
      if(cn == 1 )
      {
        cout<<"0\n";
        continue;
        
      }
      int an = dp[0];
      an = an - raise(2,n-i-1,cn-1) + cn-1;
      an%=cn-1;
      
      cout<<process(an)+1<<"\n";


    }
   }

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3780
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;

int n;
int x;
int ans[222222];
bool u[222222];
int main(void){
  cin >> n >> x;

  if(x == 1 || x == 2*n-1){
    cout << "No" << endl;
    return 0;
  }
  if(n == 2){
    if(x == 2){
      cout << "Yes" << endl;
      for(int i = 1; i <= 2*n-1; i++){
	cout << i << endl;
      }
    }else{
      cout << "No"  << endl;
    }
    return 0;
  }

  ans[n-1] = x;
  ans[n-1-1] = x-1;
  ans[n+1-1] = x+1;
  u[x] = u[x-1] = u[x+1] = true;
  if(x > 2){
    ans[n+2-1] = x-2;
    u[x-2] = true;
  } else {
    ans[n-2-1] = x+2;
    u[x+2] = true;
  }

  cout << "Yes" << endl;
  
  for(int i = 0,k = 1; i < 2*n-1; i++){
    while(u[k])k++;
    if(ans[i]) cout << ans[i] << endl;
    else cout << k++ << endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

ll dp[51][51][2501];

int main(void){
	int N, A, x[50];
	cin >> N >> A;
	for(int i = 0; i < N; i++) cin >> x[i];

	// initialization
	for(int i = 0; i <= N; i++) dp[i][0][0] = 1;

	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			for(int k = 0; k <= 2500; k++){
				dp[i][j][k] += dp[i-1][j][k];
				if(k - x[i-1] >= 0) dp[i][j][k] += dp[i-1][j-1][k - x[i-1]];

				// if(k < accumulate(x, x + N, 0ll)) printf("dp[%d][%d][%d] = %lld\n", i, j, k, dp[i][j][k]);
			}
		}
	}

	ll res = 0;
	for(int i = 1; i <= N; i++){
		res += dp[N][i][i * A];
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 50048
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
using namespace std;

typedef long long ll;

const int maxn = 100000+5;


int main()
{
	int numa, numb, N, A, B;
	string str;
	while(cin>>N>>A>>B)
	{
		numa = 0;
		numb = 0;
		cin>>str;
		for(int i = 0; i < str.length(); ++i)
		{
			if(str[i] == 'a')
			{
				if(numa + numb < A + B)
				{
					cout<<"Yes"<<endl;
					numa += 1;
				}
				else cout<<"No"<<endl;
			}
			else if(str[i] == 'b')
			{
				if(numb < B && numa + numb < A + B)
				{
					cout<<"Yes"<<endl;
					numb += 1;
				}
				else cout<<"No"<<endl;
			}
			else cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1024
function Main(input) {
	input = input.split("\n")
	var namesN = input[0]
	var names = input.slice(1)
	var nameInitialCounts = {}
	for(var name of names) {
		nameInitialCounts[name.charAt(0)]
			= ++nameInitialCounts[name.charAt(0)] || 1;
	}
	var cases = k_combinations(["M", "A", "R", "C", "H"], 3)
	var result = 0
	for(var c of cases) {
		result += (nameInitialCounts[c[0]] || 0) * (nameInitialCounts[c[1]] || 0) * (nameInitialCounts[c[2]] || 0)
	}
	console.log(result)
}


function k_combinations(set, k) {
	var i, j, combs, head, tailcombs;
	
	// There is no way to take e.g. sets of 5 elements from
	// a set of 4.
	if (k > set.length || k <= 0) {
		return [];
	}
	
	// K-sized set has only one K-sized subset.
	if (k == set.length) {
		return [set];
	}
	
	// There is N 1-sized subsets in a N-sized set.
	if (k == 1) {
		combs = [];
		for (i = 0; i < set.length; i++) {
			combs.push([set[i]]);
		}
		return combs;
	}
	
	// Assert {1 < k < set.length}
	
	// Algorithm description:
	// To get k-combinations of a set, we want to join each element
	// with all (k-1)-combinations of the other elements. The set of
	// these k-sized sets would be the desired result. However, as we
	// represent sets with lists, we need to take duplicates into
	// account. To avoid producing duplicates and also unnecessary
	// computing, we use the following approach: each element i
	// divides the list into three: the preceding elements, the
	// current element i, and the subsequent elements. For the first
	// element, the list of preceding elements is empty. For element i,
	// we compute the (k-1)-computations of the subsequent elements,
	// join each with the element i, and store the joined to the set of
	// computed k-combinations. We do not need to take the preceding
	// elements into account, because they have already been the i:th
	// element so they are already computed and stored. When the length
	// of the subsequent list drops below (k-1), we cannot find any
	// (k-1)-combs, hence the upper limit for the iteration:
	combs = [];
	for (i = 0; i < set.length - k + 1; i++) {
		// head is a list that includes only our current element.
		head = set.slice(i, i + 1);
		// We take smaller combinations from the subsequent elements
		tailcombs = k_combinations(set.slice(i + 1), k - 1);
		// For each (k-1)-combination we join it with the current
		// and store it to the set of k-combinations.
		for (j = 0; j < tailcombs.length; j++) {
			combs.push(head.concat(tailcombs[j]));
		}
	}
	return combs;
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 42884
n = int(input())
li = [0]*4
lia = ["AC","WA","TLE","RE"]
for i in range(n):
    a = input()
    if a == "AC":
        li[0] += 1
    if a == "WA":
        li[1] += 1
    if a == "TLE":
        li[2] += 1
    if a == "RE":
        li[3] += 1
for i in range(4):
    print(str(lia[i])+" x "+str(li[i]))

Measured memory_bytes: 9208
import sys
import os
import re
import datetime
import bisect

####### main #######

N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB

print(sumBAll)

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

using namespace std;

typedef long long ll;

using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;

#define x first
#define y second

ll count(vi X, ll N) {

	ll c = 0;

	for(int k = 0; k < X.size(); ++k) {

		if(X[k] == 0 && N >= 0)
			c += X.size() - 1;

		else if(X[k] > 0) {

			ll y = N / X[k];

			if(1LL * y * X[k] > N) 
				--y;

			int j = upper_bound(X.begin(), X.end(), y) - X.begin();

			if(X[k] <= y) 
				--j;

			c += j; 
		}

		else if(X[k] < 0) {

			ll y = N / X[k];

			if(1LL * y * X[k] > N)
				++y;

			int j = lower_bound(X.begin(), X.end(), y) - X.begin();

			if(X[k] >= y) 
				++j;
		
			c += X.size() - j;
		}
	}

	return c >> 1;
}

int main() {

	int N;
	ll K;

	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> N >> K;

	vi X(N);
	int p {}, n {}, z {};	

	for(int k = 0; k < N; ++k) {

		cin >> X[k];

		if(X[k] > 0) ++p;
		else if(X[k] < 0) ++n;
		else ++z;
	}

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

	ll L, R;

	if(1LL * n * p >= K)
		L = -1e18, R = -1;

	else if(1LL * n * p + 1LL * z * (n + p) + z * (z - 1LL) / 2LL >= K) {

		cout << 0 << '\n';
		return 0;
	}

	else
		L = 1, R = 1e18;

	for(int k = 0; k < 64; ++k) {

		ll mid = L + R >> 1;

		if(count(X, mid) < K)
			L = mid + 1;

		else
			R = mid;
	}

	cout << R << '\n';

	return 0;
}

Measured memory_bytes: 1800
#include<stdio.h>

int main(void){
	long long a,b,c,m=0,sa,sb,sc;
	scanf("%lld%lld%lld",&a,&b,&c);
	while(1){
		if(a%2 || b%2 || c%2){break;}
		if(a == b && b == c){printf("-1\n");return 0;}
		sa = (b/2)+(c/2);
		sb = (a/2)+(c/2);
		sc = (a/2)+(b/2);
		a = sa;b = sb;c = sc;
		m++;
	}
	printf("%lld\n",m);
	return 0;
}

Measured memory_bytes: 128