akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, input().split())
s = input()

on = []
off = []

acnt = 0
bcnt = 0
for i in s:
  if i == '0':
    if bcnt > 0:
      off.append(bcnt)
      bcnt = 0
    acnt += 1
  else:
    if acnt > 0:
      on.append(acnt)
      acnt = 0
    bcnt += 1
if bcnt > 0:
  off.append(bcnt)
  bcnt = 0
if acnt > 0:
  on.append(acnt)
  acnt = 0
ans = 0
if s[0] == '1':
  for i in range(len(on)-k+1):
    s = 0
    if i == 0:
      a = sum(on[i:i+k])
      b = sum(off[i:i+k+1])
    else:
      a += on[i+k-1]
      a -= on[i-1]
      if i+k <= len(off)-1:
        b += off[i+k]
      b -= off[i-1]
    # print (a,b)
    s = a+b
    ans = max(ans,s)
else:
  for i in range(len(on)-k+1):
    if i == 0:
      a = sum(on[i:i+k])
      b = sum(off[i:i+k])
    elif i == 1:
      a = sum(on[i:i+k])
      b = sum(off[i-1:i+k])
    else:
      a += on[i+k-1]
      a -= on[i-1]
      if i+k-1 <= len(off)-1:
        b += off[i+k-1]
      b -= off[i-2]
    s = a+b
    # print (a,b)
    ans = max(ans,s)
if ans == 0:
  print (n)
else:
  print (ans)


Measured memory_bytes: 10336
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,x,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x)ans++;
            }
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,c,i,j=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
            j++;
    }
    printf("%d\n",j);
    return 0;
}



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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}

  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return -d[find(x)]; }
};

