akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(n,m,c);
  Vi B(m);
  VIN(B)
  vector<vector<int>> A(n,vector<int>(m));
  REP(i,n){
    REP(j,m){
      IN(A[i][j]);
    }
  }
  REP(i,n){
    int num = c;
    REP(j,m){
      num += A[i][j] * B[j];
    }
    if(num > 0) x++;
  }
  OUT(x);
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

#define TEST 0
#if TEST
FILE *in = freopen("./question.txt", "r", stdin);
FILE *out = freopen("./answer.txt", "w", stdout);
#endif

int dx[4] = { 0, 1, 0, -1 }; //????????????
int dy[4] = { 1, 0, -1, 0 };
int w, h;
int min_count;
int data[20][20];

bool check_range(int nx, int ny){
	if (nx >= 0 && nx < w && ny >= 0 && ny < h){
		return true;
	}
	return false;
}

int dfs(int x, int y, int count){
	int OK=-1;
	if(count > 9)return OK;
	for (int i = 0; i < 4; i++){
		int nx=x;
		int ny=y;
		for (int j = 0; j < 20; j++){
			nx += dx[i];
			ny += dy[i];
			if(data[y+dy[i]][x+dx[i]]==1)break;
			if (!check_range(nx, ny)){
				break;
			}
			// cout << "ny " << ny << " nx " << nx << " data " << data[ny][nx] << endl;
			if (data[ny][nx] == 3){
				if (min_count > count + 1) min_count = count + 1;
				return min_count;
			}
			if (data[ny][nx] == 1){
				data[ny][nx] = 0;
				nx -= dx[i];
				ny -= dy[i];
				// cout <<"ny " << ny << " nx " << nx << endl;
				OK = dfs(nx, ny, count + 1);
				data[ny+dy[i]][nx+dx[i]] = 1;
				break;
			}
		}
	}
	if(min_count<11) return min_count;
	else return OK;
}

int main(void){
	while (1){
		min_count = 11;
		cin >> w >> h;
		if (!w && !h) break;

		int s_x, s_y;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				cin >> data[i][j];
				if (data[i][j] == 2){
					s_x = j;
					s_y = i;
				}
			}
		}

		int count = 0;
		int cnt = dfs(s_x, s_y,count);
		cout << cnt << endl;

	}
	#if TEST
	fclose(in);
	fclose(out);
	#endif
	return 0;
}

Measured memory_bytes: 3036
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

const ll C_MAX = (ll)1e18;

int main()
{
	ll A, ret, ib;
	long double B;

	cin >> A >> B;
	ib = B * 100 + 0.05;
	A *= ib;
	A /= 100;

	cout << A << endl;
	return 0;
}

Measured memory_bytes: 3732
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        long[] a = new long[n+1];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = scan.nextLong();
        }
        StringBuilder sb = new StringBuilder();
        if (n % 2 == 0) {
            for (int i = 1; i <= n / 2; i++) {
                sb.append(a[2*(n/2-i+1)] + " ");
            }
            for (int i = 1; i <= n / 2; i++) {
                sb.append(a[2*i-1] + " ");
            }
        } else {
            for (int i = 0; i < (n - 1) / 2; i++) {
                sb.append(a[2*((n-1)/2-i)+1] + " ");
            }
            sb.append(a[1] + " ");
            for (int i = 1; i <= (n - 1) / 2; i++) {
                sb.append(a[2*i] + " ");
            }
        }
        String text = sb.toString();
        text = text.substring(0, text.length() - 1);
        System.out.println(text);
    }
}


Measured memory_bytes: 101416
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main() {
    int n;
    while (1) {
        cin >> n;
        if (n == 0) return 0;
        int ma[n + 1][n + 1]; //1index
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                ma[i][j] = 0;
            }
        }
        int tate = n/2 + 2, yoko = n/2 + 1;
        int cnt = 1;
        ma[tate][yoko] = cnt;
        tate += 1; yoko += 1;
        while (1) {
            if (1 <= tate && tate <= n && 1 <= yoko && yoko <= n) {
                if (ma[tate][yoko] == 0) {
                    ma[tate][yoko] = ++cnt;
                    tate++; yoko++;
                    if (cnt == pow(n, 2) ) {
                        break;
                    }
                } else {
                    tate++; yoko--;
                }
            } else if (yoko > n){ //over right 最初はあり得ない
                yoko = 1;
            } else if (tate > n) { //over bottom
                tate = 1;
            } else if (yoko < 1){ //over left
                yoko = n;
            }
            /*
            cout << tate << " " << yoko << endl;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    cout << ma[i][j] << " ";
                }
                cout << endl;
            }
            cout << endl;
            */
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                printf("%4d", ma[i][j]);
            }
            cout << endl;
        }
    }
    return 0;
}



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

