akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

ll N;
vector<vector<ll>> aij;
vector<ll> dp;
vector<ll> score;

ll calc_score(ll group) {
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = i+1; j < N; j++) {
            if (((group & ((ll)1 << i)) != 0) && ((group & ((ll)1 << j)) != 0)) {
                ans += aij[i][j];
            }
        }
    }
    return ans;
}

void exec_dp(ll subset) {
    if (dp[subset] != numeric_limits<ll>::min()) {
        return;
    }
    ll first_bit = -1;
    while (true) {
        first_bit++;
        if (subset & ((ll)1 << first_bit)) {
            break;
        }
    }
    ll rest = subset - ((ll)1 << first_bit);
    ll rest_sub = rest;
    do {
        exec_dp(rest_sub);
        dp[subset] = max(dp[subset], dp[rest_sub] + score[subset - rest_sub]);
        rest_sub = (rest_sub - 1) & rest;
    } while (rest_sub != rest);
}

int main() {
    cin >> N;
    aij = make_vec_nd((ll)0, N, N);
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            ll elem;
            cin >> elem;
            aij[i][j] = elem;
        }
    }
    score = make_vec_nd((ll)0, (ll)1 << N);
    for (ll group = 0; group < ((ll)1 << N); group++) {
        score[group] = calc_score(group);
    }
    dp = make_vec_nd(numeric_limits<ll>::min(), 1 << N);
    dp[0] = 0;
    exec_dp(((ll)1 << N) - 1);
    cout << dp[((ll)1 << N) - 1] << endl;
}



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