int main() {
  ll n, m, a, b;
  cin >> n >> m;

  UnionFind uf(n);
  rep(i, m) {
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
  }

  int ans = 0;
  rep(i, n) ans = max(ans, uf.size(i));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048
package main

import (
	"fmt"
	"sort"
)

type PairVC struct {
	val int
	cnt int
}

type ByCnt []PairVC

func (p ByCnt) Len() int {
	return len(p)
}
func (p ByCnt) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
func (p ByCnt) Less(i, j int) bool {
	return p[i].cnt > p[j].cnt
}

func count(V []int) []PairVC {
	M := make(map[int]int)
	for _, v := range V {
		cnt, ok := M[v]
		if ok {
			M[v] = cnt + 1
		} else {
			M[v] = 1
		}
	}

	P := make([]PairVC, 0, len(M))
	for val, cnt := range M {
		P = append(P, PairVC{val, cnt})
	}

	sort.Sort(ByCnt(P))
	if len(P) == 1 {
		P = append(P, PairVC{-1, 0})
	}
	return P[:2]
}

func main() {
	var n int
	fmt.Scan(&n)

	V1 := make([]int, n/2)
	V2 := make([]int, n/2)
	for i := 0; i < n/2; i++ {
		fmt.Scan(&V1[i], &V2[i])
	}

	P1 := count(V1)
	P2 := count(V2)

	if P1[0].val != P2[0].val {
		fmt.Println(len(V1) - P1[0].cnt + len(V2) - P2[0].cnt)
	} else {
		r1 := len(V1) - P1[0].cnt + len(V2) - P2[1].cnt
		r2 := len(V1) - P1[1].cnt + len(V2) - P2[0].cnt
		if r1 < r2 {
			fmt.Println(r1)
		} else {
			fmt.Println(r2)
		}
	}
}


Measured memory_bytes: 6656
n=int(input())
E=[]
if n%2==0:
  s=n+1
else:
  s=n
for i in range(1,n):
  for j in range(i+1,n+1):
    if i+j==s:
      continue
    else:
      E.append((i,j))
print(len(E))
for i,j in E:
  print(i,j)

Measured memory_bytes: 3996
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

vector<pll> prime_factorize(ll n){
    vector<pll> res;
    for(ll i = 2; i * i <= n; i++){
        if(n % i != 0) continue;
        ll ex = 0;

        while(n % i == 0){
            ex++;
            n /= i;
        }

        res.push_back({i,ex});
    }
    if(n != 1) res.push_back({n,1});
    return res;
}

//main関数
int main() {
    ll n; cin >> n;
    vl cnt(n,1);//A*B=NとなるA,Bの個数

    ll ans = 0;
    REP(i,1,n){
        const auto &pf = prime_factorize(i);
        for(auto p : pf) cnt[i] *= (p.second + 1);
        ans += cnt[i];
    }

    cout << ans << endl;

}


Measured memory_bytes: 11192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;
bool cmp(pair<string,pair<int,int>> a, pair<string,pair<int,int>> b)
{
    if(a.first!=b.first)
    return a.first<b.first;
    return a.second.first > b.second.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<string,pair<int,int>>> temp(n);
    for(int i=0;i<n;++i)
    {
        cin >> temp[i].first >> temp[i].second.first;
        temp[i].second.second = i+1;
    }
    sort(temp.begin(),temp.end(),cmp);

    for(auto x:temp)
    {
        cout << x.second.second << endl;
    }
}

Measured memory_bytes: 256
// Returns the size of maximum bipartite matching.
// Complexity: O(V E)
// Args:
//   lSize: Number of vertexes of the left set.
//   rSize: Number of vertexes of the right set.
//   lGraph: Adjacency graph from the left to the right.
fun bipartiteMatching(lSize: Int, rSize: Int, lGraph: Array<MutableList<Int>>): Int {
  var matchSize = 0
  val lMatches = IntArray(lSize, { -1 })
  val rMatches = IntArray(rSize, { -1 })
  val rSearched = BooleanArray(rSize)

  fun search(lv: Int): Boolean {
    for (rv in lGraph[lv]) {
      if (rSearched[rv]) continue
      rSearched[rv] = true
      if (rMatches[rv] == -1 || search(rMatches[rv])) {
        lMatches[lv] = rv
        rMatches[rv] = lv
        return true
      }
    }
    return false
  }

  for (lv in 0 until lSize) {
    rSearched.fill(false)
    if (search(lv)) matchSize++
  }
  return matchSize
}

data class Int2D(val x: Int, val y: Int)

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val lPoints = Array(n, {
    val (x, y) = readLine()!!.split(" ").map(String::toInt)
    Int2D(x, y)
  })
  val rPoints = Array(n, {
    val (x, y) = readLine()!!.split(" ").map(String::toInt)
    Int2D(x, y)
  })
  val lGraph = Array(n, { mutableListOf<Int>() })
  for (lv in 0 until n) {
    for (rv in 0 until n) {
      if (lPoints[lv].x < rPoints[rv].x && lPoints[lv].y < rPoints[rv].y) {
        lGraph[lv].add(rv)
      }
    }
  }
  val ans = bipartiteMatching(n, n, lGraph)
  println(ans)
}


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


void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B){
    int i = 0, j = 0;
    long long total = 0;
    long long ans = 0;

    while (i < N && total + A[i] <= K) {
        total += A[i];
        ans++;
        i++;
    }
    
    long long max_ans = 0;
    while (1) {
        while (j < M && total + B[j] <= K) {
            total += B[j];
            ans++;
            j++;
        }
        max_ans = max(max_ans, ans);
        if (i > 0) {
            i--;
            ans--;
            total -= A[i];
        } else {
            break;
        }
    }

    cout << max_ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, M, K, std::move(A), std::move(B));
    return 0;
}


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

using namespace std;

