akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int N,K,i;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  scanf("%d",&K);
  
  for(i=0;i<N;i++){
    if(S[K-1]==S[i])
      printf("%c",S[i]);
    else
      printf("*");
  }
  puts("");
  return 0;
}

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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 405;
const int MAXC = 405;
int N;
int C;
int A[MAXN];
int B[MAXN];

const int MAXB = 405;
num sump[MAXC][MAXB];

num dp[MAXN][MAXC];

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

	for (int v = 1; v < MAXB; v++) {
		sump[0][v] = 1;
	}
	for (int a = 0; a+1 < MAXC; a++) {
		for (int v = 0; v < MAXB; v++) {
			sump[a+1][v] = sump[a][v] * v;
		}
	}
	for (int a = 0; a < MAXC; a++) {
		for (int v = 1; v < MAXB; v++) {
			sump[a][v] += sump[a][v-1];
		}
	}

	cin >> N >> C;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		int a = A[i]-1;
		int b = B[i];
		for (int c = 0; c <= C; c++) {
			for (int x = 0; c+x <= C; x++) {
				dp[i+1][c+x] += dp[i][c] * (sump[x][b] - sump[x][a]);
			}
		}
	}

	cout << dp[N][C] << '\n';

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
 
int main(){
	int v[5];
    for(int i=0; i<5; i++)
    	cin>>v[i];
    
    for(int i=0; i<5; i++){
    	if(v[i]==0){
        	cout<<i+1;
            break;
        }
    }
}

Measured memory_bytes: 3572
# -*- coding: utf-8 -*-
def Therefore():

    Num = str(input())

    one_keta = int(Num[-1])

    if one_keta == 2 or one_keta == 4 or one_keta == 5 or one_keta == 7 or one_keta == 9:
        print('hon')
    
    elif one_keta == 0 or one_keta == 1 or one_keta == 6 or one_keta == 8:
        print('pon')

    else:
        print('bon')

if __name__ == '__main__':
    Therefore()



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

using namespace std;

const int MOD=1e9+7;
//const int MOD=998244353;

const double PI=3.14159265359;

vector<int> getPrimes(int stop){
    int sieveStop=ceil(sqrt(stop));
    vector<int> psj;
    for(int i=2; i<=sieveStop; i++){
        bool isP=true;
        for(int j=2; j<i && isP; j++){
            isP=i%j;
        }
        if(isP) psj.push_back(i);
    }
    
    vector<bool> primesb(stop+1,true);
    for(int j:psj){
        for(int i=2; i*j<=stop; i++){
            primesb[i*j]=false;
        }
    }
    vector<int> ans;
    for(int i=2; i<=stop; i++){
        if(primesb[i]) ans.push_back(i);
    }
    return ans;
}


