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

using namespace std;

int main() {
	stack<int> S;
	string word;
	while(cin >> word){
		if(word == "+"){
			int x = S.top();
			S.pop();
			int y = S.top();
			S.pop();
			S.push(x+y);
		}else if(word == "-"){
			int x = S.top();
			S.pop();
			int y = S.top();
			S.pop();
			S.push(y-x);
		}else if(word == "*"){
			int x = S.top();
			S.pop();
			int y = S.top();
			S.pop();
			S.push(x*y);
		}else{
			S.push(atoi(word.c_str()));
		}			
	}
	int s = S.top();
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3208
package main

import "fmt"

func main() {
	var H, W, K int
	fmt.Scan(&H)
	fmt.Scan(&W)
	fmt.Scan(&K)

	ss := make([]string, H)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	res := devideCake(H, W, K, ss)
	for _, row := range res {
		for j, col := range row {
			if j != W-1 {
				fmt.Printf("%d ", col)
			} else {
				fmt.Println(col)
			}
		}
	}
}

func devideCake(H int, W int, K int, ss []string) [][]int {
	div := 1
	res := make([][]int, H)
	for i := range res {
		res[i] = make([]int, W)
	}

	found := make([]bool, H)
	foundRow := make([]int, 0, H)
	for i, row := range ss {
		f := 0
		for j := 0; j < W; j++ {
			col := row[j : j+1]
			if col == "#" {
				for k := f; k <= j; k++ {
					res[i][k] = div
				}
				found[i] = true
				if len(foundRow) > 0 {
					if foundRow[len(foundRow)-1] != i {
						foundRow = append(foundRow, i)
					}
				} else {
					foundRow = append(foundRow, i)
				}
				div++
				f = j + 1
			}
		}
		if len(foundRow) > 0 {
			if foundRow[len(foundRow)-1] == i {
				for k := f; k < W; k++ {
					res[i][k] = div - 1
				}
			}
		}
	}

	k := 0
	for i, row := range res {
		if i < foundRow[k] {
			for j := range row {
				res[i][j] = res[foundRow[k]][j]
			}
		} else if i == foundRow[k] && k+1 != len(foundRow) {
			k++
		} else {
			for j := range row {
				res[i][j] = res[foundRow[k]][j]
			}
		}
	}
	return res
}


Measured memory_bytes: 2688
/* 
 * Project: AtCoder Beginners Contest 137 B - One Clue
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/09/01
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

int32_t k;
int32_t coord_x;

void solve() {

    for (int i=-k+1;i<k;i++) {
        printf("%d ", coord_x+i);
    }

    printf("\n");

}

int main() {

    scanf("%d", &k);
    scanf("%d", &coord_x);

    solve();

}


Measured memory_bytes: 3212
#include <iostream>
#include <bitset>

using namespace std;

long long am = 0;
bitset<53> B;
int v1 = 0;
int v2 = 0;
int v[53];
int T;
int n;
long long dp[2503][53];

int main() {

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

    cin >> n >> T;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }

    dp[0][0] = 1;

    for(int i = 1; i <= n; i++) {
        for(int j = i; j >= 1; j--) {
            for(int k = v[i]; k <= 2500; k++) {
                dp[k][j] += dp[k-v[i]][j-1];
            }
        }
    }

    long long ans = 0;

    for(int i = 1; i <= n; i++) {
        ans += dp[T*i][i];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Linq;

namespace ABC141
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] NKQ = CIN.LongArray();
            long N = NKQ[0];
            long K = NKQ[1];
            long Q = NKQ[2];
            long[] A = new long[Q];
            for (int i = 0; i < Q; i++)
            {
                A[i] = CIN.Long();
            }
            
            long[] Scores = new long[N];
            for (int i = 0; i < N; i++)
            {
                Scores[i] = K - Q;
            }

            for (int i = 0; i < Q; i++)
            {
                Scores[A[i] - 1]++;
            }

            for (int i = 0; i < N; i++)
            {
                if (Scores[i] > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 20320
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{int p,l,r,lef;};
struct Node T[MAX]; 

void print(int u){

  int i=T[u].p, depth=0;
  while(i!=NIL){
    i = T[i].p;
    depth++;
  }

  if(depth==0){
    printf("node %d: parent = %d, depth = %d, root, ",u,T[u].p,depth);
  }else if(T[u].l==NIL){
    printf("node %d: parent = %d, depth = %d, leaf, ",u,T[u].p,depth);
  }else{
    printf("node %d: parent = %d, depth = %d, internal node, ",u,T[u].p,depth);
  }

  i = T[u].l;
  printf("[");
  if(i!=NIL){
    printf("%d",i);
  }

  while (i!=-1){
  i = T[i].r;

  if(i!=NIL){
    printf(", %d", i);
  }
  }
  printf("]\n");
}

int main(){
  int i, j, d, v, c, l, n;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for ( i = 0; i < n; i++ ){

    scanf("%d %d",&v,&d);

    for(j=0;j<d;j++){
      scanf("%d",&c);
       T[c].p = v;

       if(j==0){
	 T[v].l = c;
       }else if(j>0){
	 T[l].r = c;
       }
       l = c;

    }
  }  

  for (i=0;i<n;i++){
    print(i);
  }
  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int countways (int,int);

int main (void)
{
	int n[1000],x[1000];
	int i,j,ways[1000];

	for(i=0;;i++){
		scanf("%d %d", &n[i],&x[i]);
		if(n[i]==0&&x[i]==0) break;
	}

	for(j=0;j<i;j++){
		ways[j]=countways(n[j],x[j]);
		printf("%d\n", ways[j]);
	}

	return 0;
}

int countways (int n,int x)
{
	int how_many=0;
	int i,j,k;

	for(i=1;i<n-1;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<=n;k++){
				if(i+j+k==x) how_many++;
			}
		}
	}

	return how_many;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int a,b;
	cin>>a>>b;
	bool ok=false;
	FOR(i,0,1300){
		double it=i;
		int n8=floor((double)it*0.08);
		int n10=floor((double)it*0.1);
		//cout<<n8<<" "<<n10<<endl;
		if(n8==a&&n10==b){
			cout<<i<<endl;
			ok=true;
			break;
		}
	}
	if(!ok){
		cout<<-1<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

vector< set<int> >S(30);

int main(){
    int n,q;
    string s;
    cin >> n>>s>>q;
    rep(i,26){
        S[i].insert(n);//先にsを入れておくことで必ずlower_boundが引っかかるようにする!!!//超重要
    }
    rep(i,n){
        S[s[i]-'a'].insert(i);
    }
    rep(i,q){
        int a;
        cin >> a;
        if(a==1){
            int b;
            char c;
            cin >> b>>c;
            b--;
            char d=s[b];
            if(d==c)continue;
            s[b]=c;
            S[d-'a'].erase(b);
            S[c-'a'].insert(b);
        }else{
            int r,l;
            cin >> l>>r;
            l--;r--;
            int temp=0;
            
            rep(j,26){
                if(*S[j].lower_bound(l)<=r)temp++;
            }
            qu.push(temp);
        }
    }
    
    while(!qu.empty()){
        int ans=qu.front();
        qu.pop();
        cout<<ans<<endl;
    }
    
    return 0;
}



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

int main(){
  int a,b,k,i=0,j;
  cin >> a >> b >> k;
  if(a<=b){
    do{
      for(j=a;j>0;j--){
        if(a%j == 0 && b%j == 0)
          i++;
        if(i==k)
          break;
      }
    }while(i!=k);
  }
  else{
    do{
      for(j=b;j>0;j--){
        if(a%j == 0 && b%j == 0)
          i++;
        if(i==k)
          break;
      }
    }while(i!=k);
  }
  cout << j;
  return 0;
}


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

typedef vector<int> vi;

const int INF = (int)2e+9;
const int MAX_BIT = (1 << 12);
int N, M, X;
vector<vi> A;

void input_init(void) {
	cin >> N >> M >> X;
	A.resize(N, vi(M + 1));
	for (int j = 0; j < N; ++j) {
		for (int i = 0; i <= M; ++i)
			cin >> A[j][i];
	}
}

int solve(void) {
	int min_val = INF;
	for (int bit = 1; bit < MAX_BIT; ++bit) {
		vi sum = vi(M + 1, 0);
		for (int j = 0; j < N; ++j) {
			if ((bit & (1 << j)) != 0) {
				sum[0] += A[j][0];
				for (int i = 1; i <= M; ++i)
					sum[i] += A[j][i];
			}
		}
		bool f_ok = true;
		for (int i = 1; i <= M; ++i) {
			if (sum[i] < X) {
				f_ok = false;
				break;
			}
		}
		if (f_ok)
			min_val = min(sum[0], min_val);
	}
	return min_val;
}

int main(void) {
	input_init();
	int ans = solve();
	if (ans == INF)
		ans = -1;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int A,B,C,D,E,k;
    cin >> A >> B >> C >> D >> E >> k;
    int key = E-A;
    if(k>=key)cout << "Yay!" << endl;
    else cout << ":(" << endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0, m = 0;
  priority_queue<ll> q;
  rep(i, n) {
    if(a[i] > b[i])
      q.push(a[i] - b[i]);
    else if(a[i] < b[i]) {
      m += b[i] - a[i];
      ans++;
    }
  }
  while(!q.empty() && m > 0) {
    ll k = q.top();
    q.pop();
    m -= k;
    ans++;
  }
  if(m > 0) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
int main()
{
    using namespace std;
    int K;
    long t;
    unsigned int x;
    cin >> K;
    unsigned int result[K];
    queue<unsigned int> m_queue;
    for (int i = 1; i < 10; i++)
    {
        m_queue.push(i);
    }
    for (int i = 0; i < K; i++)
    {
        x = m_queue.front();
        result[i] = x;
        m_queue.pop();
        t = 10 * x + x % 10;
        if (x % 10 != 0)
        {
            m_queue.push(t - 1);
        }
        m_queue.push(t);
        if (x % 10 != 9)
        {
            m_queue.push(t + 1);
        }
    }
    cout << result[K - 1] << endl;
}

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

int p;
string str;
char cstr[1 << 24];

int power(int x)
{
	int n = p - 2;
	int res = 1;
	while (n){
		if (n & 1) res = (res * x) % p;
		n >>= 1;
		x = (x * x) % p;
	}
	return res;
}

char *br(char *ss)
{
	char *s = ss;
	int cnt = 0;
	while (true){
		if (*s == '(') cnt++;
		else if (*s == ')') cnt--;
		if (cnt == 0) return s;
		s++;
	}
}

int calc(char *bg, char *ed)
{
	/*
	for (char *s = bg; s != ed; s++){
		printf("%c", *s);
	}
	puts("");
	*/
	
	char *s = bg;
	deque<int> arr;
	deque<char> op;
	
	int tn = 1;
	while (s != ed){
		bool ln = false;
		
		if (*s >= '0' && *s <= '9'){
			arr.push_back(atoi(s));
			while (*s >= '0' && *s <= '9') s++;
			ln = true;
		}
		else if (*s == '+' || *s == '-'){
			if (tn == 1){
				arr.push_back(atoi(s++));
				while (*s >= '0' && *s <= '9') s++;
				ln = true;
			}
			else {
				op.push_back(*s);
				s++;
			}
		}
		else if (*s == '*' || *s == '/'){
			op.push_back(*s);
			s++;
		}
		else if (*s == '('){
			arr.push_back(calc(s + 1, br(s)));
			s = br(s) + 1;
			ln = true;
		}
		if (arr.size() && arr.back() == -1) return -1;
		if (ln && op.size() && (op.back() == '*' || op.back() == '/')){
			char c = op.back(); op.pop_back();
			int b = arr.back(); arr.pop_back();
			int a = arr.back(); arr.pop_back();
			if (c == '*') a = (a * b) % p;
			else if (c == '/'){
				if (b == 0) return -1;
				a = (a * power(b)) % p;
			}
			arr.push_back(a);
		}
		
		tn ^= 1;
	}
	while (op.size()){
		char c = op.front(); op.pop_front();
		int a = arr.front(); arr.pop_front();
		int b = arr.front(); arr.pop_front();
		if (c == '+') a = (a + b) % p;
		else if (c == '-'){
			a = (a - b + p) % p;
		}
		arr.push_front(a);
	}
	
	return arr.front();
}