int main() {

	long long h, w;
	cin >> h >> w;

	if (h == 1 || w==1) {
		cout << 1 << endl;
		return 0;
	}

	if (h % 2 == 0 && w % 2 == 0) {
		cout << h * w / 2 << endl;
		return 0;
	}
	if (h % 2 == 0) {
		cout << h * (w - 1) / 2 + h / 2 << endl;
		return 0;
	}
	if (w % 2 == 0) {
		cout << (h - 1) * w / 2 + w / 2 << endl;
		return 0;
	}

	cout << (h - 1)*(w - 1) / 2 + (h + 1) / 2 + (w + 1) / 2 -1 << endl;

	return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    vector<set<int>> alp(26);
    for(int i = 0; i < (int)s.size(); i++){
        alp[s[i] - 'a'].insert(i);
    }
    int pre = 0;
    long long ans = 0;
    long long cnt = 1;
    for(int i = 0; i < (int)t.size(); i++){
        int ind = t[i] - 'a';
        if(alp[ind].empty()){
            cout << -1 << endl;
            return 0;
        }
        if(i == 0){
            auto ite = alp[ind].begin();
            ans += (long long)*ite;
            pre = *ite;
        }
        else{
            int flag = 0;
            if(t[i] == t[i - 1]) {
                pre++;
                flag++;
            }
            auto ite = alp[ind].lower_bound(pre);
            if(ite == alp[ind].end()){
                ans = cnt * (long long)s.size() + (long long)*alp[ind].begin();
                pre = *alp[ind].begin();
                cnt++;
            }
            else{
                if(flag == 0) ans += (long long)(*ite - pre);
                else ans += (long long)(*ite - pre) + 1;
                pre = *ite;
            }
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 8492
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int N;
vector<long long> A(100000);

void solve(long long x) {
    long long ans = 0;
    long long sum = 0;
    int right = 0;
    rep(left, N) {
        while (right < N && sum + A[right] <= x) {
            sum += A[right];
            ++right;
        }
        ans += right - left;
        if (right == left) ++right;
        else sum -= A[left];
    }
    cout << ans << endl;
    return;
}

int main() {
    int Q;
    cin >> N >> Q;
    rep(i, N) cin >> A[i];
    rep(i, Q) {
        long long x;
        cin >> x;
        solve(x);
    }
    return 0;
}



Measured memory_bytes: 3448
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int t =scan.nextInt();
		int a =scan.nextInt();
		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = scan.nextInt();
		}

		double temp = Math.abs(a - (t - h[0] * 0.006));
		int ans = 0;
		for ( int i = 1; i < n; i++) {
			if (Math.abs(a - (t - h[i] * 0.006)) < temp) {
				temp = Math.abs(a - (t - h[i] * 0.006));
				ans = i;
			}
		}

		System.out.println(ans + 1);
	}
}

Measured memory_bytes: 23636
values = list(map(int, input().split()))
n = values[0]
l = values[1]

if(l > 0):
  # 一番小さいりんごを食べる
  print(sum(range(l + 1, n + l)))
elif(n + l <= 0):
  # 一番大きいりんごを食べる
  print(sum(range(l, n + l - 1)))
else:
  # 0のりんごを食べる
  print(sum(range(l, n + l)))

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

