akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){
 int h,w;
  cin >> h >> w;
  char s[h+2][w+2];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >>s[i][j];
    }
  }
  
  bool res=true;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
    if(s[i][j]=='#'&&s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#'){
    res=false;
      break;
    } 
    }
  }

 if(res) cout << "Yes" << endl;
  else cout << "No" << endl;



}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	VI a(10); rep(i, 10)cin >> a[i];
	cout << accumulate(all(a), 0) << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	
	int n; scanf("%d", &n);
	int a[n], cnt[n] = {0};
	for(int i = 1; i<n; i++){
		int j; cin>>j; j--;
		cnt[j]++;
	}
	for(int i = 0; i<n; i++){
		cout<<cnt[i]<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 4552
#include <iostream>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N];
    int n, u, k, v;
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++)M[i][j]=0;
    }
    
    for(int i=0; i<n; i++){
        cin >> u>> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j)cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
    N-=A.at(i);
  }
  if(N>-1)
    cout<<N<<endl;
  else
    cout<<"-1"<<endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    ll a,b,n;cin>>a>>b>>n;
    cout << max(0LL,a*min(n,b-1)/b);
}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

const int kMaxN = 200001;

int a[kMaxN], b[kMaxN], c[kMaxN], d[kMaxN];
int n, x;

bool C() {
  for (int i = 1; i <= n; i++) {
    if (c[a[i]] + d[a[i]] > n) {
      return 0;
    }
  }
  for (int i = 1, j = 0; i <= n; i++) {
    for (; i < n && a[i + 1] == a[i]; i++) {
    }
    for (j = max(j, i + 1); c[a[i]]; j++) {
      if (b[(j - 1) % n + 1]) {
        c[b[(j - 1) % n + 1]]++;
      }
      b[(j - 1) % n + 1] = a[i];
      c[a[i]]--;
    }
  }
  for (int i = 1, j = 1; i <= n; i++) {
    if (!b[i]) {
      for (; !c[j]; j++) {
      }
      b[i] = j;
      c[j]--;
    }
  }
  return 1;
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    c[x]++;
  }
  if (C()) {
    cout << "Yes" << endl;
    for (int i = 1; i <= n; i++) {
      cout << b[i] << " ";
    }
  } else {
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 6716
#include<iostream>
#include<cstring>

using namespace std;

int H, W;
int grid[105][105], memo[105][105][2];

int findRoute(int row, int col, int black){
    if(memo[row][col][black] != -1) return memo[row][col][black];

    if(grid[row][col] == 1){
        if(row == H && col == W) return black;
        if(row == H) return memo[row][col][black] = findRoute(row, col+1, 0) + black;
        if(col == W) return memo[row][col][black] = findRoute(row+1, col, 0) + black;
        return memo[row][col][black] = min(findRoute(row+1, col, 0), findRoute(row, col+1, 0)) + black;
    }

    if(grid[row][col] == 0){
        if(row == H && col == W) return 0;
        if(row == H) return memo[row][col][black] = findRoute(row, col+1, 1) ;
        if(col == W) return memo[row][col][black] = findRoute(row+1, col, 1) ;
        return memo[row][col][black] = min(findRoute(row+1, col, 1), findRoute(row, col+1, 1)) ;
    }

    return 121;
}

int main(){
    memset(grid, 0, sizeof(grid));
    memset(memo, -1, sizeof(memo));
    cin >> H >> W;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            char c;
            cin >> c;
            if(c == '#') grid[i][j] = 1;
        }
    }

    cout << findRoute(1, 1, 1) << endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=1e9+7;
const long double PI = acos(0);
template <class T>void UNIQUE(vector<T> &x){
	sort(all(x));
	x.erase(unique(all(x)), x.end());
}

// }}} End Header
int main() {
	ll x, k, d, ans = 0;
	cin >> x >> k >> d;
	if(abs(x)/d >= k) ans = abs(x)-k*d;
	else{
		ll a = abs(x)%d;
		ll b = d-a;
		ll c = (abs(x)-a)/d;
		if(c%2 == k%2) ans = a;
		else ans = b;
	}

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

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

int main(){
  
  while(1){
    int h,w; cin >> h >> w;
    if(h==0)break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
	if((i+j) % 2 == 0)
	  cout << "#";
	else
	  cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }

}

Measured memory_bytes: 1152
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n, a := readLengthAndSlice()
	min := a[0]
	mini := 0
	max := a[0]
	maxi := 0
	for i, v := range a {
		if v < min {
			min = v
			mini = i
		}
		if max < v {
			max = v
			maxi = i
		}
	}

	if min == 0 && max == 0 {
		println(0)
		return
	}

	var d, di int
	if absInt(min) < absInt(max) {
		d = max
		di = maxi
	} else {
		d = min
		di = mini
	}
	println(2*n - 1)
	for i := 0; i < n; i++ {
		println(di+1, i+1)
	}
	if d > 0 {
		for i := 1; i < n; i++ {
			println(i, i+1)
		}
	} else {
		for i := n; i > 1; i-- {
			println(i, i-1)
		}
	}
}