int main()
{
	while (true){
		scanf("%d%*c", &p);
		if (p == 0) return 0;
		
		getline(cin, str);
		for (int i = 0; i < str.size(); i++){
			if (str[i] == ' ') str.erase(i--, 1);
		}
		strcpy(cstr, str.c_str());
		int res = calc(cstr, cstr + strlen(cstr));
		if (res == -1) puts("NG");
		else {
			cout << str << " = " << res << " (mod " << p << ")" << endl;
		}
	}
}

Measured memory_bytes: 1456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	double n,m,d;
	cin>>n>>m>>d;
	printf("%.12f\n",(d==0?1:2)*(n-d)*(m-1)/n/n);
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();

        out.println(Math.max(0, a - 2 * b));
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	
	ll N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vll x(N), y(M);
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];
	sort(all(x));
	sort(all(y));

	if (x.back() < y[0]) {
		rep(i, y[0] - x.back()) {
			ll Z = x.back() + i + 1;
			if (X < Z && Z <= Y) {
				cout << "No War" << endl;
				return 0;
			}
		}
		cout << "War" << endl;
		return 0;
	}
	else {
		cout << "War" << endl;
		return 0;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;


signed main()
{
    int n;
    cin >> n;
    int ans = 1;
    while(ans * 2 <= n)
    {
        ans *= 2;
    }
    cout << ans << endl;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *nil;

void insert(int k){
    Node *y = nil; // xの親
    Node *x = root; // 現在の接点(挿入するべき場所)
    Node *z; // 挿入する接点

    // zの初期化
    z = new Node;
    z->key = k;
    z->left = nil;
    z->right = nil;

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

    z->parent = y;
    if(y == nil) root = z;
    else{
        if(z->key < y->key) y->left = z;
        else y->right = z;
    }
}

void inorder(Node *u){
    if(u == nil) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == nil) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);

    for(int i=0; i<n; ++i){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }


    return 0;
}


