akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
def ncr(n, r, p):
  num = den = 1
  for i in range(r):
    num = (num * (n - i)) % p
    den = (den * (i + 1)) % p
  return (num * pow(den, p - 2, p)) % p
p=10**9+7

for i in range(1, K+1):
  print((ncr(N-K+1, i, p)*ncr(K-1, i-1, p))%p)

Measured memory_bytes: 42608
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

bool isprime(long long n)
{
    if (n < 2) return false;

    for (long long i = 2; i * i <= n; ++i)
        if (n % i == 0)
            return false;

    return true;
}

int main() {
    long long n, a;
    cin >> n;
    a = n;
    for (long long i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            a = n / i;
        }
    }
    cout << to_string(a).size() << "\n";
    return 0;
}


Measured memory_bytes: 256
debug = false
N, M = gets.split.map(&:to_i)
shops = []
N.times do
  shops << gets.split.map(&:to_i)
end
shops.sort_by! { |a| a[0].to_i } # 価格が低い方から並べ替える
puts "shops: #{shops}" if debug
limit = M
sum = 0
shops.each do |shop|
  if limit >= shop[1]
    num_purchase = shop[1]
    limit = limit - shop[1]
  else
    num_purchase = limit
    limit = 0
  end
  sum += shop[0] * num_purchase
end
puts sum


