akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

typedef ll Weight;
const ll INF = (ll)1e+15;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev){
    int n = g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q;     // a < b <-> a.weight > b.weight
    Q.push(Edge(-2, s, 0));
    while(!Q.empty()){
        Edge e = Q.top(); Q.pop();
        if(prev[e.to] != -1) continue;
        prev[e.to] = e.from;
        EACH(i, g[e.to]){
        //for(Edges::const_iterator i=g[e.to].begin(); i!=g[e.to].end(); ++i){    //マクロが使えないとき
            if(dist[i -> to] > dist[i -> from] + i -> weight){
                dist[i -> to] = dist[i -> from] + i -> weight;
                Q.push(Edge(i -> from, i -> to, dist[i -> to]));
            }
        }
    }
}
vector<int> buildPath(const vector<int> &prev, int t){
    vector<int> path;
    for(int v = t; v >= 0; v = prev[v])
        path.push_back(v);
    reverse(path.begin(), path.end());
    return path;
}

int main(){
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	Graph g(n+1), h(n+1);
	for(int i = 0; i < m; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		addUndirectedEdge(g, u, v, a);
		addUndirectedEdge(h, u, v, b);
	}
	vector<Weight> dist1(n+1), dist2(n+1);
	vector<int> prev1(n+1), prev2(n+1);

	dijkstra(g, s, dist1, prev1);
	dijkstra(h, t, dist2, prev2);
	ll tmp = INF;
	vector<ll> res;
	for(int i = n; i >= 1; i--){
		tmp = min(tmp, dist1[i] + dist2[i]);
		res.push_back(tmp);
	}
	reverse(ALL(res));
	for(auto a: res) {
		cout << ((ll)1e+15)-  a << endl;
	}
	return 0;
}


Measured memory_bytes: 23492
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <complex>
#include <cctype>
#include <cassert>
#include <sstream>
#include <ctime>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int cnt[50][26];

int main() {
	int n;
	cin >> n;
	
	REP(i, n) {
		string s;
		cin >> s;
		
		REP(j, s.size()) cnt[i][s[j] - 'a']++;
	}
	
	REP(i, 26) {
		int mi = INF;
		REP(j, n) chmin(mi, cnt[j][i]);
		
		REP(j, mi) printf("%c", i + 'a');
	}
	puts("");
	
	return 0;
}

Measured memory_bytes: 256
open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f

let () =
  let _ = read_line () in
  let al = read_list int_of_string in
  let _ = read_line () in
  let ml = read_list int_of_string in
  let makeable m =
    let rec iter s = function
        [] -> if s = m then true else false
      | x :: xs -> if s > m then false
                   else if s = m then true
                   else (iter s xs || iter (s+x) xs) in
    iter 0 al in
  List.iter (fun x -> print_endline (if makeable x then "yes" else "no")) ml

Measured memory_bytes: 2136
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<stdio.h>

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_ABck //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L


#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int> >
#define VPII vector<pair<int,int> >


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言






//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int N, M, K;
	cin >> N >> M >> K;

	bool ok = false;
	FOR(i, 0, N )FOR(j, 0, M) {
		if (M * i + N * j - 2*(i * j) == K) {ok = true; break;}
	}

	YesNo(ok)


	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int n; std::cin >> n;
    std::vector<int> X(n), Y(n);
    for(int i = 0; i < n; ++i) std::cin >> X[i] >> Y[i];

    int mx = std::numeric_limits<int>::min(), mn = std::numeric_limits<int>::max();
    for(int i = 0; i < n; ++i){
        const int val = X[i] + Y[i];
        if(mx < val) mx = val; if(mn > val) mn = val;
    }
    long long int res1 = static_cast<long long int>(mx) - mn;
    mx = std::numeric_limits<int>::min(), mn = std::numeric_limits<int>::max();
    for(int i = 0; i < n; ++i){
        const int val = X[i] - Y[i];
        if(mx < val) mx = val; if(mn > val) mn = val;
    }
    long long int res2 = static_cast<long long int>(mx) - mn;
    const long long int res = (res1 > res2) ? res1 : res2;
    std::cout << res << '\n';

    return 0;
}

Measured memory_bytes: 4740
#include <stdio.h>
#include <math.h>