int main(){
    string s,t;
    cin >> s >> t;
    int count = 0;
 
    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]){
            count++;
        }
    }
  
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3916
// linear search
#include <stdio.h>

int main() {
  int a[10000];
  int b[500];
  int i, j, n, q;
  int cnt = 0;

  // input the number
  scanf("%d", &n);

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

  // input the search number
  scanf("%d", &q);

  for(i = 0; i < q; i++) {
    scanf("%d", &b[i]);
  }

  // search
  for(i = 0; i < q; i++) {
    for(j = 0; j < n; j++) {
      if(b[i] == a[j]) {
	cnt++;
	break;
      }
    }
  }

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



Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main()
{
 int i,c,l,n;
 c=l=0;
 cin >> n;
 int a[n+1];
 a[n]=-1;
 for(i=0;i<n;i++)
 cin >> a[i];
 for(i=0;i<n;i++)
 {
  if(a[i]>=a[i+1] && a[i+1]!=-1)
  c++;
  else
  {
   if(c>l)
   l=c;
   c=0;
  }
 }
 cout << l;
 return 0;
}

Measured memory_bytes: 640
package main

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

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b := scanInt(sc), scanInt(sc)
	return a * b
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
bool has_divisor(int, int);

//グローバル変数
//const int MAX_N;
//const int MAX_M;
//vvec data(N, vec(M));
//const int INF = ;
//const int mod = ;

//関数：
/* yにxをn回乗じmodで割った余りを返す。
（素数pに対して x**p = x (mod p) が成り立つ。）*/
int mod_pow(int y, int x, int n, int mod) {
	int ans = y;
	rep(i, n) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}

/* ユークリッドの互除法(mx > mn) */
int gcd(int mx, int mn) {
	if(mn == 0) return(mx);
	else gcd(mn, mx%mn);
}

/* 素数判定関数 */
bool is_prime(int n) {
	if (n == 1) return false;
	else if (n == 2) return true;
	else {
		return !has_divisor(n, 2);
	}
}

/* クイック・ソート（返し値：互換数） */
int64_t quicksort(vector<int> &arr, int left, int right) {
	int i, j, p;
	int64_t ans = 0;
	i = left; j = right;
	p = (arr[i]+arr[j]) / 2;
	while(i < j) {
		while(arr[i] < p) i++;
		while(arr[j] > p) j--;
		if (i < j) {
			swap(arr[i++], arr[j--]);
			ans += abs(i-j);
		}
		if(i == j) {
			if(arr[i] < p) i++;
			else if(arr[j] > p) j--;
		}
		if (i >= left+2) ans += quicksort(arr, left, i-1);
		if (j <= right-2) ans += quicksort(arr, j+1, right);
	}
	return ans;
}

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

	int n; cin >> n;
	string s; cin >> s;
	
	int lg = s.size();
	if(n%2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	int slg = n/2;
	bool frag = true;
	for(int i=0; i<slg; i++) {
		if(s[i] != s[slg+i]) {
			frag = false;
			break;
		}
	}
	if(frag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

// 以下の関数等は気にしない。
bool has_divisor(int n, int i) {
	//base case 1:
	if (i == n) return false;
	//base case 2:
	if (n % i == 0) return true;
	return has_divisor(n, i+1);
}

//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';
//int id = lower_bound(all(arr), x) - arr.begin();

/*struct data {
	char *name;
	int age;
	int height;
	double weight;
};*/

/*string ans = w;
string &ref = ans;
rep(i, N) {
	ref[i] = arr[i];
}*/

/*map<int,int> mp;
for(auto p : mp) {
	ct += p.second*(p.second-1); }

map<int,int>::iterator itr;
for(itr = mp.begin(); itr != mp.end(); itr++) {
	ans += itr->second * (itr->second-1);
}*/


Measured memory_bytes: 256
import sys
from math import sqrt, gcd, ceil, log
# from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
# from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# sys.setrecursionlimit(5*10**6)

def main():
	s = 0
	n, d = read(); 
	for i in range(n):
		x, y = read()
		D = sqrt(x**2 + y**2)
		s += (D <= d)
	print(s)



if __name__ == "__main__":
	main()

Measured memory_bytes: 69008
function Main(input) {
  input = input.split("\n");
  var h = parseInt(input[0].split(" ")[0]);
  var w = parseInt(input[0].split(" ")[1]);
  a = new Array(h);
  for(i=0;i<h;i++){
    asub=new Array(w);
    var x = input[i+1];
    for(j=0;j<w;j++){
      a[i]=asub;
      a[i][j]=x.substr(j,1);
    }
  }
  for(i=h-1;i>=0;i--){
    var cnt=0;
    for(j=0;j<w;j++){
      if(a[i][j]=="#"){
        cnt++;
      }
    }
    if(cnt==0){
      a.splice(i,1);
    }
  }
  for(i=w-1;i>=0;i--){
    var cnt=0;
    for(j=0;j<a.length;j++){
      if(a[j][i]=="#"){
        cnt++;
      }
    }
    if(cnt==0){
      for(j=0;j<a.length;j++){
        a[j].splice(i,1);
      }
    }
  }
  var ans ="";
  for(i=0;i<a.length;i++){
    for(j=0;j<a[i].length;j++){
      ans+=a[i][j];
      if(j==a[i].length-1&&i!=a.length-1){
        ans+="\n";
      }
    }
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int l,r;
int ans;


bool judge(int x){
	int num[10];
	memset(num,0,sizeof(num));
	int  tot=0;
	while(x){
		num[++tot]=x%10;
		x/=10;
	}
	for(int i=1;i<=tot;i++){
		if(num[i]!=num[tot-i+1]) return 0;
	}
	return 1;
}
		
int main(){
	//cout<<judge(11111);
	cin>>l>>r;
	for(int i=l;i<=r;i++){
		if(judge(i)) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

constexpr int INF = (1 << 30);
constexpr ll LINF = (1LL << 62);

int N, M;
int A[1000], B[1000], C[1000], D[1000], E[1000], F[1000];

void input() {
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
		cin >> A[i] >> B[i] >> C[i];
	for (int i = 0; i < M; ++i)
		cin >> D[i] >> E[i] >> F[i];
}

struct node {
	ll S;
	bool l, r, u, d;
	node() { S = 0; l = r = u = d = true; }
};

map<int, int> x, y;
vector<int> _x, _y;

void compress() {
	x[INF]; y[INF]; x[-INF]; y[-INF]; x[0]; y[0];
	for (int i = 0; i < N; ++i)
		x[A[i]], x[B[i]], y[C[i]];
	for (int i = 0; i < M; ++i)
		x[D[i]], y[E[i]], y[F[i]];
	int t = 0;
	for (auto& e : x) {
		e.second = t++;
		_x.push_back(e.first);
	}
	t = 0;
	for (auto& e : y) {
		e.second = t++;
		_y.push_back(e.first);
	}
}

int H, W;
node grid[3010][3010];

void make_grid() {
	W = x.size() - 1;
	H = y.size() - 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ll dx = _x[j + 1] - (ll)_x[j];
			ll dy = _y[i + 1] - (ll)_y[i];
			ll S = dx * dy;
			grid[i][j].S = S;
			if (i == 0) grid[i][j].u = false;
			if (i == H - 1) grid[i][j].d = false;
			if (j == 0) grid[i][j].l = false;
			if (j == W - 1) grid[i][j].r = false;
		}
	}
	for (int i = 0; i < N; ++i) {
		int y_idx = y[C[i]];
		for (int x_idx = x[A[i]]; x_idx < x[B[i]]; ++x_idx) {
			grid[y_idx][x_idx].u = false;
			grid[y_idx - 1][x_idx].d = false;
		}
	}
	for (int i = 0; i < M; ++i) {
		int x_idx = x[D[i]];
		for (int y_idx = y[E[i]]; y_idx < y[F[i]]; ++y_idx) {
			grid[y_idx][x_idx].l = false;
			grid[y_idx][x_idx - 1].r = false;
		}
	}
}

int visited[3010][3010];
ll res = 0;

void dfs(int y_st, int x_st) {
	stack<pair<int, int>> st;
	visited[y_st][x_st] = 1;
	st.push({ y_st, x_st });
	while (!st.empty()) {
		auto p = st.top();
		st.pop();
		int sy = p.first, sx = p.second;
		if (sy == 0 || sy == H - 1 || sx == 0 || sx == W - 1) {
			res = LINF;
			return;
		}
		res += grid[sy][sx].S;
		if (grid[sy][sx].l && !visited[sy][sx - 1])
			visited[sy][sx - 1] = 1, st.push({ sy, sx - 1 });
		if (grid[sy][sx].r && !visited[sy][sx + 1])
			visited[sy][sx + 1] = 1, st.push({ sy, sx + 1 });
		if (grid[sy][sx].u && !visited[sy - 1][sx])
			visited[sy - 1][sx] = 1, st.push({ sy - 1, sx });
		if (grid[sy][sx].d && !visited[sy + 1][sx])
			visited[sy + 1][sx] = 1, st.push({ sy + 1, sx });
	}
}

int main() {
	input();
	compress();
	make_grid();
	dfs(y[0], x[0]);
	if (res < LINF) cout << res << endl;
	else cout << "INF" << endl;
	return 0;
}

Measured memory_bytes: 210772
using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ');
            int H = int.Parse(read[0]);
            int W = int.Parse(read[1]);
            string[,] BOARD = new string[H + 2, W + 2];
            for (int i = 1; i <= H; i++)
            {
                var line = Console.ReadLine();
                for (int j = 1; j <= W; j++)
                {
                    BOARD[i, j] = line[j - 1].ToString();
                }
                BOARD[i, 0] = ".";
                BOARD[i, W + 1] = ".";

            }
            for (int i = 0; i < W+2; i++)
            {
                BOARD[0, i] = ".";
                BOARD[H + 1, i] = ".";
            }
            ;
            for (int i = 1; i <= H; i++)
            {
                for (int j = 1; j <= W; j++)
                {
                    BOARD[i, j] = number(BOARD, i, j);
                }
            }
            ;
            for (int i = 1; i <= H; i++)
            {
                string oneline = "";
                for (int j = 1; j <= W; j++)
                {
                    oneline += BOARD[i, j];

                }
                Console.WriteLine(oneline);
                oneline = "";
            }
            ;
        }

        static string number(string[,] board, int tate, int yoko)
        {
            string output = "0";
            int n_output = 0;
            if (board[tate - 1, yoko - 1] == "#") n_output++;
            if (board[tate - 1, yoko     ] == "#") n_output++;
            if (board[tate - 1, yoko + 1] == "#") n_output++;
            if (board[tate    , yoko - 1] == "#") n_output++;
            if (board[tate    , yoko + 1] == "#") n_output++;
            if (board[tate + 1, yoko - 1] == "#") n_output++;
            if (board[tate + 1, yoko    ] == "#") n_output++;
            if (board[tate + 1, yoko + 1] == "#") n_output++;
            output = n_output.ToString();
            if (board[tate, yoko] != "#")
            {
                return output;
            }
            else return "#";

        }
    }
}


Measured memory_bytes: 13268
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1003;
char ans[4][7][7], m[N][N];
string arr[4] = {"adeeadffbbghccgh",
"adf..adf..beehhb.giiccgjj",
"adgg..adhh..beii..be..jjcf..kkcf..ll",
"adg....adg....be.ii..be.jj..cff..llc.h..mm..hkknn"
};

void parse(int r) {
    int a = 4 + r;
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < a; j++) {
            ans[r][i][j] = arr[r][i * a + j];
        }
    }
}