// -----------------------------------------------------------------------------

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

int num[5];

int main()
{
	

		for( int i=0;i<5;i++)
		{
			cin >> num[i];
		}

		sort(num, num+5, greater<int>());

		cout << num[0] <<" "<< num[1] <<" "<< num[2] <<" "<< num[3]<<" "<< num[4] <<endl;


	return 0;
}

Measured memory_bytes: 0
// Last Change: 04/16/2019 23:27:08.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  cout << H * W - h * W - w * H + h * w;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>

#include <cmath>
#include <map>
#include <cstdlib>


using namespace std;

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


  int x = a[0];
  for(int i = 1; i < N; i++){
    x = (x xor a[i]);
  }

  if(x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

template<typename T>
T lcm(T a, T b) {
    ll g = gcd(a, b);
    return a / g * b;
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];
    cout << (sum - n) << endl;
}


Measured memory_bytes: 256
import java.util.*;


class Main{
    static long mod = 1000000007;
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String[] N = sc.nextLine().split("");
        for(int i=0;i<3;i++){
            if(N[i].equals(N[i+1])){
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>


using namespace std;

int main(void)
{
    string S, T;
    cin >> S >> T;

    int ans(0);

    for(int i=0; i < S.size(); i++){
        if(S[i] != T[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3920
"""
author : halo2halo
date : 19,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
words = readline().rstrip()
preword = '1'
ans = 0
for word in words:
    if preword != word:
        ans += 1
        preword = word

print(ans)


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,x;
	cin >>n;
	vector<pii> a(n);
	rep(i,n){
		int za; cin >>za;
		a[i] = pii(za, i);
	}
	sort(all(a));
	
	//for(auto x :a) printf("%d:%d, ",x.first,x.second); puts("");

	VI ck(n);
	rep(i, n){
		if(i < n/2) ck[a[i].second] = 0;
		else ck[a[i].second] = 1;
	}
	
	rep(i,n){
		cout << (ck[i]? a[(n-1)/2].first : a[n/2].first) <<"\n";
	}
	return 0;
	
}


Measured memory_bytes: 4480
class Stack:
    def __init__(self):
        self.top = 1
        self.array = [None]*1000

    def push(self, x):
        if not self.isFull():
            self.array[self.top] = x
            self.top += 1
        else:
            raise ValueError()

    def pop(self):
        if not self.isEmpty():
            self.top -= 1
            val = self.array[self.top]
            return val
        else:
            raise ValueError()

    def isEmpty(self):
        if self.top == 1:
            return True
        else:
            return False

    def isFull(self):
        if self.top >= 999:
            return True
        else:
            return False


def main():
    S = input().split()
    stack = Stack()
    operands = ["+", "-", "*"]
    for s in S:
        if s not in operands:
            stack.push(int(s))

        else:
            val1 = stack.pop()
            val2 = stack.pop()
            if s == "+":
                val = val1 + val2
                stack.push(val)
            elif s == "-":
                val = val2 - val1
                stack.push(val)
            else:
                val = val1 * val2
                stack.push(val)
    ans = stack.pop()
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	ans = (n - 1) * (n) / 2;
	cout << ans;
	return 0;
}


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

void solve () {
    string s;
    cin >> s;
    int n = (int) s.size();
    string corr, corr2;
    for (int i = 0; i < n; i++) {
        corr += i % 2 ? '1' : '0';
        corr2 += i % 2 ? '0' : '1';
    }
    vector<int> ans(2);
    for (int i = 0; i < n; i++) {
        if (s[i] != corr[i]) {
            ans[0]++;
        }
        if (s[i] != corr2[i]) {
            ans[1]++;
        }
    }
    cout << min (ans[0], ans[1]);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


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

int main(){
  int n,mmm=0,sum=0;
  cin >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++){
    cin >> data[i];
    mmm=max(mmm,data[i]);
    sum+=data[i];
  }
  
  cout << sum-(mmm/2) << endl;
}
  


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

using namespace std;

const int N = 1e5 + 5;
int dp[N], h[N];

int solve(int x) {
    if (dp[x] != -1)
        return dp[x];
    return dp[x] = min(abs(h[x]-h[x-2]) + solve(x-2), abs(h[x] - h[x-1]) + solve(x-1));
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i<=n; i++) {
        cin >> h[i];
        dp[i] = -1;
    }
    dp[1] = 0, dp[0] = 0, dp[2] = abs(h[2]-h[1]);
    cout << solve(n) << endl;
    return 0;
}


Measured memory_bytes: 5760
import java.io.*
import java.util.*

fun solve(n: Long, m: Long){
    println((n-1)*(m-1))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val n = sc.next().toLong()
    val m = sc.next().toLong()
    solve(n, m)
}



Measured memory_bytes: 31136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    ll h,w; cin >> h >> w;
    if(h%3 == 0 || w%3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(h,w);
    ll a,b,c;
    rep(i,h+1){
        int W  = w/2;
        a = i*w;
        b = (h-i)*W;
        c = (h-i)*(w-W);
        chmin(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
    rep(i,w+1){
        int H  = h/2;
        a = i*h;
        b = (w-i)*H;
        c = (w-i)*(h-H);
        chmin(ans,max(a,max(b,c))-min(a,min(b,c)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n,d = (int(i) for i in input().split())  

e = np.array([[int(i) for i in input().split()] for i in range(n)] )

count = 0

for i in range(len(e)):
    for j in range(len(e) - i - 1):
        k = j + i + 1
        dist = np.sum((e[i] - e[k])**2)
        if dist**0.5 == int(dist**0.5):
            count += 1
print(count)

Measured memory_bytes: 13392
n = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)

Measured memory_bytes: 13880
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;
    map<int, int> a;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        a[v]++;
    }

    int res = 0;
    for (auto it = a.rbegin(); it != a.rend(); it++) {
        if (it->first & (it->first - 1)) {
            int v = 1;
            while (v <= it->first) v <<= 1;
            auto p = a.find(v - it->first);
            if (p != a.end()) {
                int d = min(it->second, p->second);
                it->second -= d;
                p->second -= d;
                res += d;
            }
        } else 
            res += it->second / 2;
    }

    cout << res << endl;





}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
        
    // }
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0){
            continue;
        }
        sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int Max=0;
  vector<int> card(N);
  int count=0;

  for(int i=0;i<N;i++)
    cin>>card.at(i);
  
  for(int j=0;j<N;j++){
    Max=0;
    for(int i=0;i<N;i++){
      if(card.at(i)>Max)
        Max=card.at(i);
    }
    for(int i=0;i<N;i++){
      if(card.at(i)==Max){
        card.at(i)=0;
        break;
      }
    }
    if(j%2==0)
      count+=Max;
    else
      count-=Max;
  }
  cout<<count<<endl;
}

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

int main(void){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if(s < t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
Author : Harsh AKA Codula
*/
#include<iostream>

using namespace std;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define deb(x) cout<<"["<<#x<<"="<<x<<"]"<<"\n";
#define FOR(a,b) for(ll i=a;i<b;++i)
#define read(x) for(auto& i:x)cin>>i
#define pb push_back

class MAIN
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
				ll n,ans=0;
				cin>>n;
				for(ll i=1;i<n;++i)
				{
					if(n%i==0)
					{
						ans+=((n/i)-1);
					}
					else
					{
						ans+=(n/i);
					}
				}
				cout<<ans;
				cout<<"\n";
			}
		}	
};

int main()
{
	fast;
	MAIN solution;
	solution.run();
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main(){
    int N,M; cin>>N>>M;
    vector<int> prime;
    for(int i=1;i<sqrt(M)+1;++i){
        if(M%i==0) {
            prime.push_back(i);
            prime.push_back(M/i);
        }
    }

    sort(prime.begin(),prime.end());
    int inv=*lower_bound(prime.begin(),prime.end(),N);

    cout<<M/inv<<endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i,alice=0,bob=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n,greater<int>());
  for(i=0;i<n;i++){
    if(i%2==0)
      alice += a[i];
    if(i%2==1)
      bob += a[i];
  }
  cout << alice-bob;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {



        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] s = new String[N];
        HashMap<String,Integer> hashMap = new HashMap<String, Integer>();
        for(int i=0;i<N;i++){
            s[i] = sc.next() + String.format("%3d",100-sc.nextInt());
            hashMap.put(s[i],i);
        }

        Arrays.sort(s);

        for(int i=0;i<N;i++){
            System.out.println(hashMap.get(s[i])+1);
        }


    }



}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;
const int Nmax = 2e5 + 5, Mod = 1e9 + 7;

int n, i, j, a[105][105], dp[105][105];

int main()
{
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=2; ++i)
        for(j=1; j<=n; ++j)
            cin >> a[i][j];

    for(i=1; i<=2; ++i)
        for(j=1; j<=n; ++j)
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + a[i][j];

    cout << dp[2][n] << '\n';
    return 0;
}


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

int main() {
  int N, K, sum = 0;
  
  cin >> N >> K;
  for(int i = 1; i <= N; i++) {
    int x;
    cin >> x;
    if(x < K-x) {
      sum = sum + 2 * x;
    }else {
      sum = sum + 2 * (K - x);
    }
  }
  cout << sum << endl;
}



Measured memory_bytes: 256
import sys
import os


time=0
tmax=10
for i in range(5):
    a=int(input())
    if a%10==0:
        time +=a
    else:
        time += a-a%10+10
        tmax=min(tmax,a%10)
    #tmin=max(tmax,a%10)
print(time+tmax-10)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, sum = 0;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	cout << (sum % 2 ? "NO" : "YES") << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;


vector<string> v;
void f(lli n, string X = "") {
    if(X.size() == n) {
//        cout<<X<<endl;
        v.push_back(X);
        return ;
    }
    if(X.size() > n) {
        return ;
    }
    if(X.size() == 0) {
        for(char i = '1'; i <= '9'; i ++) {
            f(n, (string)(X + i));
        }
        return ;
    }

    lli len = X.size();
    len --;
    if(X[len] != '0')
        f(n, X + (char)(X[len] - 1));
    f(n, X + (char)(X[len]));
    if(X[len] != '9')
        f(n, X + (char)(X[len] + 1));
    return ;
}

void solve()
{
    for(int i = 1; i <= 10; i ++ ) {
        f(i);
    }
//    sort(v.begin(), v.end());
//    for(auto it : v)
//        cout<<it<<' ';
    lli n;
    cin>>n;
    cout<<v[n - 1];
    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 13936
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int n, m;
int a[100][100];
int b[100];

int main() {
    cin >> n >> m;
    rep(i, n) rep(j, m) cin >> a[i][j];
    rep(i, m) cin >> b[i];

    for (int i = 0; i < n; i++) {
        int c = 0;
        for (int j = 0; j < m; ++j) {
            c += a[i][j] * b[j];
        }
        cout << c << endl;
    }
}



Measured memory_bytes: 3100
#coding: UTF-8
import sys
import os
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
m=list(map(int,input().split()))
k=lcm_list(m)
k=k-1
answer=0
for i in range(n):
    answer=answer+(k%m[i])
print(answer)

Measured memory_bytes: 5716
j,p[1<<20],n;
main(i)
{
	for(;++i<999;)
		for(j=i+i;!p[i]&j<1<<20;j+=i)
				p[j]=1;
	for(;scanf("%d",&n),j=0,n;printf("%d\n",j))
		for(i=2;i<=n/2;i++)j+=!p[i]&!p[n-i];
	exit(0);
}

Measured memory_bytes: 4500
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

constexpr int num = 3;

int n, cnt[num];		 //0:a, 1:b, 2:c
vector<vector<int>> abc, dp; //0:a, 1:b, 2:c

int maxh_without_j(int i, int j) {
	int hx = dp[(j + 1) % num][i - 1];
	int hy = dp[(j + 2) % num][i - 1];
	return max(hx, hy);
}



int main(void) {
	cin >> n;
	abc = vector<vector<int>>(num, vector<int>(n + 1, 0));
	dp = vector<vector<int>>(num, vector<int>(n + 1, 0));
	for (int i = 1; i < n + 1; i++)
		cin >> abc[0][i] >> abc[1][i] >> abc[2][i];

	dp[0][1] = abc[0][1];
	dp[1][1] = abc[1][1];
	dp[2][1] = abc[2][1];

	for (int i = 2; i < n + 1; i++) {
		for (int j = 0; j < num; j++) {
			dp[j][i] = abc[j][i] +  maxh_without_j(i, j);
		}
	}
	cout << max({ dp[0][n], dp[1][n] , dp[2][n] }) << endl;
	return 0; {}
}

Measured memory_bytes: 5820
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define REP(i,a,b) for(int i = a ; i <= b ; ++i) 
# define Rep(i,a,b) for(int i = a ; i < b ; ++i) 
# define Rrep(i,a,b) for(int i = b ; i >= a ; --i) 
# define FOR(i,b) for(int i = 0 ; i <= b ; ++i)
# define For(i,b) for(int i = 0 ; i < b ; ++i)
# define Rfor(i,b) for(int i = b ; i >= 0 ; --i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

void pe(int a) { cout << a << "\n" ; }
void pe(ll a) {	cout << a << "\n" ; }
void pe(string a) {	cout << a << "\n" ; }
void ps(int a) { cout << a << ' ' ; }
void ps(string a) {	cout << a << " " ; }
void ps(ll a) {	cout << a << " " ; }
template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 998244353 ; 

ll nCr(ll n,ll r){
	ll res=1;
	if(r>n) return 0;
	if(r>n-r) r=n-r;
	for(ll i=0;i<r;i++) {
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}
ll power(ll a , ll n)
{
	ll res = 1;
	while(n)
	{
		if(n & 1)
			res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res%MOD;
}

const ll inf = 1e18 ; 
const int MxN = 300005; 
const ll mod = 1e9+7 ; 

vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============

void solve() {
	

}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
 	
	ll n ,a ,b ; 
	cin >> n >> a >> b ; 
	if(b < a) {
		cout << 0 ; 
		return 0 ; 
	}
	if(n==1) {
		if(a==b) {
			cout << 1 ; 
		} else {
			cout << 0 ; 
		}
		return 0; 
	}

	ll minsum = (n-1)*a+b ; 
	ll maxsum = (n-1)*b+a;
	cout << maxsum - minsum + 1 ; 


	cerr <<"\nTime : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
	return 0 ; 
}

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

int main(){
	int N, M;
	int a[1000];
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int b, c;
		cin >> b >> c;
		a[i] = max(N - b, 0);
	}
	sort(a, a + M);
	int ans = 0;
	for(int i = 0; i < M - 1; i++) ans += a[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    ll M = 1;
    while( N > 0 ){
        if(N / 10 == 0){
            break;
        }
        N /= 10;
        M++;
    }
    return M;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    ll g[n][n];
    for(ll i=0;i<n;++i){
        for(ll j=0;j<n;++j){
            if(i == j){
                g[i][j] = 0;
            }else{
                g[i][j] = INF;
            }
        }
    }
    vector<ll> a(m), b(m), c(m);
    for(ll i=0;i<m;++i){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
        g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
        g[b[i]][a[i]] = min(g[b[i]][a[i]], c[i]);
    }

    for(ll k=0;k<n;++k){
        for(ll i=0;i<n;++i){
            for(ll j=0;j<n;++j){
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    ll ans = m;
    for(ll i=0;i<m;++i){
        bool flag = false;
        for(ll j=0;j<n;++j){
            if(g[j][a[i]] + c[i] == g[j][b[i]]){
                flag = true;
            }
        }
        if(flag){
            ans--;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 384
def lower_bound(al, key):
    """
    一般に左側が満たしておらず、右側は満たしている判定基準(境目は一つ)ならlower_boundになる
    (条件を満たすもののうち、最小のインデックスを返す)
    単調にさえなっていれば、左右が逆になっていても検索には使える(ng/okも一緒に逆にする必要がある)
    """
    def isOk(a):
        # alの中でkey以上のアイテムのうち最小のインデックスを返す
        # upper_boundにする時にはa>key
        return a>key

    ng = -1
    ok = len(al)

    while abs(ok-ng)>1:
        mid = (ok+ng)//2

        if isOk(al[mid]):
            ok = mid
        else:
            ng = mid

    return ok

n,m,k = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))

acc_a = [0]*(n+1)
acc_b = [0]*(m+1)
for i in range(n):
    acc_a[i+1] = acc_a[i] + al[i]
for i in range(m):
    acc_b[i+1] = acc_b[i] + bl[i]

res = 0

for i in range(n):
    s = acc_a[i+1]
    if s>k:
        continue
    j = lower_bound(acc_b, k-s)

    if j>=0:
        res = max(res, i+1 + j-1)

for i in range(m):
    s = acc_b[i+1]
    if s>k:
        continue
    j = lower_bound(acc_a, k-s)

    if j>=0:
        res = max(res, i+1 + j-1)

print(res)

Measured memory_bytes: 49148
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(k);
  for(int i=0;i<k;i++){
    cin >> d[i];
  }
  int ans;
  bool b=false;
  for(int i=n;!b;i++){
    int t=i;
    b=true;
    for(int j=0;t!=0;j++){
      for(int l=0;l<k;l++){
        if(t%10==d[l]){
          b=false;
          break;
        }
      }
      t/=10;
    }
    if(b){
      cout << i << endl;
    }
  }
}

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

using namespace std;
using ll = long long;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int ans = 0;

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int t = 0; t <= c; t++){

                ans += (i * 500 + j * 100 + t * 50 == x);
            }
        }
    }
    cout << ans << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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

vector<ll> a, p;
ll f(ll n, ll x){
    if(n == 0){
        if(x > 0) return 1;
        else return 0;
    }
    
    if(x <= 1 + a[n-1]){
        return f(n-1, x-1);
    }else{
        return p[n-1] + 1 + f(n-1, x - 2 - a[n-1]);
    }
}

void solve() {
    ll N, X; cin >> N >> X;
    a.resize(N), p.resize(N);
    a[0] = 1, p[0] = 1;
    rep(i, N-1){
        a[i+1] = 2*a[i] + 3;
        p[i+1] = 2*p[i] + 1;
    }

    cout << f(N, X) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 1

for div in make_divisors(sum(a)):
    mod_div = []
    for ai in a:
        mod_div.append(ai % div)
    mod_div.sort()

    tmp_p = n * div - sum(mod_div)
    tmp_m = 0

    for i, x in enumerate(mod_div):
        tmp_m += x
        tmp_p -= div - x
        if tmp_m == tmp_p and tmp_m <= k:
            ans = max(div, ans)

print(ans)


Measured memory_bytes: 3188
<?php
 
fscanf(STDIN,"%d %d",$n,$k);
 
$p = explode(" ",trim(fgets(STDIN)));

$sum_max = array_sum(array_slice($p,0,$k));	//最大の合計値
$item = $sum_max;	//最初の合計値
for($i=$k;$i<$n;$i++){		//4 10
  $item -= $p[$i-$k];
  $item += $p[$i];
  $sum_max = max($item, $sum_max);
}
 echo ($sum_max + $k)/2;
?>

Measured memory_bytes: 57668
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    map<char,ull> M;
    for(string s : S){
        M[s[0]]++;
    }
    vector<ull> A;
    for(char m : {'M', 'A', 'R', 'C', 'H'}){
        A.push_back(M[m]);
    }
    int n = A.size();
    ull ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                ans += A[i] * A[j] * A[k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6308
#include<stdio.h>
#include<string.h>
int main(){
  int N,M,i;
  char O[55],E[55];
  scanf("%s",O); 
  scanf("%s",E);
  N=strlen(O);
  for(i=0;i<N;i++){
    printf("%c",O[i]);
    if(E[i]!='\0'){
      printf("%c",E[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353


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

    // solution comes here

    ll N;
    cin >> N;
    ll M=0, A=0, R=0, C=0, H=0;
    rep(i, N) {
        string s;
        cin >> s;
        if (s[0] == 'M') M++;
        if (s[0] == 'A') A++;
        if (s[0] == 'R') R++;
        if (s[0] == 'C') C++;
        if (s[0] == 'H') H++;
    }

    ll ans=0;
    rep(m,2) {
        rep(a,2) {
            rep(r,2) {
                rep(c,2) {
                    rep(h,2) {
                        if(m+a+r+c+h==3){
                            ll cnt=1;
                            if(m) cnt *= M;
                            if(a) cnt *= A;
                            if(r) cnt *= R;
                            if(c) cnt *= C;
                            if(h) cnt *= H;

                            ans += cnt;
                        }
                    }
                }
            }
        }
    }

    cout << ans << nl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int c[]={500,100,50,10,5,1};
int main(){
    int n;
    while(cin>>n,n){
        int ret=0,m=1000;
        while(m>n){
            rep(i,6){
                if(m-c[i]>=n){
                    m-=c[i];
                    ret++;
                    break;
                }
            }
        }
        cout<<ret<<endl;
    }
}

Measured memory_bytes: 1160
fun main() = Thread(null, ::abc169c, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc169c() {
    val (a, b) = readLine()!!.split(' ')

    val split = b.split(".")
    val multiply = split[0].toLong() * 100 + split[1].padEnd(2, '0').toLong()

    val answer = a.toLong() * multiply / 100

    println(answer)
}



Measured memory_bytes: 36112