akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;
 

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n), b(n);
    map<int, int> cnt;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[i] = i - a[i];
    }
    ll ans = 0;
    for (i = n - 1; i >= 0; i--) {
        int tmp = a[i] + i;
        auto it=cnt.find(tmp);
        if (it != cnt.end()) {
            ans += it->second;
        }
        cnt[b[i]]++;
    }
    printf("%lld\n", ans);


    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 13008
n, m = map(int, input().split())
a = []
b = [1] * n
py = []
for i in range(m):
    p, y = map(int, input().split())
    py.append([p, y, i, 0])
py = sorted(py, key=lambda x: (x[0], x[1]))
for i in range(len(py)):
    py[i][3] = b[py[i][0]-1]
    b[py[i][0] - 1] += 1
py = sorted(py, key=lambda x: x[2])
for i in py:
    print(("000000" + str(i[0]))[-6:] + ("000000" + str(i[3]))[-6:])


Measured memory_bytes: 35104
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
        return 0;
    }
    if(n>=k){
        cout<<n-k<<endl;
    }else{
        cout<<1<<endl;
    }




    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

// conversion number to bit
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    reverse(bit.begin(), bit.end());
    return bit;
}

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

    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    ll res = (1ll<<60);
    REP(mask, 1ll<<(H-1)){
        ll sz = __builtin_popcountll(mask);
        sz++;
        ll val = sz-1;
        vl cnt(sz, 0);
        REP(i, W){
            vl tmp(sz, 0);
            ll pos = 0;
            //dump(sz)
            REP(j, H){
                //dump(pos)
                tmp[pos] += S[j][i] - '0';
                if(mask>>j & 1) pos++;
            }
            
            //dump(tmp)
            REP(j, sz) if(tmp[j]>K) goto HELL;

            bool ok = true;
            REP(j, sz) if(cnt[j]+tmp[j]>K) ok = false;
            if(ok){
                REP(j, sz) cnt[j] += tmp[j];
            }else{
                val++;
                REP(j, sz) cnt[j] = tmp[j];
            }
        }
        // dump(num2bit(mask, H-1))
        // dump(val)
        chmin(res, val);
        HELL:;
    }    

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
int main()
{
	int N, M;
	cin >> N >> M;

	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define X 1000000007
using namespace std;
int n,lst[N+5],f[N+5];
int main()
{
	RI i,x;for(scanf("%d",&n),f[0]=i=1;i<=n;++i) scanf("%d",&x),
		f[i]=f[i-1],lst[x]&&lst[x]^(i-1)&&(f[i]=(f[i]+f[lst[x]])%X),lst[x]=i;
	return printf("%d\n",f[n]),0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k;
    scanf("%lld %lld", &n, &k);
    vl a(n);
    rep(i, n) {
        scanf("%lld", &a[i]);
    }
    sort(all(a));

    ll ub = 1e18, lb = -1e18;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        auto is_smaller = [&] {
            ll cnt = 0;
            rep(i, n) {
                if (a[i] >= 0) {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            l = o;
                        } else {
                            r = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += r;
                } else {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            r = o;
                        } else {
                            l = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += n - r;
                }

                if (a[i] * a[i] < mid) cnt--;
            }
            cnt /= 2;
            return cnt < k;
        };

        // debug(mid);
        if (is_smaller()) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << lb << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int n,q,i,j,l,r,m,key,count = 0,temp;
  scanf("%d",&n);
  int S[n];
  for(i = 0;i < n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  int T[q];
  for(i = 0;i < q;i++)
    {
      scanf("%d",&T[i]);
      //printf("test1\n");
    }
  //printf("%d",q);

  for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  if(S[i] < S[j])
	    {
	      temp = S[i];
	      S[i] = S[j];
	      S[j] = temp;
	    }
	}
    }
  /*for(i = 0;i<q;i++)
    {
      printf("%d",T[i]);
      }*/

  for(i = 0;i < q;i++)
    {
      key =T[i];
      l = 0;
      r = n;
      while(l < r)
	{
	  m = (l + r)/2;
	  //printf("m=%d\n",m);
	  if(key == S[m])
	    {
	      //printf(" %d ",S[m]);
	      count++;
	      break;
	    }
	  if(key > S[m])
	    {
	      l = m + 1;
	    }
	  else if(key <S[m])
	    {
	      r = m;
	    }
	}
      //printf("count%d",count);
    }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

#define N 100000

int partition(int *, int, int);

int main(){

  int i;
  int n;
  int q;
  int A[N];
  
    scanf("%d",&n);

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

int partition(int *A,int p,int r){

  int i;
  int j;
  int tmp;
  int x;
  
   x = A[r];
   i = p-1;
   
  for(j=p;j<=r-1;j++){
    if(A[j] <= x){
      i = i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
    
     tmp = A[i+1];
  A[i+1] = A[r];
    A[r] = tmp;

   return i+1;
}

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

long long N, K, A[1 << 18];
double B[1 << 18], M[1 << 18];

int main() {
    cin >> N >> K;
    for (int i=1; i <= N; i++) cin >> A[i];
    for (int i=1; i <= N; i++) B[i] = B[i-1] + log10(A[i]);
    for (int i=K; i <= N; i++) M[i] = B[i] - B[i-K];

    for (int i=K+1; i <= N; i++){
        if(M[i-1] + 1e-10 < M[i]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8492
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var h = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var result = 0
    h = f(h)
    for (i in 100 downTo 1) {
        for (j in h.indices) if (h[j] == i) {
            h[j] -= 1
            result++
        }
        h = f(h)
    }
    println(result)
}

fun f(a: IntArray): IntArray {
    val b = mutableListOf<Int>()
    b.add(a.first())
    for (i in 1 until a.size) {
        if (b.last() != a[i]) b.add(a[i])
    }
    return b.toIntArray()
}

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

int main(){
	int a,b,n;
	cin >> a >> b >> n;
	cout << n / 1000 * min(a, 2 * b) + (n % 1000 > 500 ? min(a, 2 * b) : n % 1000 == 0 ? 0 : min(a, b)) << endl;
	return 0;
}	


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

int main(){
string s;
  cin>>s;
  string ans="No";
  for(int i=0;i<s.size()-1;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='C'){
    ans="Yes";
    }
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  ll n;
  cin >> n;
  ll mini;
  ll maxi;
  bool minhasu = false;
  bool maxhasu = false;
  vector<pair<ll,ll>> vec1(n);
  vector<pair<ll,ll>> vec2(n);

  rep(i,n){
    cin >> t1 >> t2;
    vec1[i].first = t1;
    vec1[i].second = t2;
    vec2[i].first= t2;
    vec2[i].second = t1;

  }
  ll ans;
  sort(all(vec1));
  sort(all(vec2));
  if(n % 2 == 0){
    t1 = vec1[n/2-1].first + vec1[n/2].first;
    t2 = vec2[n/2-1].first + vec2[n/2].first;

//    mini = t1 / 2;
//    maxi = t2 / 2;
//    if(t1 % 2 == 1){
//      minhasu = true;
//    }
//    if(t2 % 2 == 1){
//      maxhasu = true;
//    }
    t3 = t2 - t1;
    ans = t3+1;
  }else{
    mini = vec1[n/2].first;
    maxi = vec2[n/2].first;

    ans = maxi - mini + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m,j,k=0;
  cin>>m;
  vector<int> x(m);
  for(j=0;j<m;j++) cin>>x.at(j);
  sort(x.begin(),x.end());
  for(j=1;j<m;j++) if(x.at(j)==x.at(j-1)) k++;
  if(k%2==1) k++;
  cout<<m-k<<endl;
}

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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef long long int llint;

// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}

// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}

//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only

// To get accurate precision
//~cout.precision(20);

int main() {
    fast_io;
	char c;
	cin >> c;
	if(c >= 'a') cout << "a" << endl;
	else cout << "A" << endl;
}


Measured memory_bytes: 3644
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    if(K == 1) cout << S[0] << endl;
    else if(S[0] == '1') {
        int i = 1;
        while(S[i] == '1') i++;
        if(i >= K) cout << 1 << endl;
        else cout << S[i] << endl;
    }
    else cout << S[0] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
const ll N = 1e6;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod = 998244353 ;
const ll INF = 1e16;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pld pair<ld,ld>
#define pll pair<ll, ll>
#define pii pair<ll, ll>
#define ld long double
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
string a,b;
bool comp(ll i,ll j){
    return a[i]>a[j];
}
int main() {   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt","w",stderr);    
    #endif
    ll t = 1;
    // cin>>t; 
    while(t--){
        ll h1,m1,h2,m2,k;
        cin>>h1>>m1>>h2>>m2>>k;
        ll m = h1*60 + m1 - ((h2*60)+m2);
        m = abs(m)-k;
        cout<<m<<'\n';
    }
}              

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

using namespace std;


int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-1; i++) {
        if(s[i] == 'A' && s[i+1] == 'C') {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 3612
program NOMURA2020B
  character(200000)::T
  integer(8)::ans=0
  read(*,*)T
  do i=1,len_trim(T)
     if(T(i:i)=='?') T(i:i)='D'
  end do
  write(*,'(a)')trim(T)
end program NOMURA2020B

Measured memory_bytes: 3308
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = (1LL<<60);

int main() {
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> a(n);
    for (auto& e : a) cin >> e;
    sort(a.begin(), a.end());
    
    // v 未満になるものの数
    // これが k 個未満かどうか
    auto f = [&] (long long v) -> bool {
        long long cnt = 0;
        for (int i = 1; i < n; i++) {
            if (a[i] == 0) { cnt += (v > 0 ? i : 0); continue; }
            if (a[i] > 0) {
                if (a[i] * a[0] >= v) continue;
                int ok = 0, ng = i;
                while (abs(ok - ng) > 1) {
                    int m = (ok + ng) / 2;
                    if (a[i] * a[m] < v) ok = m;
                    else ng = m;
                }
                cnt += ++ok;
            }
            if (a[i] < 0) {
                if (a[i] * a[i-1] >= v) continue;
                int ok = i-1, ng = -1;
                while (abs(ok - ng) > 1) {
                    int m = (ok + ng) / 2;
                    if (a[i] * a[m] < v) ok = m;
                    else ng = m;
                }
                cnt += i - ok;
            }
        }
        return cnt < k;
    };
    
    long long ok = -INF, ng = INF;
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (f(mid)) ok = mid;
        else ng = mid;
    }
    
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())

uf = UnionFind(N+1)
AB_list = []

for i in range(M):
    A, B = map(int, input().split())
    AB_list.append([A, B])
    uf.union(A, B)
ans=0
for i in range(N):
  q=uf.size(i)
  if ans<=q:
    ans=q
print(ans)


Measured memory_bytes: 40540
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> dp(n + 1, n);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = min(dp[i + 1], dp[i] + 1);
    for (int j = 6; i + j <= n; j *= 6) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
    for (int j = 9; i + j <= n; j *= 9) {
      dp[i + j] = min(dp[i + j], dp[i] + 1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 3596
require 'matrix'


n, m= gets.split.map(&:to_i)

a = n.times.map do
      gets.split.map(&:to_i)
    end

b = m.times.map do
      gets.split.map(&:to_i)
    end

ma = Matrix.rows(a)
mb = Matrix.rows(b)
mc = ma * mb


mc.row_vectors.each {|row| puts row.to_a.join("\s")}


Measured memory_bytes: 9172
import java.io.*;
import java.util.*;
import java.math.*;

class Main {
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;
    public static ArrayList<ArrayList<Integer>> adjList;
    public static int[] dx = {-1, 0, 1, 0, -1, 1, 1, -1};
    public static int[] dy = {0, 1, 0, -1, 1, 1, -1, -1};
    public static int INF = 0x3f3f3f3f;
    public static int MOD = 1000000007;

    public static void main(String[] args) throws Exception{
        int N = Integer.parseInt(br.readLine());
        int[][] A = new int[3][N];

        for(int j = 0; j < 3; j++){
            st = new StringTokenizer(br.readLine());
            for(int i = 0; i < N; i++){
                A[j][i] = Integer.parseInt(st.nextToken());
            }
            Arrays.sort(A[j]);
        }

        long[] B = new long[N];
        for(int i = 0; i < N; i++){
            int a = -1;
            int b = N-1;
            while(a != b){
                int mid = (a + b + 1) / 2;
                if(A[0][mid] < A[1][i]){
                    a = mid;
                } else{
                    b = mid - 1;
                }
            }
            B[i] = (a + 1);
        }

        for(int i = 1; i < N; i++){
            B[i] += B[i-1];
        }

        long total = 0;

        for(int i = 0; i < N; i++){
            int a = -1;
            int b = N-1;
            while(a != b){
                int mid = (a + b + 1) / 2;
                if(A[1][mid] < A[2][i]){
                    a = mid;
                } else{
                    b = mid - 1;
                }
            }
            if(a >= 0) total += B[a];
        }

        pw.print(total + "\n");


        pw.close(); 
        br.close();
    }
}

class Pair implements Comparable<Pair>{
    public int x, y;

    Pair(int _x, int _y){
        x = _x;
        y = _y;
    }

    public String toString(){
        return x + "," + y;
    }

    public int compareTo(Pair p){
        if(x != p.x) return x < p.x ? 1 : -1;
        else if(y != p.y) return y < p.y ? -1 : 1;
        return 0;
    }
}

Measured memory_bytes: 52748
if __name__ == '__main__':
    while True:
        data = [int(x) for x in input().split(' ')]
        H = data[0]
        W = data[1]

        if H == 0 and W == 0:
            break

        # ?????§?????????????????????
        for i in range(1, H+1):
            output = '#.' * W
            if i % 2 == 0:
                output = output[1:]
            print('{0}'.format(output[:W]))
        print('')  # ??????????????????????????????1????????????

Measured memory_bytes: 7664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    string in;
    cin >> in;
    int n=0;
    REP(i,in.size()){
        n += in[i] - '0';
        n %= 9;
    }
    if(n==0) cout << "Yes" << endl;
    else cout << "No" << endl;
//    cout << n;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    while(true){
        int a=n%10, b=n/10%10, c=n/100;
        if(a==b && b==c && c==a) break;
        n++;
    }
    cout << n << ln;
}




Measured memory_bytes: 256
#include <stdio.h>
#define Max 50000
int main(void)
{
	int n,i,j;
	int prime[Max]={1,1,0};
	for(i=2;i*i<Max;i++){					//エラトステネスの篩
		for(j=2;i*j<Max;j++){
			prime[i*j]=1;
		}
	}
	while(scanf("%d",&n)){
		if(n==0) break;
		int count=0;
		for(i=2;2*i<=n;i++){				//i≦jかつj=n-i⇒i≦n/2
			j=n-i;
			if(prime [i]==0 && prime[j]==0) count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

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

int main(){
    int ans = 0; //答え
    int n; //スイッチの数
    int m; //電球の数
    cin >> n >> m;

    vector<vector<int>> conections(m,vector<int>(n)) ; //電球とそれに繋がっているスイッチを格納

    for(int i=0; i<m; i++){
        int k; //スイッチの繋がっている個数
        cin >> k;

        //どの電球にどのスイッチが繋がっているか格納
        for(int j=0; j<k; j++) cin >> conections[i][j];

    }

    //スイッチのONとOFFの情報を格納
    vector<int> on_off(m);
    for(int i=0; i<m; i++) cin >> on_off[i];

    //全ての組み合わせをbit列で試す
    for(int bit=0; bit<(1<<n); bit++){
        bool found = true;

        for(int i=0; i<m; i++){
            int count = 0; //偶数か奇数かを判断するために数える

            /*電球が光っているのかそれぞれ調べる*/
            for(int j=0; j<conections[i].size(); j++){

                /*フラグが立っていればON*/
                if(bit & (1<<conections[i][j])) count++;
            }

            /*電球が光っているか判定*/
            if(on_off[i] != count % 2){
                found = false;
                break;
            }
        }

        if(found) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=2e5+5;
int n,m;
int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	cin>>m>>n;
	if(n%m==0)
		{cout<<n/m;return 0;}
	set<int> s;
	for(int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
			{s.insert(i);s.insert(n/i);}

	}
	int ans=1;
	//for(auto i:s)cout<<i<<" ";
	for(auto i:s)
	{
		if((n/i)>=m)ans=i;
	}
	cout<<ans;


	
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <map>
using namespace std;

void rep(string& str, const string& from, const string& to) {
    std::string::size_type pos = 0;
    while (pos = str.find(from, pos), pos != string::npos) {
        str.replace(pos, from.length(), to);
        pos += to.length();
    }
}

int main(){
    string l;
    getline(cin, l);
    rep(l, "apple", "@@@@@");
    rep(l, "peach", "apple");
    rep(l, "@@@@@", "peach");
    cout << l << endl;
}

Measured memory_bytes: 1188
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    def dijkstra_heap(start,edge):
        #始点から各頂点への最短距離(頂点番号:0~N-1)
        d = [inf]*N
        used = [False]*N
        d[start] = 0
        used[start] = True
        edgelist = []
        #a:重み(//), b:次の頂点(%)
        for a,b in edge[start]:
            heapq.heappush(edgelist,a*(10**6)+b)

        while len(edgelist):
            #まだ最短距離が決まっていない頂点の中から最小の距離のものを探す
            minedge = heapq.heappop(edgelist)
            if used[minedge%(10**6)]:
                continue
            node = minedge%(10**6)
            d[node] = minedge//(10**6)
            used[node] = True

            for e in edge[node]:
                if not used[e[1]]:
                    heapq.heappush(edgelist,(e[0]+d[node])*(10**6)+e[1])
        return d

    #N:頂点数   W:辺数
    N, X, Y = map(int, input().split())
    edge = [[] for i in range(N)]
    #edge[i] : iから出る道の[重み,行先]の配列
    for i in range(N-1):
        edge[i].append((1,i+1))
    for i in range(Y-1, X-1, -1):
        edge[i].append((1, i-1))
    edge[X-1].append((1, Y-1))
    res = [0]*N
    for k in range(N):
        d = dijkstra_heap(k, edge)
        for i in d[k+1:]:
            res[i] += 1
    for r in res[1:]:
        print(r)

            


if __name__ == '__main__':
    main()

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

const int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    if(n>m){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    
    int grid[101][101];
    rep(i,100){
        rep(j,100){
            if(i <= 50) grid[i+1][j+1] = 1;
            else grid[i+1][j+1] = 0;
        }
    }

    for(int i=1;i<=50;i+=2){
        for(int j=1;j<=100;j+=2){
            if(a != 1){
                if(i%2 == 0)grid[i][j] = 0;
                else grid[i][j+1] = 0;
                a--;
            }
            if(b != 1){
                if(i%2 == 0)grid[101-i][j] = 1;
                else grid[101-i][j+1] = 1;
                b--;
            }
        }
    }

    cout << 100 << " " << 100 << endl;
    rep(i,100){
        rep(j,100){
            if(grid[i+1][j+1]) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }

	return 0;
}


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

int main() {
    int N, M;
    string ans;
    bool exist_ans = true;

    cin >> N >> M;
    rep (i, N)  ans += "0";
    if (ans.size() >= 2) ans[0] = '1';

    int S[M], C[M];
    rep(i, M) cin >> S[i] >> C[i];

    for (int i=0; i<M-1; i++) {
        for(int j=i+1; j<M; j++) {
            if ((S[i] == S[j]) && (C[i] != C[j])) exist_ans = false;
        }
    }

    if (exist_ans) {
        rep(i, M) {
            ans[S[i]-1] = C[i] + '0';
            // cout << i << ":" << ans << endl; 
        }
    }

    if ((ans.size() >= 2) && (ans[0] == '0')) exist_ans = false;

    if (exist_ans) cout << ans << endl;
    else cout << "-1" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double x0,y0,x1,y1,q,x2,y2;
    cin>>x0>>y0>>x1>>y1;
    cin>>q;
    while(q--)
    {
        cin>>x2>>y2;
        double l=x2*(y0-y1)+y2*(x1-x0)+y0*(x0-x1)+x0*(y1-y0);
        if(l>0)
            cout<<"COUNTER_CLOCKWISE\n";
        else if(l<0)
            cout<<"CLOCKWISE\n";
        else
        {
            double p0p1,p1p2,p0p2;
            p0p1=sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
            p1p2=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
            p0p2=sqrt((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
            if(fabs(p0p1-p0p2-p1p2)<0.0000001)
            cout<<"ON_SEGMENT\n";
            else if(fabs(p1p2-p0p1-p0p2)<0.0000001)
            cout<<"ONLINE_BACK\n";
            else if(fabs(p0p2-p1p2-p0p1)<0.0000001)
            cout<<"ONLINE_FRONT\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  vector<int> a(5);
  for (int i = 0; i < 5; ++i) cin >> a[i];

  sort(ALL(a));

  auto f = [](int n) { return (n + 9) / 10 * 10; };

  int ans = INF;
  do {
    chmin(ans, f(a[0]) + f(a[1]) + f(a[2]) + f(a[3]) + a[4]);
  } while(next_permutation(ALL(a)));

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 100100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int dp[1010][1010];
char mat[1010][1010];


int32_t main(){
	fastio;
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>mat[i][j];
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(i==1 && j==1){
				dp[i][j] = 1;
				continue;
			}
			dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
			if(mat[i][j]=='#')dp[i][j]  =0;
		}
	}
	cout<<dp[h][w]<<endl;
	
}

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

int main() {
	// your code goes here
long long n,k;
cin>>n>>k;
long long c = n%k;
long long d = abs(c-k);
long long ans=c;
ans=min(ans,d);
long long e = abs(d-k);
ans=min(ans,e);
cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>

unsigned long long Fact(unsigned long long n);

int main()
{
	unsigned long long n, ans = 1;


	while (std::cin >> n)
	{
		ans = Fact(n);

		std::cout << ans << std::endl;
	}
}

unsigned long long Fact(unsigned long long n)
{
	if (n == 1)
		return 1;
	else
		return n * Fact(n - 1);
}


Measured memory_bytes: 2988
N=int(input())
S=list(input())
out = []

for i in range(len(S)):
	#print(ord(S[i]))
	if ord(S[i])+N>90:
		S[i] = int(ord(S[i])+N-26)
	else:
		S[i] = int(ord(S[i])+N)
	#print(S[i])
#print('==================')

for i in range(len(S)):
	out += chr(S[i])

print(''.join(out))

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

int main(void){
	int n,tmp;
	while ( cin >> n ,n){
		int list[11][11]={0};
		for(int j=0;j<n;j++)
			for(int i=0;i<n;i++)
				cin >> list[i][j];
		for(int j=0;j<n;j++)
			for(int i=0;i<n;i++)
				list[n][j]+=list[i][j];
		for(int i=0;i<=n;i++)
			for(int j=0;j<n;j++)
				list[i][n]+=list[i][j];
		for(int j=0;j<=n;j++){
			for(int i=0;i<=n;i++){
				printf("%5d",list[i][j]);
				//printf(i?" ":"");
			}
			printf("\n");
		}
	}
	return 0;
}	

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
int main(){
    ll n,m,k;
    ll c,d=0;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    rep(i,n) {
        cin>>c;
        d+=c;
        a[i]=d;
    }
    d=0;
    rep(i,m) {
        cin>>c;
        d+=c;
        b[i]=d;
    }
    int ans=upper_bound(b.begin(),b.end(),k)-b.begin();
    rep(i,n){
        if(a[i]<=k){
        int ho=upper_bound(b.begin(),b.end(),k-a[i])-b.begin()+i+1;
        ans=max(ans,ho);
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    }

Measured memory_bytes: 6424
import math
n=int(input())
suretu1=list(map(int,input().split()))
suretu2=list(map(int,input().split()))
zyun1=0
zyun2=0
count=0
for i in range(n):
    n_suretu1=sorted(suretu1)
    for j in range(len(suretu1)):
        if suretu1[0]==n_suretu1[j]:
            count=j+1
    zyun1+=math.factorial(n-i-1)*(count-1)
    del suretu1[0]
for i in range(n):
    n_suretu2=sorted(suretu2)
    for j in range(len(suretu2)):
        if suretu2[0]==n_suretu2[j]:
            count=j+1
    zyun2+=math.factorial(n-i-1)*(count-1)
    del suretu2[0]
print(abs(zyun1-zyun2))   

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

namespace ABC124_C_Coloring_Colorfully
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] nums = Console.ReadLine().ToCharArray().Select(c => int.Parse(c.ToString())).ToArray();
			int[] temp = new int[nums.Length];
			int changeCount_by0 = 0;
			int changeCount_by1 = 0;

			//0始まり
			temp = Array(0, nums.Length);
			changeCount_by0 = DiffCount(nums, temp);

			//1始まり
			temp = Array(1, nums.Length);
			changeCount_by1 = DiffCount(nums, temp);

			if(changeCount_by0 > changeCount_by1)
			{
				Console.WriteLine(changeCount_by1);
			}
			else
			{
				Console.WriteLine(changeCount_by0);
			}
		}

		static int[] Array(int start, int length)
		{
			int[] temp = new int[length];

			for (int i = 0; i < length; i++)
			{
				if(start == 0)
				{
					temp[i] = 0;
					start = 1;
				}
				else
				{
					temp[i] = 1;
					start = 0;
				}
			}

			return temp;
		}

		static int DiffCount(int[] x, int[] y)
		{
			int count = 0;
			for(int i = 0; i < x.Length; i++)
			{
				if(x[i] == y[i])
				{
					continue;
				}
				else
				{
					count++;
				}
			}

			return count;
		}
	}
}


Measured memory_bytes: 16352
#include <bits/stdc++.h>
using namespace std;
#define int long long 
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define ff first
#define ss second
#define MAXN 310
const int INF = 1e9+10;

vector<ii> adj_list[MAXN];
ii dist[MAXN][MAXN];
int n, m, l;

void dijkstra(int s){
    for(int i=1; i<=n; ++i)
            dist[s][i]=ii(INF, 0);
    dist[s][s]=ii(0, 0);
    set<iii> pq;
    pq.insert(iii(ii(0, -l), s));
    while(not pq.empty()){
            int r = -pq.begin()->ff.ss;
            int g =  pq.begin()->ff.ff;
            int u =  pq.begin()->ss;
            pq.erase(pq.begin());
            for(auto x:adj_list[u]){
                    auto v=x.ff, w=x.ss;
                    ii y = ii(g, r);
                    if(w>y.ss){
                        ++y.ff;
                        y.ss = l-w;
                    }
                    else{
                        y.ss-=w;
                    }
                    y.ss*=-1;
                    if(dist[s][v]>y){
                        pq.erase(iii(dist[s][v], v));
                        dist[s][v]=y;
                        pq.insert(iii(dist[s][v], v));
                    }
            }
    }
}

int32_t main(){
    cin >> n >> m >> l;
    for(int i=0; i<m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        if(c>l) continue;
        adj_list[a].emplace_back(b, c);
        adj_list[b].emplace_back(a, c);
    }
    for(int i=1; i<=n; ++i)
        dijkstra(i);
    for(int u=1; u<=n; ++u)
        for(int v=1; v<=n; ++v)
            if(dist[u][v].ff==INF) dist[u][v].ff = -1;
    int m;
    cin >> m;
    while(m--){
        int a, b;
        cin >> a >> b;
        cout << dist[a][b].ff << endl;
    }
}

Measured memory_bytes: 7336
n=input()
c=0
for i in range(1,int(len(n))):
    if n[i]=="9":
        c+=1
if c==len(n)-1:
    print(int(n[0])+9*(len(n)-1))
else:
    print(int(n[0])+9*(len(n)-1)-1)

Measured memory_bytes: 61724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	
	string a,b;
	cin>>a>>b;
	int n=a.size(),m=b.size();
	vector<vector<int>> dp(n+1,vector<int> (m+1,0));

	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		if(a[i-1]==b[j-1])dp[i][j]=1+dp[i-1][j-1];
		else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	}
	
	
	int i=n,j=m;
	string ans="";
	
	while(i>0 and j>0)
	{
		if(a[i-1]==b[j-1])
		{
			
			ans.push_back(a[i-1]);
			i--,j--;
		}
		else
		{
			if(dp[i-1][j]>dp[i][j-1])i--;
			else j--;
			
		}
		
	}
	
	reverse(ans.begin(),ans.end());
	cout<<ans;
	
	
	
}


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

using namespace std;

typedef long long int ll;
ll n,k,cost=0;
vector<ll> height(100005, INT_MAX);
ll memo[100005];
ll dp(int pos)
{
	if(pos>n-1)
		return INT_MAX;
	if(pos==n-1)
		return 0;
	if(memo[pos]!=-1)
		return memo[pos];
	ll ans = INT_MAX;
	for(int i = 1; i<=k ; i++)
		ans = min(ans, dp(pos+i)+abs(height[pos]-height[pos+i]));
	return memo[pos] = ans;
}
int main()
{
	cin>>n>>k;
	for(int i = 0 ; i < n; i++)
		cin>>height[i];
	memset(memo, -1, sizeof memo);
	cout<<dp(0)<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
using namespace std;
#define ll long long
#include <string>
#include <algorithm>
int main()
{
	ll a,b,c,d,count=0;
	
//	while(1)
//	{
	cin>>a>>b>>c;
	ll t1,t2,t;
	t1=a/c;
	t2=b/c;
	if(a%c==0)
	{
		t=t2-t1+1;
	}
	else
	{
		t=t2-t1;
	}
	cout<<t;
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se-a.fi < b.se-b.fi) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
} 

int main()
{
    SieveOfEratosthenes(1000005);
    ll x;
    cin >> x;
    for(int i=x;i<=1000005;i++)
    {
        if(prime[i])
        {
            cout << i << "\n";
            break;
        }
    }
} 
    

Measured memory_bytes: 9984
require 'prime'
n = gets.to_i

list = n.prime_division

count = 0
for i in 0..list.length-1 do
    power = list[i][1]
    test = 1
    while power > 0 && power >= test do
        power -= test
        test+=1
        count += 1
    end
end

puts count

Measured memory_bytes: 14468
/*
    title: A.cpp
    author: Akhil
    date: 2020-09-19
    time: 17:29:37
*/

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

int main()
{
    string s; cin >> s;
    if (s[s.length() - 1] == 's') s = s + "es";
    else s = s + 's'; 
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>

typedef long long ll;
typedef unsigned long long ull;

constexpr size_t MAXN = 1e5;
constexpr size_t MAXM = 1e5;
constexpr int MOD = 1e9 + 7;

void solve() {
  int H, W;
  std::cin >> H >> W;
  std::vector<std::vector<int>> grid;
  grid.reserve(H);
  for (int y = 0; y < H; ++y) {
    grid.push_back(std::vector<int>());
    grid.back().reserve(W);
    for (int x = 0; x < W; ++x) {
      char a;
      std::cin >> a;
      grid[y].push_back(a == '.' ? 0 : -1);
    }
  }

  grid[0][0] = 1;

  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      if (grid[y][x] == -1 || y + x == 0) continue;
      if (y == 0) {
        grid[y][x] = grid[y][x - 1];
        continue;
      }
      if (x == 0) {
        grid[y][x] = grid[y - 1][x];
        continue;
      }
      int top = grid[y - 1][x] == -1 ? 0 : grid[y - 1][x];
      int left = grid[y][x - 1] == -1 ? 0 : grid[y][x - 1];
      grid[y][x] = (top + left) % MOD;
    }
  }

  std::cout << grid.back().back() << "\n";
}

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

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


Measured memory_bytes: 7168