akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int64_t N;
    cin >> N;

    int64_t res = log10(N) + 1;
    for (int64_t a = 2; a * a <= N; a++)
    {
        if (N % a == 0)
        {
            int64_t b = N / a;
            int64_t loga = log10(a), logb = log10(b);
            res = min(res, max(loga + 1, logb + 1));
        }
    }
    cout << res << endl;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var hasira = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (hasira[1] - hasira[0] == hasira[2] - hasira[1])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            
                
        }
    }
}


Measured memory_bytes: 13140
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007LL;
const int MAX_N = 100005;

ll dp[MAX_N][3];

int main()
{
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n = (int)s.length();
	dp[0][0] = (s[0] == 'A' || s[0] == '?') ? 1 : 0;
	ll x = (s[0] == '?') ? 3 : 1;
	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'A')
		{
			dp[i][0] = (dp[i - 1][0] + x) % MOD;
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][2];
		}
		else if (s[i] == 'B')
		{
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = (dp[i - 1][1] + dp[i - 1][0]) % MOD;
			dp[i][2] = dp[i - 1][2];
		}
		else if (s[i] == 'C')
		{
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = (dp[i - 1][2] + dp[i - 1][1]) % MOD;
		}
		else
		{
			dp[i][0] = (3 * dp[i - 1][0] + x) % MOD;
			dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD;
			dp[i][2] = (3 * dp[i - 1][2] + dp[i - 1][1]) % MOD;
			x = (x * 3) % MOD;
		}
	}
	cout << dp[n - 1][2] << endl;
}

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

const int MAXN = 2e5+5;

ll n, a[MAXN], m;
ll dp[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		dp[a[i]] = dp[a[i]-1]+1;
		m = max(m, dp[a[i]]);
	}

	cout << n-m << endl;
}


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

int main(){
    // 引数の受け取り
    int A;
    scanf("%d", &A);


    // ----------------------
    //  メイン処理
    // ----------------------
    //
    int b = 0;
    for (int i =1;i <= A ;i++) {
         b+=i;
    }
    printf("%d", b);

    return 0;
}


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

int main() {
int D,N,A,B; 
cin >> D >> N;
B=1;

if(D==0){
    A=N;
}else if(D==1){
    A=N*100;
}else{
    A=N*10000;
}
if(N==100){
    for(int i=0;i<=D;i++)
    
        B=100*B;
        A=101*B/100;
}


cout << A << endl;

return 0;
}

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

using namespace std;

typedef long long ll;

ll n, m, a[10005], s = 0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n >> m;
    for (ll i = 1; i <= m; i++)
    {
        cin >> a[i];
        s += a[i];
    }
    if (s > n) cout << "-1";
    else cout << n - s;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int N, K;
	
	std::cin >> N >> K;
	
	std::cout << (N - K + 1) << "\n";
}


