akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

struct Node{
  int key;
  Node *right, *left, *parent;
};
//property
Node *root, *NIL;

void Insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z= new Node;
  z ->key = k;
  z ->left = NIL;
  z ->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x= x->left;
    else x = x-> right;
  }
  z->parent =y;
  if(y == NIL) root = z;
  else {
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}

Node* Find(int k){
  Node *x = root;
  while (x != NIL){
    if(x->key == k) break;
    else if (k < x->key) x = x->left;
    else x = x->right;
  }
  return x;
}


//return minimum key node under x
Node* TreeMinimum(Node* x){
  while(x->left != NIL) x= x->left;
  return x;
}
//
Node* TreeSuccessor(Node* x){
  if(x->right!= NIL)return TreeMinimum(x->right);
  Node* y = x->parent;
  while( y != NIL && x== y->right){
    x= y;
    y = y->parent;
  }
  return y;
}

void Delete(Node* z){
  Node* y; // Delete comp
  Node* x; // child
  if(z->left == NIL || z->right ==NIL) y = z;
  else y = TreeSuccessor(z);
  
  if(y->left != NIL) x = y->left;
  else x= y-> right;
  if(x != NIL) x->parent = y->parent;
  if(y ==  y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  
  if(y != z) z->key = y->key;
  free(y);
}

void Inorder(Node *r){
  if(r == NIL) return;
  Inorder(r->left);
  cout << " " << r->key;
  Inorder(r->right);
}

void Preorder(Node *r){
  if(r == NIL) return;
  cout << " " << r->key;
  Preorder(r->left);
  Preorder(r->right);
}


int main(){

  int m, k;
  string com;
  cin >> m;
  rep(i,m){
    cin >> com;
    if(com == "print"){
      Inorder(root);
      cout << endl;
      Preorder(root);
      cout << endl;
    }else{
      cin >> k;
      if (com == "insert"){
      Insert(k);  
    }else if(com == "find"){
      Node* u = Find(k);
      if(u != NIL) cout << "yes" << endl;
      else cout << "no" << endl;
    }else if(com == "delete"){
      Delete(Find(k));
    }
    }
    
    
  }

  return 0;
}


Measured memory_bytes: 21892
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

int a[110],b[110];
int main() {
	int n,k,ans=0;sc(n),sc(k);
	up(i,1,n)sc(a[i]);
	
	up(l,0,n)
	up(r,l+1,n+1){
		int ind=l+n-r+1,cmp=0;
		if(ind>k)continue;
		
		int cnt=0;
		up(i,1,l)b[++cnt]=a[i],cmp+=a[i];
		up(i,r,n)b[++cnt]=a[i],cmp+=a[i];
		sort(b+1,b+1+cnt);
		int f=1;
		while(b[f]<0&&ind<k&&f<=cnt)cmp-=b[f++],ind++;
		
		ans=max(ans,cmp);
	}
	pr(ans,'\n');
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a-b*2<0?0:a-b*2)<<endl;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;

    replace(s.begin(), s.end(), ',', ' ');

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop())

if __name__ == '__main__':
    ALDS1_3A()

Measured memory_bytes: 7584
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        if (a==b) printf("%d\n",c);
        else if (b==c) printf("%d\n",a);
        else printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define ll            long li
#define ull            unsigned ll
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vll           vector<ll>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;++i)               
#define forr(i,s,n)    for(auto i=s;i>=n;--i) 
const ll MOD = 1e9+7;
const li mx = 1e6+1; 
void solve()
{
    int n,h,w;
    cin>>n>>w>>h;
    cout<<((n-h+1)*(n-w+1))<<endl;
}
int32_t main()
{
    ioS
    int t;
    // cin>>t;
    // while(t--)
        solve();
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a[12];
    cin>>a;
    for(int i=0;i<4;i++){cout<<a[i];}
        cout<<" ";
    for(int i=4;i<12;i++)cout<<a[i];
        cout<<endl;
        return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    set<int> S;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        S.insert(p);
    }
    int big = X + 1, sml = X - 1;
    if (S.count(X)) {
        while (S.count(big)) {
            big++;
        }
        while (S.count(sml)) {
            sml--;
        }
        int bans = abs(X - big), sans = abs(X - sml);
        if (bans < sans) {
            cout << big << endl;
        } else {
            cout << sml << endl;
        }
    } else {
        cout << X << endl;
    }
}

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