Measured memory_bytes: 12664
#include<cstdio>
int main()
{int k,s;
scanf("%d %d",&k,&s);
int a,b,cnt=0;
for(int a=0;a<=k;a++)
	{for(int b=0;b<=k;b++)
		{if((s-a-b)<=k&&(s-a-b)>=0)	
		cnt++;

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

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i){
        int foo;
        cin >> foo;
        ++a[--foo];
    }
    sort(a.begin(), a.end());
    vector<ll> CumulativeSum(n + 1);
    CumulativeSum[0] = 0;
    for(int i = 0; i < n; ++i)  CumulativeSum[i + 1] = CumulativeSum[i] + a[i];

    for(int k = 1; k <= n; ++k){
        int lb = 0, ub = n / k + 1;
        while(ub - lb > 1){
            int mid = (lb + ub) / 2;
            int pos = lower_bound(a.begin(), a.end(), mid) - a.begin();
            ll sum = (ll)mid * (n - pos) + CumulativeSum[pos];
            if(sum >= (ll)mid * k)  lb = mid;
            else    ub = mid;
        }
        cout << lb << '\n';
    }
}

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

int main()
{
    int n;
    cin >> n;
    string s[n];
    string t[n];
    int cnt[n];
    for(int i = 0; i < n; i++){
        cnt[i] = 0;
    }
    int t1 = 1,t2 = 1;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    for(int i = 0; i < n-1; i++){
        if(s[i][s[i].size()-1] != s[i+1][0]){
            t1 = 0;
        }
    }
    for(int i = 0; i < n; i++){
        t[i] = s[i];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(s[i] == t[j]){
                cnt[i]++;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(cnt[i] > 1){
            t2 = 0;
        }
    }
    if(t1 == 0 || t2 == 0){
        cout << "No";
    }else{
        cout << "Yes";
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=inf){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;


#define endl '\n'
#define int ll

signed main() {
	fast;

	int h,w;
	cin>>h>>w;

	pii v[200002];
	for(int i=0;i<h;i++) cin>>v[i].f>>v[i].s;

	map<int,int> mp;
	for(int i=1;i<=w;i++) mp[i] = 0;

	map<int,int> mini = {{0,w}};

	for(int i=0;i<h;i++) {
		int l = v[i].f;
		int r = v[i].s;

		auto it = mp.lower_bound(l);
		int mn = inf;

		while(it!=mp.end() && it->f <= r) {
			mn = min(mn, r+1-(it->f)+(it->s));
			auto it1 = it++;
			mini[it1->s]--;
			if(mini[it1->s]==0) mini.erase(it1->s);
			mp.erase(it1);
		}

		if(r+1<=w && mn<inf) {
			auto it = mp.find(r+1);
			if(it != mp.end()) {
				if(it->s > mn) {
					if(mini[it->s]==1) mini.erase(it->s);
					else mini[it->s]--;
					mini[mn]++;
					mp[r+1] = mn;
				}
			}
			else {
				mp[r+1] = mn;
				mini[mn]++;
			}
		}

		if(mini.size()) cout<<mini.begin()->f+i+1<<endl;
		else cout<<-1<<endl;

	}
}

Measured memory_bytes: 19268
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(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()

// 
int N;
int a[5000];
ll ans = 0;

int main(){
    cin >> N;
    rep(i, 0, N){
        cin >> a[i];
    }

    rep(i, 0, N){
        ans += a[i]-1;
    }

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




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

using namespace std;

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

int main(){
    int i;
    //入力
    int n,m;
    cin>>n>>m;
    //処理
    //出力
    n>m?cout<<"No"<<endl:cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}



Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>

int main(){
    char s[10],t[10],u[10];
    int a,b;

    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    
    if(strcmp(s,u)==0){printf("%d %d",a-1, b);}
    if(strcmp(t,u)==0){printf("%d %d",a,b-1);}
    if(strcmp(s,u)*strcmp(t,u)!=0){printf("error");}
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    string S;

    cin >> S;

    if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
        cout << "Bad" << endl;
    }

    else{
        cout << "Good" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n;
char s[11],s2[11];
int main()
{
    cin >> n;
    for (int i = sqrt(n); i >= 1; -- i)
    {
        if (n % i == 0)
        {
            int i2 = n / i;            sprintf(s,"%d",i);            sprintf(s2,"%d",i2);cout << max(strlen(s),strlen(s2)) << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  ll x,sum=0,tmp=0;cin>>x;
  string s;
  rep(i,0,x){
    cin>>s[i];
    if(s[i]=='('){
      sum++;
    }
    else{
      if(sum>0){sum--;}
      else{tmp++;}
    }
  }
  rep(i,0,tmp){cout<<'(';}
  rep(i,0,x){cout<<s[i];}
  rep(i,0,sum){cout<<')';}
  cout<<endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    char x;
    cin >> a >> x >> b;
    while(x!='?')
    {
        int c;
        if(x=='+') c=a+b;
        if(x=='-') c=a-b;
        if(x=='*') c=a*b;
        if(x=='/') c=a/b;
        cout << c << endl;
        cin >> a >> x >> b;
    }
    return 0;
}


Measured memory_bytes: 3116
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])

const a = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  const aLast = a.length - 1
  const halfLine = Math.ceil(n / 2)

  const b = []

  for (let i = 0; i < n; i++) {
    b[i] = 0
  }

  for (let i = 0; i < n; i++) {
    if (i < halfLine) {
      b[aLast - i] = a[aLast - i]
    } else {
      const num = aLast - i + 1

      let count = 0
      for (let j = 2; num * j <= n + 1; j++) {
        if (b[num * j - 1] === 1) count++
      }

      if (a[aLast - i] === 1) {
        b[aLast - i] = count % 2 === 1 ? 0 : 1
      } else {
        b[aLast - i] = count % 2 === 0 ? 0 : 1
      }
    }
  }

  const filtered = b.filter(e => e === 1)

  console.log(filtered.length)
  if (filtered.length === 0) return

  let str = ''
  for (let i = 0; i < n; i++) {
    if (b[i] === 1) {
      str += ` ${i + 1}`
    }
  }
  console.log(str.trim())
}

ans()


Measured memory_bytes: 40968
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
using namespace std;

class Unionfind{
public:
  vector<int> par;
  vector<int> rak;

  Unionfind(int n): par(n), rak(n, 0){
    for(int i=0; i<n; ++i) par[i] = i;
  }

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

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

  void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(rak[x] < rak[y]) par[x] = y;
    else{
      par[y] = x;
      if(rak[x] == rak[y]) rak[x]++;
    }
  }
};


int main(){
  int n, k, l;
  cin >> n >> k >> l;
  Unionfind road(n);
  Unionfind train(n);

  int p, q;
  for(int i=0; i<k; ++i){
    cin >> p >> q;
    road.unite(p-1, q-1);
  }

  int r, s;
  for(int i=0; i<l; ++i){
    cin >> r >> s;
    train.unite(r-1, s-1);
  }

  typedef pair<int, int> P;
  map<P, int> mp;
  for(int i=0; i<n; ++i){
    mp[make_pair(road.root(i), train.root(i))]++;
  }
  for(int i=0; i<n; ++i){
    cout << mp[make_pair(road.root(i), train.root(i))] << " ";
  }
  cout << "\n";
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll moves[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll row,col,k;
    cin>>row>>col>>k;
    vector<vector<char>>grid(row,vector<char>(col));
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    x1--;
    y1--;
    x2--;
    y2--;
    rep(i,0,row)
    {
        rep(j,0,col)
        cin>>grid[i][j];
    }
    vector<vector<ll>>dist(row,vector<ll>(col,LLONG_MAX));
    dist[x1][y1]=0;
    queue<pair<ll,ll>>q;
    q.push({x1,y1});
    while(!q.empty())
    {
        ll curx=q.front().f;
        ll cury=q.front().s;
        q.pop();
        rep(i,0,4)
        {
            repA(j,1,k)
            {
                ll nx=curx+moves[i][0]*j;
                ll ny=cury+moves[i][1]*j;
                 if(nx>=0 && nx<row && ny>=0 && ny<col && grid[nx][ny]=='.' && (dist[nx][ny]==LLONG_MAX || dist[nx][ny]==dist[curx][cury]+1))
                {
                    if(dist[nx][ny]==LLONG_MAX)
                    {
                        dist[nx][ny]=1+dist[curx][cury];
                        q.push({nx,ny});

                    }
                }
                else
                break;
            }
        }
    }
    if(dist[x2][y2]>=LLONG_MAX)
    cout<<-1<<endl;
    else
    cout<<dist[x2][y2]<<endl;
}


Measured memory_bytes: 19928
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define mod(n) n % 1000000007
#define sp << " "
#define precision(n) cout << fixed << setprecision(n);
#define startTime time_t start, end;time(&start);
#define endTime time(&end);double tt = double(end-start);cout<<"Time taken : "<<fixed<<tt<<setprecision(5);cout <<" sec"<< endl;
 
using namespace std;

ll dp[100001];
ll color[100001];

void dfsVisit(vll graph[], ll u) {
	color[u] = 1;
	if (graph[u].empty()) {
		dp[u] = 0;
		return;
	}
	for (auto x: graph[u]) {
		if (color[x] == 0) dfsVisit(graph, x);
		dp[u] = max(dp[u], 1 + dp[x]);
	}
	return;
}

void dfs(vll graph[], ll n) {
	for (int i = 0; i < n; i++) {
		if (color[i] != 1) dfsVisit(graph, i);
	}
}
 
int main() { 
    IOS;
    ll n, m, u, v;
    cin >> n >> m;
    vll graph[n];
    for (int i = 0; i < m; i++) {
    	cin >> u >> v;
    	graph[--u].pb(--v);
    }
    dfs(graph, n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
    	ans = max(ans, dp[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 13364
// i_m_arin

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

string s,t;
cin>>s>>t;
ll ans=INF;
f(i,0,s.size()-t.size()+1){
	string x=s.substr(i,t.size());

	ll cnt=0;
	f(j,0,t.size()){
		if(x[j]!=t[j]) cnt++;
	}
	ans=min(cnt,ans);
}
cout<<ans<<endl;


}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int A, B;

	cin >> A >> B;

	
	if(A * B % 2 == 0){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    string S;
    cin >> N >> S;
    vector<ll> cnt(3, 0);
    vector<char> c{'R', 'G', 'B'};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            if (S[i] == c[j]) cnt[j]++;
        }
    }
    ll tmp = 0;
    for (int i = 0; i < N; i++) {
        for (int k = i + 2; k < N; k++) {
            if (((i + k) % 2) != 0) continue;
            int j = (i + k) / 2;
            if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) tmp++;
        }
    }
    ll ans = 1;
    for (ll a : cnt) ans *= a;
    cout << ans - tmp << '\n';
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int n; cin >> n;
    vint x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    map<pair<int, int>, int> m;
    rep(from, n) {
        rep(to, n) {
            if(from == to) continue;
            int p = x[to] - x[from];
            int q = y[to] - y[from];
            pair<int, int> pq = make_pair(p, q);
            if(m.count(pq) == 0) {
                m[pq] = 1;
            } else {
                m[pq]++;
            }
        }
    }

    int maxim = 0;
    for(auto&& pqk: m) {
        pair<int, int> pq = pqk.first;
        int k = pqk.second;
        chmax(maxim, k);
    }
    cout << n - maxim << endl;
    return 0;
}


Measured memory_bytes: 384
#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() {
  string s;
  cin >> s;
  rep(bit, (1 << 3)) {
    int temp = (s[0] - '0');
    rep(i,3) {
      if (bit & (1 << i)) temp += (s[i+1] - '0');
      else temp -= (s[i+1] - '0');
    }
    if (temp == 7) {
      string ans = "";
      ans += s[0];
      rep(i,3) {
        if (bit & (1 << i)) ans += '+';
        else ans += '-';
        ans += s[i+1];
      }
      cout << ans + "=7" << endl;
      return;
    }
  }
}

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

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int n, m, cur, b[MAXN];
vector <int> v[MAXN];

inline void Modify(int x, int v)
{
	for (; x <= n; x += x & -x)
		b[x] += v;
}

inline int Query(int x)
{
	int r = 0;
	for (; x; x -= x & -x)
		r += b[x];
	return r;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	cur = m = Read(), n = Read();
	for (int i = 1, l, r; i <= m; i ++)
		l = Read(), r = Read(), v[r - l + 1].pb(l);
	for (int i = 1; i <= n; i ++)
	{
		int ret = cur;
		for (int j = i; j <= n; j += i)
			ret += Query(j);
		printf("%d\n", ret);
		for (auto l : v[i])
			Modify(l, 1), Modify(l + i, -1);
		cur -= v[i].size();
	}
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> num;
  num.push_back(1);
  for (int i = 1;; ++i) {
    if (pow(6, i) <= n)
      num.push_back(pow(6, i));
    else
      break;
  }
  for (int i = 1;; ++i) {
    if (pow(9, i) <= n)
      num.push_back(pow(9, i));
    else
      break;
  }
  int dp[n + 1];
  rep(i, n + 1) dp[i] = INF;
  dp[0] = 0;
  repi(i, 1, n + 1) {
    rep(j, num.size()) {
      if (i - num[j] < 0) continue;
      dp[i] = min(dp[i], dp[i - num[j]] + 1);
    }
  }
  // rep(i, n + 1) cout << dp[i] << endl;
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 640
// AOJ DSL_3_B The Smallest Window II
// 2018.5.6 bal4u@uu

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 100003
int a[MAX_N], f[MAX_N];

int main()
{
	int N, K, i, j, s, t, ans;

	N = in(), K = in();
	if (N < K) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in();

	s = 0, i = j = 0;
	while (s < K && j < N) {
		t = a[j++];
		if (t <= K) {
			if (f[t] == 0) s++;
			f[t]++;
		}
	}
	if (s < K) goto ng;
	while ((t = a[i]) > K || f[t] > 1) {
		if (t <= K) f[t]--;
		i++;
	}
	ans = j-i;

	while (j < N) {
		t = a[j++];
		if (t <= K) f[t]++;
		while ((t = a[i]) > K || f[t] > 1) {
			if (t <= K) f[t]--;
			i++;
		}
		if (j-i < ans) ans = j-i;
	}
	printf("%d\n", ans);
	return 0;
ng: puts("0");
	return 0;
}



Measured memory_bytes: 2628
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int preT = 0;
        int preX = 0;
        int preY = 0;

        for (int i = 0; i < N; i++) {
            int postT = Integer.parseInt(sc.next());
            int postX = Integer.parseInt(sc.next());
            int postY = Integer.parseInt(sc.next());

            int dt = postT - preT;
            int dist = Math.abs(postX - preX) + Math.abs(postY - preY);
            // 1.目標地点までにかけられる時間の差より目標地点までの距離が長いと移動できない
            // 2.時刻 - 距離　
            if ((dist > dt) || ((dt - dist) % 2 != 0)) {
                System.out.println("No");
                return;
            }

            preT = postT;
            preX = postX;
            preY = postY;
        }
        System.out.println("Yes");
    }
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}
int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  ll ans = 0;
  sort(v.begin(), v.end());
  int l = 0,r = n-1;
  while(r-l>2){
    ans += v[r]*2 - v[l]*2;
    l++;
    r--;
  }
  if(r - l == 1)ans += v[r] - v[l];
  else ans += max(v[r]*2-v[l]-v[r-1],v[r]-v[l]*2+v[r-1]);
  cout << ans << endl;
}


Measured memory_bytes: 3752
#include <iostream>
using namespace std;
#define ll unsigned long long
int main() 
{
 int n;
 ll a[n];
 int i;
//  for(i=0;i<n;i++)
//  cin>>a[i];
 char c;
 cin>>c;
 c=c+1;
 cout<<c<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	int a,b;
	cin>>a>>b;
	for(int i=2;i<10000000;i++)
	{
		double p=(double)i*0.08;
		double h=(double)i*0.1;
		double q=floor((double)i*0.08);
		double w=floor((double)i*0.1);
		//cout<<p<<h<<endl;
		if(q==a&&w==b){cout<<i;return 0;}
	}
	cout<<-1;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  lint n;
  cin>>n;
  n--;

  lint s=26;
  while(s<=n){
    n-=s;
    s*=26;
  }

  vector<int> in26;
  while(s>1){
    in26.push_back(n%26);
    n/=26;
    s/=26;
  }

  rep_rev(i,in26.size(),0){
    cout<<(char)('a'+in26[i]);
  }
  cout<<endl;
}

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


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

typedef long long ll;

const int N = 2e5+1;

int p[N], pos[N];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> p[i];
		pos[p[i]] = i;
	}
	int c = 1, lcs = 1;
	for(int i = 2; i <= n; i++){
		if(pos[i] > pos[i-1])
			c++;
		else c = 1;
		lcs = max(lcs, c);
	}
	// int j = 0, k = n+1;
	// for(int i = 0; i < n; i++){
	// 	if(p[i] == j+1)
	// 		j++;
	// }
	// for(int i = n-1; i >= 0; i--){
	// 	if(p[i] == k-1)
	// 		k--;
	// }
	cout << n-lcs << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using pint = pair<int,int>;

int main() {
    int N, M; cin >> N >> M;
    vector<pint> pic(N);
    for (int i = 0; i < N; ++i) cin >> pic[i].second >> pic[i].first;
    sort(pic.begin(), pic.end(), greater<pint>());
    vector<int> gaku(M);
    for (int i = 0; i < M; ++i) cin >> gaku[i];
    sort(gaku.begin(), gaku.end(), greater<int>());

    int i = 0, j = 0;
    for (; i < gaku.size(); ++i, ++j) {
        while (j < pic.size() && pic[j].second > gaku[i]) ++j;
        if (j == pic.size()) break;
    }
    cout << i << endl;
}


Measured memory_bytes: 3892
import sys
sys.setrecursionlimit(10**9)

s = input()
l = len(s)


def dfs(i):
   #    print("->", s[i:])
    if i == l:
        print("YES")
        exit()
    if s[i:i+5] == "dream":
        if i+6 < l and s[i+5:i+7] == "er":
            dfs(i+7)
        dfs(i+5)
    elif s[i:i+5] == "erase":
        if i+5 < l and s[i+5] == "r":
            dfs(i+6)
        dfs(i+5)


dfs(0)
print("NO")


Measured memory_bytes: 18140
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt();
    basic_string <ll> a(n, 0);
    generate(all(a), nxt);

    map <ll, ll> cnt;

    for(ll i=0; i<n; i++)
    {
        cnt[a[i]]++;
    }

    ll ans = 0;

    for(auto i: cnt)
    {
        ans += (i.ss*(i.ss-1))/2;
    }

    for(ll i=0; i<n; i++)
    {
        ll temp = ans - (cnt[a[i]]*(cnt[a[i]]-1))/2;

        temp += max(0LL, ((cnt[a[i]]-1)*(cnt[a[i]]-2))/2);
        
        cout << temp << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;

int main() {
    /*
    int H, N;
    cin >> H >> N;
    vector<int> X(N), Y(N);
    vector<vector<bool> > f(4, vector<bool>(H));
    for(int i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i];
        f[X[i]][Y[i]] = true;
    }
    int cnt = 0;
    for(int i = 0; i < H - 1; ++i) {
        for(int j = 0; j < 3; ++j) {
            if(!f[j][i] && !f[j][i + 1] && !f[j + 1][i] && !f[j + 1][i + 1]) {
                f[j][i] = true;
                f[j][i + 1] = true;
                f[j + 1][i] = true;
                f[j + 1][i + 1] = true;
                ++cnt;
            }
        }
    }
    cout << cnt << endl;
     */

    int x, y;
    cin >> x >> y;
    cout << x + 1 + y + 1 - (__gcd(x, y) + 1) << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	ll n,k;
	cin>>n>>k;
	cout << (k==1?0:n-k);
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(n) for(int i=0;i<n;i++)
void out(int a[],int n){
  lp(n){
    if(i!=0) cout<<" ";
      cout<<a[i];
  }
  cout<<endl;
  return;
}
int main(){
  int n,a[10];
  cin>>n;
  for(int i=0;i<n;i++){
    a[i]=i+1;
  }
  out(a,n);
  while(next_permutation(a,a+n)){
    out(a,n);
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (ll i = 0; i < n; ++i)
#define forn1(i, n) for (ll i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second

//#define DEBUG
int main()
{
  //FastIO;
  #ifdef DEBUG
    freopen("input.txt", "r", stdin);
  #endif
  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i)
  {
    if (n % i == 0 && n / i <= 9 && n / i >= 1){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";\

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

ll my_pow(ll x, ll y) {
  ll result = 1;
  REP(i, y) { result = result * x % 998244353LL; }
  return result;
}

int main() {
  int N;
  cin >> N;
  auto C = vector<int>(N, 0);
  auto D = vector<int>(N);
  REP(i, N) {
    cin >> D[i];
    C[D[i]]++;
  }
  if(D[0] != 0 || C[0] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  // bool flag = true;
  // REP(i, N) {
  //   if(C[i] == 0) {
  //     flag = false;
  //     continue;
  //   }
  //   if(flag == false && C[i] != 0) {
  //     cout << 0 << endl;
  //     return 0;
  //   }
  // }
  // dump(C);
  ll result = 1LL;
  REPS(i, 2, N) {
    result = result * my_pow(C[i - 1], C[i]) % 998244353LL;
    //
  }
  cout << result << endl;
}


Measured memory_bytes: 1024
from sys import stdin
inp = stdin.readline

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

A.insert(0, 0)
A.append(0)


def money(a, b):
    return (abs(a - b))


sumall = 0

for i in range(len(A) - 1):
    sumall += money(A[i], A[i + 1])

for i in range(1, len(A) - 1):
    ans = sumall
    ans -= (money(A[i - 1], A[i]) + money(A[i], A[i + 1]))
    ans += money(A[i - 1], A[i + 1])
    print(ans)


Measured memory_bytes: 13924
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())
    L = []
    R = []
    for _ in range(n):
        l,r = map(int, input().split())
        L.append(l)
        R.append(r)

    ans = 0
    for i in range(n):
        ans += R[i] - L[i] + 1
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

static inline bool IsAns(string s) {
    char base = s[0];
    REP(i, s.length()) { if(base != s[i]) { return false; } }
    return true;
}

signed main()
{
    int N;
    cin >> N;
    for(int i = N; i < 10000; ++i) {
        if(IsAns(to_string(i))) {
            printf("%lld\n", i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 10 + 2;
int arr[maxn], n, sum = 0, p = 0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i], p = (arr[p] < arr[i]) ? i: p, sum += arr[i];
	cout << sum - arr[p] / 2 << '\n';
	return 0;
}

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

int main(){
	long long hoge;
	cin>>hoge;
	bitset<32> x(hoge);
	cout<<x<<endl;
	bitset<32> a=~x;
	bitset<32> b=(x<<1);
	bitset<32> c=(x>>1);
	cout<<a<<endl<<b<<endl<<c<<endl;
	return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<set>

using namespace std;

int main(){
	string s, t; cin >> s >> t;
	set<char> a[26], b[26];
	for(int i = 0; i < s.length(); i++){
		a[t[i] - 'a'].insert(s[i]);
		b[s[i] - 'a'].insert(t[i]);
	}
	bool f = 1;
	for(int i = 0; i < 26; i++){
		if(a[i].size() > 1) f = 0;
		if(b[i].size() > 1) f = 0;
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  long long ans = A.at(0);
  
  for(int i = 1; i < N; i++){
    if(ans == 0) break;
    else{
      long long div = 1000000000000000000LL / ans;
      if(div >= A.at(i)){
        ans *= A.at(i);
      }
      else{
        ans = -1;
        break;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n), del(n-1);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  int sum = abs(a.at(0)) + abs(a.at(n-1));
  for(int i = 0; i < n -1; i++){
    del.at(i) = abs(a.at(i + 1) - a.at(i));
  }
  for(int i = 0; i < n-1; i++){
	sum += del.at(i);
  }
  int ans;
  for(int i = 0; i < n; i++){
    ans = sum;
    if(i == 0){
      ans -= abs(a.at(i));
      ans += abs(a.at(i + 1));
      ans -= del.at(i);
    }
    else if(i == n-1){
      ans -= abs(a.at(i));
      ans += abs(a.at(i - 1));
      ans -= del.at(i-1);
    }
    else{
      ans -= del.at(i-1) + del.at(i);
      ans += abs(a.at(i+1) - a.at(i-1));
    }
    cout << ans << endl;
  }
}

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


//namespace _3_D

class Program
{
    static void Main(string[] args)
    {
        //???????????????3????????????????????????????????????
        string readData = Console.ReadLine();

        //???????????¨??????????????????????????????a,b,c????????????????????????
        string[] readDataValue = readData.Split(' ');
        int a = int.Parse(readDataValue[0]);
        int b = int.Parse(readDataValue[1]);
        int c = int.Parse(readDataValue[2]);

        //number???????????????a??¨b????´???°?????°
        int number = 0;

        //a??????b?????§?????°????????????????????????????????? c ????´???°???????????????????????????
        for (int x = a; x <= b; x++)
        {
            if (c % x == 0)
            {
                number++;
            }
        }
        Console.WriteLine(number);


    }
}

Measured memory_bytes: 9208
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector> 
using namespace std;
typedef long long ll;
const int maxn=10;
char s[maxn];
 
int main(){
	scanf("%s",s);
	int ans=0;
	for(int i=0;i<=5;i++){
		if(s[i]=='1') ans++;
	}
	printf("%d\n",ans); 
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int dp[1010][1010];

int main() {
    string s, t;
    cin >> s >> t;
    rep(i, s.size()+1) dp[i][0] = i;
    rep(j, t.size()+1) dp[0][j] = j;

    rep(i, s.size()) {
        rep(j, t.size()) {
            int c = (s[i] == t[j] ? 0 : 1);
            dp[i+1][j+1] = min({dp[i][j+1]+1, dp[i+1][j]+1, dp[i][j] + c});
        }
    }
    cout << dp[s.size()][t.size()] << endl;
}


Measured memory_bytes: 7124
import datetime

s = input()
# s = '2019/04/30'

y, m, d = map(int, s.split('/'))

date1 = datetime.datetime(2019, 4, 30)
date2 = datetime.datetime(y, m, d)

if date1 < date2:
    print('TBD')
else:
    print('Heisei')


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0&&a>0&&b>0){
		cout<<"Possible"<<endl;
		return 0;
	}
	cout<<"Impossible"<<endl;
	return 0;
}

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

int main() {
    ll h;
    cin >> h;
    ll cnt = 0;
    ll r = 1;
    while (h > 0) {
        h /= 2;
        cnt += r;
        r *= 2;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3604
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        if (n <= 999)
        {
            Console.WriteLine("ABC");
        }
        else
        {
            Console.WriteLine("ABD");
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  struct task{
    ll a,b;
  };
  vector<task>ab(n);
  rep(i,n){
    cin>>ab[i].a>>ab[i].b;
  }
  sort(all(ab),[&](task p,task q){return p.a<q.a;});
  priority_queue<ll>que;
  ll id=0;
  ll res=0;
  que.push(0);
//  cout<<que.top()<<endl;
  repi(i,1,m+1){
  //  cout<<"i "<<i<<" id "<<id<<endl;
    while(id<n&&ab[id].a==i){
      //cout<<ab[id].a<<" "<<ab[id].b<<endl;
      ll tb=ab[id].b;
      que.push(tb);
      id++;
    }
    //cout<<que.top()<<endl;
    if(!que.empty()){res+=que.top();que.pop();}
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 2936
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,A,B,res=0;
string S,T,U;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>A>>B;
    cout<<(N-A)%B<<endl;
}    


Measured memory_bytes: 256