int main() {
int A, B,  C, D;
cin >> A >> B >> C >> D;
int X = A + B;
int Y = C + D;
if (X == Y){
cout << "Balanced" << endl;
}
else if (X < Y){
cout << "Right" << endl;
}
else if (X > Y){
cout << "Left" << endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long N, A, B;
    cin >> N >> A >> B;
    if (A <= B) {
        if (A == B) {
            puts("1");
        }
        else {
            if (N == 1) {
                puts("0");
            }
            else {
                long long m = B+A*(N-1);
                long long M = A+B*(N-1);
                cout << M-m+1 << endl;
            }
        }
    }
    else {
        puts("0");
    }
}

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


/*
int solve(int i){
	if(i == 0) return 0;
	if(i == 1) return 0;
	if(memo[i] != -1) return memo[i];
	int m = INT_MAX;
	for(int d = 1; d <= k; d++){
		if(i - d < 0) break;
		m = min(solve(i-d, k)+abs(h[i]-h[i-d]), m);
	}
	return memo[i] = m;
}*/


int n;

double dp[301][301][301] = {};

double solve(int a, int b, int c){
	if(a == 0 && b == 0 && c == 0) return 0.0;
	if(dp[a][b][c] != 0.0) return dp[a][b][c];
	double ret = 0.0;
	double cost = n / (double)(a+b+c);
	if(a > 0) ret += (double)a * solve(a-1,b+1,c);
	if(b > 0) ret += (double)b * solve(a,b-1,c+1);
	if(c > 0) ret += (double)c * solve(a,b,c-1);
	ret /= (double)(a+b+c);
	ret += cost;
	return dp[a][b][c] = ret;
}

int main(){
	cin >> n;

	int a[3] = {};
	for(int i = 0; i < n; i++){
		int buf; cin >> buf;
		a[buf-1]++;
	}



	cout << setprecision(12) << solve(a[2], a[1], a[0]) << endl;

    return 0;
}


Measured memory_bytes: 213248
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    int ans;
    if (n%2 == 0) ans = n/2;
    else ans = n/2 + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main 
{
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) 
	{
		int w;
		int h;

		//numbers: ascii 48 ~ 57 are 0 ~ 9
		
		while(true)
		{
			w = scan.nextInt();
			h = scan.nextInt();
			
			if(w == 0 && h == 0)
			{
				break;
			}
			else
			{
				new DataSet(w,h);
			}
			
		}
	}
	
	static class DataSet
	{
		int width;
		int height;
		char[][] grid;
		String[][] calc;
		List<Integer> startX = new ArrayList<Integer>();
		List<Integer> startY = new ArrayList<Integer>();
		
		public DataSet(int w, int h)
		{
			this.width = w;
			this.height = h;
			
			grid = new char[w][h];
			calc = new String[w][h];
			
			for(int row = 0; row < h; row++)
			{
				String str = scan.next();
				
				for(int ch = 0; ch < w; ch++)
				{
					//numbers: ascii 48 ~ 57 are 0 ~ 9
					grid[ch][row] = str.charAt(ch);
				}
			}
			
			
			String biggest = "0";
			
			for(int row = h-1; row >= 0; row--)
			{
				
				for(int ch = w-1; ch >= 0; ch--)
				{
					String here;
					String right;
					String down;
					
					if(charIsNumber(grid[ch][row]))
					{
						if(ch == w-1 || !charIsNumber(grid[ch+1][row]))
						{
							right = "";
						}
						else
						{
							right = calc[ch+1][row];
						}
						
						if(row == h-1 || !charIsNumber(grid[ch][row+1]))
						{
							down = "";
						}
						else
						{
							down = calc[ch][row+1];
						}
						
						right = grid[ch][row] + right;
						down = grid[ch][row] + down;
						
						if(right.length() > down.length())
						{
							here = right;
						}
						else if(down.length() > right.length())
						{
							here = down;
						}
						else //if(right.length() == down.length())
						{
							if(firstStringIsBigger(right,down))
							{
								//right
								here = right;
							}
							else
							{
								here = down;
							}
						}
						
						calc[ch][row] = here;
						
//						System.out.println(ch + ", " + row + " is " + here);
						
						if(firstStringIsBigger(here, biggest))
						{
							biggest = here;
						}
					}
				}
			}
			
			System.out.println(biggest);
		}
		
		public String removeZeroesAtStart(String a)
		{
			String ans = a;
			
			while(true)
			{
//				System.out.println("checking " + a);
				
				if(a.equals("")) {return a;}
				if(a.charAt(0) == 48)
				{
					a = a.substring(1);
				}
				else
				{
					return a;
				}
			}
		}
		
		boolean firstStringIsBigger(String a, String b)
		{
			a = removeZeroesAtStart(a);
			b = removeZeroesAtStart(b);
			
			if(a.length() > b.length()) {return true;}
			if(a.length() < b.length()) {return false;}
			
			//when length is the same: compare from the 1st digit (most significant)
			
			for(int i = 0; i < a.length(); i++)
			{
				if(a.charAt(i) > b.charAt(i))
				{
					return true;
				}
				if(a.charAt(i) < b.charAt(i))
				{
					return false;
				}
			}
			
			return false;
		}
		
		
		boolean charIsNumber(char c)
		{
			if(c >= 48 && c <= 57)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}

}



Measured memory_bytes: 68460
#include<stdio.h>

int main(){
   int x[5],i;
   int dif = 0;
   for(i = 0;i<5;i++){
      scanf("%d",&x[i]);
      if(x[i]==0){
         dif=i+1;
      }
   }
   printf("%d",dif);
   return 0;
}


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

int main(){
  ll n; ll k;
  cin >> n >> k;
  ll a[n]; ll f[n];
  rep(i,n)  cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a,a+n); sort(f,f+n,greater<ll>()); 
  ll l = -1, r = INF;
  while(r-l > 1) {
    ll m = (r+l)/2;
    ll t = 0;
    ll b[n];
    rep(i,n) b[i] = (m/f[i]);
    bool can = true;
    ll z = k;
    rep(i,n) {
      if(a[i] > b[i]) z -= a[i] - b[i];
    }
    if(z >= 0) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4992
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var N = intShift();
  var X = intShift();
  
  var o = [];
  for(var i = 0 ; i < N; i++){
  	var a = intShift();
    o.push(a);
    X -= a;
  }
  
  
  return ~~(N+Math.floor(X/Math.min(...o)));
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
3 1000
120
100
140
`);

Measured memory_bytes: 7372
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val dp = LongArray(N + 1){ i -> i.toLong() }
    for(i in 0 until N){
        // 6の処理
        var m = 6
        while (true){
            if(i + m in 0..N){
                dp[i + m] = Math.min(dp[i + m], dp[i] + 1)
                m *= 6
            }else{
                break
            }
        }
        // 9の処理
        m = 9
        while (true){
            if(i + m in 0..N){
                dp[i + m] = Math.min(dp[i + m], dp[i] + 1)
                m *= 9
            }else{
                break
            }
        }
    }
    println(dp[N])
}

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    vector<bool> gh(h), gw(w);
    for(int i=0; i<h; ++i){cin >> s[i];}
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            if(s[i][j]=='#'){
                gh[i] = true;
                gw[j] = true;
            }
        }
    }
    for(int i=0; i<h; ++i){
        if(!gh[i]){continue;}
        for(int j=0; j<w; ++j){
            if(!gw[j]){continue;}
            cout << s[i][j];
        }
        cout << endl;
    } 
    return 0;
}

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

int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==1){
    cout << "No" << endl;
    return 0;
  }
  if(2*x<=y && y<=4*x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
n,y=map(int, input().split())
nums=[i for i in range(n+1)]
judge = 0
for i in range(n+1):
    for j in range(n+1-i):
        price = i * 10000 + j * 5000 + (n-i-j) * 1000
        if y == price:
            judge += 1
            print(str(i) + " " + str(j) + " " + str(n-i-j))
            break
    if judge == 1:
        break
if judge == 0:
    print("-1 -1 -1")

Measured memory_bytes: 9184
#N, X, Y = map(int, input().split())
#l = [0 for _ in range(N-1)]
#for i in range(1, N+1):
#    for j in range(i+1,N+1):
#        n = min(j-i, abs(i-X)+1 + abs(j-Y))
#        l[n-1] +=1
#for m in l:
#    print(m)
inf = 100000
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
ans = [0] *N
for i in range(N):
    queue = []
    dist = [inf] *N
    def push(n, d):
        if dist[n] == inf:
            dist[n] = d
            queue.append(n)
    push(i, 0)
    for q in queue:
        if q-1 >=0:
            push(q-1, dist[q] + 1)
        if q+1 <N:
            push(q+1, dist[q] + 1)
        if q == X:
            push(Y, dist[q] + 1)
        if q == Y:
            push(X, dist[q] + 1)
    for d in dist:
        ans[d] += 1
for i in range(1, N):
    print(int(ans[i]/2))


Measured memory_bytes: 51036
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

void solve_A(){
    int s, w;
    cin >> s >> w;

    cout << (w<s? "safe":"unsafe") << endl;
}

void solve_B(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

map<string, int> ans;

void solve_C(){
    int n;
    cin >> n;
  
    REP(i,n){
        string s;
        cin >> s;
        ans[s]++;
    }

    cout << ans.size() << endl;
}

int main(void){
    solve_C();
    
    return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  string res;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'B'){
      if(res.size() == 0)continue;
      res.erase(res.begin() + res.size() - 1);
    }
    else res += s[i];
  }
  cout << res << endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m; cin >> n >> m;
  int cnt[m][n]; rep(i, m) rep(j, n) cnt[i][j] = 0;
  
  rep(i, m) {
    int k; cin >> k;
    rep(j, k) {
      int x; cin >> x;
      ++cnt[i][x-1];
    }
  }
  int p[m]; rep(i, m) cin >> p[i];
  int ans = 0;

  rep(i, (1<<n)) {
    vector<int> v(n);
    rep(j, n) {
      v[j] = (i>>j & 1);
    }
    bool flag = 1;
    rep(j, m) {
      int sum = 0;
      rep(k, n) {
        sum += (cnt[j][k] * v[k]);
      }
      if(sum%2 != p[j]) flag = 0;
    }
    ans += flag;
  }
  cout << ans;
}
    


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm> 
using namespace std;
long long a[200005] = {0}, i, n, m, ans= 99000000000;
int main()
{
	scanf("%lld", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%lld", &m);
		a[i] = a[i - 1] + m;
	}
	for (i = 1; i<n; i++)ans = min(abs(a[i] * 2 - a[n]), ans);
	printf("%lld\n", ans);
	return 0;
}

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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if (n >= m/2){
		ans += m/2;
	}
	else {
		ans += n;
		m -= 2*n;
		ans += m/4;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

ll N,M;
ll diff[NUM];

int main(){

	scanf("%lld %lld",&N,&M);

	for(int i = 0; i < N; i++){
		diff[i] = 0;
	}

	int loc;
	ll A,B;
	ll sum_ADD = M;

	for(int loop = 0; loop < M; loop++){

		scanf("%lld %lld",&A,&B);
		sum_ADD += A;

		loc = B-A-1;

		while(loc < N){

			diff[loc] -= B;
			loc += B;
		}
	}

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

		diff[i] += diff[i-1];
	}

	for(ll i = 0; i < N; i++){

		printf("%lld\n",sum_ADD+diff[i]+i*M);
	}

	return 0;
}



Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

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

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

bool isOdd[105000];
vector<int> treepath[105000];

void dfs(int now, int from) {
    for(int i = 0; i < treepath[now].size(); i++) {
        int to = treepath[now][i];
        if(to == from) continue;
        dfs(to, now);
    }
    if(from == -1) return;
    if(isOdd[now]) {
        cout << now << " " << from << endl;
    } else {
        cout << from << " " << now << endl;
        isOdd[from] = !isOdd[from];
    }
}

int main() {
    //cout.precision(10);
    int N, M;
    cin >> N >> M;
    if(M & 1) {
        cout << "-1" << endl;
        return 0;
    }
    UnionFind uni(N + 1);
    for(int i = 1; i <= M; i++) {
        int u, v;
        cin >> u >> v;
        if(uni.merge(u, v)) {
            treepath[u].push_back(v);
            treepath[v].push_back(u);
        } else {
            cout << u << " " << v << endl;
            isOdd[u] = !isOdd[u];
        }
    }
    dfs(1, -1);
    return 0;
}


Measured memory_bytes: 13952
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
l=[-1]*n
z=n*(n-1)//2
b=[input().split() for _ in range(m)]
c=[0]*(m-1)+[z]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,0,-1):
  x,y=map(f,b[i])
  if x!=y:
    s,t=l[x],l[y]
    z-=s*t
    if s<t:
      l[y]=x
      l[x]+=t
    else:
      l[x]=y
      l[y]+=s
  c[i-1]=z
for x in c:
  print(x)

Measured memory_bytes: 41316
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
N, M = MAP()

print(M//2 if N > M//2 else N + (M-2*N)//4)


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
int n,m;
char r[1001][1001],b[1001][1001],a[1001][1001];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            r[i][j]='#';
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            r[i][j]='.';
    for(int i=2;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            b[i][j]='#';
    for(int i=1;i<=n;i+=2)
        for(int j=1;j<=m;j++)
            b[i][j]='.';
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++){
            char cur;
            cin>>cur;
            if(cur=='#'){
                r[i][j]='#';
                b[i][j]='#';
            }
        }
    for(int i=1;i<=n;i++)
        r[i][1]='#',b[i][1]='.';
    for(int i=1;i<=n;i++)
        r[i][m]='.',b[i][m]='#';
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
          cout<<r[i][j];
        cout<<endl;
    }
    cout<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
          cout<<b[i][j];
        cout<<endl;
    }
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int a[21][21];
int dp[22][1 << 21];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	
	rep(i, 0, n) rep(j, 0, n) read(a[i][j]);

	dp[0][0] = 1;

	const ll mod = 1000000007;
	rep(i, 0, n) {
		rep(j, 0, 1 << n) if (dp[i][j]) {
			//printf("%d %d\n", i, j);
			rep(k, 0, n) {
				if (!((j >> k) & 1) && a[i][k]) {
					(dp[i + 1][j | (1 << k)] += dp[i][j]) %= mod;
					//cout << (i + 1) << " " << bitset<3>(j | (1 << k)) << endl;
				}
			}
		}
	}

	write(dp[n][(1 << n) - 1]);
}


Measured memory_bytes: 162048
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <numeric>
#include <complex>
#include <iomanip>

using namespace std;

#define bitcount(n) __builtin_popcount(n)

#define debug(n) cout << n << endl;

#define PREC(n) setprecision(n)
#define DOTPREC(n) fixed << setprecision(n)

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false); cin.tie(0)

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

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

const ll MOD = 1000000007;

ll N;
ll T[100000], A[100000];
ll U[100000], L[100000];
int main(void)
{
    omajinai;
    cin >> N;

    ll t_max = -1;
    rep(i, N) {
        cin >> T[i];
        if (chmax(t_max, T[i])) {
            U[i] = L[i] = T[i];
        }
        else {
            U[i] = t_max >= 1 ? t_max : 1;
            L[i] = 1;
        }
    }
    rep(i, N) cin >> A[i];

    ll a_max = -1;
    rrep(i, N) {
        if (chmax(a_max, A[i])) {
            if (U[i] == L[i] && U[i] != A[i]) {
                debug(0);
                return 0;
            }
            U[i] = L[i] = A[i];
        }
        else {
            if (U[i] == L[i]) { // match in T
                if (U[i] > A[i]) { // impossible
                    debug(0);
                    return 0;
                }
                continue;
            }
            U[i] = a_max > U[i] ? U[i] : (a_max >= 1 ? a_max : 1);
        }
    }

    ll ans = 1;
    rep(i, N) {
        ll size = U[i] - L[i] + 1;
        if (size < 1) {
            debug(0);
            return 0;
        }
        ans = (ans * size) % MOD;
    }
    debug(ans);
    return 0;
}


Measured memory_bytes: 3328
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    LL h,w;
    cin >> h >> w;

    LL ans;
    if(w == 1 || h == 1){
        ans = 1;
    }else{
        ans = (h*w+1)/2;
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
struct node *T;
void Insert(int);
void Inorder(struct node*);
void Preorder(struct node*);
int Find(int);
void Free(struct node*);
int main(){
  int n, i, key;
  char func[6];
  T = (struct node *)malloc(sizeof(struct node) * 1);
  T->parent = T->left = T->right = NULL;
  T->key = -1;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",&func);
    if(strcmp(func,"insert") == 0){
      scanf("%d",&key);
      Insert(key);
    }
    else if(strcmp(func,"print") == 0){
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
    }
    else if(strcmp(func,"find") == 0){
      scanf("%d",&key);
      Find(key) ? printf("yes\n") : printf("no\n");
    }
  }
  Free(T);
  return 0;
}

void Inorder(struct node* X){
  if(X != NULL){
    Inorder(X->left);
    printf(" %d",X->key);
    Inorder(X->right);
  }
}

void Preorder(struct node* X){
  if(X != NULL){
    printf(" %d",X->key);
    Preorder(X->left);
    Preorder(X->right);
  }
}

void Free(struct node* X){
  if(X != NULL){
    Free(X->left);
    Free(X->right);
    free(X);
  }
}

void Insert(int key){
  struct node *x, *y, *S;
  if(T->key == -1){
    T->key = key;
    return;
  }
  S = (struct node *)malloc(sizeof(struct node) * 1);
  S->key = key;
  S->parent = S->left = S->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  S->parent = y;
  if(S->key < y->key)
    y->left = S;
  else
    y->right = S;
}

int Find(int key){
  struct node *X;
  for(X=T; X != NULL;){
    if(X->key > key)
      X = X->left;
    else if(X->key < key)
      X = X->right;
    else return 1;
  }
  return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Run(args));
        }

        private static string Run(string[] args)
        {
            var s = Console.ReadLine();
            var ret = "Yes";
            for (int i = 0; i < s.Length; i++)
            {
                var c = s[i];
                if (c == 'R' && i % 2 == 1) {
                    ret = "No";
                    break;
                }
                if (c == 'L' && i % 2 == 0) {
                    ret = "No";
                    break;
                }
            }
            return ret;
        }
    }
}


Measured memory_bytes: 13140
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,d;
  cin >> n >> d;
  d *= 2; d++;
  cout << ceil((double)n / d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<endl;
using namespace std;
#define int long long
signed main() {
	string s;
	cin>>s;
	int k;
	cin>>k;
	if(s.length()==1) {
		cout<<(k)/2;
		return 0;
	} else {
		int tot=0;
		for(int i=1; i<=s.length(); ++i) {
			if(s[i-1]==s[i]) {
				s[i]='A';
				++tot;
			}
		}

		int flag=0;
		int qwq=tot;
		if(s[s.length()-1]==s[0]&&s[s.length()]!='A') {
			++tot;
			flag=1;
		}
		for(int i=1; i<=s.length(); ++i) {
			if(s[i]=='A') {
				s[i]=s[i-1];
			}
		}
		int ans=tot*k-flag;
		if(s[s.length()-1]==s[0]) {
			if(s[0]==s[1]) {
				flag=0;
			} else {
				flag=1;
			}
			tot=0;
			s[0]='A';
			++tot;
			for(int i=1; i<=s.length(); ++i) {
				if(s[i]==s[i-1]) {
					s[i]='A';
					++tot;
				}
			}
			ans=min(ans,tot*k-flag);
			if(s[s.length()-1]=='A') {
				ans=min(ans,tot*(k/2)+qwq*(k-k/2));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int sum = a + b;
        int minus = a -b;
        int kake = a * b;

        if ((sum >= minus)&&(sum >= kake)) {
        	System.out.println(String.valueOf(sum));
        } else if ((minus >= sum)&&(minus >= kake)) {
        	System.out.println(String.valueOf(minus));
        } else {
        	System.out.println(String.valueOf(kake));
        }


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


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

vector<pair<long long, long long>> prime_factorize(long long n,vector<pair<long long, long long>> &res) {
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int sam(int k){
    for(int i = 0;i <100;i++){
        if(k < (i+1)*i/2){
            return i-1;
        }
    }
}

int main(){
    vector<pair<long long, long long> > k;
    long long a;
    cin >> a;
    int sum = 0;
    k = prime_factorize(a,k);
    for(int i = 0;i < k.size();i++){
        sum += sam(k[i].second);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int N=610;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll F[N];
ll dp1[N][N], dp2[N][N];
int A[N];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	F[0]=1;
	for (int i=2; i<N; i++) F[i]=F[i-2]*(i-1)%mod;
	memset(A, -1, sizeof(A));
	cin>>n>>m;
	while (m--){
		cin>>x>>y;
		x--;
		y--;
		A[x]=y;
		A[y]=x;
	}
	n<<=1;
	for (int l=0; l<n; l++) for (int r=l+1; r<n; r+=2){
		int bad=0, ted=0;
		for (int i=l; i<=r; i++){
			if (A[i]==-1) ted++;
			else if (A[i]<l || A[i]>r) bad=1;
		}
		if (bad) continue ;
		dp1[l][r]=F[ted];
	}
	for (int l=0; l<n; l++) for (int r=l-1; 0<=r; r-=2){
//		debug2(l, r)
		int bad=0, ted=0;
		for (int i=l; ; i=(i+1)%n){
			if (A[i]==-1) ted++;
			else if (r<A[i] && A[i]<l) bad=1;
			if (i==r) break ;
		}
//		debug(ted)
		if (bad) continue ;
		dp1[l][r]=F[ted];
	}
	for (int lr=1; lr<n; lr+=2) for (int l=0; l<n; l++){
		int r=(l+lr)%n;
		if (l>r || !dp1[l][r]) continue ;
		dp2[l][r]=dp1[l][r];
		for (int i=l; i!=r; i=(i+1)%n) dp2[l][r]=(dp2[l][r]-dp2[l][i]*dp1[(i+1)%n][r])%mod;
		if (lr!=n-1) ans=(ans + dp2[l][r]*dp1[(r+1)%n][(l+n-1)%n])%mod;
		else ans=(ans + dp2[l][r])%mod;
//		if (dp2[l][r]) cerr<<l<<' '<<r<<" : "<<dp2[l][r]<<'\n';	
	}
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
//	debug(dp1[0][1])
//	debug(dp1[1][2])
//	debug(dp1[2][3])
//	debug(dp1[3][0])
	
	
	return 0;
}


Measured memory_bytes: 9232