void spread(int x, int r) {
    int a = 4 + r;
    for (int i = x; i < x + a; i++) {
        for (int j = x; j < x + a; j++) {
            m[i][j] = ans[r][i - x][j - x];
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    for (int i = 0; i < 4; i++) {
        parse(i);
    }

    int n;
    cin >> n;
    if (n <= 2) {
        cout << -1;
        return 0;
    }
    if (n == 3) {
        cout << "acc\na.d\nbbd";
        return 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            m[i][j] = '.';
        }
    }
    int rem = n % 4;
    spread(0, rem);
    int times = (n - (4 + rem)) / 4, cur = 4 + rem;
    while (times--) {
        spread(cur, 0);
        cur += 4;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << m[i][j];
        }
        cout << '\n';
    }
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
#define ll long long
const double EPS = 1e-10;


int main(){
  ll n,k;
  cin>>n;
  k=(1+sqrt(8*n+1))/2;
  if(k*(k-1)/2!=n){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    vector<vector<int> > a(n,vector<int>(2,-1));
    vector<vector<int> > b(k,vector<int>(k,0));
    for(int i=0;i<k;i++){
      ll c=0;
      cout<<k-1;
      for(int j=0;j<k-1;c++){
        if(a[c][0]==-1){
          a[c][0]=i;
          j++;
          cout<<" "<<c+1;
        }
        else if(a[c][1]==-1&&b[a[c][0]][i]==0){
          a[c][1]=i;
          b[a[c][0]][i]=1;
          b[i][a[c][0]]=1;
          j++;
          cout<<" "<<c+1;
        }
      }
      cout<<endl;
    }
  }
}


Measured memory_bytes: 7680
#include <stdio.h>
#include <math.h>
double f(int q, double x){
    return (x * x * x - q) / (3 * x * x);
}

double root(int q){
    double x = q / 2.0;    
    while (fabs(x * x * x - q) >= 0.00001 * q) {
        x = x - f(q, x);
    }
    return x;
}

int main(void){
    int q;
    while(scanf("%d\n", &q) != EOF) {
        if(q == -1) break;
        printf("%.6f\n", root(q));
    }
    return 0;
}


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

using vi = vector<int>;

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

    vi v(k, INT_MAX);
    set<vi> q;

    v[1] = 0;
    q.insert({v[1], 1});

    while(!q.empty())
    {
        auto elt = *begin(q); q.erase(begin(q));

        int c = elt[0];
        int x = elt[1];

        int next1 = (x * 10) % k;
        int next2 = (x + 1) % k;

        if(c < v[next1])
        {
            v[next1] = c;
            q.insert({v[next1], next1});
        }

        if(c + 1 < v[next2])
        {
            v[next2] = c + 1;
            q.insert({v[next2], next2});
        }
    }

    cout << (v[0] + 1) << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(vr) vr.begin(),vr.end()
const int N=1e3+10,mod=1e9+7;
ll dp[N],n,a,b,c,d,C[N][N],fact[N],ifact[N],inv[N],p[N][N];

void build()
{
    inv[1]=ifact[0]=ifact[1]=fact[0]=fact[1]=1;
    for (int i=2;i<=n;i++)
    {
        inv[i]=mod-mod/i*inv[mod%i]%mod;
        ifact[i]=ifact[i-1]*inv[i]%mod;
        fact[i]=fact[i-1]*i%mod;
    }
    for (int i=0;i<=n;i++)
    {
        C[0][i]=1;
        for (int j=1;j<=i;j++) C[j][i]=(C[j][i-1]+C[j-1][i-1])%mod;
    }
    for (int i=1;i<=n;i++)
    {
        p[i][0]=1;
        for (int j=1;j<=n;j++) p[i][j]=p[i][j-1]*ifact[i]%mod;
    }
}

ll modpow(ll x,ll h)
{
    ll res=1;
    for (;h;h>>=1)
    {
        if (h&1) res=res*x%mod;
        x=x*x%mod;
    }
    return res;
}

int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>a>>b>>c>>d;
    dp[0]=1;
    build();
    for (int i=a;i<=b;i++)
        for (int j=n;j>=0;j--)
            for (int t=c;t<=min(d,(n-j)/i);t++)
                dp[j+t*i]=(dp[j+t*i]+dp[j]*C[t*i][n-j]%mod*fact[t*i]%mod*ifact[t]%mod*p[i][t])%mod;
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 15616
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[0 for i in range(5)] for j in range(L+1)]

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    DP[i+1][0] = DP[i][0] + cost(0, i, A)
    DP[i+1][1] = min(DP[i][:2]) + cost(1, i, A)
    DP[i+1][2] = min(DP[i][:3]) + cost(2, i, A)
    DP[i+1][3] = min(DP[i][:4]) + cost(3, i, A)
    DP[i+1][4] = min(DP[i][:5]) + cost(4, i, A)