using namespace std;

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

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

    for(int i=3;i<=n;i++){
        int x = i;
        if(!(x%3))printf(" %d", i);
        else if(x % 10 == 3)printf(" %d", i);
        else {
            while(x / 10){
                x /= 10;
                if(x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
            }
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpStr = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpStr[0]);
		int k = Integer.parseInt(tmpStr[1]);
		
		int[] length = new int[n];
		tmpStr = br.readLine().split(" ");
		for(int i = 0; i < n; i++){
			length[i] = Integer.parseInt(tmpStr[i]);
		}
		
		Arrays.sort(length);
		
		int sum = 0;
		for(int i = 1; i <= k; i++){
			sum += length[length.length - i];
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 23124
#include <stdio.h>
int main()
{
	int h, w, i, j;
	while (1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			return 0;
		}
		else {
			for (i = 1;i <= h;i++) {
				for (j = 1;j <= w;j++) {
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2604
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static string Solve(string S, int Q, string[][] queries)
        {
            bool reversed = false;
            var head = new List<char>();
            var tail = new List<char>();
            foreach (string[] query in queries)
            {
                switch (query[0][0])
                {
                case '1':
                    reversed = !reversed;
                    break;
                case '2':
                    switch (query[1][0])
                    {
                    case '1':
                        (reversed ? tail : head).Add(query[2][0]);
                        break;
                    case '2':
                        (reversed ? head : tail).Add(query[2][0]);
                        break;
                    }
                    break;
                }
            }
            if (reversed)
            {
                tail.Reverse();
                return new string(tail.ToArray()) + new string(S.Reverse().ToArray()) + new string(head.ToArray());
            }
            else
            {
                head.Reverse();
                return new string(head.ToArray()) + S + new string(tail.ToArray());
            }
        }

        static void Main(string[] args)
        {
            string S = Read();
            int Q = ReadInt();
            var queries = new string[Q][];
            for (int i = 0; i < Q; ++i) { queries[i] = Read().Split(); }
            Console.WriteLine(Solve(S, Q, queries));
        }
    }
}


Measured memory_bytes: 47712
n=int(input())
s=list(input())
e_cnt=s[1:].count("E")
cnt=e_cnt
for i in range(1,n):
    if s[i-1]=="W":
        e_cnt+=1
    if s[i]=="E":
        e_cnt-=1
    if e_cnt<cnt:
        cnt=e_cnt
print(cnt)


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

using namespace std;

struct Edge {
    int to;
    int value;
};

struct Node {
    int value;
    vector<Edge> edge;
};

int v, e;
int s, t, d;
Node node[15];

int dp[15][1 << 16];

int solve(int pos, int stat){

    if(dp[pos][stat] != -1) return dp[pos][stat];

    int cost = 1 << 24;

    if(stat == (1 << v) - 1) return 0;
    else if(stat & 1) return cost;

    for(int i = 0; i < node[pos].edge.size(); ++i) {
        if(!(stat & 1 << node[pos].edge[i].to)) {
            cost = min(cost, solve(node[pos].edge[i].to, stat | 1 << node[pos].edge[i].to) + node[pos].edge[i].value);
        }
    }

    return dp[pos][stat] = cost;

}

int main() {

    cin >> v >> e;

    for(int i = 0; i < e; ++i) {
        cin >> s >> t >> d;
        node[s].edge.push_back((Edge){t, d});
    }

    memset(dp, -1, sizeof(dp));

    int dst = solve(0, 0);

    if(dst == 1 << 24) {
        cout << -1 << endl;
    } else {
        cout << dst << endl;
    }

}

Measured memory_bytes: 5060
#include <stdio.h>
#include <stdlib.h>


int main(){

  int N,i,j,k,v;
  int *A;

  scanf("%d", &N);

  if (N<1 && N>100) printf("error!\n");


  A=(int *)malloc(sizeof(int) * N);

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

  for(i=0 ; i<N ; i++){
    printf("%d",A[i]); 
    if(i==N-1)printf("\n");
    else printf(" ");
  }

  for(i=1 ; i<=N-1 ; i++){
    v=A[i];
    j=i-1;
    while(j >= 0 && A[j] > v){
      A[j+1]=A[j];
	j--;
	A[j+1]=v;
    }

    for(k=0 ; k<N ; k++){
      printf("%d",A[k]);
      if(k==N-1)printf("\n");
      else printf(" ");
    }
  }
 
  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#include <functional>
#include <numeric>

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;
  vector<int> va(n);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
  }

  vector<MInt> cnts(n, 0), cnts_all(n, 0);
  for (int i = 0; i < va.size(); i++) {
    for (int j = 0; j < va.size(); j++) {
      if (va[i] > va[j]) {
        cnts_all[i] += 1;
        if (j >= i) {
          cnts[i] += 1;
        }
      }
    }
  }

  MInt mk(k);
  MInt sum_cnts = accumulate(cnts.begin(), cnts.end(), MInt(0), plus<MInt>()),
       sum_cnts_all =
           accumulate(cnts_all.begin(), cnts_all.end(), MInt(0), plus<MInt>());
  MInt ans = (mk * sum_cnts) + (sum_cnts_all * (mk * (mk - MInt(1))) / MInt(2));
  cout << ans.Get() << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <atcoder/dsu>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N, M;
    cin >> N >> M;
    int a, b;
    atcoder::dsu uf(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b;
        a--, b--;
        uf.merge(a,b);
    }
    ll ans = uf.groups().size() - 1;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8912
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	int N;
	ll Y;
	cin >> N >> Y;
	ll bill[] = {10000,5000,1000};
	for(int a=0;a<=N;a++){
		for(int b=0;b<=N;b++){
			if(a+b>N)continue;
			if(a*bill[0] + b*bill[1] > Y)continue;
			else {
				ll sum = a*bill[0] + b*bill[1];
				if( a+b + (Y-sum)/bill[2] == N ){
					cout << a << " " << b << " " << N - a - b << endl;
					return 0;
				}
			}
		}
	}
	printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf = 1000000000000000;
main(){
    int n,k;
    scanf("%lld%lld",&n,&k);

    int dp[2][100005];
    dp[0][0] = dp[1][0] = 0;
    for (int i = 1; i <= 100001; i++) dp[0][i] =dp[1][i] =inf;
    for (int i = 0; i < n; i++){
        int w,v;
        scanf("%lld%lld",&w,&v);
        for (int j = 100000; j >= 1; j--){
            dp[i%2][j] = min(dp[1-i%2][j],dp[i%2][j+1]);
            if (v <= j) dp[i%2][j] = min(w+dp[1-i%2][j-v],dp[i%2][j]);
        }
    }
    int q =1-n%2;
    int lo = 0, hi = 100000;
    while (lo + 1 < hi){
        int mid = (lo+hi)>>1;
        if (dp[q][mid] <= k){
            lo = mid;
        }
        else hi = mid;
    }
    if (lo+1 == hi){
        if (dp[q][hi] <= k) lo = hi;
        else hi = lo;
    }
    printf("%lld",lo);
}


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

int main() {
	string a, b , c;
	int x, y;
	cin >> a >> b;
	cin >> x >>y;
	cin >> c;
	if (c == a)
		cout << --x <<" "<< y;
	else if (c == b)
			cout << x <<" "<< --y;

}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, ans = 0;
  scanf("%lld", &n);
  ll p[n];
  for(i = 0; i < n; ++i) scanf("%lld", &p[i]);
  for(i = 1; i < n - 1; ++i) 
    if((p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1])) ++ ans;
  printf("%lld", ans);
  return 0;
}

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

using namespace std;

int n;
int a[105], b[105];

int32_t main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i=1; i<n; i++) cin >> b[i];
  a[1] = b[1];
  a[n] = b[n - 1];
  for (int i=2; i<n; i++) 
  {
      a[i] = min(b[i], b[i - 1]);
  }
  int res = 0;
  for (int i=1; i<=n; i++) res += a[i];
  cout << res;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {

    bool first = true;

    while (true) {
        
        ll a, b; cin >> a >> b;
        if (!a && !b) break;

        if (!first) cout << "\n";
        first = false;

        bool exist = false;
        RANGE(i, a, b) {
            if (i % 4 == 0 && (i % 100 || i % 400 == 0)) {
                cout << i << endl;
                exist = true;
            }
        }

        if (!exist) {
            cout << "NA\n";
        }

    }
    
}


Measured memory_bytes: 3096
from bisect import bisect_left
from itertools import accumulate, takewhile
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bba = list(accumulate(takewhile(lambda x: x > max_a, sorted(bb, reverse=True))))
    if not bba:
        return ceil(h / max_a)
    remain = h - bba[-1]
    if remain <= 0:
        return bisect_left(bba, h) + 1
    return ceil(remain / max_a) + len(bba)


n, h = map(int, input().split())
aa, bb = zip(*(map(int, input().split()) for _ in range(n)))

print(solve(h, aa, bb))


Measured memory_bytes: 59224
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N, K;
  cin >> N >> K;
  ll V[N];
  REP(i, N) cin >> V[i];
  int R = min(N, K);
  ll ans = 0;
  for (int i = 0; i <= R; i++) {
    for (int j = 0; i + j <= R; j++) {
      priority_queue<ll> pq;
      ll temp = 0;
      for (int a = 0; a < i; a++) {
        pq.push(-V[a]);
        // cout << -V[a] << '\n';
      }
      for (int b = 0; b < j; b++) {
        pq.push(-V[N - 1 - b]);
        // cout << -V[N-1-b] << '\n';
      }
      for (int k = 0; k < K - (i + j); k++) {
        if (!pq.empty() && pq.top() > 0) pq.pop();
      }
      int count = pq.size();
      REP(k, count) {
        temp -= pq.top();
        pq.pop();
      }
      // cout << temp << '\n';
      ans = max(ans, temp);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
void permutation(vector<string> &S, vector<int> perm, int n) {
    int k = 0;
    do {
        string str;
        for (int i = 0; i < n; ++i) {
            char c = (char)(perm[i] + 48);
            str += c;
        }
        S[k] = str;
        k++;
    } while (next_permutation(perm.begin(), perm.end()));
    return ;
}
int main() {
    int N; cin >> N;
    string P, Q;
    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;
        P += c;
    }
    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;
        Q += c;
    }
    int M = N;
    for (int i = N - 1; i > 1; --i) {
        M *= i;
    }
    vector<string> S(M, "");
    vector<int> p(N, 0);
    for (int i = 0; i < N; ++i) {
        p[i] = i + 1;
    }
    permutation(S, p, N);
    int a = -1, b = -1;
    for (int i = 0; i < M; ++i) {
        if (P == S[i]) {
            a = i + 1;
        }
        if (Q == S[i]) {
            b = i + 1;
        }
        if (a != -1 && b != -1) break;
    }
    printf("%d\n", abs(a - b));
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
signed main(){
  int x;
  cin>>x;
  int ans=0;
  int y=100;
  while(y<x){
    y+=y/100;
    ans++;
  }

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

Measured memory_bytes: 3632
x, y, z, k = list(map(int, input().split()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
alist.sort(reverse=True)
blist.sort(reverse=True)
clist.sort(reverse=True)
delist = []
for a in range(x) :
    for b in range(y) :
        if a*b > k :
            break
        for c in range(z) :
            if a*b*c > k :
                break
            else :
                delist.append(alist[a]+blist[b]+clist[c])
delist.sort(reverse=True)
for n in delist[:k] :
    print(n)

Measured memory_bytes: 112344
#include<stdio.h>

int main (void)
{
    int height[10];
    int i;

    int rank[3] = {};
    int storage[2] = {};


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

    for(i = 0; i < 10; i++){
        if((height[i] > rank[2]) && (height[i] > rank[1]) && (height[i] > rank[0])){
            storage[0] = rank[0];
            storage[1] = rank[1];

            rank[0] = height[i];
            rank[1] = storage[0];
            rank[2] = storage[1];
        }
        else if((height[i] > rank[2]) && (height[i] > rank[1])){
            storage[0] = rank[1];

            rank[1] = height[i];
            rank[2] = storage[0];
        }
        else if((height[i] > rank[2])){
            rank[2] = height[i];
        }
    }

    for(i = 0; i < 3; i++){
        printf("%d\n",rank[i]);
    }

    return 0;
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
    int k,x;
    cin >>  k >> x;
    for(int i=max(x-k+1,-1000000);i<min(x+k,1000001);i++){
        cout << i <<" ";
    }
    

return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;


int main(){
    ll A, B, C;
    ull K;
    cin >> A >> B >> C >> K;
    if(K % 2) cout << B - A << endl;
    else cout << A - B << endl;
}

Measured memory_bytes: 256
import collections


def main():
    N, K, Q = map(int, input().split())

    answers = []
    for i in range(Q):
        answers.append(int(input())-1)
    counter = collections.Counter(answers)

    # points = [K-Q] * N
    for i in range(N):
        temp = K - Q + counter[i]
        if temp <= 0:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 60888
k, x = gets.chomp.split(' ').map(&:to_i)
# 500 円玉の枚数 split 分割　map 数字にする
count = 0
# while を使って繰り返し処理をする
total = 0
while count < k do
  total += 500
  count += 1
end
if x <= total
puts "Yes"
else
puts "No"
end



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

int main() {

  int n;
  cin >> n;
  vector<int> d(n);

  for(int i = 0; i < n; i++) { cin >> d.at(i); }

  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());

  int tmp = 10e5;
  int ans = 0;

  for(int i = 0; i < n; i++) {
    if(d.at(i) < tmp ) {
      tmp = d.at(i);
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) {
	if (c)print("Yes");
	else print("No");
}
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
void solve() {
	int N; cin >> N;
	int X; cin >> X;
	vector<int>A(N);
	REP(i, N) {
		cin >> A[i];
		A[i] = abs(X - A[i]);
	}
	int ans = A[0];
	REP(i, N) {
		ans = gcd(ans, A[i]);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 1024
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, a[109]; bool dp[10009];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	dp[0] = true;
	for (int i = 0; i < n; i++) {
		for (int j = 10000; j >= a[i]; j--) {
			if (dp[j - a[i]]) dp[j] = true;
		}
	}
	int ret = 0;
	for (int i = 0; i <= 10000; i++) {
		if (i % 10 != 0 && dp[i]) ret = max(ret, i);
	}
	printf("%d\n", ret);
	return 0;
}

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


int main(void) {
	string S;
	cin >> S;
	int ans = 0;

	char stone = S.at(0);
	for (int i = 0; i < S.length(); i++) {
		if (stone != S.at(i)) {
			stone = S.at(i);
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,a=0,b=0,c=0,d=0;
    cin>>n;
    string s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")a++;
        else if(s=="WA")b++;
        else if(s=="TLE")c++;
        else if(s=="RE")d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;
}


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

MOD = 1000000007  # type: int

def solve(S: str):
    current = [0, 0, 0]
    power = 1
    for c in S:
        if c == 'A':
            current[0] = (current[0] + power) % MOD
        elif c == 'B':
            current[1] = (current[1] + current[0]) % MOD
        elif c == 'C':
            current[2] = (current[2] + current[1]) % MOD
        else:
            current[2] = (3 * current[2] + current[1]) % MOD
            current[1] = (3 * current[1] + current[0]) % MOD
            current[0] = (3 * current[0] + power) % MOD
            power = power * 3 % MOD
    print(current[2])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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


bool comp(const pii& a, const pii& b) {

	if (a.first == b.first) {
		return a.second > b.second;
	}
	else
	{
		return a.first < b.first;
	}
}


int main() {

	int n, m;
	cin >> n >> m;
	priority_queue<int> que;

	vector<pii> v(n);

	for (int i = 0; i < n; i++)
	{
		cin >> v[i].first >> v[i].second;
	}

	sort(v.begin(), v.end(), comp);

	int idx = 0;
	int ans = 0;

	for (int i = m; i >= 0; i--)
	{
		//残りi日ある（i日前）

		while (idx < n && v[idx].first + i <= m) {
			que.push(v[idx].second);
			idx++;
		}
		if (!que.empty()) {
			ans += que.top();
			que.pop();
		}
	}

	cout << ans << endl;









	return 0;
}


Measured memory_bytes: 1660
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    string S;
    cin >> S;
    ll count = 0;
    ll res = 0;
    for (auto & s : S) {
        switch (s)
        {
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            ++count;
            break;
        default:
            res = max(res, count);
            count = 0;
            break;
        }
    }
    res = max(res, count);
    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
// #define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


const int SIZE=1e8;//ADD
int phi[SIZE+1];
//////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
// mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


ll n,p; cin>>n>>p;
ll ans=1;
for(ll i=2;i*i<=p;++i){
    int ct=0;
    while(p%i==0) ct++, p/=i;
    ct/=n;
    for(int j=0;j<ct;++j) ans*=i;
    DD(i,ct);
}
if(n==1) ans*=p;
cout<< ans <<'\n'; 

return 0;
}


Measured memory_bytes: 256
def main():
    N=int(input())
    A=[int(_) for _ in input().split()]
    dp=[[0,0,0] for _ in range(N//2+1)]
    for i in range(N//2):
        dp[i+1][0]=dp[i][0]+A[i*2]
        dp[i+1][1]=max(dp[i][1],dp[i][0])+A[i*2+1]
        if N%2:
            dp[i+1][2]=max(dp[i][2],dp[i][1],dp[i][0])+A[i*2+2]
    if N%2:
        print(max(dp[-1]))
    else:
        print(max(dp[-1][:2]))

main()


Measured memory_bytes: 42160
#include<iostream>
#include<algorithm>
using namespace std;
int n, W, v[105], w[105], dp[105][10300], maxn;
int main() {
	cin >> n >> W; for (int i = 0; i < n; i++)cin >> v[i] >> w[i];
	for (int i = 0; i < 105 * 10300; i++)dp[i / 10300][i % 10300] = 1000000007; dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10000; j++) {
			dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	for (int i = 0; i <= 10000; i++)if (dp[n][i] <= W)maxn = i;
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 7300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
map<int,int>ma;
int n,m;
ll f(int a,int b){
	if(b==n+1){
		return 0;
	}
	int t=ma[b];
	ll out;
	if(a==t)out=f(a,b+1);
	else if(t==1){
		out=f(a==2?0:2,b+1)+pow(3,n-b);
	}else{
		out=f(a,b+1)+pow(3,n-b)*2;
	}
	return out;
}
int main(){
	while(cin>>n>>m,n+m){
		rep(i,3){
			int a;cin>>a;
			rep(j,a){
				int b;cin>>b;
				ma[b]=i;
			}
		}
		ll out=min(f(0,1),f(2,1));
		cout<<out<<endl;
	}
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> road(N,0);
  for(int i=0;i<M*2;i++){
    int j;
    cin>>j;
    road.at(j-1)+=1;
  }
  for(int i=0;i<N;i++){
    cout<<road.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    ll k;
    cin >> k;
    ll p = 1;
    ll x = 0;
    for2(i, 1, 2e6){
        x = (x + 7 * p) % k;
        p = (10 * p) % k;
        if (x == 0){
            cout << i << '\n';
            return;
        }
    }
    cout << "-1\n";
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3636
from itertools import product as pro

n = int(input())
s = str(input())

r = [i for i in range(n) if s[i] == 'R']
g = [i for i in range(n) if s[i] == 'G']
b = [i for i in range(n) if s[i] == 'B']
cnt = len(r) * len(g) * len(b)

length = max(len(r), len(g), len(b))
for i, j, k in [(r, g, b), (g, b, r), (b, r, g)]:
    if length == len(i):
        max1 = set(i)
        min1 = j
        min2 = k

for i, j in pro(min1, min2):
    if 2*j-i in max1:
        cnt -= 1
    if 2*i-j in max1:
        cnt -= 1
    if (i+j)/2 in max1:
        cnt -= 1

print(cnt)



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

int main(){
  int N, M;
  std::cin >> N >> M;
  
  std::vector<int> items;
  int item;
  float score = 0;
  
  while (std::cin >> item){
    items.push_back(item);
    score += item;
  }
  
  std::sort(items.begin(), items.end(), std::greater<int>());
  
  if (items[M - 1] < score / 4 / M) std::cout << "No";
  else std::cout << "Yes";
  
  return 0;
  
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int A, B;
  cin >> A >> B;
  ll ans = 0;
  ll num = 1;
  while(num<B){
    ans++;
    num += A - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d", $num);
  $ones_place = substr($num, -1);
  $ans;

  if (in_array($ones_place, [2, 4, 5, 7, 9])) {
    $ans = 'hon';
  } else if (in_array($ones_place, [0, 1, 6, 8])) {
    $ans = 'pon';
  } else if ($ones_place == 3){
    $ans = 'bon';
  }

  echo $ans;

Measured memory_bytes: 16240
function main(input) {
  input=input.trim();
  const n = parseInt(input.split("\n")[0], 10);
  const k = parseInt(input.split("\n")[1], 10);
  const x = parseInt(input.split("\n")[2], 10);
  const y = parseInt(input.split("\n")[3], 10);

  if(n>k){
    console.log(k*x+(n-k)*y);
  }else{
    console.log(n*x);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
int main() {
	int w,h;
	while (true){
	std::cin >> w >> h;
	if(w==0 && h==0){break;}
	int wc=1;
	int hc=1;
	while(wc<=w){
		while(hc<=h){
			if(wc%2==1 && hc%2==0){    //wc%2??§????????¶??°?????´???,h%2??§??????????\???°?????´???
			std::cout << ".";}else if(wc%2==0 && hc%2==1){
			std::cout << ".";}else{std::cout << "#";
			}
			hc++;
		}
		hc=1;
		std::cout << std::endl;
		wc++;
	}
	std::cout << std::endl;
}
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
const ll MAX_N = 100000;
const ll INF = 1e12;

ll dp[MAX_N+1];

int main() {
  int N;
  std::cin >> N;
  std::vector< ll > vl;
  std::vector< ll >::iterator it;

  vl.push_back(1);

  ll val6 = 6;
  while (val6 <= MAX_N) {
    vl.push_back(val6);
    val6 *= 6;
  }

  ll val9 = 9;
  while (val9 <= MAX_N) {
    vl.push_back(val9);
    val9 *= 9;
  }

  std::sort(vl.begin(), vl.end());

  for (ll i = 0; i <= MAX_N; i++) {
    dp[i] = INF;
  }
  dp[0] = 0;

  for (ll i = 1; i <= MAX_N; i++) {
    for (it = vl.begin(); it != vl.end(); it++) {
      if (i - *it >= 0) {
	dp[i] = std::min(dp[i], dp[i-*it] + 1);
      }
    }
  }

  std::cout << dp[N] << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double h_angle = 0.5*(h*60+m);
    double m_angle = 6*m;
    double diff = abs(h_angle-m_angle);
    diff = diff*(M_PI/180.0);
    double sol = a*a+b*b-2*a*b*cos(diff);
    double ans = sqrt(sol);
    cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 4120
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_071_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(6).
    01 j      PIC 9(6).

    01 S      PIC X(100000).

    01 maxlen PIC 9(2) VALUE 26.
    01 alpha  PIC X(26) VALUE "abcdefghijklmnopqrstuvwxyz".

    01 f1.
        03 f11 OCCURS 26.
            05 f PIC 9(1) VALUE ZERO.

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT S.

    PERFORM VARYING i FROM 1 BY 1 UNTIL S(i:1) = SPACE
        PERFORM VARYING j FROM 1 BY 1 UNTIL maxlen < j
            IF S(i:1) = alpha(j:1) THEN
                MOVE 1 TO f(j)
            END-IF
        END-PERFORM
    END-PERFORM

    PERFORM VARYING i FROM 1 BY 1 UNTIL maxlen < i
        IF f(i) = ZERO THEN
            DISPLAY alpha(i:1)
            EXIT PERFORM
        ELSE
            IF i = maxlen THEN
                DISPLAY "None"
            END-IF
        END-IF
    END-PERFORM

    STOP RUN.


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()
using namespace std;

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

    vector<int> s(m);
    vector<int> c(m);
    
    for(int i=0; i<m; i++){
        cin >> s[i] >> c[i];
    }

    int start = 1;
    int end = 10;

    for(int i=1; i<n; i++){
        start *= 10;
        end *= 10;
    }
    if(n == 1) start = 0;

    // cout << start << "," << end << endl;

    // 整数loop
    for(int i=start; i<end; i++){
        bool flag = true;
        for(int j=0; j<m; j++){
            int digN = 0;
            if(n==1){
                digN = i;
            }else if(n==2){
                if(s[j]==1) digN = i/10;
                if(s[j]==2) digN = i%10;
            }else{
                if(s[j]==1) digN = i/100;
                if(s[j]==2) digN = (i/10) % 10;
                if(s[j]==3) digN = i%10;
            }
            if(digN != c[j]){
                flag = false;
                continue;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

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


int main() {
    string S;
    int count0=0,count1=0;
    cin >>S;
    rep(i,S.size()){
        if(S[i]=='0')count0++;
        else count1++;
    }
    int mn =min(count0,count1);
    cout << 2*mn <<endl;

}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int x;
        cin >>x;
        cout <<1-x <<endl;
        return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long s[10];
int main()
{
    int x,y,z,i,j,k;
    scanf("%d%d%d",&s[1],&s[2],&s[3]);
    scanf("%d",&k);
    sort(s+1,s+4);
    for(i=1;i<=k;i++)
    {
        s[3]=s[3]*2;
    }
    printf("%d\n",s[1]+s[2]+s[3]);
    return 0;
}


Measured memory_bytes: 128
n=int(input())
dp=[0]
for i in range(1,n+1):
    if i<6:
        dp.append(dp[i-1]+1)
    elif 6<=i<9:
        dp.append(dp[i-6]+1)
    else:
        i6=i
        count6=0
        while i6>=6:
            i6=i6/6
            count6=count6+1
        a=dp[i-6**count6]+1
        i9=i
        count9=0
        while i9>=9:
            i9=i9/9
            count9=count9+1
        b=dp[i-9**count9]+1
        dp.append(min(a,b))
print(dp[n])


Measured memory_bytes: 44508
data = list(map(int,input().split()))
ans = data[1]
a1 = (data[0]//2)*2 + (data[3]//2)*2 + (data[4]//2)*2
a2 = 3 + ((data[0]-1)//2)*2 + ((data[3]-1)//2)*2 + ((data[4]-1)//2)*2
if data[0]*data[3]*data[4] == 0:
    a2 = 0
print(ans + max(a1,a2))


Measured memory_bytes: 38384
n, m = map(int, input().split())
inf = 10**10
# G[i][j] = iからjへの距離
G = [{} for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    G[l-1][r-1] = d
    G[r-1][l-1] = -d
# D[j] = jの属する連結成分のトップからjへの距離
D = [inf for i in range(n)]
# まだ探索していないiをトップとして探索する
for i in range(n):
    if D[i] != inf:
        continue
    Q = [i]
    D[i] = 0
    while Q:
        j = Q.pop()
        for k in G[j].keys():
            if D[k] == inf:
                Q.append(k)
            if D[k] == inf:
                D[k] = D[j]+G[j][k]
            elif D[k] != D[j]+G[j][k]:
                print('No')
                exit()
print('Yes')


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

int main(void)
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max({
                a * c,
                a * d,
                b * c,
                b * d
        }) << endl;
    
    return 0;
}


Measured memory_bytes: 3588
//Microwave
#include <iostream>

using namespace std;

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int T = 0;

    if(A < 0) {
        T += (0 - A) * C + D + B * E;
    } else {
        T += (B - A) * E;
    }

    cout << T << endl;
}


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

int main()
{
	int N, K;
	int cnt = 0;
	int num = 0;

	cin >> N >> K;

	for ( int i = 0; i < N; i++ ) {
		num++;
		if ( num * K >= N - i - 1 ) {
			num = 0;
			cnt++;
		}
	}

	cout << cnt << endl;

	return ( 0 );
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    
    ll ans = k;

    for (int i = 1; i < n; i++){
        ans *= k-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384