akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n, a, b; cin >> n >> a >> b;
    --a; --b;
    int co = 1;
    while((a != -1 && a != n) && (b != -1 && b != n)) {
        if(co > 0) {
            //Alice
            co = -co;
            if(a + 1 < b) {
                ++a;
            } else if(a + 1 == b) {
                --a;
            } else if(b < a - 1) {
                --a;
            } else {
                ++a;
            }
        } else {
            //Borys
            co = -co;
            if(b + 1 < a) {
                ++b;
            } else if(b + 1 == a) {
                --b;
            } else if(a < b - 1) {
                --b;
            } else {
                ++b;
            }
        }

        if(a == -1 || a == n) {
            cout << "Borys" << endl;
            return;
        }
        if(b == -1 || b == n) {
            cout << "Alice" << endl;
            return;
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N + 1);
  for (int i = 1; i <= N; i++) cin >> h[i];

  vector<int> dp(N + 1);
  dp[0] = dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= N; i++) {
    int dif1 = abs(h[i] - h[i - 1]);
    int dif2 = abs(h[i] - h[i - 2]);
    dp[i] = min(dp[i - 1] + dif1, dp[i - 2] + dif2);
  }

  cout << dp[N] << endl;
}

Measured memory_bytes: 1024
import java.lang.Integer.min
import java.util.*
import kotlin.math.max

fun readInt(): Int = readLine()!!.toInt()
fun readInts(): List<Int> = readLine()!!.split(" ").map { it.toInt() }

fun parseInt(): Int {
    var digit = System.`in`.read()
    while(digit <= 32) {
        digit = System.`in`.read()
    }

    val negative = digit == '-'.toInt()
    if (negative) {
        digit = System.`in`.read()
    }
    var res = 0
    while (digit in '0'.toInt()..'9'.toInt()) {
        res *= 10
        res += digit - '0'.toInt()
        digit = System.`in`.read()
    }
    return if (negative) -res else res
}

fun gcd(x : Int, y : Int) : Int {
    var a = x
    var b = y
    var r = 0
    while(b > 0) {
        r = a % b
        a = b
        b = r
    }
    return a
}

fun main() {
//    val t = readLine()!!.toInt()
    val t = 1

    for(testNumber in 1..t) {
        val (m, n, k) = readInts()
        val a = readInts()
        val b = readInts()

        var j = 0
        var s = 0L

        while(j < n && s + b[j] <= k) {
            s += b[j]
            ++j
        }

        var ans = j
        for(i in 0 until m) {
            s += a[i]
            while(s > k && j > 0) {
                --j
                s -= b[j]
            }

            if(s <= k) {
                ans = max(ans, i + j + 1)
            }
        }

        println(ans)
    }
}

Measured memory_bytes: 80420
#ABC85-B KagamiMochi
N = int(input())
d = [int(input()) for i in range(N)]
import numpy as np
size = np.zeros(101)
for i in range(N):
    size[d[i]] += 1
cnt = 0
for n in range(101):
    if size[n]:
        cnt += 1

print(cnt)

Measured memory_bytes: 12508
import sys
 
def calc_det(lis):
  return lis[0]*lis[3]-lis[1]*lis[2]
 
def sq(x):
  return x*x
 
for s in sys.stdin:
  d = map(float, s.split() )
  if len(d) == 1:
    continue
  x1,y1,x2,y2,x3,y3 = d[0],d[1],d[2],d[3],d[4],d[5]
  d11 = 2*(x3-x2)
  d12 = 2*(y3-y2)
  d21 = 2*(x2-x1)
  d22 = 2*(y2-y1)
  x11 = sq(x3)-sq(x2)+sq(y3)-sq(y2)
  x21 = sq(x2)-sq(x1)+sq(y2)-sq(y1)
  y12 = x11
  y22 = x21
 
  x0 = calc_det( [x11,d12,x21,d22] )/calc_det( [d11,d12,d21,d22] )
  y0 = calc_det( [d11,y12,d21,y22] )/calc_det( [d11,d12,d21,d22] )
 
  r = ( (x0-x1)**2 + (y0-y1)**2 )**0.5
 
  print "%.3f %.3f %.3f" % (x0,y0,r)

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

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

#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;
typedef vector<string> vs;

#define SZ(x) ((int)(x).size())