print(min(DP[L]))

Measured memory_bytes: 74060
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int a,b=0,ans=0,N,H;cin>>N>>H;
  vector<int> A(N),B(N);
  REP(i,0,N)cin>>A[i]>>B[i];
  sort(ALL(A));
  sort(ALL(B),greater<int>());
  a=A[N-1];
  each(_,B){
    if(_>=a){
      ans++;
      H-=_;
    }
    if(H<=0){
      print(ans);
      re 0;
    }
    
  }
  ans+=(H+a-1)/a;
  print(ans);



}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

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

	vector<int> a(M), b(M);

	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}

	int bridge = 0;

	for (int j = 0; j < M; j++) {
		UnionFind tree(N);
		bool ok = true;
		for (int i = 0; i < M; i++) {
			if (i != j) tree.unite(a[i], b[i]);
		}
		for (int i = 0; i < N - 1; i++) {
			if (tree.root(i) != tree.root(i + 1)) ok = false;
		}
		if (!ok) bridge++;
	}

	cout << bridge << endl;


	return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

//yakusuu rekkyo
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // push its partner
            if (N/i != i) res.push_back(N/i);
        }
    }

    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main() {
    int n; cin >> n;
    int h[100001];
    int prev,cur;
    int ans = true;
    rep(i,n){
        cin >> cur;
        if(i == 0) prev = cur;
        else{
            if(cur > prev){
                cur --;
                prev = cur;
            }else if(cur < prev) ans = false;
        }
    }
    cout << ((ans)?"Yes":"No");

    return 0;
}











Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    ll n,k; cin >> n >> k;
    vl a(n); rep(i,n) cin >> a[i], a[i]--;
    vl pre(n,-1);
    pre[0] = 0;
    ll now = 0;
    ll t = 1;
    ll first;
    ll shuuki = 0;
    while(1){
        if(pre[a[now]] != -1){
            shuuki = t - pre[a[now]];
            first = a[now];
            break;
        }
        now = a[now];
        pre[now] = t;
        if(t == k){
            cout << now+1 << endl;
            return 0;
        }
        t++;
    }
    k -= t;
    k %= shuuki;
    now = first;
    while(k--){
        now = a[now];
    }
    cout << now+1 << endl;
}