Measured memory_bytes: 256
fn main() {
    let n: usize = readln();
    let a: Vec<i64> = readln();
    let mut s: Vec<i64> = Vec::new();
    s.push(0);
    for &x in &a {
        let next = x + s[s.len() - 1];
        s.push(next);
    }

    let mut answer: i64 = 0;
    let mut cnt = HashMap::new();
    for x in s.iter().rev() {
        answer += *cnt.get(x).unwrap_or(&0);
        *cnt.entry(x).or_insert(0 as i64) += 1;
    }
    println!("{}", answer);
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Measured memory_bytes: 18184
a,b = map(int, input().split(' '))
 
posts = input().split('-')

if len(posts) == 2:
    if a == len(posts[0]) and b == len(posts[1]) and posts[0].isnumeric() and posts[1].isnumeric():
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int e[3];
    int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    while(cin>>e[0]>>e[1]>>e[2]){
        sort(e,e+3);
        int a=e[0],b=e[1],m=e[2];
        if(m<a+b){
            ++cnt1;
            if(m*m<a*a+b*b) ++cnt3;
            else if(m*m==a*a+b*b) ++cnt2;
            else ++cnt4;
        }
        else break;
    }
    cout<<cnt1<<" "<<cnt2<<" "<<cnt3<<" "<<cnt4<<endl;
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>    // replace
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    string ans = "~";
    for (int i = 0; i <= n - m; i++) {
        bool ok = true;
        string s2 = s;
        for (int j = 0; j < m; ++j){
            if (s[i+j] != '?' && s[i+j] != t[j]) {
                ok = false;
            }
            s2[i+j] = t[j];
        }
        if (ok) {
            replace(s2.begin(), s2.end(), '?', 'a');
            ans = min(ans, s2);
        }
    }

    if (ans == "~") {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll x;
    cin >> x;
    for(int a = -200; a <= 200; a++){
        for(int b = -200; b <= 200; b++){
            if(pow(a,5) - pow(b,5) == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int main(){
  int n,i,j;
  long int count=1,kotae=0;
  cin>>n;
  string s[n];
  char x[10];
  for(i=0;i<n;i++){
    cin>>s[i];
    for(j=0;j<10;j++){
      x[j]=s[i][j];
    }
    sort(x,x+10);
    for(j=0;j<10;j++){
      s[i][j]=x[j];
    }
  }
  sort(s,s+n);
  for(i=1;i<n;i++){
    if(s[i]==s[i-1]){
      count++;
    }else{
      kotae+=(count*(count-1))/2;
      count=1;
    }
  }
  kotae+=(count*(count-1))/2;
  count=1;
  cout<<kotae;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct I
{
    int x,y;
};


int a,b,k,d,n,m,i,c,e,o[212026],l[232322],dx[20]={1,0,-1,0},dy[20]={0,1,0,-1},dz[20]={1,-1};

long long x,y,z;
//map <string,int> m;
int j[225060][3];



//deque<int> d;
struct P
{
    string r;
    int x,y,z;
    bool operator<(const P &a)const
    {
            if(x-y!=a.x-a.y)
            return x-y<a.x-a.y;
       return x<a.x;
    }
};
stack<int> s;
double u;
//P u[500000];
vector <int> v[411010];
queue<int> q,q1;
string r,r1;
//char r[3333];
map<int,int > p;
//A==65
//Z==90

//a==97
bool asd(P a,P b)
{
    if(a.z!=b.z) return a.z>b.z;
    if(a.y!=b.y) return a.y>b.y;
    return a.x>b.x;
}

int g(int t,int w)
{
    int k=0;
    if(t%10==w/100||t%10==(w/10%10)) k++;
    if(t/10%10==w/100||t/10%10==w%10) k++;
    if(t/100==w%10||t/100==(w/10%10)) k++;
    return k;
}

int f(int t,int w)
{
    if(t<w) swap(t,w);
    for(;w;)
    {
        int u=w;
        w=t%w;
        t=u;
    }
    return t;
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    for(int t=1;t<=a;t++)
    {
        if(t==o[t])
        {
            if(t+1==o[t+1])
                t++,k++;
            else k++;
        }
    }
    printf("%d",k);
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

vector<pi > adj;
ll ar[M];

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

	ll z = 0,n,k,i,x,y,u,v,p,c;

	cin >> n >> k;
	for(i=1;i<=n;++i)
	{
		cin >> ar[i];
		if(ar[i] >= 0)
			adj.pb(pi(ar[i],1));
		else
			adj.pb(pi(-1*ar[i],-1));
		if(ar[i] == 0)
			z = 1;
	}

	sort(all(adj));

	if(adj[n-k].ff == 0)
	{
		cout << 0 << "\n";
		return 0;
	}

	p = 1;
	c = 0;
	for(i=n-1;i>=n-k;i--)
	{
		p = 1ll*p*adj[i].ff%md;
		if(adj[i].ss == -1)
			c++;
	}
	if(c%2 == 0)
	{
		cout << p << "\n";
		return 0;
	}

	v = 0;
	for(i=n-k-1;i>=0;i--)
	{
		if(adj[i].ss == 1)
		{
			v = adj[i].ff;
			break;
		}
	}

	x = 0;
	for(i=n-k-1;i>=0;i--)
	{
		if(adj[i].ss == -1)
		{
			x = adj[i].ff;
			break;
		}
	}

	u = 0;
	for(i=n-k;i<n;++i)
	{
		if(adj[i].ss == -1)
		{
			u = adj[i].ff;
			break;
		}
	}

	y = 0;
	for(i=n-k;i<n;++i)
	{
		if(adj[i].ss == 1)
		{
			y = adj[i].ff;
			break;
		}
	}

	if(u > 0 && v > 0 && x > 0 && y > 0)
	{
		// cout << "h1" << endl;
		// cout << v << " " << u << " " << x << " " << y << endl;
		if(v*y > x*u)
		{
			p = 1ll*p*pwr(u,md-2,md)%md;
			p = 1ll*p*v%md;
		}
		else 
		{
			p = 1ll*p*pwr(y,md-2,md)%md;
			p = 1ll*p*x%md;
		}
	}
	else if(u > 0 && v > 0 && (x <= 0 || y<= 0))
	{
		// cout << "h2" << endl;
		// cout << v << " " << u << " " << x << " " << y << endl;
		p = 1ll*p*pwr(u,md-2,md)%md;
		p = 1ll*p*v%md;
	}
	else if((u<=0 || v<=0) && x>0 && y>0)
	{
		// cout << "h3" << endl;
		// cout << v << " " << u << " " << x << " " << y << endl;
		p = 1ll*p*pwr(y,md-2,md)%md;
		p = 1ll*p*x%md;	
	}
	else if(z == 1)
	{
		p = 0;
	}
	else
	{
		p = 1;
		for(i=0;i<k;++i)
			p = 1ll*p*adj[i].ff%md;
		p = (md-p)%md;
	}

	cout << p << "\n";
}




	

Measured memory_bytes: 8468
#include <iostream>
#include <algorithm>
#include <string>
#include <memory>
#include <cmath>
#include <vector>
int main() {
	int n, k; std::cin >> n >> k;
	std::string str; std::cin >> str;
	std::vector<int> count(n, 0);
	if (str[0] == '0') count[0] = 1;
	for (auto i = 1; i < n; ++i) {
		if (str[i] == '0' && str[i - 1] == '1') count[i] = 1 + count[i - 1];
		else count[i] = count[i - 1];
	}
	auto left = 0;
	auto right = 0;
	auto max = 0;
	while (right < n) {
		if (str[left] == '1') {
			while (right < n && count[right] - count[left] <= k) {
				++right;
			}
		}
		else {
			while (right < n && count[right] - count[left] < k) {
				++right;
			}
		}
		max = std::max(right - left, max);
		++left;
	}
	std::cout << max << std::endl;
}



Measured memory_bytes: 896
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, log
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
from decimal import Decimal
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 = INT()
AB = [LIST() for _ in range(N)]
A, B = [], []
for a, b in AB:
	A.append(a)
	B.append(b)

cnt = 0
for i in range(N-1, -1, -1):
	if (A[i]+cnt)%B[i] == 0:
		continue
	else:
		cnt += B[i] - (A[i]+cnt)%B[i]

print(cnt)



Measured memory_bytes: 31300
#include <stdio.h>

int main() {
  int a;
  scanf("%d", &a);
  long long int arr[a], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < a; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

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

int main() {
	// your code goes here
	int n, d;
	cin >> n >> d;
	int count = 0;
	while(n--){
		long a, b;
		cin >> a >> b;
		if(sqrt(a*a + b*b) <= d){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	int arr[n];
	for(int i = 0; i < n; i++)scanf("%d",&arr[i]);
	for(int i = n; i > 1; i--)printf("%d ",arr[i-1]);
	printf("%d\n",arr[0]);
	return 0;
}



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

typedef long long ll;

#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)
#define all(a) (a).begin(), (a).end()


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

    string s;
    int k;
    cin >> s >> k;

    int N = s.size();
    map<string, int> mp;
    REP(i, 0 ,N) {
        for(int j = 1; i+j <= N && j <= k; j++) {
            string subs = s.substr(i, j);
            mp[subs]++;
        }
    }
    int cnt = 0;
    for(auto e : mp) {
        cnt++;
        if(cnt == k) {
            cout << e.first << '\n';
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll x, k, d;
	cin >> x >> k >> d;
	ll need = abs(x) / d;
	ll mn = abs(x) % d;
	ll nmn = abs(mn - d);
	if (need >= k) {
		cout << abs(x) - k * d << endl;
	} else {
		ll left = k - need;
		if (left % 2 == 0) {
			cout << mn << endl;
		} else {
			cout << nmn << endl;
		}
	}
}

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
  cin>>a>>b;
  for(int i=0;i<1001;i++){
if(floor(i*0.08)==a&&floor(i*0.10)==b){
cout<<i<<endl;
  return 0;
}
  }
cout<<-1<<endl;
  return 0;
}

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

#define fi first
#define se second
#define ll long long

const int N = 100100;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int k;
int h[N];
long long d[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> k;
        for(int i = 1; i <= n; i++){
                cin >> h[i];
        }
        for(int i = 2; i <= n; i++){
                d[i] = 1e9;
                for(int j = 1; j <= k; j++){
                        if(i - j < 1){
                                continue;
                        }
                        long long cost = d[i - j] + abs(h[i - j] - h[i]);
                        d[i] = min(d[i], cost);
                }
        }
        cout << d[n] << "\n";
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int h,w,cnt[30];
char s[1010];
bool check0() {
	rep(i,0,26) if (cnt[i]%4!=0) return 0;
	return 1;
}
bool check1() {
	int c=0;
	if (h%2==1) c=w/2; else c=h/2;
	rep(i,0,26) if (cnt[i]%2!=0) return 0;
	rep(i,0,26) if (cnt[i]%4==2) --c;
	if (c<0) return 0;
	return 1;
}
bool check2(int c) {
	int od=0;
	rep(i,0,26) od+=(cnt[i]%2==1);
	if (od!=1) return 0;
	rep(i,0,26) if (cnt[i]%2==1) --cnt[i];
	rep(i,0,26) if (cnt[i]%4==2) --c;
	if (c<0) return 0;
	return 1;
}
int main() {
	scanf("%d%d",&h,&w);
	rep(i,0,h) {
		scanf("%s",s);
		rep(j,0,w) cnt[s[j]-'a']++;
	}
	if (h%2==0&&w%2==0) puts(check0()?"Yes":"No");
	else if (h*w%2==0) puts(check1()?"Yes":"No");
	else if (h%2==1&&w%2==1) puts(check2(h/2+w/2)?"Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  if(k>=n){
    cout << s << endl;
  } else {
    cout << s.substr(0,k) << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
"""
C - Bridge
とりあえず、グラフ構造を作る
そして、全通りの辺を抜いてみて、探索を行うことで確かめる
"""

N, M = map(int, input().split())

pairs = []
for side in range(M):
    pair = []
    for side in input().split():
        pair.append(int(side))
    pairs.append(pair)

graph = [[0 for i in range(N)] for j in range(N)]

# グラフ構築
for pair in pairs:
    a = pair[0]
    b = pair[1]

    # 無向グラフ
    graph[a - 1][b - 1] += 1
    graph[b - 1][a - 1] += 1

def bfs(graph, start):
    queue = []
    exist_v = [False for v in range(N)]
    exist_v[start] = True
    queue.append(start)

    # Q が殻ではない
    while queue:
        # 現在の場所
        v = queue.pop(0)
        
        # vに接続している頂点
        for i in range(N):
            # vにつながっているとき
            if graph[v][i] != 0:
                if exist_v[i] is False:
                    #print("頂点に到達しました", i+1)
                    exist_v[i] = True
                    queue.append(i)
    
    # 行けなかった漏れがあるなら
    for exist in exist_v:
        if exist is False:
            return False
    
    return True

cnt = 0
for pair in pairs:
    a = pair[0]
    b = pair[1]
    #print(a, b, "を抜いてみる")

    # 辺を試しに切る
    graph[a - 1][b - 1] -= 1
    graph[b - 1][a - 1] -= 1
    
    if bfs(graph, 0) is False:
        cnt += 1

    # もとに戻す
    graph[a - 1][b - 1] += 1
    graph[b - 1][a - 1] += 1

print(cnt)

Measured memory_bytes: 3064
using System;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;

namespace ConsoleApp2
{
    class Program
    {
        static void Main()
        {
        lbl:
            var n = Parse(ReadLine());
            var list = Enumerable.Range(1, (1 << n) - 1).ToList();
            for(int i = 0; i < n; ++i)
            {
                int x1 = 1 << i;
                int a = Parse(ReadLine());
                for(int j = 0; j < a; ++j)
                {
                    var sp = ReadLine().Split();
                    var x2 = 1 << (Parse(sp[0]) - 1);
                    if (sp[1][0] == '1')
                    {
                        list.RemoveAll(ff => 0 < (ff & x1) && 0 == (ff & x2));
                    }
                    else
                    {
                        list.RemoveAll(ff => 0 < (ff & x1) && 0 < (ff & x2));
                    }
                }
            }
            int max = 0;
            for(int i = 0; i < list.Count; ++i)
            {
                int c = 0;
                for (int j = list[i]; 0 < j; j >>= 1)
                {
                    if ((j & 1) == 1) ++c;
                }
                if (max < c) max = c;
            }
            WriteLine(max);
        }
    }
}


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

typedef long long ll;

ll M, K;
int main() {
  cin >> M >> K;
  if ((M == 1 && K == 1) || K >= (1 << M))
    cout << -1 << endl;
  else if (M == 1 && K == 0) {
    cout << "0 0 1 1" << endl;
  } else {
    cout << K;
    for (ll i = 0; i < (1 << M); ++i)
      if (i != K) cout << " " << i;
    cout << " " << K;
    for (ll i = (1 << M) - 1; i >= 0; --i)
      if (i != K) cout << " " << i;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int h,w;
    while(1){
        cin >> h >> w;
        
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0;i < h;++i){
            for(int j = 0;j < w;++j){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
  return 0;
}

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

long long int N, K, a[222222];

int main(){
    scanf("%lld%lld", &N, &K);
    for(int i = 0; i < N; ++i, ++a[a[222000] - 1])scanf("%lld", a + 222000);
    sort(a, a + N, greater<long long>());
    for(int i = 0; i < K; ++i)N -= a[i];
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 1792
#define deb 123321
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=2e5+69, INF=2e9+6969;

ull n,x,ans=1,res=1e18;

int main()
{
	bool ok=1;
	scanf("%llu", &n);
	ull t[R];
	for(int i=0;i<n;++i) scanf("%llu", &t[i]);
	sort(t,t+n);
	for(int i=0;i<n;++i)
	{
		x=t[i];
		if(ans==0)
		{
			printf("0\n");
			return 0;
		}
		if(res/ans<x)
		{
			printf("-1\n");
			return 0;
		}
		else
		{
			ans*=x;
		}
	}
	printf("%llu\n", ans);
	return 0;
}


Measured memory_bytes: 4592
#include<bits/stdc++.h>
typedef long long ll;
const int N=1e5+5;
int n;
char s[1010];
int main(){
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);for(int tttt=1;tttt<=T;tttt++){
    if(1){
    scanf("%s",s);
    int len=strlen(s);
    if(s[len-1]=='s') printf("%ses\n",s);
    else printf("%ss",s);
    }return 0;
}


Measured memory_bytes: 3836
MM = input().split()
A = int(MM[0])
B = int(MM[1])
S = input()
SS = '1234567890'
SSS =list(SS)
count = 0
for i in range(A):
  if S[i] not in SSS:
    count +=1
if S[A] != '-':
  count +=1
for i in range(A+1,A+B):
  if S[i] not in SSS:
    count +=1
if count ==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9104
#include <iostream>
#include <map>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;

inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int main(){
    long long ans=ceil((read()+read())/(1.0*2));
    cout<<ans<<"\n";
	return 0;
}

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

int main()
{
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int count=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int sum = i*500 + j*100 + k*50;
                if(sum==x)
                    count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			long n = sc.nextLong();
			 
	        String ret = "";
	        
	        while(n>0) {
	        	int c = (int)(n%26L);
	        	if(c==0) {
	        		c=26;
	        	}
	        	n = (n-c)/26L;
	        	ret = (char)('a'+c-1) + ret;
	        }
	        
	        System.out.println(ret);
		}
	}


Measured memory_bytes: 38988
#!/usr/bin/env python3
# R*W*
n = int(input())
c = list(input())
l, r = 0, n - 1
ans = 0
while True:
    while l < n and c[l] != "W":
        l += 1
    while r >= 0 and c[r] != "R":
        r -= 1
    if l >= r:
        break
    ans += 1
    c[l], c[r] = "R", "W"
    l += 1
    r -= 1
print(ans)


Measured memory_bytes: 10772
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner scan = new Scanner(System.in);
    int K = scan.nextInt();
    int S = scan.nextInt();
    int c = 0;
    
    for(int i = 0; i < K+1;i++){
      for(int j = 0; j < K+1;j++){
        if(S-(i+j) <= K && 0 <= S-(i+j)){ c+= 1;}
      }
    }
    System.out.println(c);
  }
}

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



int main() {
  ll N, K, Q;
  //vector<ll> person(N, K);
  cin >> N >> K >> Q;
  vector<ll> win(N, 0), score(N);
  int A;
  for(int i=0; i<Q; i++){//各人の勝利数を数える
    cin >> A;
    //cout << " N: "<< N << " K: "<< K << " Q: " << Q 
    //  << " A_i: " << A-1 << endl; 
    win.at(A-1)++;//indexは0から始まるので-1する
  }
  
  for(int i=0; i<N; i++){//各人の点数を計算
    score.at(i) = K - ( Q - win.at(i) ) ;
    //cout <<" score.at("<< i << "): " << score.at(i) << endl;
  }
  
  for(int i=0; i<N; i++){
    if(score.at(i) <=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  
  
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    ll sum = 0;
    map<int,int> mp;
    rep(i,n) {
        int x; cin >> x;
        sum += x;
        mp[x]++;
    }
    int q; cin >> q;
    rep(i,q) {
        ll b, c; cin >> b >> c;
        sum += (c-b)*mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 8004
local str = io.read()
local n = tonumber(str)
local min = 753
for i=1,#str-2 do
	local newmin = math.abs(753 - tonumber(string.sub(str,i,i)..string.sub(str,i+1,i+1)..string.sub(str,i+2,i+2)))
	if min > newmin then min = newmin end
end
print(min)

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; int M; ll K; cin >> N >> M >> K;
    vector<vpl> preGraph(N);

    F0R(i, M) {
        ll A, B, C; cin >> A >> B >> C;
        A--;
        B--;
        preGraph[A].pb({B, C});
        preGraph[B].pb({A, C});
    }

    ll distLen[N][N]; F0R(i, N) F0R(j, N) distLen[i][j] = 1000000000000000;
    F0R(root, N) {
        distLen[root][root] = 0;
        priority_queue<pi, vpi, greater<pi> > q;
        q.push({0, root});
        while (!q.empty()) {
            pi cp = q.top(); q.pop();
            int cur = cp.s;
            if (cp.f != distLen[root][cur]) continue;
            F0R(i, sz(preGraph[cur])) {
                int nxt = preGraph[cur][i].f;
                ll dist = distLen[root][cur] + preGraph[cur][i].s;
                if (dist < distLen[root][nxt]) {
                    distLen[root][nxt] = dist;
                    q.push({dist, nxt});
                }
            }
        }
    }

    vector<vi> graph(N); F0R(i, N) F0R(j, N) if (distLen[i][j] <= K) graph[i].pb(j);
    int dist[N][N]; F0R(i, N) F0R(j, N) dist[i][j] = -1;
    F0R(root, N) {
        dist[root][root] = 0;
        queue<int> q; q.push(root);
        while (!q.empty()) {
            int cur = q.front(); q.pop();
            F0R(i, sz(graph[cur])) {
                int nxt = graph[cur][i];
                if (dist[root][nxt] != -1) continue;
                dist[root][nxt] = dist[root][cur] + 1;
                q.push({nxt});
            }
        }
    }

    int Q; cin >> Q;
    while(Q--) {
        int A, B; cin >> A >> B; A--; B--;
        cout << max(-1, dist[A][B]-1) << '\n';
    }
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 4568
#include<iostream>
using namespace std;
#define ll long long
int main()
{
  ll int n;
  cin>>n;
  int x;
  cin>>x;
  ll int sum=0;
  for(int i=0;i<x;i++){
    int k;
    cin>>k;
    sum+=k;
  }
  if(sum>=n)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<LL,LL>
#define lowbit(x) ((x)&(-(x)))
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=400005,Mo=1000000007;
const double eps=1e-8,PI=3.1415926535897932384626433832;
struct P{
	LL x,y;
	P(LL xx=0,LL yy=0):x(xx),y(yy){}
	bool operator <(const P &B)const{ return x<B.x||x==B.x&&y<B.y; }
}A[MAXN],S,T;
LL n,m,f[MAXN],g[MAXN],c[MAXN];
LL add(LL x,LL y){ for (;x<MAXN;x+=lowbit(x)) f[x]=max(f[x],y); }
LL sum(LL x){ LL y=0; for (;x;x-=lowbit(x)) y=max(y,f[x]); return y;}
int main(){
	S.x=read(); S.y=read(); T.x=read(); T.y=read();
	if (S.x>T.x) swap(S,T);
	n=read();
	FOR(i,1,n) {
		A[i].x=read(); A[i].y=read();
		if (A[i].x>T.x||A[i].x<S.x||A[i].y>max(S.y,T.y)||A[i].y<min(S.y,T.y)) --i,--n;
	}
	double ans=(fabs(S.x-T.x)+fabs(S.y-T.y))*double(100);
	if (n==0) {
		printf("%.20f\n",ans);
		return 0;
	}
	else if (S.x==T.x||S.y==T.y) {
		ans+=PI*10-20;
		printf("%.20f\n",ans);
		return 0;
	}
	if (S.y>T.y) {
		FOR(i,1,n) A[i].y=T.y+S.y-A[i].y;
		swap(S.y,T.y);
	}
	FOR(i,1,n) c[i]=A[i].y;
	sort(c+1,c+1+n);
	
	FOR(i,1,n) A[i].y=lower_bound(c+1,c+1+n,A[i].y)-c;
	//FOR(i,1,n) cout<<A[i].y<<endl;
	sort(A+1,A+1+n);
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	FOR(i,1,n) {
		g[i]=sum(A[i].y)+1;
		add(A[i].y,g[i]);
	}
	m=sum(n+1);
	//cout<<m<<endl;
	if (m) ans+=(PI*5-20)*double(m);
	if (m==min(abs(S.x-T.x),abs(S.y-T.y))+1) ans+=PI*5;
	printf("%.20f\n",ans);
	
	return 0;
}

/*
6 5 1 1
3
3 2
5 3
2 4
100000000 0 0 100000000
2
1 1
2 2

*/


Measured memory_bytes: 15360
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"

inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    X=I()
    # print(int(math.ceil(X/1.08)))
    Y=int(math.ceil(X/1.08))
    if X==math.floor(Y*1.08):
        print(Y)
    else:
        print(":(")
        # math.floor()
    # print(A,B)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14216
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	vector<int> req(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		req[i] = a;
	}
	vector<int> ans;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < req[i]; j++) {
			ans.push_back(i);
		}
	}
	for (int i = 0; i < H; i++){
		if (i % 2 == 0) {
			for (int j = 0; j < W; j++) {
				cout << ans[i*W + j] + 1;
				if (j != W - 1)cout << " ";
				else cout << endl;
			}
		}
		else {
			for (int j = W - 1; j >= 0; j--) {
				cout << ans[i*W + j] + 1;
				if (j != 0)cout << " ";
				else cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int A[1000000];
int n;

int search(int key);

int main(){
  int i, q, k, cnt = 0;

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

  scanf("%d", &q);
  for ( i = 0; i < q; i++ ){
    scanf("%d", &k);
    if ( search(k) ) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}

int search(int key){
  int l = 0;
  int r = n;
  int m;
  while( l < r ){
    m = (l + r ) /2;
    if ( key == A[m] ) return 1;
    if ( key > A[m] ) l = m+1;
    else if ( key < A[m] ) r = m;
  }
  return 0;
}



Measured memory_bytes: 2108
n,k=map(int,input().split())
ans=0
for i in range(k+1,n+1):
    ans_i=(i-k)*(-(-(n+1)//i))
#    print(i,ans_i,end=" ")
    if(n%i<k):
        ans_i-=(i-k)
    else:
        ans_i-=(i-1)-(n%i)
#    print(ans_i)
    ans+=ans_i

if(k==0):
    ans-=n
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
   if(n<=('Z'-s[i])) cout<<(char)(s[i]+n);
    else cout<<(char)(n-('Z'-s[i])-1+'A');
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int n;
  cin >> n;
  cout << n/2+n%2 << endl;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashSet<String> hs = new HashSet<>();
		for (int i = 0; i < n; i++) {
			hs.add(sc.next());
		}
		if (hs.size() == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}

	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 100000;
        int c = 0;
        for (int i = 0; i <=N; i++) {
            int t = i;
            while (t > 0) {
                c += t % 6;
                t /= 6;
            }
            t = N - i;
            while (t > 0) {
                c += t % 9;
                t /= 9;
            }
            ans = Math.min(c, ans);
            c = 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())
print(a[n - 1])

Measured memory_bytes: 3060
A, B, C, D, E, F = map( int, input().split() )

concent = 0
answeight = 0
anssugar = 0
for i in range( F//(100*A) + 1 ):
    for j in range( (F - 100*A*i)//B + 1 ):
        water = 100 * (A*i + B*j)
        maxsugar = min( E * (A*i + B*j), F - water )
        if 0 < water:
            for k in range( maxsugar//C + 1 ):
                sugar = C*k + D*((maxsugar - C*k)//D)
                if concent < sugar/(water + sugar):
                    concent = sugar/(water + sugar)
                    answeight = water + sugar
                    anssugar = sugar             

if answeight == 0: print( 100*A, 0 )
else :             print( answeight, anssugar )

Measured memory_bytes: 3064
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e4+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll n;
    cin>>n;
    string res="";
    n--;
    while(n>=26){
        ll x=n%26;
        res+=char(x+'a');
        n/=26;
        n--;
    }
    res+=char(n+'a');
    reverse(all(res));
    cout<<res;
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void) {
	long long int even = 0,odd = 0;
	int n, p, bag;

	scanf("%d %d", &n,&p);
	for (int i = 0; i < n; i++) {
		scanf("%d", &bag);
		if (bag % 2 == 0)even++;
		else odd++;
	}
	if (odd) {
		printf("%lld\n", (long long int)pow(2, n - 1));
	}
	else {
		if (p)printf("0\n");
		else printf("%lld\n", (long long int)pow(2, n));
	}

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

int main(){
	int a,b,ans;
	cin >> a >> b;
	if(a<10 && b<10){
		ans=a*b;
	}else{
		ans=-1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int decode_ab(char *plain, const char *str, const int *from)
{
	int i;
	for (i = 0; str[i] != '\n'; i ++) {
		if (str[i] == ' ')
			plain[i] = ' ';
		else
			plain[i] = from[str[i]-'a']+'a';
	}
	plain[i] = '\0';
	return strstr(plain, "that") || strstr(plain, "this");
}
int decode_a(char *plain, const char *str, int a)
{
	int f[26]={0}, from[26], i, to, b;
	for (i = 0; i < 26; i ++) {
		to = (a*i)%26;
		if (f[to])
			return 0;
		f[to] = 1;
		from[to] = i;
	}
	for (b = 0; b < 26; b ++) {
		if (decode_ab(plain, str, from))
			return 1;
		for (i = 0; i < 26; i ++)
			from[i] = (from[i]+1)%26;
	}
	return 0;
}
void decode(char *plain, const char *str)
{
	int a;
	for (a = 1; a <= 26; a ++) {
		if (decode_a(plain, str, a))
			return;
	}
}
int main()
{
	int N;
	char str[258], plain[258];
	scanf("%d\n", &N);
	while (N--) {
		fgets(str, sizeof(str), stdin);
		decode(plain, str);
		puts(plain);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int r,c,sr,sc;
  cin>>r>>c;
  int arr[r+1][c+1];
   for(int i=0;i<r;i++){
      sr=0;
    for(int j=0;j<c;j++){
      cin>>arr[i][j];
      sr+=arr[i][j];

    }
     arr[i][c]=sr;
  }


  for(int i=0;i<=c;i++){
      sc=0;
      for(int j=0;j<r;j++){
         sc+=arr[j][i];

    }
     arr[r][i]=sc;
  }


  for(int i=0;i<=r;i++){
      for(int j=0;j<=c;j++){
        if(j ==0)
      cout<<arr[i][j];
      else
    cout<<' '<<arr[i][j];
   }
    cout<<endl;
  }

}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int gcd(int a, int b) {
  for (int i = a; i >= 1; --i) {
    if (a%i == 0 && b%i == 0) return i;
  }
  return 1;
}

int main () {
  int a, b;
  cin >> a >> b;
  ll ans = ll(a)*b/gcd(a,b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include<iostream>
using namespace std; 
int min(int a,int b)
{
	if(a<=b) return a;
	else return b;
}

int mincost(vector<int> v, int n)
{
	int dp[n+1] = {-1};
	dp[0] = 0;
	dp[1] = 0;
	dp[2] =  abs(v[0]-v[1]); 
	for(int i=3;i<=n;i++)
	{
		dp[i] = min(dp[i-1]+abs(v[i-1]-v[i-2]),dp[i-2]+abs(v[i-1]-v[i-3]));
	}
	
	return dp[n];
}

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

	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	
	cout<<mincost(p,n)<<endl;

 
}



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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}
void max_self(ll &a, ll b) {
	a = max(a, b);
}
bool is_ap(vl v, int n) {
	ll d = v[1] - v[0];
	F0R(i, n) {
		if (v[i] != v[0] + i * d)
			return false;
	}
	return true;
}


int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ll X;
	cin >> X;
	ll points, h1, h2;
	h1 = X / 500;
	X = X % 500;
	h2 = X / 5;
	points = 1000 * h1 + 5 * h2;
	cout << points << endl;

}




Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
    
    int N;

    scanf("%d",&N);

    if(N < 10){
        printf("%d",N);
    }else if(N >= 10 && N < 100){
        printf("9");
    }else if(N >= 100 && N < 1000){
        printf("%d",N - 90);
    }else if(N >= 1000 && N < 10000){
        printf("909");
    }else if(N >= 10000 && N < 100000){
        printf("%d",N - 9999 + 9 + 900);
    }else{
        printf("90909");
    }
    return 0;
}

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

int main() {
	int	n;
	int ans;

	cin >> n ;
	if(n==111) ans=999;
	if(n==119) ans=991;
	if(n==191) ans=919;
	if(n==199) ans=911;
	if(n==911) ans=199;
	if(n==919) ans=191;
	if(n==991) ans=119;
	if(n==999) ans=111;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604