int main(){

    int n, k;
    cin >> n >> k;

    int a[k];
    int minn = INT_MAX;
    int maxx = INT_MIN;

    for(int i = 0; i < k; i++){
        a[i] = 0;
    }
    int i = 0;
    while(n){
        a[i]++;
        n--;
        i++;
        if(i == k)i = 0;
    }
    for(int i = 0; i < k; i++){
        minn = min(minn, a[i]);
        maxx = max(maxx, a[i]);
    }

    cout << maxx - minn << endl;

    return 0;
}


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

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

  for (int i=0; i<S.length(); i++){
    S[i] += N;
    if ('Z' < S[i]){
      S[i] -= 26;
    }
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M, X = map(int, readline().split())

res = 0
A = [[0 for j in range(M)] for i in range(N)]
C = [0 for i in range(N)]

for i in range(N):
    line = list(map(int, readline().split()))
    C[i] = line[0]
    A[i] = line[1:]

isPossible = True
for col in range(M):
    tmp = 0
    for row in range(N):
        tmp += A[row][col]
    if tmp < X:
        isPossible = False

if not isPossible:
    print(-1)
    exit()

res = sum(C)
for b in range(1 << N):
    isPossible = True
    tmp = 0
    acc = [0 for j in range(M)]
    for i in range(N):
        if b & 1 << i > 0:
            tmp += C[i]
            for j in range(M):
                acc[j] += A[i][j]

    for j in range(M):
        if acc[j] < X:
            isPossible = False
    if isPossible:
        res = min(res, tmp)
print(res)

Measured memory_bytes: 27152
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c, d := nextInt(), nextInt(), nextInt(), nextInt()
	if abs(a-c) <= d {
		fmt.Println("Yes")
	} else if abs(a-b) <= d && abs(b-c) <= d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
ll dp[110][limit];

int main(void){
	int n,wlimit;
	cin >> n >> wlimit;
	rep(i,n){
		ll w,v;
		cin >> w >> v;
		rep(j,wlimit+1){
			chmax(dp[i+1][j], dp[i][j]);
			if(j + w <= wlimit) chmax(dp[i+1][j + w], dp[i][j] + v);
		}
	}

	ll ans = 0LL;
	rep(j,wlimit+1) chmax(ans, dp[n][j]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 79360
from itertools import combinations_with_replacement
n,m,x=map(int,input().split())

c=[]
a=[]

INF=1001001001
ans=INF

for i in range(n):
  tmp=list(map(int,input().split()))
  c.append(tmp[0])
  a.append(tmp[1:])

for i in range(1<<n):
  cost=0
  skill=[0 for _ in range(m)]
  for j in range(n):
    if (i>>j)&1==1:
      #print("i,j,(i>>j&1)",i,j,(i>>j&1))
      cost+=c[j]
      for k in range(m):
        skill[k]+=a[j][k]
  #print("skill",skill,"i",i)
  flag=True
  for j in range(m):
    if skill[j]<x:
      flag=False
      break
  if flag:
    ans=min(ans,cost)
if ans==INF:
  ans=-1
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int x=a[0],y=a[1];
    set<int> v;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            v.insert(i);
            v.insert(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            v.insert(i);
            v.insert(y/i);
        }
    }
    bool maki;
    auto i=v.end();
    while(1){
        i--;
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%*i){
                if(maki){
                    j=n;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                printf("%d\n", *i);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cstring>
#include <vector>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
const ll maxn = 100010;
const ll mod = 1000000007;

ll arr[maxn];
ll dp[2][maxn];

int main(){
    ll n,k;

    scanf("%lld %lld",&n,&k);

    for(ll i = 1; i <= n; i++){
        scanf("%lld",arr+i);
    }
    dp[0][0] = 1;
    for(ll i = 1; i <= k; i++)  dp[0][i] = 0;
    for(ll i = 1; i <= k; i++)  dp[0][i] = dp[0][i-1] + dp[0][i];
    for(ll i = 1; i <= n; i++){
        for(ll j = 0; j <= k; j++){
            int write_row = i & 1;
            int read_row = 1-write_row;
            int read_col = max(j - arr[i],0LL);
            int sum = dp[read_row][j];
            if(read_col > 0)    sum -= dp[read_row][read_col-1];
            sum = ((sum%mod) + mod)%mod;
            //cerr << i << "," << j << ":" << sum << endl;
            dp[write_row][j] = sum;
        }
        if(i != n){
            for(int j = 1; j <= k; j++){
                dp[i&1][j] = dp[i&1][j-1] + dp[i&1][j];
                dp[i&1][j] %= mod;
            }
        }
    }
    printf("%lld\n",dp[n&1][k]);


}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class Procon2019_B // ←Class名変更！！
{
    public static void Main()
    {
        var n = Ri();
        var s1 = Rs();
        var s2 = Rs();
        var s3 = Rs();

        var count = 0;
        for (int i = 0; i < n; i++)
        {
            if (s1[i] == s2[i] && s2[i] == s3[i])
            {
                continue;
            }

            if (s1[i] == s2[i] || s1[i] == s3[i] || s2[i] == s3[i])
            {
                count++;
            }
            else
            {
                count = count + 2;
            }
        }

        WriteLine($"{count}");
    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
} // Class


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define pb push_back
using namespace std;
using ll = long long;

template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

int main() {
    int H, W; cin >> H >> W;
    vector<string> A(H); rep(i, H) cin >> A[i];
    cout << string(W + 2, '#') << "\n";
    rep(i, H) cout << '#' << A[i] << "#\n";
    cout << string(W + 2, '#') << "\n";
    return 0;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

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

    vector<int> acc(N + 1);
    for (int i = 0; i < N; i++) {
        acc[i + 1] = max(acc[i], A[i]);
    }
    vector<int> acc2(N + 1);
    for (int i = N; i > 0; i--) {
        acc2[i - 1] = max(acc2[i], A[i - 1]);
    }

    for (int i = 0; i < N; i++) {
        cout << max(acc[i], acc2[i + 1]) << endl;
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cstdbool>

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

	std::string str;

	std::size_t N, T;
	std::vector<std::size_t> c, t;

	if( std::getline(std::cin, str) ){
		std::istringstream ss( str );
		ss >> N >> T;
	}

	for( int i = 0; i < N; i++ ){
		std::getline( std::cin, str );
		std::istringstream ss( str );
		size_t c_val, t_val;
		ss >> c_val >> t_val;

		c.push_back( c_val );
		t.push_back( t_val );
	}

	std::size_t min = 1000;
	bool tle_flag = true;

	for( std::size_t i = 0; i < N; i++ ){
		if( t[ i ] <= T ){
			tle_flag = false;

			if( c[ i ] < min ){
				min = c[ i ];
			}
		}
	}

	if( !tle_flag ){
		std::cout << min << std::endl;
	}
	else{
		std::cout << "TLE" << std::endl;
	}

	return 0;
}


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

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0 )
    {
        cout<<"Possible"<<endl;
    }
    else
    {
        cout<<"Impossible"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let n: usize = splited.next().unwrap().parse().unwrap();
    let _: usize = splited.next().unwrap().parse().unwrap();
    let abs = lines.map(|l| {
        let l = l.unwrap();
        let mut ls = l.trim().split_whitespace();
        let a: usize = ls.next().unwrap().parse().unwrap();
        let b: usize = ls.next().unwrap().parse().unwrap();
        (a, b)
    });

    let mut counts: Vec<i32> = vec![0; n];
    for (a, b) in abs {
        counts[a - 1] += 1;
        counts[b - 1] += 1;
    }

    let ans = if counts.iter().all(|n| n % 2 == 0) {
        "YES"
    } else {
        "NO"
    };

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"4 4
1 2
2 4
1 3
3 4",
            br"YES
",
        ),
        (
            br"5 5
1 2
3 5
5 1
3 4
2 3",
            br"NO
",
        ),
    ];

    #[test]
    fn test_b() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n;
  cin >> n;
  ll i = 1;
  bool succeed = false;
  for(i = 1; i <= 1000; i++){
    if(n==i*(i-1)/2){
      succeed = true;
      break;
    }
  }
  if(!succeed){
    cout << "No" << endl;
    return 0;
  }else{
    cout << "Yes" << endl;
  }
  vector<ll> groups[i];
  ll start = 0;
  ll end = 1;
  for(ll j = 1; j <= n; j++){
    groups[start].push_back(j);
    groups[end].push_back(j);
    end++;
    if(end==i){
      start++;
      end = start + 1;
    }else{
    }
  }
  cout << i << endl;
  for(ll k = 0; k < i; k++){
    cout << n*2/i;
    for(auto v: groups[k]){
      cout << " " << v ;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define INL inline
#define REG register
#define DB double
#define LDB long double
#define ULL unsigned long long
#define LL long long

#define RPT(i,x,y) for (REG int i=(x);i<(y);i++)
#define DRPT(i,x,y) for (REG int i=(x);i>(y);i--)
#define MST(a,b) memset((a),(b),sizeof(a))
#define MRK() cout<<"Mark"<<endl;
#define WRT(x) cout<<#x<<" = "<<(x)<<endl;

#define MAXN 10000
#define MAXM 10000
#define MOD 998244353
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-5

#define _ 0
using namespace std;

int main()
{
	int a;
	cin>>a;
	cout<<3*a*a;
	return ~~(0^_^0);
}



Measured memory_bytes: 256
// si < ti !!! si < ti !!! si < ti !!! do you have eyes ???
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 605;
const double inf = (double)0x3f3f3f3f;
int n, m, sons;
bool vis[N];
double ans, f[N];
struct edge { int s, t; }e[N * N];
vector<int> nxt[N];

double calc(int pos) {
    rep(i, 1, n) f[i] = 0;
    for (int x = n - 1; x >= 1; x--) {
        int num = nxt[x].size();
        if (pos == x && num == 1) { f[x] = inf; continue; }
        double t = 1.0 / (num - (pos == x)), mx = 0;
        for (int i = 0; i < num; i++) {
            int y = nxt[x][i];
            f[x] += (f[y] + 1) * t;
            // printf("%d %d %.2lf %.2lf\n", x, y, f[x], f[y]);
            mx = max(mx, (f[y] + 1) * t);
        }
        if (pos == x) f[x] -= mx;
    }
    // rep(i, 1, n) printf("%.2lf ", f[i]); puts("");
    return f[1];
}

int main() {
    cin >> n >> m;
    rep(i, 1, m) {
        scanf("%d%d", &e[i].s, &e[i].t);
        nxt[e[i].s].push_back(e[i].t);
        if (e[i].s == 1) sons++;
    }
    ans = calc(0);

    rep(i, 1, n) ans = min(ans, calc(i));
    printf("%.7lf\n", ans);
    return 0;
}


Measured memory_bytes: 2816
*s, = input()

s.append("")
s.insert(0, "")

r = [0]*len(s)
l = [0]*len(s)

cnt = 0
for i in range(1, len(s)):
    if s[i] == "L":
        if cnt == 0:
            continue

        if cnt%2 == 0:
            r[i] = cnt//2
            r[i-1] = cnt//2
        else:
            r[i] = cnt//2
            r[i-1] = cnt//2 + 1

        cnt = 0
    else:
        cnt += 1

cnt = 0
for i in range(len(s)-2, 0, -1):
    if s[i] == "R":
        if cnt == 0:
            continue

        if cnt%2 == 0:
            l[i] = cnt//2
            l[i+1] = cnt//2
        else:
            l[i] = cnt//2
            l[i+1] = cnt//2 + 1

        cnt = 0
    else:
        cnt += 1

ans = []
for i in range(1, len(s)-1):
    ans.append(r[i]+l[i])
print(*ans)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> numbers(N);
  for (int i = 0; i < N; i++) {
    cin >> numbers.at(i);
  }
  
  sort(numbers.begin(), numbers.end());
  reverse(numbers.begin(), numbers.end());
  
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += numbers.at(i);
    }
    else {
      Bob += numbers.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
      
}




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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

vector<ll> TopologicalSort(ConnectNodeInfo& connect){
	int N=connect.size();
	stack<ll> vertex;
	vector<ll> input(N),sorted;
	REP(i,N){
		for(auto& x:connect[i]) input[x.first]++;
	}
	REP(i,N){
		if(input[i]==0) vertex.push(i);
	}
	while(!vertex.empty()){
		auto v=vertex.top();vertex.pop();
		sorted.push_back(v);
		for(auto& x:connect[v]){
			input[x.first]--;
			if(!input[x.first]) vertex.push(x.first);
		}
	}
	if(sorted.size()!=N) sorted.clear();
	return sorted;
}

ll CalcLongestPathOnDAG(ConnectNodeInfo& connect,vector<ll>& DAG){
	int N=connect.size();
	vll dist(N,-1);
	ll maxD=0;
	REP(i,N){
		if(dist[DAG[i]]<0) dist[DAG[i]] = 0; 
		for(auto& x:connect[DAG[i]]){
			dist[x.first] = max(dist[x.first],dist[DAG[i]]+x.second);
			maxD = max(maxD,dist[x.first]);
		}
	}
	return maxD;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in(),M=in();
	ConnectNodeInfo connect(N);
	REP(i,M){
		auto u=in()-1,v=in()-1;
		connect.AddDirectionalConnection(u,v,1);
	}
	auto V=TopologicalSort(connect);
	out(CalcLongestPathOnDAG(connect,V));
	return 0;
}


Measured memory_bytes: 10540
#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 fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 1000000007
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 300003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long n,m,s,t,u,v,w,dist1[mx],dist2[mx],dp1[mx],dp2[mx];
vector<pair<long long,long long>>g[mx];
set<pair<int,int>>ini;
int main(){
	cin>>n>>m>>s>>t;
	for(int i=0;i<m;i++){
		cin>>u>>v>>w;
		g[u].pb({v,w});
		g[v].pb({u,w});
	}
	priority_queue<pair<long long,int>>q;
	q.push({0,s});
	for(int i=1;i<=n;i++)dist1[i]=dist2[i]=1e18;
	dist1[s]=0;
	while(!q.empty()){
		auto now=q.top();
		q.pop();
		for(auto i:g[now.s]){
			long long nxt=-now.f+i.s;
			if(dist1[i.f]>nxt){
				dist1[i.f]=nxt;
				q.push({-nxt,i.f});
			}
		}
	}
	q.push({0,t});
	dist2[t]=0;
	while(!q.empty()){
		auto now=q.top();
		q.pop();
		for(auto i:g[now.s]){
			long long nxt=-now.f+i.s;
			if(dist2[i.f]>nxt){
				dist2[i.f]=nxt;
				q.push({-nxt,i.f});
			}
		}
	}
	for(int i=1;i<=n;i++)q.push({-dist1[i],i});
	dp1[s]=1;
	while(!q.empty()){
		auto now=q.top();
		q.pop();
		//cout<<"ini ";
		//debug(now.s);
		for(auto i:g[now.s]){
			if(dist1[i.f]==-now.f+i.s){
				//debug(now.s);
				//debug(i.f);
				dp1[i.f]=(dp1[i.f]+dp1[now.s])%MOD;
			}
		}
	}
	for(int i=1;i<=n;i++)q.push({-dist2[i],i});
	dp2[t]=1;
	while(!q.empty()){
		auto now=q.top();
		q.pop();
	//	cout<<"ini ";
	//	debug(now.s);
		for(auto i:g[now.s]){
			if(dist2[i.f]==-now.f+i.s){
				//debug(now.s);
				//debug(i.f);
			//	debug(now.s);
			//	debug(i.f);
				dp2[i.f]=(dp2[i.f]+dp2[now.s])%MOD;
			}
		}
	}
	long long node=0,edge=0;
	for(int i=1;i<=n;i++){
		if(dist1[i]==dist2[i] && dist1[i]+dist2[i]==dist1[t]){
			long long sem=(dp1[i]*dp2[i])%MOD;
			node=(node+(sem*sem)%MOD)%MOD;
		}
	}
	for(long long i=1;i<=n;i++){
		for(auto j:g[i]){
			if(dist1[i]+j.s+dist2[j.f]==dist1[t] && dist1[i]*2<dist1[t] && dist2[j.f]*2<dist1[t]){
				long long sem=(dp1[i]*dp2[j.f])%MOD;
				edge=(edge+(sem*sem)%MOD)%MOD;
			}
		}
	}
	long long jaw=(dp1[t]*dp2[s])%MOD;
//	debug(dp1[t]);
//	debug(dp2[s]);
//	debug(node);
//	debug(edge);
	jaw-=node;
	jaw%=MOD;
	if(jaw<0)jaw+=MOD;
	jaw-=edge;
	jaw%=MOD;
	if(jaw<0)jaw+=MOD;
	cout<<jaw<<endl;
}




Measured memory_bytes: 28784
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main(void){
    string s;
    cin >> s;
    ll count = 0;
    while(s.length() > 0){
        count = s.length();
        string five = s.substr(count-5, 5);
        string six = s.substr(count-6, 6);
        string seven = s.substr(count-7, 7);
        //cout << five << " " << six << " " << seven << endl;
        if(seven=="dreamer")
            count = 7;
        else if(six=="eraser")
            count = 6;
        else if(five=="dream" || five=="erase")
            count = 5;
        else{
            cout << "NO" << endl;
            break;
        }
        for(ll i = 0; i < count; i++)
            s.pop_back();
        if(s == "dream" || s == "dreamer" || s == "erase" || s == "eraser"){
            cout << "YES" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i, n;
  int *N;

  scanf("%d", &n);

  N = (int *)malloc(sizeof(int) * (n + 1));

  for(i = 1; i <= n; i++){
    scanf("%d", &N[i]);
  }

  for(i = 1; i <= n; i++){
    printf("node %d: key = %d, ", i, N[i]);

    if(i != 1) printf("parent key = %d, ", N[i / 2]);

    if(2 * i + 1 <= n) printf("left key = %d, right key = %d, ", N[2 * i], N[2 * i + 1]);

    else if(2 * i <= n) printf("left key = %d, ", N[2 * i]);

    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int h,w;
    cin>>h>>w;
    vector<string>grid(h);
    for(int i=0;i<h;i++) cin>>grid[i];
    map<char,int>mp;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            mp[grid[i][j]]++;
        }
        
    }
    vector<int>v(30);
    for(char moji='a';moji<='z';moji++){
        v[moji-'a']=mp[moji];
    }
   int four=(h/2)*(w/2);
   int one=0;
   if(h%2==1 &&w%2==1) one=1;
   int two = (h*w-4*four-one)/2;
   while(four--){
       bool ok=false;
       for (int i = 0; i < 26; i++)
       {
           if(v[i]>=4) {
               v[i]-=4;
               ok = true;
               break;
           }
       }
       if(!ok) {
           cout<<"No"<<endl;
           return 0;
       }
       
   }
   while(two--){
       bool ok=false;
       for (int i = 0; i < 26; i++)
       {
           if(v[i]>=2) {
               v[i]-=2;
               ok = true;
               break;
           }
       }
       if(!ok) {
           cout<<"No"<<endl;
           return 0;
       }
       
   }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi = sorted(sushi, key=lambda x: x[1], reverse=True)
typ = set()
lstA = []
lstB = []
for item in sushi:
    if item[0] in typ:
        item[0] = 0
        lstB.append(item[1])
    else:
        typ.add(item[0])
        item[0] = 1
        lstA.append(item[1])
ans = 0
neta = 0
for i in range(K):
    ans += sushi[i][1]
    if sushi[i][0] == 1:
        neta += 1
ans += neta ** 2
C = sum(lstA[:neta])
D = sum(lstB[:K - neta])
for i in range(neta + 1, min(K, len(lstA)) + 1):
    C += lstA[i - 1]
    D -= lstB[K - i]
    tmp = C + D + i ** 2
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 34236
#include <iostream>

using namespace std; 

int input1; 
int input2;

int main () { 
    cin >> input1 >> input2;
    int total = (input1 * 3) + input2;
    int pies = 0;
    while(total>=2){
        total = total - 2;
        pies = pies + 1;
    }


    cout << pies;

    return 0;
}

Measured memory_bytes: 256
// Problem : C - Chocolate Bar
// Contest : AtCoder - AtCoder Beginner Contest 062
// URL : https://atcoder.jp/contests/abc062/tasks/arc074_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
int calc(int val,int left,int w)
{
	int ans;
		int val2=left*(w/2);
		int val3=left*((w+1)/2);
		int mx=max2(val,max2(val2,val3));
		int mi=min2(val,min2(val2,val3));
		ans=mx-mi;
	int val4=(left/2)*w;
	int val5=(left+1)/2*w;
	mx=max2(val,max2(val4,val5));
	mi=min2(val,min2(val4,val5));
	ans=min2(ans,mx-mi);
	return ans;
}
void solve()
{
int h,w;
cin>>h>>w;
int ans=INF;
for(int i=1;i<=h-1;i++)
{
	ans=min2(ans,calc(i*w,h-i,w));
	//cout<<ans<<" ";
}
//cout<<"\n";
for(int i=1;i<=w-1;i++)
{
	//cout<<ans<<" ";
	ans=min2(ans,calc(i*h,w-i,h));
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(zz) for zz in input().split()]
B = [0]*N

tmp = 0
for i in range(N):
    if i%2 == 0:
        tmp += A[i]*2
    else:
        tmp -= A[i]*2

B[0] = int(tmp/2)
for i in range(1,N):
    B[i] = A[i-1]*2 - B[i-1]

[print(i, end=' ') for i in B]


Measured memory_bytes: 14024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int n;
    int i, j = 0;
    string s, ans;
    
    cin >> s;
    
    n = s.size();
    
    for(i = 0; i < n; i++) {
        
        if(s[i] != 'B') {
            ans[j] = s[i];
            j++;
        } else {
            if(j != 0) {
                ans[j-1] = -1;
                j = j - 1;
            }
        }
    }
    
    for(i = 0; i < j; i++) {
        cout << ans[i];
    }
    
    cout << endl;
    
    return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  string s;
  cin >> s;
  int n=s.length()-1;
  ll ans=0;
  for(int bit=0; bit< (1<<n); bit++){
    ll plusbefore=s[0]-'0';
    rep(i, n){
      if(bit&(1<<i)){
        ans+=plusbefore;
        plusbefore=0;
      }
      plusbefore=plusbefore*10+s[i+1]-'0';
    }
    ans+=plusbefore;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,p,i,a[50];
main(){
	for(;~scanf("%d", &n),n;) {
		for(i=0;i<n;i++)scanf("%d",&a[i]);p=0;
		for(i=1;i<n;i++){
			if(a[i-1]+1!=a[i]) {
				if(i-p-1)printf("%d-%d ",a[p],a[i-1]);
				else printf("%d ",a[p]);
				p=i;
			}
		}
		if(n-p-1)printf("%d-%d\n",a[p],a[n-1]);
		else printf("%d\n",a[p]);
	}
	exit(0);
}

Measured memory_bytes: 596
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,k,c=0;
    for ( ; ; )
    {
        scanf("%d",&x);
        if (x ==0)
        {
            break;
        }
        else
        {
            c++;
            printf("Case %d: %d\n",c,x);
        }
    }
    return 0;
}



Measured memory_bytes: 3112
#define _USE_MATH_DEFINES

#include <bits/stdc++.h> 
  
using namespace std;
  
#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second    
#define int long long
#define double long double       
#define vec vector            
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double> 
#define beg begin
  
#ifdef LOCAL
    #define dbg(x) cerr << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    // freopen("output.txt", "w", stdout);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
    cout.setf(ios::fixed); cout.precision(9);    
    solve();   
    return 0;
} 

void solve() {
    int n;
    cin >> n;
    int cnt = 0;
    while (n > 0) {
        cnt++;
        n /= 2;
    }

    cout << (1ll << cnt) - 1 << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
const ll MAX = 2e5;

sl point[MAX+1];
vl counter(MAX+1), root_of_cnt(MAX+1);

void dfs(ll p) {
  counter[p] += root_of_cnt[p];
  for (ll i: point[p]) {
    point[i].erase(p);
    counter[i] = counter[p];
    dfs(i);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll N, Q;
  cin >> N >> Q;
  
  rep(i, N-1) {
    ll a, b;
    cin >> a >> b;
    point[a].insert(b);
    point[b].insert(a);
  }
  
  rep(i, Q) {
    ll p, x;
    cin >> p >> x;
    root_of_cnt[p] += x;
  }
  
  dfs(1);
  
  rep2(i, N) cout << counter[i] << " ";
  return 0;
}

Measured memory_bytes: 52352
'use strict';

const main = input => {
  input = input.split('\n');
  const N = Number(input[0]);
  const A = input[1]
    .trim()
    .split(' ')
    .map(Number);
  bubbleSort(A, N);
};

function bubbleSort(A, N) {
  let flag = true;
  let count = 0;
  while (flag) {
    flag = false;
    let i = 0;
    for (let j = N - 1; j >= i + 1; --j) {
      if (A[j - 1] > A[j]) {
        const tmp = A[j];
        A[j] = A[j - 1];
        A[j - 1] = tmp;
        flag = true;
        ++count;
      }
    }
    ++i;
  }
  console.log(A.join(' '));
  console.log(count);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15412
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] l = new Integer[n];
        for (int i = 0; i < n; i++) {
            l[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(l);
        int sum = 0;
        for (int length : l) {
            sum += length;
        }

        boolean result = sum - l[n - 1] > l[n - 1];

        System.out.println(result ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  string s;
  cin>>s;
  if(s=="A")cout<<"T"<<endl;
  else if(s=="T")cout<<"A"<<endl;
  else if(s=="G")cout<<"C"<<endl;
  else if(s=="C")cout<<"G"<<endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int_fast64_t ll;
// inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}

int main() {
    // fastio();
    int N, M, a, b, s, t;
    bool f;
    cin >> N >> M;
    vector<vector<int>> G(N + 1, vector<int>(0));
    REP(i, M) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    s = 1;
    t = G[s][0];
    list<int> ans = {s, t};
    vector<int> visited(N + 1, 0);
    visited[s] = visited[t] = 1;
    while(true) {
        visited[s] = 1;
        f = false;
        for(auto& x : G[s]) {
            if(visited[x] == 0) {
                s = x; f = true;
                ans.push_front(s);
                break;
            }
        }
        if(f) continue;
        break;
    }
    while(true) {
        visited[t] = 1;
        f = false;
        for(auto& x : G[t]) {
            if(visited[x] == 0) {
                t = x; f = true;
                ans.push_back(t);
                break;
            }
        }
        if(f) continue;
        break;
    }
    cout << ans.size() << "\n";
    for(auto it = ans.begin(); it != ans.end(); it++) cout << *it << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 9856
from bisect import bisect_right as bir
N, K = map(int, input().split())

t = [K]
i = K
while i > 1:
    i += 1
    i //= 2
    t.append(i)
t.sort()
l = len(t)


def log(i):
    return l - bir(t, i)


ans = 0
for i in range(1, N+1):
    ans += 0.5**log(i)/N

print(ans)


Measured memory_bytes: 3060
n=int(input())
a=[0]*n;b=a[:]
for i in range(n):
  c,d=map(int,input().split())
  a[i]=c;b[i]=d
ans=0
for i in range(n)[::-1]:
  a[i]+=ans
  if a[i]%b[i]==0:continue
  ans+=b[i]-(a[i]%b[i])
print(ans)


Measured memory_bytes: 14836
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new ABC045().doIt();
	}
	class ABC045{
		long ans = 0;
		void doIt(){
			String str = sc.next();
			int length = str.length();
			dfs(str,length,0,0);
			System.out.println(ans);
		}
		void dfs(String str,int length,int Pos,long sum) {
			for(int i = Pos+1;i <= length;i++) {
				long num = Long.parseLong(str.substring(Pos, i));
				dfs(str,length,i,sum + num);
			}
			if(Pos == length) {
				ans = ans + sum;
			}
		}
	}
}


Measured memory_bytes: 23380
H, M, C = map(int,input().split())
B = list(map(int,input().split()))
A = []
for i in range(H):
    a = list(map(int,input().split()))
    A.append(a)

count = 0
for i in range(H):
    naiseki = [x * y for x,y in zip(B,A[i])]
    if sum(naiseki,C) > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
{$goto+}
uses math;
label 1;
var s:ansistring;
    i,j,t,p,x:longint;
begin
  readln(s);
  for i:=1 to length(s) do
    if s[i]<>'9' then
      goto 1;
  writeln(length(s)*9);
  halt;
  1:
  for i:=1 to length(s) do
  begin
    for j:=1 to i do
      inc(p,ord(s[j])-48);
    for j:=i+1 to length(s) do
      inc(p,9);
    t:=max(t,p-1);
    p:=0;
  end;
  for i:=1 to length(s) do
    inc(p,ord(s[i])-48);
  writeln(max(p,t));
end.

Measured memory_bytes: 256
from collections import deque
N, M = list(map(int, input().split()))

g = [[] for _ in range(N)]
sign = [-1 for _ in range(N)]

for _ in range(M):
    a, b = list(map(int, input().split()))

    g[a-1].append(b-1)
    g[b-1].append(a-1)

queue = deque()
queue.append(0)

while len(queue) > 0:

    now = queue.popleft()

    for adj in g[now]:
        if sign[adj] == -1:
            queue.append(adj)
            sign[adj] = now


allVisited = True

for i in range(1, len(sign)):
    if sign[i] == -1:
        allVisited = False

if not allVisited:
    print("No")
    exit()

else:
    print("Yes")
    for i in range(1, len(sign)):
        print(sign[i]+1)


Measured memory_bytes: 99764