int main(void){
  int X,num;
  scanf("%d",&X);

  if(X == 1 || X == 2){
    printf("1\n");
    return 0;
  }
  int flag[X];
  for(int i = 0;i < X;i++){
    flag[i] = 0;
  }

  for(int a = 1;a <= X;a++){
    for(int b = 2;b < X;b++){
      num = pow(a,b);
      if(num <= X){
        flag[num-1] = 1;
      }else{
        break;
      }
    }
  }

  for(int i = X-1;i >= 0;i--){
    if(flag[i]){
      printf("%d\n",i+1);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
        int a[20000],b[20000];
        char op[20000];
        int j,i = 0;
        while(1){
                scanf("%d %c %d",&a[i],&op[i],&b[i]);
                if(op[i] == '?'){
                        i--;
                        break;
                }
                i++;
        }
        for(j = 0;j <= i;j++){
                if(op[j] == '+'){
                        printf("%d\n",a[j]+b[j]);
                }else if(op[j] == '-'){
                        printf("%d\n",a[j]-b[j]);
                }else if(op[j] == '*'){
                        printf("%d\n",a[j]*b[j]);
                }else if(op[j] == '/'){
                        printf("%d\n",a[j]/b[j]);
                }
        }
        return 0;
}

Measured memory_bytes: 616
// 0241
#include <iostream>
using namespace std;

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

		if(n == 0)
			break;

		for(int i=0;i<n;i++){
			int a, b, c, d, e, f, g, h;
			cin>>a>>b>>c>>d>>e>>f>>g>>h;

			cout<<a*e-b*f-c*g-d*h<<" "<<a*f+b*e+c*h-d*g<<" "<<a*g-b*h+c*e+d*f<<" "<<a*h+b*g-c*f+d*e<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		while(true){
			int m = stdIn.nextInt();
			int n = stdIn.nextInt();
			if((m|n)==0){
				return;
			}
			boolean[] a = new boolean[m+1];
			a[0] = true;
			int now = 0;
			int player = m;
			for(int i=1;i<=n;i++){
				if(player!=1){
					while(true){
						now++;
						if(now==m+1){
							now = 1;
						}
						if(!a[now]){
							break;
						}
					}
				}
				String tmp = stdIn.next();
				if(player==1){
					continue;
				}
				boolean judge = false;
				if(i%3==0&&i%5==0){
					if(tmp.equals("FizzBuzz")){
						judge = true;
					}
				}
				else if(i%3==0){
					if(tmp.equals("Fizz")){
						judge = true;
					}
				}
				else if(i%5==0){
					if(tmp.equals("Buzz")){
						judge = true;
					}
				}
				else{
					int num = 0;
					try{
						num = Integer.parseInt(tmp);
					}
					catch(Exception e){
					}
					if(num==i){
						judge = true;
					}
				}
				if(!judge){
					a[now] = true;
					player--;
				}
			}
			boolean flag = true;
			for(int i=0;i<=m;i++){
				if(!a[i]){
					if(flag){
						System.out.print(i);
						flag = false;
					}
					else{
						System.out.print(" "+i);
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n; cin >> n;
  if((n[1]==n[2])&&(n[0]==n[1]||n[2]==n[3])) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

#define x first
#define y second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

struct C {
	pdd p;
	double r;
	C() {}
	C(pdd p_, double  r_) {
		p = p_;
		r = r_;
	}
};

double dist(C a, C b) {
	pdd aa, bb;
	aa = a.p; bb = b.p;
	double d;
	d = sqrt((aa.x - bb.x) * (aa.x - bb.x) + (aa.y - bb.y) * (aa.y - bb.y));
	return max(0.0, d - a.r - b.r);
}

vector<vector<pair<int,double> > >  E;
vector<double > cost;
const double INF = 4e9;

int main() {
	vector<C> v;
	pdd s, t;
	int N;
	cin >> s.fi >> s.se >> t.fi >> t.se;
	cin >> N;
	v.push_back(C(s,0)); v.push_back(C(t,0));
	rep(i,N) {
		pdd tmp;
		double r;
		cin >> tmp.x >> tmp.y >> r;
		v.push_back(C(tmp,r));
	}
	E.resize(N+2);
	rep(i,v.size()) {
		for(int j = i+1; j < v.size(); j++) {
			double d;
			d = dist(v[i], v[j]);
			E[i].push_back(mkp(j,d));
			E[j].push_back(mkp(i,d));
		}
	}
	cost.resize(N+2);
	rep(i,N+2) cost[i] = INF;
	priority_queue<pair<double,int> > q;
	cost[0] = 0;
	q.push(mkp(0,0));
	while(q.size()) {
		pair<double, int> a;
		a = q.top(); q.pop();
		for(int i = 0; i < E[a.se].size(); i++) {
			double b;
			b = -a.fi + E[a.se][i].se;
			if(b < cost[E[a.se][i].fi]) {
				cost[E[a.se][i].fi] = b;
				q.push(mkp(-b, E[a.se][i].fi));
			}
		}
	}
	printf("%.10f\n", cost[1]);
	return 0;
}


Measured memory_bytes: 20720
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct UF{
    vector<int> par;
    vector<int> sz;
    vector<int> sum;
    UF(){}
    UF(int n){
        par.resize(n);
        sz.resize(n, 1);
        sum.resize(n);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        // return par[x] = find(par[x]);
        return find(par[x]);
    }
    void unite(int x, int y){
        // x = find(x); y = find(y);
        // if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        sum[x] += sum[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    int dec(int x, int s){
        if(x == par[x]){
            return x;
        }else{
            sum[par[x]] -= s;
            return dec(par[x], s);
        }
    }
};

struct edge{
    int u, v, w;
    bool operator<(const edge &e) const{
        return w < e.w;
    }
};
struct S{
    int e, pu, pv;
};

int n, m;
vector<edge> es; 
int a[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    UF uf(n);
    rep(i, 0, n){
        cin >> a[i];
        uf.sum[i] = a[i];
    }
    rep(i, 0, m){
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        es.push_back({u, v, w});
    }
    sort(es.begin(), es.end());
    vector<S> d;
    for(int i = 0; i < m; i++){
        edge e = es[i];
        int pu = uf.find(e.u);
        int pv = uf.find(e.v);
        if(pu != pv){
            if(uf.sz[pu] < uf.sz[pv]) swap(pu, pv);
            uf.unite(pu, pv);
            d.push_back({i, pu, pv});
        }
    }
    for(int i = d.size() - 1; i >= 0; i--){
        int id = d[i].e;
        int pu = d[i].pu;
        int pv = d[i].pv;
        int ppu = uf.find(pu);
        if(uf.sum[ppu] >= es[d[i].e].w) continue;
        uf.dec(pv, uf.sum[pv]);
        uf.par[pv] = pv;
        uf.sz[ppu] -= uf.sz[pv];
        // uf.sum[ppu] -= uf.sum[pv];
    }
    int ans = 0;
    rep(i, 0, m){
        edge e = es[i];
        int pu = uf.find(e.u);
        int pv = uf.find(e.v);
        if(pu != pv) continue;
        if(uf.sum[pu] >= e.w) ans++;
    }
    cout << m - ans << endl;
}

Measured memory_bytes: 11888
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = [int(x) for x in input().strip().split()]
    X = 0
    for a in A:
        X ^= a
    B = [0] * N
    for i, a in enumerate(A):
        B[i] = X ^ a
    print(*B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31428
#include <iostream>
using namespace std;
long long pre,temp,N,c=0;
#define d(x)  cerr << #x << " = " << (x) << endl;
int main(void){
    cin>>N;
    cin>>pre;
    for(int i=1;i<N;i++){
        cin>>temp;
        if(pre==temp){
            c++; 
            i++;
            cin>>temp;
        }
        pre=temp;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>x, y, t;

int main()
{
	in >> N;
	x.resize(N + 1);
	y = x; t = x;
	rep(i, N) { in >> t[i + 1] >> x[i + 1] >> y[i + 1]; }

	rep(i, N)
	{
		auto dis = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
		auto b = t[i + 1] - t[i];
		if (dis <= b)
		{
			if ((b - dis) % 2 != 0)
			{
				out << "No" << std::endl;
				return 0;
			}
		}
		else
		{
			out << "No" << std::endl;
			return 0;
		}
	}
	out << "Yes" << std::endl;
	return 0;
}

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

using namespace std;

string c;
int n;

int main()
{
	cin >> n >> c;
	for (auto& i : c)
		if (i + n <= 'Z')
			i = i + n;
		else
			i = (i - 'A' + n) % 26 + 'A';
	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef long long ll;
//A*Bの計算
mat mul(mat &A,mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(int i =0;i <A.size();i++){
		for(int k =0;k <B.size();k++){
			for(int j =0;j <B[0].size();j++){
				C[i][j] =(C[i][j]+A[i][k]*B[k][j]);
			}
		}
	}
	return C;
}

//A^nの計算
mat pow(mat A,ll n){
	mat B(A.size(),vec(A.size()));
	for(int i =0;i <A.size();i++){
		B[i][i]=1;
	}
	while(n >0){
		if(n&1)B =mul(B,A);
		A =mul(A,A);
		n >>=1;
	}
	return B;
}


int main(){
	int n;
	cin>>n;
	mat A(2,vec(2));
	A[0][0]=1;
	A[0][1]=1;
	A[1][0]=1;
	A[1][1]=0;
	A =pow(A,n+1);
	cout <<A[1][0]<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int n, m;
  cin >> n;
  vector<string> blue(n);
  for (int i=0; i<n; i++) {
    cin >> blue.at(i);
  }
  cin >> m;
  vector<string> red(m);
  for (int i=0; i<m; i++) {
    cin >> red.at(i);
  }
  int ans = 0;
  for (string s : blue) {
    int buf = 0;
    for (string t : blue) {
      if (s == t) buf++;
    }
    for (string t : red) {
      if (s == t) buf--;
    }
    if (buf > ans) ans = buf;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php

$in = file_get_contents('php://stdin');

$inarr = explode(" ", $in);

$a = intval($inarr[0]);
$b = intval($inarr[1]);

$_a = floor($a / 0.08);
$_b = floor($b / 0.1);

$lower = min($_a, $_b);
$upper = max($_a, $_b);

$ans = -1;
for ($i = $lower - 10; $i <= $upper + 13; $i++) {
  $_a = floor($i * 0.08);
  $_b = floor($i * 0.1);
  if ($_a == $a && $b == $_b) {
    $ans = $i;
    break;
  }
}
echo $ans . PHP_EOL;


Measured memory_bytes: 4604
#python3
def main():
    k = int(input())
    a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(a[k-1])
main()

Measured memory_bytes: 2940
N = int(input())
S = list(map(int, input().replace('o', '0').replace('x', '1')))

for p in [[0, 0], [0, 1], [1, 0], [1, 1]]:
    for s in S[1:]:
        if p[-1] ^ p[-2] ^ s == 1:
            p.append(1)
        else:
            p.append(0)

    if (p[0] == p[-1]) and (p[-2] ^ p[-3] ^ p[0] ^ S[-1] == 0) and (p[0] ^ p[-2] ^ p[1] ^ S[0] == 0):
        print(''.join(map(str, p[:-1])).replace('0', 'S').replace('1', 'W'))
        break
else:
    print(-1)


Measured memory_bytes: 14736
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 7964
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <22/Jun/2019 06:07:06 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    n = int(input())
    arr = [0] * n
    ans = 'Yes'
    d = {}
    for i in range(n):
        arr[i] = get_array()
        if arr[i][0] > arr[i][1]:
            ans = 'No'
        if arr[i][1] not in d:
            d[arr[i][1]] = 0
        d[arr[i][1]] += arr[i][0]
    if ans == 'No':
        print(ans)
        return
    od = sorted(list(d.items()))
    d = []
    for i in od:
        d.append([i[0], i[1]])
    for i in range(1, len(d)):
        d[i][1] += d[i - 1][1]

    for i in d:
        if i[0] < i[1]:
            ans = 'No'
            break

    print(ans)


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 93776
//nays//nays//nays//nays//nays//nays//nays//nays//nays//nays//nays
//nays//nays//nays//nays//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays
//nays

#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000
#define MOD 1000000007
#define N 2000005
#define M 1000003
#define LOG 16
#define KOK 650
#define EPS 0.00001
using namespace std;
 
int f[N],p[N],n;
 
int main() {
 
//	freopen("input.txt","r",stdin);
 
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
 
	cin>>n;
 
	f[1]=n;
 
	for(int i=0;i<=M;i++) p[i]=(p[i-1]+1)%MOD;
 
	p[1+M]=(p[M]+n)%MOD;
 
	for(int i=2;i<=n;i++) {
 
		f[i]=(p[i-3+M]-p[i-n-2+M]+f[i-1]+(ll)(n-1)*(n-1))%MOD;
		
		p[i+M]=(p[i-1+M]+f[i])%MOD;
 
	}
 
	cout<<f[n];
 
}

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

using namespace std;
#define lint long long


int main() {
    int H, W, N;
    cin >> H >> W >> N;
    
    map<int, vector<int>> obs;
    
    for(int i = 0; i < N; ++i){
        int x, y;
        cin >> x >> y;
        obs[x].push_back(y);
    }
    
    for(auto e : obs){
        vector<int> v = e.second;
        sort(v.begin(), v.end());
        obs[e.first] = v;
    }
    
    int M = 1;
    for(int i = 2; i < H + 1; ++i){
        bool flag = 1;
        for(auto e : obs[i]){
            if(e < M + 1){
                cout << i - 1 << endl;
                return 0;
            } else if(e == M + 1){
                flag = 0;
                break;
            } else if(e > M + 1){
                break;
            }
        }
        if(flag){
            ++M;
        }
    }
    
    cout << H << endl;
}


Measured memory_bytes: 22144
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {

    int test_cases;
    cin >> test_cases;

    unordered_map<string, int> verdicts;
    vector<string> strs = {"AC", "WA", "TLE", "RE"};

    string verdict;
    while(test_cases--) {
        cin >> verdict;
        ++verdicts[verdict];
    }

    for(string& s: strs){
        cout << s << " x " << verdicts[s] << endl;
    }


    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int top, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top+1];
}


int main() {
  int a, b;
  top = 0;
  char s[100];

  while(!cin.eof()) {
    string s;
    cin >> s;
    if(s == "") break;

    if (s == "+") {
      a = pop();
      b = pop();
      push(a + b);
    } else if (s == "-") {
      b = pop();
      a = pop();
      push(a - b);
    } else if (s == "*") {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s.c_str()));
    }
  }

  cout << pop() << endl;

  return 0;
}



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

int main() {
	int w; cin >> w; int h; cin >> h; char c; cin >> c;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i == 0 || i == h - 1) {
				if (j == 0 || j == w - 1) cout << "+" << flush;
				else cout << "-" << flush;
			}
			else if (j == 0 || j == w - 1) cout << "|" << flush;
			else if (i == (h - 1) / 2 && j == (w - 1) / 2) cout << c << flush;
			else cout << "." << flush;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
const int N=5010;
int n,A,B,f[N],a[N];
main()
{
    n=in,A=in,B=in;
    forinc(i,1,n) a[i]=in;
    a[++n]=n;
    forinc(i,1,n)
    {
        f[i]=LLONG_MAX;
        int res=0;
        fordec(j,i-1,0)
        {
            if(a[j]>a[i]) ++res;
            else if(f[i]>f[j]+A*res+B*(i-j-1-res)) f[i]=f[j]+A*res+B*(i-j-1-res);
        }
    }
    cout<<f[n]<<"\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " <<  to_string(x) << endl)
//#define debug_cout(x) ( )
#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(ll i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T& b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 2e9;

/*****/

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)	cin >> A.at(i);

	int max = -1, maxSec = -1;
	int maxNum = -1, maxSecNum = -1;
	rep(i, N)
	{
		if (max < A.at(i))
		{
			max = A.at(i);
			maxNum = i;
		}
		else if (maxSec < A.at(i))
		{
			maxSec = A.at(i);
			maxSecNum = i;
		}
	}

	rep(i, N)
	{
		if (i == maxNum)
		{
			cout << maxSec << endl;
		}
		else
		{
			cout << max << endl;
		}
	}

	return 0;
}


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

int main() {
  
  int64_t x;
  cin >> x;
  int64_t y=0;
  int64_t d=100;
  
  while(true){
    y++;
    d=d*1.01;
    if(d>=x){
      break;
    }
  }
  cout << y << endl; 
}

Measured memory_bytes: 3620
import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()
c = list(set(a))
b = [0 for _ in range(n + 1)]
for i in range(n):
    b[a[i]] += 1
d = [0 for _ in range(n + 1)]
e = [0 for _ in range(n + 1)]
for i in range(n + 1):
    if b[i] >= 2:
        d[i] = b[i] * (b[i] - 1) // 2
    if b[i] >= 3:
        e[i] = (b[i] - 1) * (b[i] - 2) // 2
sd = sum(d)
se = sum(e)
for k in range(n):
    ans = sd - d[a[k]] + e[a[k]]
    print(ans)


Measured memory_bytes: 87856
#include<cstdio>
#include<iostream>
#include<cstring>
#define MAXN 100+10
using namespace std;
inline int read(){
	int out=0;
	char c=getchar();
	while(c<47||c>58)c=getchar();
	while(c>=47&&c<=58){
		out=(out<<1)+(out<<3)+c-48;
		c=getchar();
	}
	return out;
}
inline void write(int x){
    if(x>9)write(x/10);
    putchar(x%10+48);
}
int a[MAXN];
int b[MAXN];
int n;
int sum=0;
int main(){
    n=read();
    for(int i=1;i<=n;++i){
        a[i]=read();
        sum+=a[i];
    }
    int m=read();
    for(int i=1;i<=m;++i){
        int x=read();
        int y=read();
        int ans=sum;
        ans-=a[x];
        ans+=y;
        write(ans);
        putchar(10);
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int d = sc.nextInt();  
      	int[] c = new int[26];
      	int[][] s = new int[d][26];
      	for(int i=0;i<26;i++){
          c[i] = sc.nextInt();
        }
      	for(int i=0;i<d;i++){
          for(int j=0;j<26;j++){
            s[i][j] = sc.nextInt();
          }
        }
      	for(int i=0;i<d;i++){
          int n = s[i][0];
          int pos = 0;
          for(int j=1;j<26;j++){
            if( s[i][j] > n ){
              n = s[i][j];
              pos = j;
            }
          }
          System.out.println(1);
        }
    }
}

Measured memory_bytes: 38240
A = input()
B = input()
C = input()

now = 'a'
a = 0
b = 0
c = 0

while True:
    if now == 'a':
        if a  == len(A):
            res = 'A'
            break
        now = A[a]
        a = a + 1
        
    elif now == 'b':
        if b  == len(B):
            res = 'B'
            break
        now = B[b]
        b = b + 1
        
    elif now == 'c':
        if c  == len(C):
            res = 'C'
            break
        now = C[c]
        c = c + 1

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
bool as[30000][10], de[30000][10];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    for (int i = 0; i < N-2; ++i) {
        if (i != 0) for (int j = 0; j < 10; ++j) {
            as[i][j] = as[i-1][j];
            de[N-i-1][j] = de[N-i][j];
        }
        as[i][S[i]-'0'] = true;
        de[N-i-1][S[N-i-1]-'0'] = true;
    }
    map<int, bool> M;
    for (int i = 1; i < N-1; ++i) {
        for (int j = 0; j < 10; ++j) for (int k = 0; k < 10; ++k){
            if (as[i-1][j] && de[i+1][k]) {
                M[j*100+(int)(S[i]-'0')*10+k] = true;
            }
        }
    }
    printf("%d\n", (int)M.size());
    return 0;
}


Measured memory_bytes: 896
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ').map(Number);
  console.log(inputs.sort(function(a,b) {
  	return a-b;
  })
  .join(' '));

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

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

	scanf("%d%d%d", &a, &b, &c);

	if (a < b && b < c){
		printf("Yes\n");
	}else printf("No\n");

	return 0;
}

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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    int ans = 0, m = -1;
    rep(_, n) {
        int p;
        cin >> p;
        ans += p;
        if(p > m) m = p;
    }
    cout << ans - m / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int b[3][3];
int main() {
	// your code goes here
	int a[3][3];
	for(int i=0;i<3;i++)
	  { for(int j=0;j<3;j++)
	      {
	         cin>>a[i][j]; 
	          
	      }}
	  int n;cin>>n;
	for(int i=0;i<n;i++)
	  {
	      int x;
	      cin>>x;
	      for(int j=0;j<3;j++)
	         { for(int k=0;k<3;k++)
	            {
	               if(a[j][k]==x)
	                 b[j][k]=1;
	            }}
	  }
	  bool f=false;
	  for(int i=0;i<3;i++)
	    {
	        if(b[i][0]&&b[i][1]&&b[i][2])f=true;
	        if(b[0][i]&&b[1][i]&&b[2][i])f=true;
	    }
	  if(b[0][0]&&b[1][1]&&b[2][2])f=true;
	  if(b[0][2]&&b[1][1]&&b[2][0])f=true;
	  
	  if(f)cout<<"Yes"<<endl;
	  else cout<<"No\n";
	return 0;	
}


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

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

const int MAX = 4, I=1, J=2, K = 3;

int d[MAX][MAX] = 
{0,1,2,3,
1,0,3,2,
2,3,0,1,
3,2,1,0};

int s[MAX][MAX] = 
    {1,1,1,1,
    1,-1,1,-1,
    1,-1,-1,1,
    1,1,-1,-1};

int main()
{
    int n;
    int p[3][MAX];
    while(cin >> n && n)rep(r,n)
    {
        REP(2)rep(j,MAX)cin >> p[i][j];
        int ans[MAX] = {};        

        rep(i,MAX)rep(j,MAX)ans[d[i][j]] +=s[i][j] * ( p[0][i] * p[1][j]);
        
        cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;


    }


    return 0;
}

Measured memory_bytes: 0
n = int(input())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())
ans = 0
for i in range(n - 1, -1, -1):
    a[i] += ans
    if a[i] % b[i] != 0:
        ans += b[i] - a[i] % b[i]
print(ans)


Measured memory_bytes: 15016
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (x - a > b || a > x) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}



Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ret = 0;
    rep(r, 3001) {
        rep(g, 3001) {
            int left = N - r * R - g * G;
            if (left < 0) continue;
            ret += left % B == 0;
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,K,M,cnt=0;
  	cin >> N >> K;
  
  	for(int i=0; i<N; i++){
      cin >> M;
      if(M >= K)
        cnt++;
    }

  	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include<string>
using namespace std;
#define int long long
const int inf = 10e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
int dp[100010];
int a[] = { 1,6,36,216,1296,1296 * 6,1296 * 36,1296 * 216,9,81,729,729 * 9,729 * 81 };
signed main(){
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++)dp[i] = 10000000;
	dp[0] = 0;
	for (int i = 0; i <= n; i++) {
		rep(j, 13) {
			if (i < a[j])continue;
			dp[i] = min(dp[i], dp[i - a[j]] + 1);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<assert.h>
#include<vector>
#include<string.h>
#include<algorithm>
#include<memory.h>
#include<cmath>
#include<string>
#include<iostream>
#include<set>
#include<unordered_set>
#include<map>
#include<queue>
#include<functional>
#include<list>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double, double> pdd;
typedef tuple<int,int,int> t3;

const int MX = 500005;
const int MM = 1000000007;

int D[MX];
ll ans[MX];
int N;

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%d", D+i);
	int cur = 0;
	for(int i = 1; i <= N; i++){
		if( cur < D[i] ) ans[i] = cur+1, cur = D[i];
	}
	map<int, int> L;
	for(int i = N; i >= 1; i--){
		L[D[i]] += 1;
		if( ans[i] == 0 ) continue;
		int to = ans[i]-1;
		ll tot = 0, cur = 0;
		while(L.size() && L.rbegin()->first >= to){
			tot += (ll)(L.rbegin()->first - to) * L.rbegin()->second;
			cur += L.rbegin()->second;
			L.erase(--L.end());
		}
		L[to] = cur;
		ans[i] = tot;
	}
	for(int i = 1; i <= N; i++) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#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 FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N,M;
	in(N,M);
	auto a = mv(N);
	in(a);
	sort(ALL(a));
	auto sum = mv(N+1);
	REP(i,N)sum[i+1]+=sum[i]+a[i];
	auto f =[&](int x){
		int s = 0;
		int total = 0;
		REP(i,N){
			int idx = lower_bound(ALL(a),x-a[i])-a.begin();
			s += N - idx;
			total += sum[N]-sum[idx]+a[i]*(N-idx);
		}
		return pair<int,int>(s >= M,total-(x*(s-M)));
	};
	int l = -1, r = 1e10 + 1;
	while(r - l > 1){
		int c = (l + r) / 2;
		if(f(c).first) l = c;
		else r = c;
	}
	out(f(l).second);
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, n)
#define repc(i, n)     REPC(i, 0, n)
#define REP(i, n, m)   for (long long i = (long long)(n); i <  (long long)(m); i++)
#define REPC(i, n, m)  for (long long i = (long long)(n); i <= (long long)(m); i++)
#define REPCM(i, n, m) for (long long i = (long long)(n); i >= (long long)(m); i--)
#define yesno(cond)       YESNO(cond, "Yes", "No")
#define YESNO(cond, a, b) printf("%s\n", cond ? a : b)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, K, A[110];
  bool dp[100010];

  void init() {
    scanf("%lld %lld", &N, &K);
    rep(i, N) scanf("%lld", A+i);
  }

  void solve() {
    dp[0] = false;
    REPC(i, 1, K) rep(j, N) if(i-A[j]>=0) dp[i] |= !dp[i-A[j]];
    cerr << "\n";
    YESNO(dp[K], "First", "Second");
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
string s;
long long flag=0;
int main()
{
	cin>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		if(flag==0&&s[i]=='C')
		{
			flag=1;
		}
		if(flag==1&&s[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{

    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    if(K-1 > 0) cout << S.substr(0,K-1);
    cout << (char)(*(S.substr(K-1,1).c_str()) + 0x20);
    if(K < S.length()) cout << S.substr(K)<< endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0;i < (n);i++)
int main(){
  bool flag = true;
  int c[3][3];
  rep(y,3){
    rep(x,3){
      cin >> c[y][x];
    }
  }
  rep(x,2){
    rep(y,2){
      if(c[y][x]-c[y][x+1]!=c[y+1][x]-c[y+1][x+1]){
        flag = false;
      }
    }
  }
  rep(y,2){
    rep(x,2){
      if(c[y][x]-c[y+1][x]!=c[y][x+1]-c[y+1][x+1]){
        flag = false;
      }
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main() {
  
  string s,t,u;
  cin >> s >> t;
  
  for ( int i = 0; i < s.size(); i++){
    u = s[s.size()-1];
    s.erase(s.end()-1,s.end());
    u += s;
    if ( u == t ){
      cout << "Yes" << endl;
      return 0;
    }else{
      s = u;
    }
  }
  
  cout << "No" << endl;
  
}

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

using namespace std;

int main() {
    int max = 0;
    int count = 0;
    int N;

    cin >> N;

    int H[N];

    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    for (int j = 0; j < N - 1; j++) {
        if (H[j] >= H[j + 1]) {
            count++;
            if (count > max) {
                max = count;
            }
        } else {
            count = 0;
        }
    }

    cout << max << endl;

    return 0;
}



Measured memory_bytes: 640
/*     !ya khoda!     */
#include <bits/stdc++.h>
#define ll long long
#define ld long double

#define pp push
#define po pop()
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()

#define F first
#define S second

#define mkp make_pair
#define pll pair<ll,ll>

#define coutghat(x)      cout<<tolower(x);
#define coutashar(x,d)   cout<<fixed<<setprecision(x)<<(ld)d
#define IOS ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
//#define poow(a,b,M)   b?(poow((a*a)%M,b/2)%M * (b&1?a))%M:1 ;
/*==========================================================================*/
using namespace std;
//#pragma optimize O3
// 107,109, 211,223, 307, 401,409, 503,509, 601,607, 701,709, 809, 907, 1009
/*==========================================================================*/
const int N=2e3+100 , M=1e3 , LG=30 , base=2;
const int MOD=1e9+7 , mod=1e9+9;
const ll  INF=1e9   , inf=1e18 ;
ll n,a[N],b[N] , ans;
/*==========================================================================*/
int main()
{
    IOS;
	cin>>n;
	for(int i=0;i<n;i++)   cin>>a[i];
	for(int i=0;i<n;i++)   cin>>b[i];
	for(int i=1;i<n;i++)   a[i]+=a[i-1];
	for(int i=n-2;i>=0;i--)b[i]+=b[i+1];
	for(int i=0;i<n;i++)   ans=max(ans , a[i]+b[i]);
	cout<<ans;
    return 0;
}


Measured memory_bytes: 256