Measured memory_bytes: 6424
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

string s;
int n;
signed main() {
	cin >> s;
	n = s.size();
	if (n < 26) {
		cout << s;
		sort(all(s));
		for (char a = 'a'; a <= 'z'; a++) {
			if (!binary_search(all(s), a)) {
				cout << a << endl;
				return 0;
			}
		}
	}
	else {
		int w = 0;
		Rep(i, 24) {
			if (s[i] < s[i + 1]) {
				w = i + 1;
				break;
			}
		}
		if (w == 0) {
			cout << -1 << endl;
		}
		else {
			char a = 'z';
			for (int i = w; i < 26; i++) {
				if (s[w - 1] < s[i]) {
					a = min(a, s[i]);
				}
			}
			rep(i, w - 1) cout << s[i];
			cout << a << endl;
		}
	}
}

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

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

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

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

template <class T>
inline istream &operator,(istream &is, T &rhs) {
    return is >> rhs;
}

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

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

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

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

constexpr int MOD = int(1e9) + 7;

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

    var(int, N);
    vector<i64> a(N);
    cin >> a;

    vector<i64> cum(N + 1);
    rep(i, 0, N) {
        cum[i + 1] = cum[i] + a[i];
    }

    i64 ans = 0;
    rep(i, 0, N - 1) {
        i64 s = cum[N] - cum[i + 1];
        s %= MOD;
        ans += a[i] * s;
        ans %= MOD;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 6364
use std::cmp::min;

fn main() {
  let (n, a, b) = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let n: usize = ws.next().unwrap().parse().unwrap();
    let a: usize = ws.next().unwrap().parse().unwrap();
    let b: usize = ws.next().unwrap().parse().unwrap();
    (n, a, b)
  };

  print!("{}", min(n * a, b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;

  string T;
  cin >> T;

  int answerA = 0;
  int answerB = 0;
  vector<string> playerA(N);
  vector<string> playerB(N);

  for (int i = 0; i < N; i++) {
    if (T[i] == 'r') {
      playerA[i] = "p";
      playerB[i] = "p";
      answerA += P;
      answerB += P;  
    } else if (T[i] == 's') {
      playerA[i] = "r";
      playerB[i] = "r";
      answerA += R;
      answerB += R; 
    } else {
      playerA[i] = "s";
      playerB[i] = "s";
      answerA += S;
      answerB += S; 
    }
  }

  for (int i = 0; i < N; i++) {
    if (K <= i) {
      if (playerA[i - K] == playerA[i]) {
        playerA[i - K] = 'z';
        if (T[i - K] == 'r') {
          answerA -= P;  
        } else if (T[i - K] == 's') {
          answerA -= R; 
        } else {
          answerA -= S; 
        }
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (K <= i) {
      if (playerB[i - K] == playerB[i]) {
        playerB[i] = 'z';
        if (T[i] == 'r') {
          answerB -= P;  
        } else if (T[i] == 's') {
          answerB -= R; 
        } else {
          answerB -= S; 
        }
      }
    }
  }

  cout << max(answerA, answerB) << endl;
 
}

Measured memory_bytes: 11264
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define lb(x) (x&-x)
#define get(x) ((int)log2(x))

const int INF=0x3f3f3f3f;
const int N=66666;

int f[17][N],sum[N];
int v[17][17];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void upd(int &x,int v) {
	(x<v)?(x=v):0;
}

int main(void) {
	int n=read(),m=read();
	int prt=0;
	rep(i,1,m) {
		int x=read()-1,y=read()-1;
		v[x][y]=v[y][x]=read(),prt+=v[x][y];
	}
	for (int S=1;S<(1<<n);++S) {
		int x=get(lb(S));
		sum[S]=sum[S-(1<<x)];
		rep(i,0,n-1) if (v[i][x]&&(S>>i&1)) {
			sum[S]+=v[i][x];
		}
	}
	rep(i,0,n-1) for (int S=0;S<(1<<n);++S) f[i][S]=-INF;
	int ans=0; f[0][1]=0;
	for (int S=1;S<(1<<n);++S) {
		if (!(S&1)) continue;
		rep(i,0,n-1) {
			if (!((S>>i))&1) continue;
			for (int T=S;T;T=(T-1)&S) {
				if (T>>i&1) upd(f[i][S],f[i][S-T+(1<<i)]+sum[T]);
			}
			for (int T=(1<<n)-1-S,j;T;T-=lb(T)) {
				j=get(lb(T));
				if (v[i][j]) upd(f[j][S+(1<<j)],f[i][S]+v[i][j]);
			}
		}
		if (S>>(n-1)&1) upd(ans,f[n-1][S]);
	}
	printf("%d\n", prt-ans);
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;


ll X;



ll Pow(ll x, ll n) {
	if (n == 0) return 1;
	ll res = Pow(x*x, n / 2);
	if (n & 1) res = res * x ;
	return res;
}


bool isOK(ll index, ll key,ll p) {//indexはbの値

	ll A = Pow(p + index, 5);
	ll B = Pow(index, 5);

	

	if (A-B >= key)return true;//ここの配列名を適宜変えよう！
	else return false;
}


ll binary_search(ll key,ll p) {//Bの値を返す

	ll left = -1, right = 1e3+1;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key,p))right = mid;
		else left = mid;
	}
	return right;
}

bool isOK2(ll index, ll key, ll p) {//indexはbの値

	ll A = Pow(p + index, 5);
	ll B = Pow(index, 5);

	if (p == 6)cout << B << " " << A - B << endl;


	if (A - B <= key)return true;//ここの配列名を適宜変えよう！
	else return false;
}

ll binary_search2(ll key, ll p) {//Bの値を返す

	ll left = -1e3-1, right = -p/2;//ここの配列名を適宜変えよう！
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK2(mid, key, p))right = mid;
		else left = mid;
	}
	return right;
}

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

	cin >> X;

	for (ll i = 1; i*i <= X; i++) {
		if (X%i == 0) {

			ll cur = binary_search(X, i);

			

			ll AA = Pow(i + cur, 5);
			ll BB = Pow(cur, 5);
			if (AA - BB == X) {
				cout << i + cur << " " << cur << endl;
				break;
			}



			ll cur2 = binary_search2(X, i);


			ll A = Pow(i + cur2, 5);
			ll B = Pow(cur2, 5);
			if (A - B == X) {
				cout << i+cur2 << " " << cur2 << endl;
				break;
			}

			ll s = X / i;

			cur = binary_search(X, s);

			AA = Pow(s + cur, 5);
			BB = Pow(cur, 5);
			if (AA - BB == X) {
				cout << s + cur << " " << cur << endl;
				break;
			}



			cur2 = binary_search2(X, s);

			A = Pow(s + cur2, 5);
			B = Pow(cur2, 5);
			if (A - B == X) {
				cout << s + cur2 << " " << cur2 << endl;
				break;
			}

		}
	}





	return 0;
}