int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        if(x%2){
            cout<<"first";
            return 0;
        }
    }
    
    cout<<"second";
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int N,M;
string s;
vector<int>G[2<<17];
int cnt[2][2<<17];
main()
{
	cin>>N>>M>>s;
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	queue<int>P;
	for(int i=0;i<N;i++)
	{
		for(int v:G[i])
		{
			cnt[s[v]=='A'?0:1][i]++;
		}
		if(!cnt[0][i]||!cnt[1][i])
		{
			P.push(i);
			cnt[0][i]=cnt[1][i]=0;
		}
	}
	while(!P.empty())
	{
		int u=P.front();
		P.pop();
		int id=s[u]=='A'?0:1;
		for(int v:G[u])
		{
			if(--cnt[id][v]==0)
			{
				cnt[1-id][v]=0;
				P.push(v);
			}
		}
	}
	for(int i=0;i<N;i++)
	{
		if(cnt[0][i]>0&&cnt[1][i]>0)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 13828
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    vector<ll> A(4,0);
    for(ll i=0;i<4;++i){
        char c;cin>>c;
        A[i]=c-'0';
    }
    for(ll i=0;i<(1<<3);++i){
        vector<ll> B(3,1);
        for(ll j=0;j<3;++j)if((1<<j)&i)B[j]=-1;
        ll sum=A[0];
        for(ll j=0;j<3;++j)sum+=A[j+1]*B[j];
        if(sum==7){
            vector<char> C(3);
            for(ll j=0;j<3;++j){
                if(B[j]==1)C[j]='+';
                else C[j]='-';
            }
            cout<<A[0];
            for(ll j=0;j<3;++j)cout<<C[j]<<A[j+1];
            cout<<"=7";
            cout<<endl;return 0;
        }
    }
    

    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	int ans = INT_MAX;
	for(long long i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			long long m = max(i, n / i);
			int x = 0;
			while(m > 0) {
				x++;
				m /= 10;
			}
			ans = min(x, ans);
		}
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct dat{
  int T,t,f,lap;
  dat(){T=t=f=lap=0;}
  vector<dat> V;
  bool operator > (const dat &a)const{return T-t>a.T-a.t;}
};

bool onFront(const dat &a,const dat &b){return a.f==b.f&&1.0*a.t/a.T<1.0*b.t/b.T;}
bool checkJam(const dat &a,const dat &b){return onFront(a,b)&&a.T-a.t<b.T-b.t;}

int merge(vector<dat>&A,int idx){
  dat &a = A[idx];
  for(int i=0;i<(int)A.size();i++){
    dat &b = A[i];
    if(!checkJam(a,b))continue;
    a.t=0, a.lap-=a.f, a.f=!a.f;
    b.V.push_back(a);
    A.erase(A.begin()+idx);
    return 1e9;
  }
  return a.T-a.t;
}

void Push(vector<dat>&A,dat &a){
  for(int i=0;i<(int)a.V.size();i++)Push(A,a.V[i]);
  a.V.clear();
  if(a.lap) A.push_back(a);
}

int sim(vector<dat> A){
  int res=0;
  while(!A.empty()){
    sort(A.begin(),A.end(),greater<dat>());
    int mn = 1e9;
    for(int i=A.size()-1;i>=0;i--)mn=min(mn,merge(A,i));

    vector<dat>nA;
    for(int i=0;i<(int)A.size();i++)
      if(A[i].t+mn<A[i].T) A[i].t+=mn,nA.push_back(A[i]);
      else A[i].t=0, A[i].lap-=A[i].f, A[i].f=!A[i].f,Push(nA,A[i]);

    A=nA;
    res+=mn;
  }
  return res;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<dat> A(n);
    for(int i=0;i<n;i++)cin>>A[i].T>>A[i].lap;
    cout<<sim(A)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;
ll mpow(ll a, ll b) { ll r = 1; a %= mod; while (b) { r = r * ((b % 2) ? a : 1) % mod, a = a * a % mod, b >>= 1; }return r; }



int main() {
	int n, m; cin >> n >> m;
	vector<int> s(n), t(m);
	rep(i, 0, n) cin >> s[i];
	rep(i, 0, m)cin >> t[i];
	vector<vector<ll>> dp(n + 1);
	rep(i, 0, n + 1)dp[i].resize(m + 1, 0);
	rep(i, 0, m + 1)dp[0][i] = 1;
	rep(i, 0, n + 1)dp[i][0] = 1;
	rep(i, 1, n + 1)rep(j, 1, m + 1) {
		dp[i][j] = (ll)(dp[i - 1][j] + dp[i][j - 1] + dp[i - 1][j - 1] * (s[i-1] == t[j-1] ? 0LL : -1LL)+mod) % mod;
	}
	printf("%lld", dp[n][m]);
	return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

int Func2(int n,int m){
    long int s2 = 1,
        r = 1;


    for(int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % pow107;
    }

    return s2;
}

//long intの最大llimit
//intの最大ilimit
//10^9+7    pow107
//素数pn
//n乗jou
//階乗factorial
//コンビネーションFunc2

int main(){
    string s;
    cin >> s;
    cout << "ABC" << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

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

    if(n < 1000) { 
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }

    return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

ll safeMul(ll a, ll b, bool& overflow) {
  overflow = false;
  if (b > 0 ? a > INT64_MAX / b || a < INT64_MIN / b
            : (b < -1 ? a > INT64_MIN / b || a < INT64_MAX / b : b == -1 && a == INT64_MIN)) {
    overflow = true;
    return INT64_MAX;
  }
  return a * b;
}

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

  ll n;
  cin >> n;
  bool zero = false;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] == 0) {
      zero = true;
    }
  }

  if (zero) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 1;
  rep(i, n) {
    if ((ll)(1e18) / ans < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }

  cout << ans << endl;

  return 0;
}


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


def solve(a: int, b: int):
    print(math.ceil((a+b)/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()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    vec t(N+1), v(N+1);
    rep(i,N){
        cin>>t[i];
        t[i] <<= 1;
        if(i != 0) t[i] += t[i-1];
    }
    rep(i,N) {
        cin>>v[i];
        v[i] <<= 1;
    }
    t[N] = t[N-1] + 1;
    v[N] = 0;
    ll take_care = N + 1;
    ll lastv = 0;
    vec run(t[N],0);
    reps(i,1,t[N]){
        ++lastv;
        for(int j = N; j > N + 1 - take_care; --j){
            lastv = min(lastv, v[j] + t[j-1] - i);
        }
        lastv = min(lastv, v[N + 1 - take_care]);
        run[i] = lastv;
        if(i == t[N + 1 - take_care]) --take_care;
    }
    ll ans = 0;
    reps(i,1,t[N]) ans += run[i];
    long double out = ans;
    out /= 4.0;
    cout<<fixed<<setprecision(11)<<out<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(s) scanf("%s", s)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) cout<<v[X]<<" "; cout<<endl;
#define grid(v) for(int X=0;X<v.size();X++){for(int Y=0;Y<v[X].size();Y++) cout<<v[X][Y]<<" ";cout<<endl;}
#define endl "\n"
const int INF = 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector< vector< int > > vvi;
typedef vector< vector< ii > > vvii;
const int MOD=1e9+7;
const ll LINF=100000000000000000LL;
vector<int> adj[28];
int main()
{
    BUFF;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        adj[s[i]-'a'].pb(i);
    }
    pair<int,int> resp;
    resp=mp(-1,-1);
    for(int i=0;i<=26;i++)
    {
        for(int j=0;j<(int)adj[i].size() - 1;j++)
        {
            if(((adj[i][j+1]-adj[i][j]+1)/2) < 2)
            {
                resp=mp(adj[i][j]+1,adj[i][j+1]+1);
            }
        }
    }
    cout<<resp.first<<" "<<resp.second<<endl;
    return 0;
}


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

int main(){
    int N;  cin >> N;
    vector<int> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2; i<N; i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}


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

int main()
{
  int n,m,a[100050];
  cin>>n>>m;
  ll sum=0;
  for(int i=1;i<=m;i++)
  {
      cin>>a[i];
      sum+=a[i];
  }
  if(sum>=n)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <map>
using namespace std;

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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << "A" << s2.at(0) << "C" << endl;

	return 0;
}

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

int main(){
    string s; cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
 
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        int maximumVal = 200;
        int padding = 9;
        int [][][] dp = new int[maximumVal + padding][maximumVal + padding][maximumVal + padding];
        for(int[][] array2d : dp){
            for(int[] array1d : array2d){
                Arrays.fill(array1d, Integer.MAX_VALUE / 2);
            }
        }
 
        dp[a][b][c] = 0;
        for(int i = 0; i <= maximumVal; i++){
            for(int j = 0; j <= maximumVal; j++){
                for(int k = 0; k <= maximumVal; k++){
                    if(i - 1 >= 0 && j - 1 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i - 1][j - 1][k] + 1);
                    }
                    if(i - 1 >= 0 && k - 1 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i - 1][j][k - 1] + 1);
                    }
                    if(j - 1 >= 0 && k - 1 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i][j - 1][k - 1] + 1);
                    }
                    if(i - 2 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i - 2][j][k] + 1);
                    }
                    if(j - 2 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i][j - 2][k] + 1);
                    }
                    if(k - 2 >= 0){
                        dp[i][j][k] = Integer.min(dp[i][j][k], dp[i][j][k - 2] + 1);
                    }
                }
            }
        }
 
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i <= maximumVal; i++){
            ans = Integer.min(ans, dp[i][i][i]);
        }
 
        System.out.println(ans);
 
    }
}

