akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

int N;
double dp[310][310][310];
double rec(int i, int j, int k){
    if(dp[i][j][k] >= 0) return dp[i][j][k];

    double res = 0.0;
    if(i > 0) res += rec(i-1,j,k) * i;
    if(j > 0) res += rec(i+1,j-1,k) * j;
    if(k > 0) res += rec(i,j+1,k-1) * k;
    res += N;
    res /= double(i+j+k);
    return dp[i][j][k] = res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    cin >> N;
    int one = 0, two = 0, three = 0;
    REP(i,N){
        int a; cin >> a;
        if(a == 1) one++;
        if(a == 2) two++;
        if(a == 3) three++;
    }
    REP(i,310) REP(j,310) REP(k,310){
        dp[i][j][k] = -1.0;
    }
    dp[0][0][0] = 0.0;
    cout << rec(one,two,three) << endl;



}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n / 2; ++i) {
    if (n - i != i) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int a,b,c,d;
  int yasui1,yasui2;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  if(a>=b){yasui1=b;}
  else if(b>a){yasui1=a;}
    if(c>=d){yasui2=d;}
  else if(d>c){yasui2=c;}
  printf("%d",yasui1+yasui2);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main(){
    int N;
    cin >> N;
    out((N+1)/2);
}

Measured memory_bytes: 256
N, M = map(int,input().split( ))
l = []
for i in range(M):
	a,b = map(int,input().split( ))
	l.append([a, b])

t_a = []
t_b = []

ans = 'IMPOSSIBLE'
for i in range(M):
	if l[i][0] == 1:
		t_a.append(l[i][1])
	elif l[i][1] == N:
		t_b.append(l[i][0])
t_and = set(t_a) & set(t_b)
t_and_l = list(t_and)
if len(t_and_l) > 0:
	ans = 'POSSIBLE'
print(ans)

Measured memory_bytes: 45520
#include<iostream>
using namespace std;
int main()
{
    long int A, B, K;
    cin >> A >> B;
    if(A > B)
    {
        K = B;
        while(K < A)
        {
            K++;
            if(A - K == K - B)
            {
                cout << K;
                return 0;
            }
        }
    }
    else
    {
        K = A;
        while(K < B)
        {
            K++;
            if(B - K == K - A)
            {
                cout << K;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int K;
  cin >> N >> K;
  int d;
  int a;
  set<int> sss;
  for(int i=0;i<K;i++){
    cin >> d;
    for(int j=0;j<d;j++){
      cin >> a;
      sss.insert(a);
    }
  }
  int count = 0;
  for(int k=1;k<=N;k++){
    if(sss.count(k)){
    }else{
      count += 1;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 200007
#define mo 19930726
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
int head[MAXN],a[MAXN],c[MAXN],num,size[MAXN],f[MAXN],g[MAXN],si[MAXN],d[MAXN],ans,n;
char s[MAXN];
struct po
{
	int nxt,to;
}edge[MAXN];
inline int read()
{
    int x=0,c=1;
    char ch=' ';
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    while(ch=='-')c*=-1,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-'0',ch=getchar();
    return x*c;
}
inline void add_edge(int from,int to)
{
	edge[++num].nxt=head[from];
	edge[num].to=to;
	head[from]=num;
}
void dfs(int u,int fa)
{
	size[u]=1;si[u]=c[u];
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v!=fa){
			dfs(v,u);
			size[u]+=size[v];si[u]+=si[v];
			if(si[v]!=size[v]) d[v]++,d[u]++;
		}
	}
}
void dfs2(int u,int fa)
{
	int max1=0,max2=0;
	if(d[u]==1&&fa){f[u]=a[u],g[u]=-1<<30;return;}
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(v!=fa&&size[v]!=si[v]){
			dfs2(v,u);
			ans=max(ans,f[v]+max2+a[u]);
			ans=max(ans,g[v]+max1+a[u]);
			max1=max(max1,f[v]);
			max2=max(max2,g[v]);
		}
	}
	f[u]=max1+a[u];g[u]=max2+a[u];
}
int main()
{
	n=read();
	for(re int i=1;i<=n-1;i++){
		int x=read(),y=read();
		add_edge(x,y);add_edge(y,x);
	}
	scanf("%s",s+1);
	int root=0;
	for(re int i=1;i<=n;i++){
		if(s[i]=='B') c[i]=1;
		else root=i;
	}
	
	if(root) dfs(root,0);
	
	else {
		cout<<"0";
		return 0;
	}
	int sum=0;
	
	for(int i=1;i<=n;i++){
		if(size[i]==si[i]) continue;
		sum+=d[i];
		if((d[i]+c[i])%2==0) sum++,a[i]=2;
	}
	dfs2(root,0);
	cout<<sum-ans;
}


Measured memory_bytes: 14464
n, m = map(int, input().split())

success = 0
fail = 0
check = {}
for i in range(m):
    p, s = input().split()
    if s == "WA":
        if p in check:
            if check[p] < 0:
                pass
            else:
                check[p] += 1
        else:
            check[p] = 1
    else:
        if p in check:
            if check[p] < 0:
                continue
            fail += check[p]
        check[p] = -1
        success += 1
print(success, fail)


Measured memory_bytes: 17108
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
#include <iostream>
#include <string>
using namespace std;

const int MAX_V = 100000;
const int MAX_D = 10000;
const int MAX_E = 500000;
const int INF = 999999999;
int V, E, R;

struct edge {
  int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];

void solve() {
  for (int i = 0; i < V; i++) {
    d[i] = INF;
  }
  d[R] = 0; // 初期化
  while (true) {
    bool update = false;
    for (int i = 0; i < E; i++) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) {
      break;
    }
  }
  for (int i = 0; i < V; i++) {
    cout << ((d[i] == INF) ? "INF" : to_string(d[i])) << endl;
  }
}

int main() {
  cin >> V >> E >> R;
  cin.ignore();
  for (int i = 0; i < E; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    cin.ignore();
    es[i] = edge{from, to, cost};
  }
  solve();
}



Measured memory_bytes: 9340
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n"
#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()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

class REP;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}


void rec(vector<ll> &path, vector<vector<bool>> &graph, bool &isConnected, ll &N) {
    if (isConnected) {
        return;
    }
    if (path.size() == N) {
        isConnected = true;
        return;
    }
    bool isChanged = false;
    for (ll node : path) {
        REP(i, N) {
            if (graph[node][i] && find(path.begin(), path.end(), i) == path.end()) {
                path.push_back(i);
                isChanged = true;
            }
        }
    }
    if (isChanged) {
        rec(path, graph, isConnected, N);
    }
}

int main() {
    ll N, M, ans;
    vector<vector<bool>> graph;
    cin >> N >> M;
    ans = 0;
    graph = vector<vector<bool>>(N, vector<bool>(N, false));
    REP(n, M) {
        ll a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = true;
        graph[b - 1][a - 1] = true;
    }
    REP(i, N) {
        REP(j, N) {
            if (graph[i][j]) {
                graph[i][j] = false;
                graph[j][i] = false;
                vector<ll> path;
                bool isConnected = false;
                path.push_back(0);
                rec(path, graph, isConnected, N);
                if (!isConnected) {
                    ans++;
                }
                graph[i][j] = true;
                graph[j][i] = true;
            }
        }
    }
    cout << ans / 2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
 
const int maxn = 20;
int n, m, swaped[maxn];
bool used[maxn], ans;
 
string s[20];
 
bool check()
{
    memset(used, false, sizeof(used));
    for(int i = 0; i < m; i ++) {
        if(used[i])
            continue;
        for(int j = 0; j < m; j ++) {
            bool cur = true;
            if(i == j || used[j])
                continue;
            for(int k = 0; k < n; k ++) {
                if(s[swaped[k]][i] != s[swaped[n - 1 - k]][j]) {
                    cur = false;
                    break;
                }
            }
            if(cur) {
                used[i] = used[j] = true;
                break;
            }
        }
    }
 
    int cnt = 0, noused = -1;
    for(int i = 0; i < m; i ++)
        if(!used[i])
            cnt ++, noused = i;
    if((cnt >= 2 ) || (cnt && (m % 2 == 0)))
        return false;
    for(int i = 0; i < n; i ++)
        if(s[swaped[i]][noused] != s[swaped[n - 1 - i]][noused])
            return false;
    return true;
}
 
void dfs(int u, int flag)
{
    if(u == (n + 1) / 2) {
        if(check())
            ans = true;
        return;
    }
 
    for(int i = u; i < n; i ++) {
        if(swaped[i] == -1) {
            for(int j = i + 1; j < n; j ++) {
                if(swaped[j] >= 0)
                    continue;
                swaped[i] = i;
                swaped[j] = j;
                dfs(u + 1, flag);
 
                swaped[i] = j;
                swaped[j] = i;
                dfs(u + 1, flag);
                swaped[i] = swaped[j] = -1;
            }
            if(flag) {
                swaped[i] = i;
                dfs(u + 1, false);
            }
            swaped[i] = -1; 
            break;
        }
    }
}
 
int main()
{
    scanf("%d%d", &n, &m);
    memset(swaped, -1, sizeof(swaped));
    for(int i = 0; i < n; i ++)
        cin >> s[i];
 
    if(n & 1)
        dfs(0, true);
    else
        dfs(0, false);
    printf(ans ? "YES" : "NO");
    return 0;
}

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

class Program
{
    static void Main()
    {
        var n = ReadInts()[0];
        var vals = ReadInts();
        var result = Coloc(n, vals);


        Console.WriteLine(result ? "Yes": "No");
    }

    static bool Coloc(int n, int[] vals)
    {
        vals = (int[])vals.Clone();
        Array.Sort(vals, IntDisComparetor.Instance);

        var slimes = new List<int>(vals.Length);
        slimes.Add(vals[0]);
        vals[0] = int.MaxValue;
        for (int slimeNum = 1; slimeNum < vals.Length;)
        {
            var index = 0;
            for (int i = 0; i < slimeNum; i++)
            {
                var item = slimes[i];
                index = Utils.FindFirstIndex(vals, p => p < item, index + 1);
                if (index < 0)
                    return false;

                slimes.Add(vals[index]);
                vals[index] = int.MaxValue;
            }
            slimes.Sort(IntDisComparetor.Instance);
            slimeNum = slimes.Count;
        }
        return true;
    }

    #region Utils
    static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    #endregion
}

static class Utils
{
    public static int FindFirstIndex<T>(IList<T> source, Func<T, bool>func, int start)
    {
        for (int i = start; i < source.Count; i++)
        {
            if (func(source[i]))
            {
                var ret = source[i];
                return i;
            }
        }
        return -1;
    }
}

class IntDisComparetor : IComparer<int>
{
    public static IComparer<int> Instance { get; } = new IntDisComparetor();
    private IntDisComparetor()
    {

    }
    public int Compare(int x, int y)
    {
        return Comparer<int>.Default.Compare(y, x);
    }

}


Measured memory_bytes: 41124
import Control.Monad

main = do
    [n, m] <- map read . words <$> getLine
    ab <- map (map read. words) <$> replicateM n getLine
    cd <- map (map read. words) <$> replicateM m getLine
    mapM_ print $ [minIdx [mht xab xcd | xcd <- cd] | xab <- ab]

mht [a, b] [c, d] = abs(a - c) + abs(b - d)
minIdx as = snd $ minimum $ zip as [1..]

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

int main(void){
	int a,b;

	cin >> a;
	cin >> b;

	if(a>b)       cout << "a > b" << endl;
	else if(a==b) cout << "a == b" << endl;
	else          cout << "a < b" << endl;

	return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
const int N=2e5+10;
int a[N];
int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    ll res=a[n],d=n-2;
    for (int i=n-1;d;i--)
    {
        if (d==1) d=0,res+=a[i];
        else d-=2,res+=a[i]*2;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 4344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = read[0];
            var V = read[1];
            read = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var B = read[0];
            var W = read[1];
            var T = long.Parse(Console.ReadLine());

            if (B == A)
                Console.WriteLine("YES");
            else if (B > A)
            {
                if (A + V * T >= B + W * T)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
            else
            {
                if (A - V * T <= B - W * T)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 28244
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
	vi t(n), x(n), y(n);
	f_v3I(t, x, y, n);
	if (x[0] + y[0] > t[0]) {
		_n();
		return 0;
	}
	f(i, 0, n - 1) {
		if ((t[i + 1] - t[i]) % 2 != 0) {
			if (t[i+1]-t[i]>=abs(x[i + 1] + y[i + 1] - (x[i] + y[i])) &&abs(x[i + 1] + y[i + 1] - (x[i] + y[i])) % 2 != 0) {
				continue;
			}
			else {
				_n();
				return 0;
			}
		}
		else {
			if (t[i + 1] - t[i] >= abs(x[i + 1] + y[i + 1] - (x[i] + y[i])) && abs(x[i + 1] + y[i + 1] - (x[i] + y[i])) % 2 == 0) {
				continue;
			}
			else {
				_n();
				return 0;
			}
		}
	}
	_y();
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n,p,c=0,ans=0;
    cin>>n;
    vector<ll>v;
    for(ll i=0;i<n;i++)
    {
        cin>>p;
        v.pb(p);
    }
    for(ll i=1;i<n;i++)
    {
        if(v[i]<=v[i-1])
        {
            c++;
        }
        else
        {
            c=0;
        }
        ans=max(ans,c);
    }
    cout<<ans;
}

Measured memory_bytes: 1400
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

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

  int n;
  cin >> n;
  vector<int> dp(n + 1, INF);
  dp[0] = 0;
  vector<int> c = {6, 9};
  for (auto& v : c) {
    for (int w = v; w <= n; w *= v) {
      for (int i = w; i <= n; ++i) {
        dp[i] = min(dp[i], dp[i - w] + 1);
      }
    }
  }
  int ret = INF;
  for (int i = n; i >= 0; --i) {
    ret = min(ret, dp[i] + n - i);
  }
  cout << ret << endl;
  return 0;
}


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

//return reversed s (string)
#define rev(s)(string(s.rbegin(),s.rend()))

int main(void){
  int n;

  cin>>n;
  while(n--){
    int l; //train's length
    string t; //train string
    set<string> s; //pattern set

    cin>>t;
    l = t.length();

    //search all pattern -> s(set)
    for(int i=1;i<=l-1;i++){
      string f,b; //forward, backward string
      f = t.substr(0,i);
      b = t.substr(i,l-i);

      s.insert(f+b);
      s.insert(f+rev(b));
      s.insert(rev(f)+b);
      s.insert(rev(f)+rev(b));
      s.insert(b+f);
      s.insert(b+rev(f));
      s.insert(rev(b)+f);
      s.insert(rev(b)+rev(f));
    }
    cout<<s.size()<<endl;
  }

  return 0;
}

Measured memory_bytes: 1000
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b){
		printf("a < b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 1964
#include <stdio.h>

int main()

{
    int a,b,sum,c;
    while(scanf("%d %d",&a,&b)==2)
    {
        c=0;
        sum= a+b;
       while(sum)
       {
           sum=sum/10;
           c++;
       }
    printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace apc001a
{
    public class Problem
    {
        private int X_, Y_;
        public Problem(int x, int y) {
            X_ = x;
            Y_ = y;
        }
        public int Solve() {
            var list = new List<int>() { X_ };
            //checked {
                for(var i = 2; X_ * i <= (int)Math.Pow(10, 18); ++i) {
                    list.Add(X_ * i);
                }
            //}
            var v = list.Where(k => k % Y_ != 0);
            return (v.Any()?v.First():-1);

        }
    }
    class Program
    {
        static void Main(string[] args) {
            var x_y = Console.ReadLine().Split();
            var X = int.Parse(x_y[0]);
            var Y = int.Parse(x_y[1]);
            var problem = new Problem(X, Y);

            Console.WriteLine(problem.Solve());
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; ++i) {
    cin >> p[i];
  }
  for (int i = 0; i < b; ++i) {
    cin >> q[i];
  }
  for (int i = 0; i < c; ++i) {
    cin >> r[i];
  }
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> all;
  for (int i = 0; i < x; ++i) {
    all.push_back(p[i]);
  }
  for (int i = 0; i < y; ++i) {
    all.push_back(q[i]);
  }
  for (int i = 0; i < c; ++i) {
    all.push_back(r[i]);
  }
  sort(all.rbegin(), all.rend());
  ll ans = 0;
  for (int i = 0; i < x + y; ++i) {
    ans += all[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>

#define int ll

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define per(i,b) for(ll i=b-1;i>=0;i--)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

struct Node {
    int par;
    vi cs;
    Node(int p, vi const& cs) : par(p), cs(cs) {}
    Node(){}
};

vi ansester;
vi marked;

void update(vector<Node> & g, int v, int a){
    ansester[v] = a;
    for(int c : g[v].cs) if(!marked[c]) update(g,c,a);
}

int solve(vector<Node> & g, vector<pair<char,int>> & query){
    ansester.assign(g.size()+1, 1);
    marked.assign(g.size()+1, 0);
    int ans = 0;
    for(auto & p : query){
        char q; int v;
        tie(q,v) = p;
        if(q=='M'){
            update(g,v,v);
            marked[v] = true;
        } else {
            ans += ansester[v];
        }
    }
    return ans;
}

signed main(){
    int N, Q;
    while(cin>>N>>Q && N){
        vector<Node> g(N+1);
        rep(i,N-1){
            int x; cin>>x;
            g[i+2].par = x;
            g[x].cs.eb(i+2);
        }
        vector<pair<char,int>> query(Q);
        rep(i,Q){
            char c; int v;
            cin >> c >> v;
            query[i] = mp(c,v);
        }
        cout << solve(g,query) << endl;
    }
}

Measured memory_bytes: 14136
#include<stdio.h>

int main(void)
{
	int Montha;
	int Dayb;

	scanf("%d %d",&Montha,&Dayb);

	if (Montha <= Dayb)
	{
		printf("%d",Montha);
	}

	if (Montha > Dayb)
	{
		printf("%d",Montha-1);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    int res = 0;
    int a = -1;
    for(int i=0; i<N; ++i){
        int tmp;
        cin >> tmp;
        a = max(a, tmp);
        res += tmp;
    } 
    res -= (a/2);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    vector<ll> Ac(N);
    Ac[0] = A[0];
    FOR(i, 1, N){
        Ac[i] = Ac[i-1] + A[i];
    }

    ll x = 0;
    for(ll b=40; b>=0; b--){
        ll count = 0;
        ll binary = 1LL<<b;

        FOR(l, 0, N){
            FOR(r, l, N){
                ll Ai;
                if(l==0){
                    Ai = Ac[r];
                }else{
                    Ai = Ac[r] - Ac[l-1];
                }
                ll xb = x+binary;
                if((xb&Ai) == xb){
                    count++;
                }
            }
        }
        if(count>=K){
            x += binary;
        }
    }

    p(x);
    
    return 0;
}

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

int main() {
    int64_t n, m, x;
    cin >> n >> m >> x;

    vector<int64_t> c(n);
    vector< vector<int64_t> > a(n, vector<int64_t>(m));
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++) cin >> a[i][j];
    }

    int64_t ans = 1200000;
    bool cannot = true;
    vector<int64_t> abl(m, 0);
    for(int i = 0; i < 2 << n; i++) {
        int price = 0;
        int dig = i;
        abl.assign(m, 0);
        for(int j = 0; j < n; j++) {
            if(dig % 2 == 1) {
                price += c[j];
                for(int k = 0; k < m; k++) {
                    abl[k] += a[j][k];
                }
            }
            dig /= 2;
        }

        bool ok = true;
        for(int j = 0; j < m; j++) {
            if(abl[j] < x) {
                ok = false;
                break;
            }
        }

        if(ok && price <= ans) {
            ans = price;
            cannot = false;
        }
    }

    cout << (cannot ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 3636
n,m = map(int, input().split())

s=[]
for i in range(m):
    s.append(list(map(int, input().split())))
if n==1:
    kaisuu_start=0
    kaisuu_stop=10
elif n==2:
    kaisuu_start=10
    kaisuu_stop=100
elif n==3:
    kaisuu_start=100
    kaisuu_stop=1000
    
for suuzi in range(kaisuu_start,kaisuu_stop):
    hantei=True
    suuzi=str(suuzi)
    for gyou in range(m):
        if suuzi[s[gyou][0]-1]!=str(s[gyou][1]):
            hantei=False
            continue
    if hantei:
        print(suuzi)
        exit()

print(-1)

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int n; cin >> n;
    set<string> st;
    rep(i,n) {
        string s; cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ c.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/

Measured memory_bytes: 19228
K, X = map(int, input().split())
listKX = [X]
ans = ''
for i in range(1,K):
    listKX.append(X-i)
    listKX.append(X+i)
listKX.sort()
for j in range(len(listKX)):
   ans = ans + ' ' +str(listKX[j])
print(ans[1:])

Measured memory_bytes: 3060
#include <stdio.h>
int father[10009];
int find(int x);
int unionn(int x,int y);

int main() 
{
	int n,q,com,x,y,i;
	scanf("%d%d",&n,&q);
	for(i=0;i<n;i++)
	{
		father[i]=i;
	}
	for(i=0;i<q;i++)
	{
		scanf("%d%d%d",&com,&x,&y);
		if(com==0)
		unionn(x,y);
		else if(com==1)
		{
			find(x);
			find(y);
			if(find(x)==find(y))
			printf("1\n");
			else if (find(x)!=find(y))
			printf("0\n");
		}
		
	}
	return 0;
}

int find(int x)
{
	return x==father[x]?x:father[x]=find(father[x]);	
}


int unionn(int x,int y)
{
	if(find(x)!=find(y))
	father[find(y)]=father[find(x)];
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int h, w, n;
    cin >> h >> w >> n;
    int ans = ceil(n, max(h, w));
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long M, std::vector<long long> p, std::vector<std::string> S){
  map<ll, ll> m;
  ll ac = 0;
  ll w = 0;
  vector<ll> wa(N+1, 0);
  for(ll i=0; i<M; i++) {
    if(m.find(p[i]) == m.end()) {
      if(S[i] == "AC") {
	ac++;
	w += wa[p[i]];
	m[p[i]] = 1;
      }
      if(S[i]=="WA") {
	wa[p[i]]++;
      }
    }
  }
  std::cout << ac << " " << w << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> p(M);
  std::vector<std::string> S(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&p[i]);
    std::cin >> S[i];
  }
  solve(N, M, std::move(p), std::move(S));
  return 0;
}



Measured memory_bytes: 13568
#include <stdio.h>

int main(void)
{
  int S;
  int h, m, s;

  scanf("%d", &S);

  h = S / 3600;
  m = (S - h * 3600) / 60;
  s = S - h * 3600 - m * 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

bool pal(string s){
    string t = s;
    reverse(all(t));
    return s == t;
}

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

    string s; cin>>s;
    int n = s.size();

    if(pal(s) && pal(s.substr(0, (n - 1) / 2)) && pal(s.substr((n + 3) / 2 - 1))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
<?php
  
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);
fscanf(STDIN, "%d", $k);

$length = strlen($s);

for ($i=0; $i<$length; $i++) {
    $matches[] = substr($s, $i, 1);
}
$asta = $matches[$k-1];

for ($i=0; $i<$length; $i++) {
    if($asta != $matches[$i]){
        $matches[$i] = "*";
    }
}

for ($i=0; $i<$length; $i++) {
    echo $matches[$i];
}
?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll k,a,b;
    cin>>k>>a>>b;
    ll kk=k;
    while(kk<=b)
    {
        if(kk>=a&&kk<=b)
        {
            cout<<"OK";
            return 0;
        }
        kk+=k;
    }
    cout<<"NG";
}



Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	ll a, b, x;
	cin >> a >> b >> x;
	ll c, d;
	c = (a +x-1)/ x;
	d = b  / x;
	cout << d - c + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()

mod = 10**9 + 7

import math

ans = math.factorial(n)
print(ans%mod)

Measured memory_bytes: 43120
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  long ans=0;
  vector<int>vec;
  cin >> a;
  int roop = a.size();
  for (int i=0;i<roop;i++){
  	vec.push_back(a.at(i)-48);
  }
  
  reverse(vec.begin(),vec.end());
  vector<vector <int>>vect(roop);
  vect.at(0).push_back(roop-1);
  for(int i=0;i<roop;i++){
    if(i==0)
      continue;
    else{
      int w=0;
      vect.at(i)=vect.at(i-1);
      w=vect.at(i).at(i-1);
      vect.at(i).pop_back();
      vect.at(i).push_back(w-1);
      vect.at(i).push_back(w-1);
    }
  }
  for(int i=0;i<roop;i++){
    int counter=0;
    for(int q:vect.at(i)){
      //cout<<q<<endl;
      ans += vec.at(i)*pow(10,counter)*pow(2,q);
      counter++;
      //cout <<vec.at(i)<<" " <<ans << endl;
    }
  }      
  	cout << ans <<endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, k;
ll a[200100];

ll add[200100];

void solve() {
    for (int i = 0; i < k; i++) {
        memset(add, 0, sizeof(add));
        for (ll j = 0; j < n; j++) {
            add[max(0LL,j-a[j])]++;
            add[min(n,j+a[j]+1)]--;
        }
        bool f = false;
        for (int j = 0; j < n; j++) {
            a[j] = add[j];
            add[j+1] += add[j];
            if (a[j] < n) {
                f = true;
            }
        }
        if (!f) {
            for (int j = 0; j < n; j++) {
                a[j] = n;
            }
            break;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i == n-1) cout << endl;
        else cout << " ";
    }
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


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

int main() {
    int n;
    cin >> n;
    int max_p = 0, res = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        max_p = max(max_p, p);
        res += p;
    }
    cout << (res - max_p + (max_p / 2)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int a[10000], i=0;
    while (1) {
        cin >> a[i];
        if (a[i] == 0) break;
        i++;
    }
    for (int j = 0; j < i; j++) {
        printf("Case %d: %d\n", j+1, a[j]);
    }
}


Measured memory_bytes: 3152
class DisjointSet:
    def __init__(self, size):
        self.rank = [0] * size
        self.p = list(range(size))

    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def link(self, x, y):
        if self.rank[x] > self.rank[y]:
            self.p[y] = x
        else:
            self.p[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))


class Edge:
    def __init__(self, source=0, target=0, cost=0):
        self.source = source
        self.target = target
        self.cost = cost

def kruskal(n, edges):
    totalCost = 0
    edges.sort(key=lambda e: e.cost)
    dset = DisjointSet(n)

    for e in edges:
        if not dset.same(e.source, e.target):
            totalCost += e.cost
            dset.unite(e.source, e.target)

    return totalCost


if __name__ == '__main__':
    n, m = [int(v) for v in input().split()]
    edges = []
    for i in range(m):
        s, t, w = [int(v) for v in input().split()]
        edges.append(Edge(s, t, w))

    print(kruskal(n, edges))


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

int main() {
  int n;
  cin >> n;
  map<int,int> a;
  vector<int> b(n+10);
  for(int i=1;i<=n;i++){
    cin >> b.at(i);
  }
  for(int i=1;i<=n;i++){
    a[b.at(i)] = i;
    
  }
  for(int i=1;i<=n;i++){
    cout << a.at(i)<<" "<<endl;
  }
  
  
 
}

Measured memory_bytes: 6016
import math

a, b, x = map(int, input().split())
res = 0

if x > a**2*b/2:
    res = math.degrees(math.atan(2*(a**2*b-x)/a**3))
else:
    res = math.degrees(math.atan(a*b**2/2/x))

print('{:.10f}'.format(res))

Measured memory_bytes: 3060
#include <stdio.h>
typedef long long ll;
ll abs(ll x){
	return x >= 0 ? x : -x;
}
int sum(int n) {
int sum=0;
if (n<0) return 0;
while (n>0) {
sum += n%10;
n /= 10;
}
return sum;
}
int main(){
  int a, b, n, t, i, j, tmp1, tmp2, tmp3,ans=10e6;
	scanf("%d",&n);
	for (i = 1; i < n; i++){
		a = i, b = n - i;
		tmp1 = sum(a) + sum(b);
		if(tmp1 < ans) ans = tmp1;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    vector<pair<double, string> > moonlight;
    string l;
    int p, a, b, c, d, e, f, s, m;
    for(int i = 0; i < n; i++){
      cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      int income = f * m * s - p;
      int time = a + b + c + (d + e) * m;
      moonlight.push_back(make_pair(-income/(double)time, l));
    }
    sort(moonlight.begin(), moonlight.end());
    for(int i = 0; i < n; i++){ cout << moonlight[i].second << endl; }
    cout << "#" << endl;
  }

  return 0;
}

Measured memory_bytes: 3116
import math

def modpow(a,b,mod=10**9+7):
    res=1
    a%=mod
    leng=int(math.log2(b))
    for i in range(leng,-1,-1):
        res=(res*res)%mod
        if (b>>i)&1:
            res=(res*a)%mod
    return res

def fact(x):
    ans=1
    for i in range(2,x+1):
        ans = (ans*i)%(10**9+7)
    return ans

def comb(n,r):
    return fact(n)*modpow(fact(r),10**9+5)*modpow(fact(n-r),10**9+5)%(10**9+7)

x,y=map(int,input().split(' '))
if (x+y)%3!=0 or 2*x-y<0 or 2*y-x<0:
    print(0)
else:
    x,y=max(x,y),min(x,y)
    d=x-y
    n=((x-2*d)//3)
    m=n+d
    print(comb(n+m,n))

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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
	long long int x,y;
	cin >> x >> y;
	long long int d = max(x,y)%min(x,y);
	long long int ans = min(d,min(x,y));
	long long int tmp = min(x,y);
	if(x == y){
		cout << x << endl;
		return 0;
	}
	while(ans > 0){
		if(d%ans == 0 && tmp%ans == 0){
			cout << ans << endl;
			return 0;
		}
		ans--;
	}
	return 0;
}


Measured memory_bytes: 3104