Measured memory_bytes: 3168
#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 int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

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;
	cin >>n >>m;
	vector<VI> vv(m, VI(2));
	rep(i, m) cin >>vv[i][0] >> vv[i][1];
	sort(all(vv),[](auto& l, auto& r){return l[1]<r[1];});
	map<int,int> mp={{1,n}};
	int ans =0;
	rep(i, m){
		auto it = mp.upper_bound(vv[i][0]);
		it--;
		if(it->second >= vv[i][1]){
			ans++;
			int sv = it->second;
			it->second = vv[i][1] -1;
			mp[vv[i][1]] = sv;
		}
	}
	cout << ans <<"\n";
	return 0;
}


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

int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  
  vector<vector<int>> s(h, vector<int>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if((i < b && j < a) || (i >= b && j >= a)){
        cout << 0;
      }
      else{
        cout << 1;
      }
    }
    cout << endl;
  }
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
int koushin(int c[26],int last[26],int used,int d,int kasan,int sum){
    last[used]=d;
    int sum_m=sum;
    for(int i=0;i<26;i++){
        sum_m-=c[i]*(d-last[i]);
    }
    sum_m+=kasan;
    return sum_m;
}

int main()
{
    int D;
    int c[26];
    int last[26];
    for(int i=0;i<26;i++){
        last[i]=0;
    }
    cin>>D;
    pair<int,int>s[D][26];
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++){
            int tmp;
            cin>>tmp;
            s[i][j]=make_pair(tmp,j+1);
        }
    }
    int sum=0;
    vector<int>anss;
    random_device seed_gen;
    mt19937 engine(seed_gen());
    for(int i=0;i<D;i++){
        int x= engine()%26;
        if(x==0){
            x=26;
        }
        anss.push_back(x);
        sum=koushin(c,last,x,i+1,s[D][x].first,sum);

    }
    for(int i=0;i<D;i++){
        cout<<anss[i]<<endl;
    }

    


    
    

}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