#define fill(x,y) memset(x,y,sizeof(x))

// with compile option -DLOCAL
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define pcnt __builtin_popcount
#define pcntll __builtin_popcountll

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    string s;
    cin >> s;
    int ret = INF;

    rep(SZ(s) - 2) {
        int val = 0;
        val = s[i] - '0';
        val *= 10;
        val += s[i + 1] - '0';
        val *= 10;
        val += s[i + 2] - '0';
        int diff = abs(val - 753);
        if(diff < ret)
            ret = diff;
    }

    cout << ret << endl;
    
    return 0;
}



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

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

int N;
long long W, weight[110], value[110];
long long dp[110][100010] = {0};

int main()
{
    cin >> N >> W;
    for (int i=0; i<N; i++) cin >> weight[i] >> value[i];

    for (int i=0; i<N; i++) {
        for (int sum_w=0; sum_w<=W; sum_w++) {
            if (sum_w - weight[i] >= 0) {
                chkmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
            chkmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    foreach (i; 0..S.length-1) if (S[i..i+2] == "AC") {
        writeln("Yes");
        return;
    }
    writeln("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K;
  cin>>N>>K;
  ll R,S,P;
  cin>>R>>S>>P;
  string T;
  cin>>T;
  vector<ll> check(T.size(),-1);
  ll ans=0;
  for(ll i=0;i<N;i++){
    if(i-K>=0&&check[i-K]!=-1&&T.at(i-K)==T.at(i))continue;
    if(T.at(i)=='r')ans+=P;
    if(T.at(i)=='s')ans+=R;
    if(T.at(i)=='p')ans+=S;
    check[i]=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <algorithm>
using namespace std;

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int n;
	int a[10];
	int ans1 = 0;
	int ans2 = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		ans1 = 0;
		ans2 = 0;
		for(int j = 0; j < 10; j++){
			scanf("%d",&a[j]);
		}
		for(int j = 0; j < 10; j++){
			if(ans1 >= ans2 && ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 > ans1 && ans2 < a[j]){
				ans2 = a[j];
			}else if(ans1 < a[j]){
				ans1 = a[j];
			}else if(ans2 < a[j]){
				ans2 = a[j];
			}else{
				printf("NO\n");
				break;
			}
			if(j == 9){
				printf("YES\n");
			}
		}
	}
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

Measured memory_bytes: 1008
def linearSearch(A,key,i):
    c = 0
    A[i] = key
    while A[c] != key:
        c += 1
        if i == c:
            return 0
    return 1
    
n1 = int(input())
A = [int(e) for e in input().split()]
n2 = int(input())
B = [int(e) for e in input().split()]
A.append(0)
c = 0
for i in range(n2):
    c = c + linearSearch(A,B[i],len(A)-1)
print(c)


Measured memory_bytes: 6556
#include <stdio.h>

int main(void)
{
    int a,b,c,d, total;
    int i;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);

    if (a > b) {
        total = b;
    } else {
        total = a;
    }
    if (c > d) {
        total += d;
    } else {
        total += c;
    }
    
    printf("%d\n", total);
    return 0;
}

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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  vector<bool> p(26);
  for (int i = 0; i < (int)S.size(); i++) {
    p.at(S.at(i) - 'A') = true;
  }
  if (p.at('E' - 'A') != p.at('W' - 'A') || p.at('S' - 'A') != p.at('N' - 'A')) {
    cout << "No\n";
  }else {
    cout << "Yes\n";
}

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		map<ll,ll> m;
		ll n;
		cin>>n;
		for(ll i=2;i*i<=n;i++){
			int cnt=0;
			while(n%i==0){
				n/=i;
				cnt++;
			}
			if(cnt!=0){
				m[i]=cnt;
			}
		}
		if(n!=1){
			m[n]++;
		}
		int ans=0;
		for(auto i:m){
			int lo=0;
			for(int j=1;j<=i.second;j++){
				lo+=j;
				if(lo>i.second)
					break;
				ans++;
			}
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 3664
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,n=parseMap(split(readline()))
    p=sort(parseMap(split(readline())))
    ans=0
    for i in 1:101
        if !(i in p) && abs(ans-x)>abs(i-x)
            ans=i
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 165612
#!/usr/bin/env python3
n, m, q = map(int, input().split())
from itertools import*
t = 0
l = [list(map(int, input().split())) for _ in range(q)]
for i in combinations_with_replacement(range(1, m+1), n):
    s = 0
    for a, b, c, d, in l:
        if i[b-1] - i[a-1] == c: s += d
    t = max(t, s)
print(t)

Measured memory_bytes: 9192
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if(s[0] == t[0]){
        cout << "=" << endl;
    }
    else if(s[0] < t[0]){
        cout << "<" << endl;
    }
    else {
        cout << ">" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Program
{
  public static void Main(string[] args)
  {
    while(true)
    {
      string[] read = Console.ReadLine().Split(' ');
      int range = int.Parse(read[0]);
      int total = int.Parse(read[1]);
      int count = 0;
      if(range == 0 && total == 0) break;
      for(int i = 1;i <= range;i++)
      {
        for(int j = i;j <= range;j++)
        {
          for(int k = j;k <= range;k++)
          {

            if(i == j || j == k || k == i) continue;
            // else Console.Write(i + " " + j + " " + k);
            if(i + j + k == total)
            {
              count++;
              //Console.WriteLine("o");
            }
            //Console.WriteLine();
          }
        }
      }
      Console.WriteLine(count);
    }
  }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


long long N;
map<long long, int> MP;
vector<long long> A;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
		if(MP.count(a) == 0){
			MP[a] = 1;
		}
		else{
			MP[a]++;
		}
	}
	if(A.size() == 1){
		printf("1\n");
		return 0;
	}

	if(A[0] == A[A.size()-1]){
		printf("0\n");
		return 0;
	}
	sort(A.begin(), A.end()); //ソートしておく

	for(auto itr = MP.begin(); itr != MP.end(); ++itr){
		long long k = itr->first;
		int v = itr->second;
		for(int i=2; ; i++){
			long long w = k * i;
			if(w > A[A.size() - 1]){
				break;
			}
			if(MP.count(w) != 0){
				MP[w] = -1;
			}
		}
	}

	int ans = 0;
	for(auto itr = MP.begin(); itr != MP.end(); ++itr){
		long long k = itr->first;
		int v = itr->second;
		if(v == 1){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 17332
#include <iostream>

int main()
{
	int a, b, c, buf;
	std::cin >> a >> b >> c;
	for (int i = 0; i < 2; i++) {
		if (b < a) {
			buf= a;
			a = b;
			b = buf;
		}
		if (c < b) {
			buf = b;
			b = c;
			c = buf;
		}
	}
	std::cout << a << " " << b << " " << c << std::endl;
    return 0;
}


Measured memory_bytes: 3092
fn main() {
    let n = read::<usize>();
    let a = read_vec::<f64>();

    let mut ret = 0.0;
    for i in 0..n {
        ret += 1.0 / a[i];
    }

    println!("{}", 1.0 / ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4476
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j;
	int ng = 0;
	int ok = 0;
	int ngeq = 0;
	string s, t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(), t.end(),greater<char>());
//	cout << s << endl;
//	cout << t << endl;
	for (i = 0; i < s.size(); ++i) {
		if (s[i] < t[i]) {
			++ok;
			break;
		}
		else if (s[i] == t[i]) {

		}
		
		else {
			++ng;
		}
	}

	if (ok == 0 && ng == 0) {
		if (s.size() >= t.size()) {
			++ng;
		}
	}



	if (ng == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long mod = 1000000007;
const long long MOD = 998244353;

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

	int n;
	cin >> n;
	ll* a = new ll[n];
	rep(i, n) cin >> a[i];

	ll ans = 0;
	bool flag = false;
	rep(i, n) {
		if (flag && a[i] >= 1) {
			ans += 1;
			--a[i];
		}

		ans += a[i] / 2;
		flag = (a[i] % 2 == 1);
	}

	cout << ans << "\n";

	return 0; 
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 

int main(){
  long double w,h,x,y;
 cin>>w>>h>>x>>y;
  long double m=w*h/2.0;
  cout<<fixed;
  cout<<setprecision(11)<<m<<" ";
  if(x==w/2&&y==h/2){
    cout<<1<<endl;}
  else{
    cout<<0<<endl;}
  
  
  
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;			
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll x;
			cin>>x;
			x=x%10;
			if(x==3)
			{
				cout<<"bon";
			}
			else if(x==0 or x==1 or x==6 or x==8)
			{
				cout<<"pon";
			}
			else
			cout<<"hon";
			return 0;
		 }	


Measured memory_bytes: 3640
mod = 10 ** 9 + 7

n, k = map(int, input().split())
a = list(map(int, input().split()))

r = [[]] * n
for i in range(n):
  r[i] = [len([x for x in a[:i] if a[i] > x]), len([x for x in a[i+1:] if a[i] > x])]

ans = 0
for i in range(n):
  ans += r[i][0] * (k - 1) * k // 2 + r[i][1] * k * (k + 1) // 2
  ans %= mod 
print(ans)

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

int main() {
  int N,A;
  string op;
  cin >> N >> A;

  if (N <= A) {
    cout << "Yes" << endl;
  }
  
  else if (N>=500&&A>=N%500){
    cout<< "Yes"<< endl;
  }
  
  else if(N>=500&&A<N%500){
    cout<< "No"<<endl;
  }
}

Measured memory_bytes: 256
import numpy as np
x = input()
y = input()

a=np.array(list(x))
b=np.array(list(y))
ans=0

for i in range(len(a)-len(b)):    
    tmp=(a[i:len(b)+i]==b).sum()
    if ans<tmp:
        ans=tmp
        
if len(a)==len(b):
    print(len(b)-(a==b).sum())
else:
    print(len(b)-ans)

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

int main()
{
    int n;
    cin >> n;
    
    vector<int> a, b;
    for(int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        a.push_back(c);
    }
    
    for(int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        b.push_back(c);
    }
    
    ll op = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] < b[i])
        {
            op += (b[i]-a[i])/2;
        }
        else if(a[i] > b[i])
        {
            op -= (a[i]-b[i]);
        }
    }
    if(op >= 0){cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std; 
int main(void){

  int n, k;
  cin >> n >> k;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  int result = 0;
  
  for(int h : vec){
    if (k <= h){
      result++;
    }
  }
   
  cout << result << endl;
  return 0;
}

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

#define NIL -1

struct node {
	int p, l, r;
};

node T[25];
int D[25], H[25];

void setdepth(int id, int d) {
	D[id] = d;
	if (T[id].l != NIL)
		setdepth(T[id].l, d + 1);
	if (T[id].r != NIL)
		setdepth(T[id].r, d + 1);
}

int setheight(int id) {
	int h1 = 0, h2 = 0;
	if (T[id].l != NIL)
		h1 = setheight(T[id].l) + 1;
	if (T[id].r != NIL)
		h2 = setheight(T[id].r) + 1;
	return H[id] = max(h1, h2);
}

void initnode(int n) {
	for (int i = 0; i < n; i++) {
		T[i] = { NIL, NIL, NIL };
	}
}

void regnode(int id, int l, int r) {
	T[id].l = l;
	T[l].p = id;
	T[id].r = r;
	T[r].p = id;
}

int getsibling(int id) {
	if (T[id].p == NIL) {
		return NIL;
	} else if (T[T[id].p].l == id) {
		return T[T[id].p].r;
	} else {
		return T[T[id].p].l;
	}
}

int getdegree(int id) {
	int ans = 0;
	if (T[id].l != NIL)
		ans++;
	if (T[id].r != NIL)
		ans++;
	return ans;
}

string gettype(int id) {
	if (T[id].p == NIL)
		return "root";
	else if (T[id].l == NIL && T[id].r == NIL)
		return "leaf";
	else
		return "internal node";
}

int main() {
	int n, root;
	cin >> n;
	initnode(n);
	for (int i = 0; i < n; i++) {
		int id, l, r;
		cin >> id >> l >> r;
		regnode(id, l, r);
	}
	for (int i = 0;; i++) {
		if (T[i].p == NIL) {
			root = i;
			break;
		}
	}
	setheight(root);
	setdepth(root, 0);
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].p << ", sibling = "
				<< getsibling(i) << ", degree = " << getdegree(i)
				<< ", depth = " << D[i] << ", height = " << H[i] << ", "
				<< gettype(i) << endl;
	}
	return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;
vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

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

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(10000);
    
    int N;cin>>N;
    vector<ll> A(N+1);
    for(int i=0;i<N+1;i++){
        cin>>A[N-i];
    }
    ll g=abs(A[0]);
    for(int i=1;i<N+1;i++) g=gcd(g,abs(A[i]));
    
    set<int> ans;
    
    for(int p:prime){
        while(g%p==0){
            ans.insert(p);
            g/=p;
        }
    }
    if(g!=1) ans.insert(g);
    
    for(int p=2;p<=N;p++){
        if(!is_prime[p]) continue;
        
        vector<ll> sum(p);
        for(int i=0;i<p;i++){
            sum[i]+=p+A[i]%p;
            sum[i]%=p;
        }
        
        for(int i=p;i<N+1;i++){
            int ii=i%(p-1);
            if(ii==0) ii=p-1;
            
            sum[ii]+=p+A[i]%p;
            sum[ii]%=p;
        }
        
        sort(all(sum));
        
        if(sum[p-1]==0) ans.insert(p);
    }
    
    for(auto p:ans) cout<<p<<endl;
    
    
}



Measured memory_bytes: 512
fun main(args: Array<String>) {
    val t = readLine()!!.toInt()
    val map = HashMap<String, Int>()
    map["AC"] = 0
    map["WA"] = 0
    map["TLE"] = 0
    map["RE"] = 0
    for (i in 0 until t) {
        val cur = readLine()!!.toString()
        map[cur] = map[cur]!! + 1
    }
    println("AC x ${map["AC"]}")
    println("WA x ${map["WA"]}")
    println("TLE x ${map["TLE"]}")
    println("RE x ${map["RE"]}")
}

Measured memory_bytes: 58548
# https://atcoder.jp/contests/abc093/tasks/abc093_a


import itertools
import collections
import bisect

def main():
    S = input()
    if 'a' in S and 'b' in S and 'c' in S:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<iostream>
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main()
{
    int n = 0;
    //printf("Hello World");
    scanf("%d", &n);
    call(n);
    return 0;
}


Measured memory_bytes: 3212
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long ans = 1;
        long num = 1000000007;
        for (long i = 1; i <= n; i++) {
            ans =  (ans * i) % num;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(H: int, W: int, a: "List[List[str]]"):

    dp = []
    for _ in range(0, H):
        L = [0]*W
        dp.append(L)
    
    # initialize
    for i in range(0, H):
        if a[i][0][0] == "#": 
            break
        dp[i][0] = 1
    for j in range(0, W):
        if a[0][0][j] == "#":
            break
        dp[0][j] = 1

    for i in range(1, H):
        for j in range(1, W):
            if a[i][0][j] == ".":
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]

    print(dp[H - 1][W - 1] % MOD)
            
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [[next(tokens) for _ in range(1)] for _ in range(H)]  # type: "List[List[str]]"
    solve(H, W, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 157484
N = int(input())
ans = N

for i in range(N + 1):
    cnt = 0
    t1 = i
    t2 = N - i
    while t1 > 0:
        cnt += t1 % 6
        t1 //= 6

    while t2 > 0:
        cnt += t2 % 9
        t2 //= 9
        
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 2940
// B - Golden Coins
#include <bits/stdc++.h>
using namespace std;

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

	int ans = 0;
	int c;

	c = X/500;
	ans += c*1000;
	X -= c*500;

	c = X/5;
	ans += c*5;
	X -= c*5;

	cout<< ans <<endl;
}

Measured memory_bytes: 256
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split(/\s+/g))},function(e,r,t){"use strict";e.exports=function(e){for(var r=0,t=parseInt(e[r++],10),n=new Array(t),o=0;o<t;o++)n[o]=[];for(var u=0;u<t-1;u++){var a=parseInt(e[r++],10),f=parseInt(e[r++],10),i=parseInt(e[r++],10);n[a-1].push([f-1,i]),n[f-1].push([a-1,i])}for(var l=parseInt(e[r++],10),p=parseInt(e[r++],10),s=new Array(t).fill(-1),c=[[p-1,0]];c.length>0;)for(var d=c.pop(),v=n[d[0]].length,y=0;y<v;y++){var b=n[d[0]][y];if(-1==s[b[0]]){var g=d[1]+b[1];s[b[0]]=g,c.push([b[0],g])}}for(var x=0;x<l;x++){var I=parseInt(e[r++],10)-1,j=parseInt(e[r++],10)-1,m=s[I]+s[j];console.log(m)}}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 114380
# coding: utf-8
# Your code here!
import math

def main():
    N = int(input()) #counted people
    a = int(input()) #train
    b = int(input()) # bus
    c = int(input()) # taxi
    d = int(input()) # airplane
    e = int(input()) # boat

    lst = [a,b,c,d,e]
    mi = min(a,b,c,d,e) # 一番狭い人数
    index = lst.index(mi) # そこのインデックス
    mintime = math.ceil(N / mi) # ここを通るのにかかる時間
    
    #addr = 5 - index
    #ans = math.ceil(N / mi) + addr
    #print(ans,addr,math.ceil(N / mi),mi,index)
    
    print(mintime+4)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll k,a,b,x;
int main()
{
	scanf("%lld%lld%lld",&k,&a,&b);
	if(k <= a) printf("1");
	else if(a <= b) printf("-1");
	else {
		if((k-a)%(a-b) >= 1) x=1;
		x = ((k-a)/(a-b)+x)*2+1;
		printf("%lld",x);
	}
	printf("\n");
	return 0;
}

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

using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);
int N;
  string s;
  cin >>N;
  cin >> s;
  int cnt=0;
  for (int i=0; i<N-2 ;i++){
    if (s.at(i)=='A' && s.at(i+1)=='B' && s.at(i+2)=='C') cnt++;
  }
  cout <<cnt;

	
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long int llint;

int n;
llint memo[200010];
int a[200000];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        memo[a[i]]++;
    }
    llint sum=0;
    for(int i=0;i<=200000;i++)
    {
        sum+=memo[i]*(memo[i]-1);
    }
    for(int i=0;i<n;i++)
    {
        printf("%lld\n",(sum-memo[a[i]]*(memo[a[i]]-1)+(memo[a[i]]-1)*(memo[a[i]]-2))/2);
    }
}

Measured memory_bytes: 3840
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $card_count = [];
  for($i=0; $i<$n; $i++){
    if(!isset($card_count[$a[$i]])){
      $card_count[$a[$i]]=0;
    }
    $card_count[$a[$i]]++;
  }

  for($i=0; $i<$m;$i++){
    list($b, $c) = explode(" ", trim(fgets(STDIN)));
    if(!isset($card_count[$c])){
      $card_count[$c]=0;
    }
    $card_count[$c]+=$b;
  }

  krsort($card_count);
    
  $ans = 0;
  $zan = $n;
  foreach($card_count as $value => $count){
    if($zan > $count){
      $ans += $value * $count;
      $zan -= $count;
    }else{
      $ans += $value * $zan;
      break;
    }
  }
  echo $ans;

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int ans=0;

    int N;cin>>N;
    int K;cin>>K;
    for(int i=0;i<11;i++){
        if(i>N-2)continue;

        int tmp=(N-2-i)/11+1;
        if(i==0)tmp--;

        int hoge=(K-9-8*i+114514*11)%11;
        hoge=hoge*5%11;
        if(hoge>=1&&hoge<=5)ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  a, b = input().split()
  ansA = ''
  ansB = ''
  
  for _ in range(int(b)):
    ansA += a
  for _ in range(int(a)):
    ansB += b
    
  if ansA > ansB:
    print(ansB)
  elif ansA <= ansB:
    print(ansA)
  
  
  
  
main()

Measured memory_bytes: 9044
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
template <typename T> T max(T, T);
int gcd(int a, int b);

int main() {
    // source
    int a, b;
    cin >> a >> b;
    int ans = 0;
    repd(i, 1, 13) {
        if (i < a | (i == a && i <= b)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T max(T a, T b) {

    if (a > b) {
        return a;
    } else {
        return b;
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


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

int main(){
    long int n;
    cin>>n;
    int count=0;
    for(long int i=1;i<=n;i++){
        if(10000 <= i && i < 100000){
            count++;
        }else if(100 <= i && i < 1000){
            count++;
        }else if(i < 10){
            count++;
        }
    }
    cout << count << endl;
}

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

using namespace std;
#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);
const int N = 21;

const int mod = 1e9 + 7;
int n, k, m;

ll min_self(ll &mn, ll x) {
    return mn = min(mn, x);
}

ll mem[N][(1 << N)];
int arr[N][N];

void sum_self(ll &fi, ll y) {
    fi += y;
    if (fi > mod)fi -= mod;
}

ll solve(int i = 0, int j = 0, int mask = 0) {
    if (j == n)return 0;
    if (i == n) {
        return (mask == (1 << n) - 1);
    }
    if (~mem[i][mask])return mem[i][mask];
    ll ret = 0;
    if (arr[i][j] && !((mask >> j) & 1)) {
        sum_self(ret, solve(i + 1, 0, mask | (1 << j)));
    }
    sum_self(ret, solve(i, j + 1, mask));
    return mem[i][mask] = ret;

}

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> arr[i][j];
        }
    }
    memset(mem, -1, sizeof mem);
    cout << solve() << endl;
}

Measured memory_bytes: 344448
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int A, B, X;
    cin >> A >> B >> X;

    if (X > A + B || X < A) print("NO");
    else print("YES");
    
}


Measured memory_bytes: 3608
MOD = 10 ** 9 + 7

X, Y = map(int, input().split())

a = (2 * X - Y) // 3
b = (2 * Y - X) // 3

if not ((2 * X - Y) % 3 == 0 and (2 * Y - X) % 3 == 0 and a >= 0 and b >= 0):
    print(0)
    exit()

maxf = a + b + 1
f = [1 for _ in range(maxf)]
invf = [1 for _ in range(maxf)]

for i in range(1, maxf):
    f[i] = (i * f[i - 1]) % MOD
invf[maxf - 1] = pow(f[maxf - 1], MOD - 2, MOD)

for i in range(maxf - 1, 0, -1):
    invf[i - 1] = (i * invf[i]) % MOD


def comb(a, b):
    return (f[a + b] * invf[a] * invf[b]) % MOD


print(comb(a, b))


Measured memory_bytes: 55832
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[65000];
	int b,i,j=0,k=0,sum,s;
	cin>>a;
	sum=strlen(a);
	for(i=0;i<sum;i++){
		if(a[i]=='C') k=1;//qqq
		if(k==1&&a[i]=='F'){cout<<"Yes";return 0;}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n,dp[N];
vi v = {1};

int main(){
    readi(n);
    int x = 9;
    while(x <= n) v.pb(x), x *= 9;
    x = 6;
    while(x <= n) v.pb(x), x *= 6;

    lp(i,1,n){
        dp[i] = infi;
        for(int x : v) if(x <= i) dp[i] = min(dp[i], 1 + dp[i-x]);
    }
    cout <<dp[n];
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


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

int main()
{
int n,a,b,c;

scanf("%d",&n);

a = n%10;
n = n/10;
b = n%10;
n = n/10;
c = n%10;

if(a!=7&&b!=7&&c!=7)
{
    printf("No");
    return 0;
}

printf("Yes");

return 0;

}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool chkmax(int &x,int y){return x<y?x=y,true:false;}
bool chkmin(int &x,int y){return x>y?x=y,true:false;}

int readint(){
	int 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;
}

int n;
int a[100005],p[100005];

int main(){
	n=readint();
	for(int i=1;i<=n;i++) p[i]=a[i]=readint();
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++) a[i]=lower_bound(p+1,p+n+1,a[i])-p;
	int cnt=0;
	for(int i=2;i<=n;i+=2) if(a[i]&1) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1024
#coding:utf-8
#1_5_C 2015.4.1
while True:
    length,width = map(int,input().split())
    if length == width == 0:
        break

    for i in range(length):
        for j in range(width):
            if (i + j) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()

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

int main(){
string s[100];
int d[100] = {0};  
bool a;  

int N;
  cin >> N;
string S;  
int youso = 0;  
  for(int i = 0;i < N;i++){
    a = true;
    cin >> S;
    for(int j = 0;j <= youso;j++){
    if(s[j] == S){
    d[j]++;
    a = false;
    }
    }
    if(a){
    s[youso] = S;
    d[youso]++;
    youso++;  
         }
  }
int M;
  cin >> M;
    for(int i = 0;i < M;i++){
    cin >> S;
      for(int j = 0;j < youso;j++){
      if(S == s[j]){
      d[j]--;
        break;
      } 
      }
    }

int ans = 0;  
  for(int i = 0;i < youso;i++){
  ans = max(ans, d[i]);
  }
  
  cout << ans << endl;
  return 0;

}

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

int main(){
    map<char, int> count;
    string str;
    while (cin >> str)
    {
        for(int i = 0; i < (int)str.size(); i++){
            if(isupper(str[i])){
                str[i] = tolower(str[i]);
            }
        }
        for(int i = 0; i < (int)str.size(); i++){
            count[str[i]]++;
        }
    }

    for(char ch = 'a'; ch <= 'z'; ch++){
        cout << ch << " : " << count[ch] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3184
from collections import deque
import numpy as np
h, w = map(int, input().split())
mass = [[ord(i) for i in input()] for _ in range(h)]
wall = ord("#")
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]


def bfs(s, t):
    if mass[s][t] == wall:
        return 0
    visited = [[False] * w for _ in range(h)]
    depth = np.zeros((h, w))
    q1 = deque([s])
    q2 = deque([t])
    visited[s][t] = True
    while q1:
        i = q1.popleft()
        j = q2.popleft()
        r = depth[i][j] + 1
        if j != w - 1:
            if mass[i][j + 1] != wall and not visited[i][j + 1]:
                q1.append(i)
                q2.append(j+1)
                visited[i][j + 1] = True
                depth[i][j + 1] += r
        if j != 0:
            if mass[i][j - 1] != wall and not visited[i][j - 1]:
                q1.append(i)
                q2.append(j - 1)
                visited[i][j - 1] = True
                depth[i][j - 1] += r
        if i != 0:
            if mass[i - 1][j] != wall and not visited[i - 1][j]:
                q1.append(i-1)
                q2.append(j)
                visited[i - 1][j] = True
                depth[i - 1][j] += r
        if i != h - 1:
            if mass[i + 1][j] != wall and not visited[i + 1][j]:
                q1.append(i + 1)
                q2.append(j)
                visited[i + 1][j] = True
                depth[i + 1][j] += r
    return np.max(depth)


ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(int(ans))


Measured memory_bytes: 12444
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N = int(input())
A = list(map(int,input().split()))

list.sort(A, reverse=True)

ans = A[0]

for i in range(2,N):
    ans += A[i//2]

print(ans)

Measured memory_bytes: 49800
// Aizu Vol-1 0164: Ohajiki Game
// 2017.8.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int a[10];

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int main()
{
	int i, n, k;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		gets(p = buf);
		for (i = 0; i < n; i++) a[i] = getInt();
		puts("31"), k = 31;
		for (i = 0, k = 31; k > 1; ) {
			k -= a[i];
			printf("%d\n", k);
			k = k - (k - 1) % 5;
			printf("%d\n", k);
			if (++i >= n) i = 0;
		}
		puts("0");
	}
	return 0;
}

Measured memory_bytes: 524
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        return
    i = 1
    ans = 1
    while i*i <= m:
        if m % i != 0:
            i += 1
            continue
        a = i
        if m // i >= n:
            ans = max(ans, i)
        if m // (m // i) >= n:
            ans = max(ans, m // i)
        i += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b) {
    a %= MOD;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
void solve()
{
    int n;
    cin >> n;
    int ans = (binpow(10, n) - binpow(9, n) + MOD) % MOD;
    ans = (ans - binpow(9, n) + MOD) % MOD;
    ans = (ans + binpow(8, n)) % MOD;
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

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

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

    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;

    int ans = H * W - h * W - w * H + h * w;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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 Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

bool flag = false;

void dfs(vector<int> &A, int N, int max_, int vn) {
    if (A.size() == N) {
        for(int a : A) {
            char s = 'a'+a;
            cout << s;
        }
        cout << endl;
        return;
    }
    if(max_ < vn+1 && flag) max_ = vn+1;
    for (int v = 0; v <= max_; ++v) {
        flag = true;
        A.push_back(v);
        dfs(A, N, max_, v);
        A.pop_back();
    }
}

int main(){
    int n;
    cin >> n;
    vi A;
    dfs(A, n, 0, 0);
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

const ll INF = 1e13;

int main() {
  ll n;
  cin >> n;
  ll m = INF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll j = n / i;
      m = min(m, i - 1 + j - 1);
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3604