Measured memory_bytes: 83220
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]
    t = lines[1]

    return (s, t)


def solve(s, t):


    n = len(t) 
    count = n
    for i in range(len(s) - len(t) + 1):
        tmp_s = s[i:i+n]
        
        cnt = 0
        for j in range(n):
            if tmp_s[j] != t[j]:
                cnt = cnt + 1

        if cnt < count:
            count = cnt 


    return count


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

string G[12];

void dfs(int x, int y) {
  G[y][x] = '0';
  for(int i = -1; i <= 1; i += 2) {
    for(int j = 0; j < 2; ++j) {
      int nx = x + i*j;
      int ny = y + i*(1-j);
      if(nx < 0 || nx >= 12) continue;
      if(ny < 0 || ny >= 12) continue;
      if(G[ny][nx] == '0') continue;
      dfs(nx, ny);
    }
  }
}

int solve() {
  int res = 0;
  for(int i = 0; i < 12; ++i) {
    for(int j = 0; j < 12; ++j) {
      if(G[i][j] == '1') {
	dfs(j, i);
	++res;
      }
    }
  }
  return res;
}

int main() {
  while(cin >> G[0]) {
    for(int i = 1; i < 12; ++i) cin >> G[i];
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
int main ()
{
    char s[100];
    stack<int>A;
    int a,b;
    while(~scanf("%s",s))
    {
        if(s[0]=='+')
        {
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(a+b);
        }
        else if(s[0]=='-')
        {
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(b-a);
        }
        else if(s[0]=='*')
        {
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(a*b);
        }
        else
        {
            A.push(atoi(s));
        }
    }
    printf("%d\n",A.top());
    return 0;
}



Measured memory_bytes: 3228
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	string a,b;
	cin>>a;
	cin>>b;
	
	if(a.size()>b.size()) pf("GREATER");
	else if(a.size()<b.size()) pf("LESS");
	else{
		for0(i,a.size()){
			if(a[i]!=b[i]){
				if(a[i]>b[i]){ pf("GREATER"); return 0;}
				else{ pf("LESS"); return 0;}
				}
			}
		pf("EQUAL");
		}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll a,b,x;cin>>a>>b>>x;
    if(a==0){
        cout<<b/x+1<<endl;
    }else{
        cout<<b/x-(a-1)/x<<endl;
    }
}

Measured memory_bytes: 3588
n = int(input())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

ans = 0
surplus = 0

for i in range(n) :
    tmp = min(a[i],surplus)
    ans += tmp
    a[i] -= tmp
    if b[i] > a[i] :
        ans += a[i]
        surplus = b[i] - a[i]
    else :
        ans += b[i]
        surplus = 0

tmp = min(a[n],surplus)
ans += tmp
print(ans)


Measured memory_bytes: 24324
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

const int N=405;

typedef long long LL;

int n,h,de[N],f[N];

bool vis[N],bz[N];

int Get(int x)
{
	return (f[x]==x)?x:f[x]=Get(f[x]);
}

int main()
{
	for (int i=0;i<N;i++) f[i]=i;
	scanf("%d%d",&n,&h);
	for (int i=0,a,b,c,d,l,r;i<n;i++)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		l=(c==0)?a:-c; r=(d==0)?-b:d;
		l+=h; r+=h; vis[l]=vis[r]=1;
		de[l]++; de[r]--;
		a=Get(l); b=Get(r);
		f[b]=a;
	}
	for (int i=0;i<h;i++) if (de[i]>0)
	{
		printf("NO\n"); return 0;
	}
	for (int i=N-1;i>h;i--) if (de[i]<0)
	{
		printf("NO\n"); return 0;
	}
	for (int i=0;i<N;i++)
	{
		int j=Get(i); vis[j]|=vis[i]; bz[j]|=(de[i]!=0);
	}
	for (int i=0;i<N;i++) if (Get(i)==i && vis[i] && !bz[i])
	{
		printf("NO\n"); return 0;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

struct Node {
    int pos;
    int sum_cost;

    Node(int p, int c) {
        pos = p;
        sum_cost = c;
    }

    bool operator >(const Node &other) const {
        return sum_cost > other.sum_cost;
    }
};

struct Edge {
    int to_node;
    int cost;

    Edge(int n, int c) {
        to_node = n;
        cost = c;
    }
};

vector<vector<Edge>> adj; // 隣接行列
priority_queue<Node, vector<Node>, greater<Node>> pq; // ヒープ
int dist[10100];

int main() {
    int n; cin >> n;
    adj.resize(n);
    rep(i, n) {
        int u, k; cin >> u >> k;
        rep(j, k) {
            int v, c; cin >> v >> c;
            adj[u].emplace_back(Edge(v, c));
        }
    }

    // 初期化
    rep(i, n) {
        dist[i] = (i == 0) ? 0 : INT_INF;
        pq.push(Node(i, dist[i]));
    }

    while (!pq.empty()) {
        Node popped = pq.top();
        pq.pop();

        for (auto &edge: adj[popped.pos]) {
            Node next(edge.to_node, popped.sum_cost + edge.cost);
            if (next.sum_cost < dist[edge.to_node]) {
                pq.push(next);
                dist[edge.to_node] = next.sum_cost;
            }
        }
    }

    rep(i, n) {
        cout << i << ' ' << dist[i] << endl;
    }
}



Measured memory_bytes: 7856
#include <functional>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> adj[n];
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        if (a[u] > a[v]) adj[u].push_back(v);
        if (a[u] < a[v]) adj[v].push_back(u);
    }
    enum stat { UNKNOWN, WIN, LOSE };
    stat st[n];
    fill(st, st+n, UNKNOWN);
    for (int cnt = 0; cnt < n; ) {
        function<void(int)> check = [&](int j) {
            for (int k : adj[j]) {
                if (st[k] == LOSE) {
                    st[j] = WIN;
                    cnt++;
                    return;
                } else if (st[k] == UNKNOWN) 
                    return;
            }
            st[j] = LOSE;
            cnt++;
            return;
        };
        for (int j = 0; j < n; j++)
            if (st[j] == UNKNOWN) check(j);
    }
    for (int i = 0; i < n; i++) if (st[i] == WIN) cout << i+1 << ' ';
    cout << endl;
}


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

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