/////////////         qsortのラッピング

int qsort_int_compare_ascend(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int qsort_int_compare_descend(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
void ascendOrder(int size, int *array) {//昇順
	qsort(array, size, sizeof(int), qsort_int_compare_ascend);
}
void descendOrder(int size, int *array) {//降順
	qsort(array, size, sizeof(int), qsort_int_compare_descend);
}

int main() {
	int N; cin >> N;
	bool flag = true;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		if (a % 2 == 1) { flag = !flag; }
	}

	cout << ((flag) ? "YES" : "NO") << endl;

	return 0;
}

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


int main() {
    string s;
    cin>>s;
    ll sum=0;
    int plus_num=int(s.length())-1;
    for(int bit=0;bit<(1<<plus_num);++bit){
        ll tmp=0;
        for(int i=0;i<plus_num;++i){
            tmp*=10;
            tmp+=stoi(string(1,s[i]));
            if(bit&(1<<i)){
                sum+=tmp;
                tmp=0;
        }
    }
    tmp*=10;
    tmp+=stoi(string(1,s.back()));
    sum+=tmp;
    }
    cout<<sum;
return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
#define BR "\n"

#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define  DUMP(x)  cerr << #x << " = " << (x) <<endl
#define DEBUG(x) DUMP(x) << " (L" << __LINE__ << ")" << " " << __FILE__<<endl
#define CHECK(exp,act)  if(exp!=act){DUMP(exp);DEBUG(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DEBUG(x)
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}
template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int main(){
	int p1,p2,p3;cin >>p1 >> p2 >> p3;
	int j1,j2;cin >>j1>>j2;
	cout<<min(p1,min(p2,p3))+min(j1,j2)-50<<endl;
	return 0;
}

Measured memory_bytes: 1160