Measured memory_bytes: 26740
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int a=0,b=0;
  cin >> a >> b;
  cout << (a>b?a-1:a) << endl;

  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
// utility
#include <bitset>
#include <tuple>
#include <typeinfo>
// error handling
#include <cassert>
// string
#include <cctype>
#include <cstring>
#include <string>
// container
#include <array>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// algorithm
#include <algorithm>
// iterator
#include <iterator>
// math
#include <cmath>
#include <complex>
#include <numeric>
#include <random>
// i/o
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
vector<int> divisor(int n) {
  vector<int> ret;
  int i;
  for (i = 1; i * i < n; i++) {
    if (n % i == 0) {
      ret.emplace_back(i);
      ret.emplace_back(n / i);
    }
  }
  if (i * i == n) {
    ret.emplace_back(i);
  }
  return ret;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    if (divisor(i).size() == 8)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
static const int INF = 2e9;
static const int SIZE = 10001;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

int d[SIZE];
vector<edge> G[SIZE];

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int to, cost;
			cin >> to >> cost;
			edge e1;
			e1.to = to;
			e1.cost = cost;
			G[u].push_back(e1);
		}
	}
	for (int i = 0; i < SIZE; ++i)
	{
		d[i] = INF;
	}
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				pque.push(P(d[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < n; ++i)
	{
		cout << i << " " << d[i] << endl;
	}
}

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

Measured memory_bytes: 6348
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

ll gcd(ll a, ll b) {
  if (b > a) {
    swap(a, b);
  }
  ll r = a%b;
  while (r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

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


signed main() {
    fio();
    string s;
    int n;
    cin >> n;
    cin >> s;
    ll r = 0, g = 0, b = 0;
    rep (i, n) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'B') b++;
        else g++;
    }

    ll ans = r * g * b;
    rep (i, n) {
        for (int j = 1; j <= n; j++) {
            int ni = i - j, nj = i + j;
            if (ni < 0 or nj >= n) break;
            if (s[i] != s[ni] and s[i] != s[nj] and s[ni] != s[nj]) ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
ft = 0

B, A = zip(*sorted(zip(B, A)))

for i in range(N):
    ft += A[i]
    if ft > B[i]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 47528
#include <cstdio>
using namespace std;


int main()
{
	long long r, d, x;
	
	scanf("%lld%lld%lld", &r, &d, &x);
	for (int i = 1; i <= 10; ++i)
		printf("%lld\n", x = r * x - d);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const int MAX_N = 50;
ll ans = 0;
int N, M, Q;
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

void dfs(vector<int> A){
    if(A.size() == N){
        ll t = 0;
        for(int i=0; i<Q; i++){
            if(A[b[i]] - A[a[i]] == c[i]) t += d[i];
        }
        ans = max(t, ans);
        return;
    }

    if(A.size() == 0){
        A.push_back(0);
        for(int i=1; i<=M; i++){
            A.back() = i;
            dfs(A);
        }
    }else{
        int p = A.back();
        A.push_back(p);
        for(int i=p; i<=M; i++){
            A.back() = i;
            dfs(A);
        }
    }

}

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

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

    vector<int> init;
    dfs(init);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
//***Because people who are crazy enough to think that they can change the world are the ones who do it***
//Think different
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[100];
int main(){
  ll n,c=0;
  cin>>n;
  forn(i,n){
   cin>>a[i];
   if((i%2==0)&&(a[i]%2!=0)) c++;
  }
  cout<<c;
}

Measured memory_bytes: 3536
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - 4-adjacent
            int n = int.Parse(Console.ReadLine());
            var a = ReadLine();

            var classifications = new List<List<int>>();

            for (int i = 0; i < 5; i++)
            {
                var c = new List<int>();
                classifications.Add(c);
            }

            //数列の要素を 4の倍数,2の倍数,奇数 に分類
            foreach (var ai in a)
            {
                if (ai % 4 == 0)
                {
                    classifications[4].Add(ai);
                }
                else if (ai % 2 == 0)
                {
                    classifications[2].Add(ai);
                }
                else
                {
                    classifications[1].Add(ai);
                }
            }

            if (IsGoal(classifications))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsGoal(List<List<int>> c)
        {
            if (c[4].Count >= c[1].Count)
            {
                return true;
            }
            else if (c[4].Count + 1 == c[1].Count)
            {
                if (c[2].Count == 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 20960
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            string n;
            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')

                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

           Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD SYSIN.
   01 INDATA  PIC X(10000).
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 S          PIC X(10000).
01 alp        PIC X(26) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
01 cnt        PIC 9(10) VALUE 26.
01 i          PIC 9(10) COMP.
01 j          PIC 9(10) COMP.
01 f          PIC X(26).
01 t          PIC X(26).
01 ans        PIC X(10000).

PROCEDURE DIVISION.
  ACCEPT N.
  OPEN INPUT SYSIN.
  READ SYSIN INTO INDATA.
  CLOSE SYSIN.
  MOVE INDATA TO S.
  MOVE alp TO f.
  STRING alp(N + 1 : cnt - N) alp(1 : N) INTO t.
  PERFORM TRAN.
  DISPLAY FUNCTION TRIM(ans).
  STOP RUN.

TRAN SECTION.
  PERFORM VARYING i FROM 1 BY 1 UNTIL FUNCTION STORED-CHAR-LENGTH(S) < i
    PERFORM VARYING j FROM 1 BY 1 UNTIL cnt < j
      IF S(i : 1) = f(j : 1)
        EXIT PERFORM
      END-IF
    END-PERFORM
    MOVE t(j : 1) TO ans(i : 1)
  END-PERFORM.


Measured memory_bytes: 3844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n;    
    cin >> n;
    vector<double> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,n-1) {
        a[i+1] = (a[i+1] + a[i])/2.0;
    }
    cout << a[n-1];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 10000;
typedef pair<int, int>P;
#define MOD 1000000007
int N, A[21][21];
ll dp[22][1 << 21];
//---------------------------------------------------------------------------------------------------
int main() {
    cin >> N;
    rep(i,N) rep(j,N) cin >> A[i][j];
    rep(i,N){rep(j,(1<<N)-1){dp[i][j]=0ll;}}
    dp[0][0] = 1;
    rep(i,N) rep(msk,1 << N) if(i == __builtin_popcount(msk)) {
        rep(j,N) if (!(msk & (1 << j))) if (A[i][j]) {
            dp[i+1][msk | (1 << j)] += dp[i][msk];
          dp[i+1][msk | (1 << j)]%=MOD;
        }
    }
    dp[N][(1<<N)-1]+=MOD;
    dp[N][(1<<N)-1]%=MOD;
    cout << dp[N][(1 << N) - 1] << endl;
}

Measured memory_bytes: 346368
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        var ans = 0L
        repeat(N) {
            val A = sc.next().toInt()
            ans += A - 1
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 32272
# -*- coding: utf-8 -*-


def main():
    n, w = map(int, input().split())
    items = [tuple(map(int, input().split())) for i in range(n)]

    dp = [[10**12] * 100001 for i in range(n + 1)]
    dp[0][0] = 0

    for i, item in enumerate(items):
        for i_v in range(100001):
            if item[1] - i_v > 0:
                dp[i + 1][i_v] = dp[i][i_v]
            else:
                dp[i + 1][i_v] = min(dp[i][i_v - item[1]] + item[0], dp[i][i_v])

    result = 0
    for sum_v, weght in enumerate(dp[-1]):
        if weght <= w:
            result = sum_v
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 119792
#include<cstdio>
//x,y方向のコストは独立
//2マスを選ぶとき距離dになる選び方は(n-d)*m*m通り（高さの選び方×1個目の位置×2個目の位置）
//その2マスについて加算される回数は、残りのn*m-2マスからk-2マスを選ぶ場合の数

long long ext_gcd(long long a,long long b,long long &x,long long &y){
    if(b==0){x=1;y=0;return a;}
    long long q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;
    x=y; y=z;
    return g;
}

long long inv(long long a,long long p){
    long long x,y;
    ext_gcd(a,p,x,y);
    return (x+p)%p;
}

void make_factorial(long long *x, int len, long long p){
    x[0]=1;
    for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%p;
}

long long ncr(long long n,long long r,long long *fct,long long p){
    if(n<0||n<r||r<0)return 0;
    return (fct[n]*inv(fct[r],p)%p)*inv(fct[n-r],p)%p;
}

long long fct[200001];
constexpr long long p=1e9+7;
int main(){
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    make_factorial(fct,n*m+1,p);
    long long sum=0;
    //xについて加算
    for(int d=1;d<n;d++){
        sum+=(((ncr(n*m-2,k-2,fct,p)*(n-d)%p)*m%p)*m%p)*d%p;
    }
    //yについて加算
    for(int d=1;d<m;d++){
        sum+=(((ncr(n*m-2,k-2,fct,p)*(m-d)%p)*n%p)*n%p)*d%p;
    }
    printf("%lld\n",sum%p);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<double, string>> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m.at(i).first;
    cin >> m.at(i).second;
  }
  double res = 0;
  for (int i = 0; i < n; i++) {
    if (m.at(i).second == "JPY") {
      res += m.at(i).first;
    }
    else {
      res += m.at(i).first * 380000;
    }
  }
  cout << res << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        if (s.at(i) == '1') cout << "9";
        else if (s.at(i) == '9') cout << '1';
        else cout << s.at(i);
    }
    cout << endl;
}


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

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<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A, B; cin >> A >> B;
    cout << (ll) ceil((double)(B - 1) / (A - 1)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

template<typename T>
class DoublyLinkedList {
private:
    struct Node {
    public:
        T val;
        Node *prev;
        Node *next;
    };

    Node *dummy;

public:
    DoublyLinkedList() {
        dummy = new Node();
        dummy->prev = dummy;
        dummy->next = dummy;
    }

    ~DoublyLinkedList() {
        Node *node = dummy->next;
        while (node != dummy) {
            node = node->next;
            delete node->prev;
        }
        delete dummy;
    }

    void insert_head(T x) {
        Node *temp = dummy->next;
        dummy->next = new Node();
        dummy->next->val = x;
        dummy->next->prev = dummy;
        dummy->next->next = temp;
        temp->prev = dummy->next;
        return;
    }

    Node *search_node(T x) {
        Node *node = dummy->next;
        while (node != dummy && node->val != x) node = node->next;
        return node;
    }

    void delete_node(Node *node) {
        if (node != dummy) {
            node->prev->next = node->next;
            node->next->prev = node->prev;
            delete node;
        }

        return;
    }

    void delete_key(T x) {
        delete_node(search_node(x));
        return;
    }

    void delete_first() {
        delete_node(dummy->next);
        return;
    }

    void delete_last() {
        delete_node(dummy->prev);
        return;
    }

    void print() {
        Node *node = dummy->next;
        while (node != dummy) {
            cout << node->val << (node->next == dummy ? "\n" : " ");
            node = node->next;
        }

        return;
    }
};

int main() {
    ios::sync_with_stdio(false);
    uint32_t n;
    cin >> n;

    DoublyLinkedList<uint32_t> l;
    string cmd;
    uint32_t key;
    while (n--) {
        cin >> cmd;

        if (cmd == "insert") {
            cin >> key;
            l.insert_head(key);
        } else if (cmd == "delete") {
            cin >> key;
            l.delete_key(key);
        } else if (cmd == "deleteFirst") {
            l.delete_first();
        } else if (cmd == "deleteLast") {
            l.delete_last();
        }
    }

    l.print();

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

vi g[100010];

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

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--, b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	queue<int> q;
	vi dist(n, inf);
	vi pre(n, -1);
	dist[0] = 0;
	q.push(0);

	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int u : g[v]) {
			if (dist[u] != inf) continue;
			dist[u] = dist[v] + 1;
			pre[u] = v;
			q.push(u);
		}
	}

	cout << "Yes" << endl;
	rep(i, n) {
		if (i == 0) continue;
		int ans = pre[i];
		++ans;
		cout << ans << endl;
	}
}

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

# 1リットル買う
min_for_one = min(a*4, b*2, c)

min_for_two = min(a*8, b*4, c*2, d)

if n % 2 == 1:
    print((n //2)* min_for_two + min_for_one)
else:
    print(n // 2 * min_for_two)


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;
vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main(void)
{
	ll n,ans=0;
	cin>>n;
	vector<ll> ret = enum_div(n);
	sort(all(ret));
	for(ll p : ret){
		if(p * (p + 2) > n){
			break;
		}
		if((n/p)>(p+1)){
			ans+=(n/p-1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	for (int i = 1; i < 10; i++) {
		if (N % i == 0 && N / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
def solve(n, m):
    ans = [-1] * n
    for _ in range(m):
        s, c = input().split()
        s = int(s) - 1
        if ans[s] == c:
            continue
        elif ans[s] == -1:
            ans[s] = c
        else:
            return -1
 
    if ans[0] == '0':
        if n == 1:
            return '0'
        else:
            return -1
    elif ans[0] == -1:
        if n == 1:
            return '0'
        else:
            ans[0] = '1'
    for i in range(1, n):
        if ans[i] == -1:
            ans[i] = '0'
    return ''.join(ans)
 
 
n, m = list(map(int, input().split()))
print(solve(n, m))

Measured memory_bytes: 3064