using namespace std;
typedef long long ll;
const int INF = 1001001001;

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct monster_t {
  ll X, H;
};

struct value_t {
  ll L, R, A;
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll D, A;
  while (cin >> N >> D >> A) {
    vector<monster_t> monsters(N);
    for (auto& x : monsters) cin >> x.X >> x.H;
    sort(monsters.begin(), monsters.end(), [&](auto& a, auto& b) {
      return a.X < b.X;
    });
    ll acc = 0, res = 0;
    queue<value_t> q;
    for (auto& x : monsters) {
      while (!q.empty() && q.front().R < x.X) {
        acc -= q.front().A;
        q.pop();
      }
      if (x.H - acc > 0) {
        ll cnt = (x.H - acc + A - 1) / A;
        res += cnt;
        q.push({x.X, x.X + 2 * D, cnt * A});
        acc += cnt * A;
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

d = [a]
a = sorted(a)
ans = a[q - 1] - a[0]

while True:
    newd = list()
    li = list()
    for sub in d:
        for c in sub:
            if c != a[0]:
                li.append(c)
            else:
                newd.append(li)
                li = list()
        newd.append(li)
        li = list()

    d = list()
    a = list()
    for li in newd:
        if len(li) < k:
            continue
        else:
            d.append(li)
            li = sorted(li)
            a.extend(li[0:len(li) - k + 1])
 
    a.sort()

    if len(a) >= q:
        ans = min(a[q - 1] - a[0], ans)
    else:
        break
print(ans)

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int N = 3e5 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(cr x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(cr x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(cr x) {put(x), putchar(' ');}
I void pr2(cr x) {put(x), puts("");}

int p[N];

bool check(cr l, cr r) {
	reg len = r - l + 1;
	if(len == 1) return 1;
	if(!(len & 1)) return 0;
	for(reg i = l + 1; i <= r; i += 2) if(p[i] ^ i) return 0;
	for(reg i = l, hl = 0, hr = 0; i <= r; i += 2) {
		if(p[i] < i) {
			if(p[i] < hl) return 0;
			hl = p[i];
		} else {
			if(p[i] < hr) return 0;
			hr = p[i];
		}
	} return 1;
}

int main() {
	reg n = read();
	fo(i, 1, n) p[i] = read();
	reg L = 1, mx = 0;
	fo(i, 1, n) {
		mx = _max(mx, p[i]);
		if(mx == i) {
			if(!check(L, i)) {puts("No"); return 0;}
			L = i + 1;
		}
	} puts("Yes");
	return 0;
}



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

int main()
{
  ll N;
  cin >> N;
  ll index = -1;
  for (ll i = 2; i * (i - 1) / 2 < N + 1; ++i)
  {
    if (i * (i - 1) / 2 == N)
    {
      index = i;
    }
  }
  if (index == -1)
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << index << endl;
  ll each_len = index - 1;
  vector<vector<ll>> cordinate(each_len);
  ll cnt = 1;
  for (ll i = 0; i < each_len; ++i)
  {
    for (ll j = 0; j < i + 1; ++j)
    {
      cordinate.at(i).push_back(cnt);
      cnt += 1;
    }
  }
  vector<ll> temp;
  for (ll i = 0; i < each_len; ++i)
  {
    temp = cordinate.at(i);
    for (ll j = i + 1; j < each_len; ++j)
    {
      temp.push_back(cordinate.at(j).at(i));
    }
    cout << each_len;
    for (ll j = 0; j < each_len; ++j)
    {
      cout << ' ' << temp.at(j);
    }
    cout << endl;
  }
  cout << each_len;
  for (ll i = 0; i < each_len; ++i)
  {
    cout << ' ' << cordinate.at(i).at(cordinate.at(i).size() - 1);
  }
  cout << endl;


  // for (ll i = 0; i < each_len; ++i)
  // {
  //   for (ll j = 0; j < cordinate.at(i).size(); ++j)
  //   {
  //     cout << cordinate.at(i).at(j) << ' ';
  //   }
  //   cout << endl;
  // }
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[2001];
	cin>>n;
	int i,j,k,z=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(i=1;i<=n-2;i++)
	{
		for(j=i+1;j<=n-1;j++)
		{
			for(k=j+1;k<=n;k++)
			{
				if(a[i]+a[j]>a[k])
				{
					z++;
				}
			}
		}
	}
	cout<<z<<endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0; i<n; i++){
        int val;
        cin >> val;
        v.push_back(val);
    }
    sort(v.begin(), v.end(), greater<int>());
    
    int alice = 0;
    int bob = 0;
    for(int i=0; i<n/2; i++){
        alice += v[i*2];
        bob += v[i*2+1];
    }
    if(n%2 == 1){
        alice += v.back();
    }
    
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


void Warshall_Floyd(ll N, vector<vector<ll>> &g) {
	repn(k, N) {
		repn(i, N) {
			repn(j, N) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int main() {

	string S;
	cin >> S;
	ll N = S.size();

	ll b = 1;

	rep(i, N) {
		if (S[i] != S[N - 1 - i]) { b = 0; }
	}

	ll M = (N - 1) / 2;

	rep(i, M) {
		if (S[i] != S[M - 1 - i]) { b = 0; }
		if (S[M + 1 + i] != S[N - 1 - i]) { b = 0; }
	}

	if (b == 1) { cout << "Yes"; }
	else { cout << "No"; }


	

	system("PAUSE");

}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,jm1[200009],jm2[200009],k,pas;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b>>k;
    for(i=1; i<=a; i++){
        cin>>c;
        jm1[i]=jm1[i-1]+c;
    }
    for(i=1; i<=b; i++){
        cin>>c;
        jm2[i]=jm2[i-1]+c;
    }
    ii=0;
    for(jj=1; jj<=b; jj++){
        if(jm2[jj]>k) break;
    }
    jj--;
    if(pas<ii+jj) pas=ii+jj;
    for(ii=1; ii<=a; ii++){
        if(jm1[ii]>k) break;
        while(jj>=1&&jm1[ii]+jm2[jj]>k) jj--;
        if(pas<ii+jj) pas=ii+jj;
    }
    cout<<pas;
    return 0;
}

Measured memory_bytes: 6776
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int i;
	long long ans[87];
	ans[0] = 2;
	ans[1] = 1;
	for(i=2;i<=N;i++) ans[i] = ans[i-1] + ans[i-2];
	printf("%lld",ans[N]);
	return 0;
}

Measured memory_bytes: 128
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"6 3
" => r"9",

r"6 4
" => r"error"
}

use std::cmp;
use std::cmp::{max, min};
use std::collections::HashSet;
use std::f32::MAX;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: i32,
        b: i32,
    }

    if a + b >= 10 {
        "error".to_string()
    } else {
        (a + b).to_string()
    }
}


Measured memory_bytes: 4352
//abc156_b.cpp
//Sat Feb 22 20:51:52 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll count = 1;
	ll ans = 0;
	while (count<=n){
		count = count * k;

		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<(int)(n);i++)
 
int main()
{
    int N;
    cin>>N;
    
    int a[N];
    for(int i=0;i<N;i++)
    {
        cin>>a[i];
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll  long long int
#define mod 1000000007
using namespace std;
vector<ll> edges[100001];
ll n,k;
ll ans;
ll fun(ll n,ll r){
    ll ans1=1;
    for(ll i=n;i>n-r;i--)ans1=(ans1%mod*i%mod)%mod;
    return ans1;
}
void dfs(ll v,ll p=-1){
   
    if(p==-1)ans=ans%mod*(fun(k-1,edges[v].size())%mod)%mod;
    else if(p==1)ans=ans%mod*(fun(k-2,edges[v].size()-1)%mod)%mod;
    else
        ans=ans%mod*(fun(k-2,edges[v].size()-1)%mod)%mod;
   
    for(auto i:edges[v]){
        if(i==p)continue;
        dfs(i,v);
    }
    
}
 
int main() {

    cin>>n>>k;
    ans=k;
    for(ll i=0;i<n-1;i++){
        ll x,y;
        cin>>x>>y;
        edges[x].push_back(y);
         edges[y].push_back(x);
    }
  
    dfs(1);
    cout<<ans<<endl;
}



Measured memory_bytes: 12524
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n;

int kaiseki(string s,int y) {
	int i = 0;
	string ns = "";

	int d = 0;
	if (s[0] == '['&&s[1] != '[') {
		
		i = 1;
		while (s[i] != ']') {
			d = d * 10 + (int)(s[i] - '0');

			i++;
		}

		return d;
	}
	while (i < s.length()) {
		if (s[i] == '['||s[i]==']') {
			ns += s[i];
			//cout << "a" << endl;
			i++;
		}
		else {
			ns.pop_back();
			int j = i;
			vector<int>m;
			//cout << "c" << endl;
			while (1) {
				//cout << "b" << endl;
				int d = 0;
				while (s[j] != ']') {
					d = d * 10 + (int)(s[j] - '0');
					j++;
				}
				if(y==0)m.push_back(d / 2 + 1);
				else m.push_back(d);
				if (s[j + 1] == ']') {
					sort(m.begin(), m.end());

					int x=0;
					/*
					for (int k = 0; k < (int)m.size(); k++) {
						cout << m[k] << endl;
					}
					*/
					for (int k = 0; k <=(int) m.size() / 2; k++) {
						x += m[k];

					}
					ns += to_string(x);
					ns += ']';
					i = j + 2;
					break;
				}
				j += 2;
			}

		}
	}
	//cout << ns << endl;
	return kaiseki(ns,1);
}

int main()
{
	cin >> n;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;

		int ans=0;
		ans = kaiseki(s,0);
		cout << kaiseki(s,0)<< endl;



	}



	return 0;
}



Measured memory_bytes: 3312
# greedy
N, K = map(int, input().split())

ans = 0
mod = [0]*K
for i in range(1, N+1):
  mod[i%K] += 1
  
for a_modk in range(K)  :
  b_modk = (K - a_modk) % K
  c_modk = (K - a_modk) % K
  if (b_modk + c_modk) % K == 0:
    ans += mod[a_modk] * mod[b_modk] * mod[c_modk]
print(ans)    

Measured memory_bytes: 4596
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
bool valid(int x){
    return x>=1&&x<=12;
}
int main(){
    int AA;R(AA);
    int v1=AA/100;
    int v2=AA%100;
    if(valid(v1)&&valid(v2))W("AMBIGUOUS");
    else if(valid(v1))W("MMYY");
    else if(valid(v2))W("YYMM");
    else W("NA");
    return 0;
}


Measured memory_bytes: 256