akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

l = []

for i in range(N):
    l += [i+1]*a[i]

for i in range(H):
    row = l[W*i:W*i+W]
    if i%2:
        row = row[::-1]

    for v in row:
        print(v, end=' ')
    print()

Measured memory_bytes: 44632
#include <iostream>

using namespace std;

int main(){
  /**
   * 考え方
   *  3桁の回文数は1桁目と2桁目が同じであれば成立する
   *  →1桁目と3桁目が同じか判定し、出力する文字を決める
   * ヒント
   *  string 型の文字列は添字を指定することで文字列の中から1文字だけを取り出せる
   *    ex) string str="12C45"; str[2]→C
   *  文字列も == で同じ文字列かどうか判定できる
   * 変数
   *  n : 3桁の正の整数 N, 指定した桁の数値を取り出したいので string 型で受け取る
   *  str : 判定結果「Yes」「No」を保持する値, 初期値を「No」とし、回文数であった場合のみ「Yes」を代入する
   */
  string n, str="No"; //文字列 n, str を定義
  cin >> n; //回文数(N)を入力
  if(n[0]==n[2]){ //入力された回文数の1桁目と3桁目が同じかどうか判定する
    str = "Yes"; //判定結果を「Yes」に変更
  }
  cout << str << endl; //結果を出力
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> x;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        x.push_back(temp);
    }

    for (int i = 0; i < N; i++)
    {
        ans += min(2 * x[i], 2 * abs(x[i] - K));
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

struct edge{
	int to,co,p;
};

vector<edge> vs[105];

int ds[105];
void bfs(int st){
	queue<mp> que;
	que.push(mp(0,st));
	memset(ds,-1,sizeof(ds));
	while(!que.empty()){
		mp pa=que.front();
		que.pop();
		int no=pa.sec,
			nd=pa.fir;
		if(ds[no]>=0)continue;
		ds[no]=nd;
		rep(i,vs[no].size()){
			int to=vs[no][i].to,
				ec=vs[no][i].co;
			if(ec<=0 || ds[to]>=0)continue;
			que.push(mp(nd+1,to));
		}
	}
}

int seen[105];
int dfs(int no,int gl,int f){
	if(no==gl)return f;
	for(int& i=seen[no]; i<vs[no].size(); i++){
		edge& e=vs[no][i];
		if(e.co<=0 || ds[e.to]<=ds[no])continue;
		int tf=dfs(e.to,gl,min(f,e.co));
		if(tf<=0)continue;
		e.co-=tf;
		vs[e.to][e.p].co+=tf;
		return tf;
	}
	return 0;
}

/*
??????????????????????????¨???

print "32 61"
for i in xrange(30):
	print ("%d %d %d" % (i,i+1,3))
	print ("%d %d %d" % (i,i+1,3))
print "0 31 1"

??§????????????
???????????????????????????gone?????\?????????????????????????????§????????????

?????£???????????¬???????£??????¨???????????????????????????iterate?????????????????????

(?????????AOJ??§?????????????????£???????????????????????????...)
*/

int dinic(int st,int gl){
	int res=0;
	for(;;){
		bfs(st);
		if(ds[gl]<0)break;
		for(;;){
			memset(seen,0,sizeof(seen));
			int f=dfs(st,gl,IINF);
			if(f<=0)break;
			res+=f;
		}
	}
	return res;
}
	
int n,m;
int main(void){
	scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		edge e;
		e.to=b; e.co=c; e.p=vs[b].size();
		vs[a].push_back(e);
		e.to=a; e.co=0; e.p=vs[a].size()-1;
		vs[b].push_back(e);
	}
	printf("%d\n",dinic(0,n-1));
	return 0;
}

Measured memory_bytes: 1260
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include <math.h>
#include<algorithm>
#include<map>
#include<string>

using namespace std;

int main(int argc,char** argv)
{

	int n;
	cin  >> n;
	int a,b;
	cin >> a >> b;
	if(n==1){
		cout << "Hello World" <<endl;
	}
	else{
		cout << a+b <<endl;
	}

	return 0;

}

Measured memory_bytes: 256
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
using ld = long double;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
#pragma endregion

const lint INF = 1ll << 60;
const int mod = 1000000007;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	string s;
	cin >> n >> k >> s;
	vector<int> d;
	int cnt = 1;
	lint ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == s[i + 1]) cnt++, ans++;
		else {
			d.emplace_back(cnt);
			cnt = 1;
		}
		if (cnt != 1 && n == n - 2) d.emplace_back(cnt);
	}
	for (int i = 0; i < min((int)d.size(), k); i++) {
		ans += 2;
	}
	if (ans >= n) ans = n - 1;
	cout << ans << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i] - 1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> mp;
    REP(i,n) {
        int x; cin >> x;
        mp[x]++;
    }
    bool two = false;
    for(auto p:mp) {
        if (p.second % 2 == 0) two = !two;
    }
    int ans = mp.size();
    if (two) ans--;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif


struct Question
{
	llong start_;
	llong end_;
};

class ABC122C
{
public:
	ABC122C()
	{
		cin >> n_;
		cin >> q_;
		cin >> input_;

		q_collection_.resize(q_);
		loop(i, q_)
		{
			cin >> q_collection_[i].start_;
			cin >> q_collection_[i].end_;
		}

	}
	void Run(void)
	{
		CountAll();

		llong ans;
		for(const auto & e: q_collection_)
		{
			ans = count_all_collection_[e.end_ - 1] - count_all_collection_[e.start_ - 1];
			cout << ans << endl;
		}
	}
private:
	llong n_;
	llong q_;
	llong count_;
	string input_;
	vector<Question> q_collection_;
	vector<llong> count_all_collection_;
	void CountAll(void)
	{
		count_all_collection_.resize(n_);
		count_all_collection_[0] = 0;
		count_all_collection_[1] = CheckAC(0);
		for(llong i = 1; i < n_-1; i++)
			count_all_collection_[i + 1] = count_all_collection_[i] + CheckAC(i);
	}
	llong CheckAC(llong index)
	{
		if (input_[index] == 'A' && input_[index+1] == 'C')
			return 1;
		return 0;
	}
};

int main()
{
//	ABC122B abc122b;
//	abc122b.Run();

	ABC122C abc122c;

	TimeStart();
	abc122c.Run();
	TimeEnd();

	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    rep(i, 5){ll x; cin >> x; if (x == 0){cout << i + 1 << endl; exit(0);}}
}

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


Measured memory_bytes: 3604
from operator import itemgetter


def main():
    n, m = [int(e) for e in input().split()]
    l = []
    for i in range(m):
        p, y = [int(e) for e in input().split()]
        l.append((i, p, y))

    sorted_l = sorted(l, key=itemgetter(1, 2))
    # print(l)
    # print(sorted_l)

    n_nums = []
    pref = None
    for e in sorted_l:
        p = e[1]
        if (pref is None) or p != pref:
            pref = p
            c = 1
        p_str = str(p).zfill(6)
        c_str = str(c).zfill(6)
        nums = p_str + c_str
        n_nums.append((e[0], nums))
        c += 1

    for num in sorted(n_nums, key=itemgetter(0)):
        print(num[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 37088
def solve(q)
  x = q.to_f / 2.to_f
  loop do
    x = x - (x ** 3 - q) / (3 * x ** 2)
    break if (x ** 3 - q).abs < 0.00001 * q
  end
  return x
end

loop do
  break if (q = $stdin.gets.to_i) == -1
  printf "%.6f\n", solve(q)
end

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a = ivec(n);
    sort(all(a), greater<int>());

    int cnt = 0;
    int it = 0;
    int ans = 0;
    while (cnt < n - 1) {
        if (cnt == 0) {
            ans += a[it];
            cnt++;
        } else {
            rep (j, 2) {
                ans += a[it];
                cnt++;
                if (cnt == n - 1) break;
            }
        }
        it++;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e5+5;
const ll p=1000000007;

int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}

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

int main(int argc, char *argv[]) {
        int pack_a = 0;
        int pack_b = 0;
        int pack_c = 0;

        std::cin >> pack_a;
        std::cin >> pack_b;
        std::cin >> pack_c;

        bool can_solve(false);
        if (pack_a + pack_b == pack_c) {
                can_solve = true;
        }
        if (pack_b + pack_c == pack_a) {
                can_solve = true;
        }
        if (pack_c + pack_a == pack_b) {
                can_solve = true;
        }

        std::cout << (can_solve ? "Yes" : "No") << std::endl;
        return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d;
    ll g;
    cin >> d >> g;
    vector<int> p(d);
    vector<ll> c(d),a(d);
    rep(i,d){
        cin >> p[i] >> c[i];
    }
    rep(i,d){
        a[i]=(i+1)*100*(p[i]-1);
    }
    ll ans=100000000000000000;
    for(int bit=0;bit<(1<<d);++bit){
        ll pr=0,preans=0;
        vector<int> t;
        for(int i=0;i<d;++i){
            if(bit&(1<<i)){
                pr+=((i+1)*100*p[i]+c[i]);
                preans+=p[i];
            }else{
                t.push_back(i);
            }
        }
        int x=0;
        ll res=0;
        for(auto u:t){
            if(res<a[u]) x=u;
            res=max(res,a[u]);
        }
        if(g>pr){
            ll y=g-pr;
            if(y%(100*(x+1))!=0 && (pr+res)>=g){
                preans+=(y/(100*(x+1))+1);
            }else if(y%(100*(x+1))==0 && (pr+res)>=g){
                preans+=y/(100*(x+1));            
            }else{
                continue;
            }
        }
        ans=min(ans,preans);
    }
    cout << ans << "\n";
    return 0;
}   

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

using namespace std;

int main () {

    cout << fixed << setprecision(10);

    int n, k;
    cin >> n >> k;
    vector<double> E(n);
    for (int i = 0; i < n; i++) {
        double p;
        cin >> p;
        E[i] = (p + 1) / 2.0;
    }
    double t = 0.0;
    for (int i = 0; i < k; i++) {
        t += E[i];
    }
    double a = t;
    for (int i = 1; i < n - k + 1; i++) {
        t -= E[i - 1];
        t += E[i + k - 1];
        if (a < t) {
            a = t;
        }
    }
    cout << a << "\n";
    return 0;
}

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

int main()
{
	int n; cin >> n;
	int x[n], y[n];	for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; }

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

	double tmpDist = 0;
	int cnt = 0;
	do {
		double tmpSum = 0;
		for (int i = 0; i < n - 1; i++) {
			int next = vec.at(i + 1);
			int prev = vec.at(i);
			tmpSum += sqrt((x[next] - x[prev]) * (x[next] - x[prev]) + (y[next] - y[prev]) * (y[next] - y[prev]));
		}
		tmpDist += tmpSum;
		cnt++;
				
	} while (next_permutation(vec.begin(), vec.end()));

	cout << fixed << setprecision(11) << tmpDist / cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

typedef struct edge_{
	int to,cost;
}edge;

class graph{ 
	typedef long cost_type;
	typedef int edge_type;
	typedef pair<cost_type,edge_type> P; 	//first:最短経路コスト second:頂点番号
	
	
	private:
		vector<vector<edge> > gra; 	//グラフ本体
		priority_queue<P,vector<P>,greater<P> > que; 	//最短経路の値の小さいものから取り出せる
		edge_type V; 	//頂点の個数
	  vector<cost_type> dp; 	//開始地点からの最小コストを格納する配列
	
	public:
		void init(int num){
			V = num;
			dp.assign(V,0x7FFFFFFF);
			gra.assign(V,vector<edge>());
		}


		void setCost(edge_type from , edge_type to , edge_type cost){
			edge e = {to , cost};
			edge e2 = {from , cost};
			gra[from].push_back( e );
			gra[to].push_back(e2);
		}	

		
		void setDirectCost(edge_type from , edge_type to , edge_type cost){
			edge e = {to , cost};
			gra[from].push_back( e );
		}	


		void dijkstra(edge_type s){
			dp[s] = 0;
			que.push(pair<cost_type,edge_type>(0,s)); 

			while(!que.empty()){
				P p = que.top();
				que.pop();
				edge_type v = p.second;
				if( dp[v] > p.first ) continue;
				for(edge_type i = 0 ; i < gra[v].size() ; i++ ){
					edge e = gra[v][i];
					if( dp[e.to] > dp[v] + e.cost ){
						dp[e.to] = dp[v] + e.cost;
						que.push(pair<cost_type,edge_type>(dp[e.to],e.to));
					}
				}
			}
		}

		cost_type getCost(edge_type to){
			return dp[to];
		} 

};

int main(){
	graph g;
	int n;
	cin >> n;
	g.init(n);
	rep(i,0,n){
		int from , k;
		cin >> from >> k;
		rep(i,0,k){
			int to;
			long cost;
			cin >> to >> cost;
			g.setDirectCost(from,to,cost);
		}

	}

	g.dijkstra(0);

	rep(i,0,n)
		cout << i << " " << g.getCost(i) << endl;

	ret 0;
}


Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,s,k;
int main()
{
    scanf("%d%d%d",&n,&k,&s);
    rep(i,1,k) printf("%d ",s);
    rep(i,k+1,n) {
        printf("%d ",s==1000000000?1:1000000000);
    }
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <set>
#include <fstream>
#include <cstring>
#include <climits>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

#define ll long long
#define mod 1000000007

pair<ll, ll> dp[101][100001];

//dp[i][j].first is the no of ways to distribute j candies among students i onwards
//dp[i][j].second is the no of ways to distribute atmost j candies among students i onwards

ll solve_ite(int* a, int n, int total_candies) {

	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j <= total_candies; j++) {
			if (j > a[i])
				dp[i][j].first = dp[i + 1][j].second - dp[i + 1][j - a[i] - 1].second + mod;
			else
				dp[i][j].first = dp[i + 1][j].second;
			if (j == 0)
				dp[i][j].second = dp[i][j].first;
			else
				dp[i][j].second = dp[i][j].first + dp[i][j - 1].second;
			dp[i][j].first %= mod;
			dp[i][j].second %= mod;
		}
	}
	return dp[0][total_candies].first;
}

int main() {

	int n, k;
	cin >> n >> k;
	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < 101; ++i) {
		for (int j = 0; j < 100001; ++j) {
			dp[i][j].first = 0;
			dp[i][j].second = 0;
		}
	}
	dp[n][0].first = 1;
	dp[n][0].second = 1;
	for (int j = 0; j <= k; ++j) {
		dp[n][j].second = 1;
	}
	cout << solve_ite(a, n, k);

	return 0;
}

Measured memory_bytes: 158208
#!/usr/bin/ruby
n=gets.to_i
x=40.downto(0).find{|i|n>=(1<<i)-1}
q=[*1..x]
n-=(1<<x)-1
(x-1).downto(0){|i|
	next if n<1<<i
	x+=1
	q.insert(i,x)
	n-=1<<i
}
q+=[*1..q.size]
p q.size
puts q*' '

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define inver(a) power(a,mod-2)
using namespace std;
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;}
typedef long long ll;
const int mod=1e9+7;
const int maxn=1000+5;
const int maxk=70+5;
int n,k;
int an;
int r[maxk],b[maxk];
int fac[maxn];
int inv[maxn];
int num[maxk];
bool vis[maxk];
char s[maxk];
vector<int> a; 
inline int add(int x) {return x>=mod?x-mod:x;}
ll power(ll x,ll y)
{
	ll re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
inline int binom(int x,int y)
{
	return (ll)fac[x]*inv[y]%mod*inv[x-y]%mod;
}
bool check()
{
	memset(vis,0,sizeof(vis));
	for(int i=0,j=1;i<a.size();++i)
	{
		while(j<=k&&s[j]!='r') ++j; if(j>k) return 0;
		r[i]=j,vis[j++]=1;
	}
	for(int i=0,j=1;i<a.size();++i) if(a[i]>=2)
	{
		Cmax(j,r[i]+1);
		while(j<=k&&s[j]!='b') ++j; if(j>k) return 0;
		b[i]=j,vis[j++]=1;
	}
	for(int i=0,j=1;i<a.size();++i) if(a[i]>=3)
	{
		Cmax(j,b[i]+1);
		int T=a[i]-2; while(T--)
		{
			while(j<=k&&vis[j]) ++j; if(j>k) return 0;
			vis[j++]=1;
		}
	}
	return 1;
}
void dfs(int rest,int las)
{
	if(check())
	{
		int v=a.size()+1;
		for(int i=0;i<a.size();++i)
		{
			v+=num[a[i]];
			if(a[i]>1) v+=2;
		}
		int re=(ll)binom(rest+v-1,rest)*fac[a.size()]%mod;
		for(int i=0,j;i<a.size();i=j)
		{
			j=i; while(j<a.size()&&a[j]==a[i]) ++j;
			re=(ll)re*inv[j-i]%mod;
		}
		an=add(an+re);
	}
	for(int i=1;i<=las;++i)
	{
		if(num[i]+1>rest) break;
		a.push_back(i);
		dfs(rest-num[i]-1,i);
		a.pop_back();
	}
}
void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
	{
		fac[i]=(ll)fac[i-1]*i%mod;
	}
	inv[n]=inver(fac[n]);
	for(int i=n;i>=1;--i)
	{
		inv[i-1]=(ll)inv[i]*i%mod;
	}
}
int sol()
{
	init(1000);
	an=1;
	num[1]=1;
	num[2]=1;
	for(int i=3;i<=70;++i) num[i]=num[i-1]+2;
	for(int i=1;;++i)
	{
		if(num[i]>n) break;
		a.push_back(i);
		dfs(n-num[i],i);
		a.pop_back();
	}
	return an;
}
int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	printf("%d\n",sol());
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
  #include <math.h>
  #include <stdlib.h>
  int logarithme(long long int x, long long int base)
{
  return log(x) / log(base);
}
  int main() {
    long long int H,C=1,tem=1;
    int L;
    scanf("%lld",&H);
    L=logarithme(H,2);
    for (int i = 0; i <L; i++) {
      C+=tem*2;
      tem*=2;
    }
    printf("%lld",C);
    return 0;
  }


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,d;
  cin>>n>>d;
 long long  int x[n];
  long long int y[n];
 long long  int count=0;
  for(long long int i=0;i<n;i++)
  {
    cin>>x[i]>>y[i];
    if((x[i]*x[i]+y[i]*y[i])<=(d*d))
      count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
       

template <typename T>
class CumulativeSum2D {
  vector<vector<T>> S;

 public:
  CumulativeSum2D(const vector<vector<T>>& a) {
    int n = a.size(), m = a[0].size();
    S.resize(n + 1, vector<T>(m + 1, 0));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        S[i + 1][j + 1] = S[i + 1][j] + S[i][j + 1] - S[i][j] + a[i][j];
      }
    }
  }
  T query(int i1, int j1, int i2, int j2) {
    return S[i2][j2] - S[i2][j1] - S[i1][j2] + S[i1][j1];
  }
};

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<int>> S(H, vector<int>(W));
  for (int i = 0; i < (int)(H); ++i) for (int j = 0; j < (int)(W); ++j) {
    char c;
    cin >> c;
    S[i][j] = (c == '1');
  }

  CumulativeSum2D<int> cum(S);

  int ans = 1e9;
  for (int s = 0; s < (int)(1 << (H - 1)); ++s) {
    int cost = 0;
    vector<int> y;
    y.push_back(0);
    for (int i = 0; i < (int)(H - 1); ++i) if ((s >> i) & 1) {
      y.push_back(i + 1);
      ++cost;
    }
    y.push_back(H);

    int Y = y.size();
    int l = 0;
    for (int r = 1; r <= W;) {
      bool ok = true;
      for (int j = 0; j < (int)(Y - 1); ++j) ok &= (cum.query(y[j], l, y[j + 1], r) <= K);
      if (!ok) {
        if (r == l + 1) goto HOGE;
        ++cost;
        l = r - 1;
      } else {
        ++r;
      }
    }
    chmin(ans, cost);
  HOGE:;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main() {
	
	int arr[3][3];
	for (int i=0; i<3; i++) for (int j=0; j<3; j++) cin >> arr[i][j];
	
	int x;
	cin >> x;
	bool got[3][3];
	memset(got, 0, sizeof got);
	
	for (int i=0; i<x; i++) {
		int t;
		cin >> t;
		for (int j=0; j<3; j++) {
			for (int k=0; k<3; k++) {
				if (arr[j][k] == t) got[j][k] = true;
			}
		}
	}
	
	if (got[0][0] && got[0][1] && got[0][2]) {
		cout << "Yes" << endl;
	}
	else if (got[1][0] && got[1][1] && got[1][2]) {
		cout << "Yes" << endl;
	}
	else if (got[2][0] && got[2][1] && got[2][2]) {
		cout << "Yes" << endl;
	}
	else if (got[0][0] && got[1][0] && got[2][0]) {
		cout << "Yes" << endl;
	}
	else if (got[0][1] && got[1][1] && got[2][1]) {
		cout << "Yes" << endl;
	}
	else if (got[0][2] && got[1][2] && got[2][2]) {
		cout << "Yes" << endl;
	}
	else if (got[0][0] && got[1][1] && got[2][2]) {
		cout << "Yes" << endl;
	}
	else if (got[2][0] && got[1][1] && got[0][2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}


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

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define lb long double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

char buf[30];
bool vis[30];

int main()
{
    scanf("%s",buf);
    ll n=strlen(buf);
    for (ll i=0;i<n;i++) {
        vis[buf[i]-'a']=1;
    }
    buf[n]='a'-1;
    for (ll i=n;i>=0;i--) {
        for (char c=buf[i]+1;c<='z';c++) {
            if (!vis[c-'a']) {
                buf[i]=c;
                buf[i+1]=0;
                printf("%s\n",buf);
                return 0;
            }
        }
        if (buf[i]>='a'&&buf[i]<='z') vis[buf[i]-'a']=0;
    }
    printf("-1\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

template <class T> class MultiArray2
{
    public:
        T* _a;
        int _w;
        int _h;
        MultiArray2(int w, int h, bool clr = false)
        {
            _w = w; _h = h;
            _a = new T[_w * _h];
            if(clr) memzero();
        }

        void memzero()
        {
            memset(_a, 0, _w * _h * sizeof(T));
        }

        ~MultiArray2()
        {
            delete _a;
        }

        T* operator[](int i)
        {
            return _a + (i * _h);
        }

        void print()
        {
            for( int j = 0; j < _h; j++ )
            {
                for( int i = 0; i < _w; i++ )
                {
                    cout << (*this)[i][j] << " ";
                }
                cout << endl;
            }
        }
};

void bithakidasi(_LL *a, int n, int keta)
{
    int r = 0;
    for(int k = keta - 1; k >= 0; k-- )
    {
        if( r >= n ) return;
        int tr = r;
        for(tr = r; tr < n; tr++)
        {
            if( (a[tr] & (1LL << k)) == 0 ) continue;
            if( tr != r ) swap(a[r], a[tr]);
            break;
        }

        if( (a[r] & (1LL << k)) == 0 ) continue;

        for(int i = 1; i < n; i++)
        {
            if( i == r ) continue;
            if( (a[i] & (1LL << k)) != 0 ) 
            a[i] ^= a[r];
        }

        if( (a[0] & (1LL << k)) == 0 ) a[0] ^= a[r];
        r++;
    }
}

int main()
{
    _LL n = 0;
    cin >> n;
    MultiArray2<char> a(n, 60);
    char sum[60];
    bool hasm[60];
    rep(j, 60) sum[j] = 0;
    rep(j, 60) hasm[j] = false;
    rep(i, n)
    {
        _LL t;
        cin >> t;
        rep(j, 60)
        {
            a[i][j] = ((t & (1LL << j)) == 0) ? 0 : 1;
            if(a[i][j]) hasm[j] = true;
            sum[j] = sum[j] ^ a[i][j];
        }
    }


    _LL ans = 0;
    _LL leftrank = n;

    int bit[60];
    int index = 0;
    _LL *ta = new _LL[n];
    rep(i, n) ta[i] = 0;

    int *x = new int[n];

    rep(ij, 60)
    {
        int j = 60 - ij - 1;
        if( !hasm[j] ) continue;
        if( sum[j] == 1 )
        {
            ans += (1LL << j);
        }
        else
        {
            rep(i, n) ta[i] = (ta[i] << 1) + a[i][j];
            bit[index++] = j;
        }
    }
//    rep(j, index) cout << ta[j] << endl;
    bithakidasi(ta, n, index);
//    cout << endl;
//    rep(j, index) cout << ta[j] << endl;
    rep(j, index)
    {
        if( ta[0] & (1LL << j) )
        {
            ans += 2 * (1LL << bit[index - 1 - j]);
        }
    }

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

Measured memory_bytes: 9832
h,n=map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())
dp = [0]*(h+1)
for i in range(h+1):
    dp[i]=1000000000
dp[h]=0
for i in range(h+1):
    now=h-i
    for j in range(n):
        now2=max(now-a[j],0)
        dp[now2]=min(dp[now2],(dp[now]+b[j]))
print(dp[0])

Measured memory_bytes: 41708
import bisect
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
from operator import mul

import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, K = list(map(int, input().split()))

ans = 0
if K == 0:
    print(N ** 2)
    exit()
# K < b <= N
for b in range(K + 1, N + 1):
    nk = (N - K)
    bk = (b - K)
    ans += nk // b * bk + min((nk % b) + 1, bk)
print(ans)


Measured memory_bytes: 13652
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

bool check(const string& s,char c) {
    bool flag = true;
    REP(i,s.size()) if (s[i] != c) flag = false;
    return flag;
}

void solve() {
    string s;
    cin >> s;
    // 文字のカウント
    map<char,int> mp;
    for(auto const &it: s) {
        if (mp.count(it) == 0) mp[it] = 0;
        mp[it]++;
    }
    int mini_cnt = INF;
    for (auto const &it: mp) {
        int cnt = 0;
        string cs = s;
        while(!check(cs,it.first)) {
            cnt++;
            string ns;
            REP(i,cs.size()-1) ns.push_back((cs[i] == it.first || cs[i+1] == it.first) ? it.first : '.');
            cs = ns;
        }
        chmin(mini_cnt,cnt);
    }

    cout << mini_cnt << endl;
}

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


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n), x(n, 0);
	rep(i, n) cin >> a.at(i);
	x.at(0) = a.at(0);
	rep(i, n / 2) {
		x.at(0) = x.at(0) - a.at(2 * i + 1) + a.at(2 * i + 2);
	}
	reps(i, 1, n - 1) x.at(i) = 2 * a.at(i - 1) - x.at(i - 1);
	x.at(n - 1) = 2 * a.at(n - 1) - x.at(0);
	rep(i, n) cout << x.at(i) << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;

    if (a < b && b < c){
        puts("Yes");
        return 0;
    }
    else{
        for(int i=0;i<k;i++){
            if (a < b && b < c){
                break;
            }
            else if(a>=b)    b *= 2;
            else{
                c *= 2; 
            }
        }
    }

    if (a < b && b < c)
        puts("Yes");
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct street{
	int x1,y1,x2,y2;
};

vector<street> matatabi;
Int road[20][20];

int main() {
	int n;
	cin>>n;
	while(n--){
		matatabi.clear();
		int xx,yy;
		cin>>xx>>yy;
		int k=in();
		int i;
		for(i=0;i<k;i++){
			street buf;
			cin>>buf.x1>>buf.y1>>buf.x2>>buf.y2;
			if(buf.x1>buf.x2){
				buf.x1=buf.x2;
				buf.x2=buf.x1+1;
			}
			if(buf.y1>buf.y2){
				buf.y1=buf.y2;
				buf.y2=buf.y1+1;
			}
			matatabi.push_back(buf);
		}
		int x,y;
		road[0][0]=1;
		for(x=0;x<xx;x++){
			road[0][x+1]=road[0][x];
			for(i=0;i<k;i++){
				if(matatabi[i].x1==x&&matatabi[i].y1==0&&matatabi[i].x2==x+1&&matatabi[i].y2==0){
					road[0][x+1]=0;
				}
			}
		}
		for(y=0;y<yy;y++){
			road[y+1][0]=road[y][0];
			for(i=0;i<k;i++){
				if(matatabi[i].y1==y&&matatabi[i].x1==0&&matatabi[i].y2==y+1&&matatabi[i].x2==0){
					road[y+1][0]=0;
				}
			}
		}
//cout<<xx<<" "<<yy<<endl;
		for(x=1;x<=xx;x++){
			for(y=1;y<=yy;y++){
				road[y][x]=road[y-1][x]+road[y][x-1];
				for(i=0;i<k;i++){
					if(matatabi[i].y1==y-1&&matatabi[i].x1==x&&matatabi[i].y2==y&&matatabi[i].x2==x){
						road[y][x]-=road[y-1][x];
					}
				}
				for(i=0;i<k;i++){
					if(matatabi[i].x1==x-1&&matatabi[i].y1==y&&matatabi[i].x2==x&&matatabi[i].y2==y){
						road[y][x]-=road[y][x-1];
					}
				}
			}
		}
		if(road[yy][xx])cout<<road[yy][xx]<<endl;
		else cout<<"Miserable Hokusai!"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
	long long n{}, m{}, limit{};

	scanf("%lld%lld", &n, &m);
	limit = m / n;
	for (long long i = limit; i > 0; --i)
	{
		if (m % i) continue;
		printf("%ld\n", i);
		break;
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <double> vd;

vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}

//int cnt =0;
//
//void SieveOfEratosthenes(int n)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
//

//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}
long long int mx = 1000000000000000000;

long long int power(long long int base, long long int powerRaised)
{
    if (powerRaised != 0)
        return (base*power(base, powerRaised-1));
    else
        return 1;
}


int main() {
    
    int a,b,c,n;
    
    scanf("%d/%d/%d",&a,&b,&c);
    
    if(a<=2019&&b<=4&&c<=30)cout << "Heisei" << endl;
    else cout << "TBD" << endl;
    
    
    
    
    return 0;
}
 
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



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

   int n;
   cin>>n;
   if(n>=400 and n<=599){
       cout<<8;
   }else if(n>=600 and n<=799){
       cout<<7;
   }
   else if(n>=800 and n<=999){
       cout<<6;
   }else if(n>=1000 and n<=1199){
       cout<<5;
   }
   else if(n>=1200 and n<=1399){
       cout<<4;
   }else if(n>=1400 and n<=1599){
       cout<<3;
   }else if(n>=1600 and n<=1799){
       cout<<2;
   }else if(n>=1800 and n<=1999){
       cout<<1;
   }

}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef struct tri{
  int Index;
  int number;
  int Prefecture;
  ll year;
}T;

#define REP(i,N) for(i=0;i<N;i++)
int N,M;
vector<T> v;

bool pairCompIndex(T& firstElof, T& secondElof){
  return firstElof.Index < secondElof.Index;
}

bool pairCompYear(T& firstElof, T& secondElof){
  return firstElof.year < secondElof.year;
}

int main(void){
  cin >> N >> M;
  int i;
  v.resize(M);
  vector<int> num(N,0);

  REP(i,M){
    v[i].Index = i;
    cin >> v[i].Prefecture >> v[i].year;
  }

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

  REP(i,M){
    v[i].number = ++num[v[i].Prefecture];
  }

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

  REP(i,M){
    printf("%06d%06d\n",v[i].Prefecture,v[i].number);
  }
  return 0;
}

Measured memory_bytes: 4224
#line 1 "main.cpp"

/**
 * @title Template
 */

#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

#line 2 "/Users/kodamankod/Desktop/Programming/Library/other/chmin_chmax.cpp"

template <class T, class U>
constexpr bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { 
    lhs = rhs; 
    return true; 
  }
  return false;
}

template <class T, class U>
constexpr bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { 
    lhs = rhs; 
    return true; 
  }
  return false;
}

/**
 * @title Chmin/Chmax
 */
#line 2 "/Users/kodamankod/Desktop/Programming/Library/other/range.cpp"

#line 4 "/Users/kodamankod/Desktop/Programming/Library/other/range.cpp"

class range {
public:
  class iterator {
  private:
    int64_t M_position;

  public:
    constexpr iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { ++M_position; }
    constexpr bool operator != (iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }

  };

  class reverse_iterator {
  private:
    int64_t M_position;
  
  public:
    constexpr reverse_iterator(int64_t position) noexcept: M_position(position) { }
    constexpr void operator ++ () noexcept { --M_position; }
    constexpr bool operator != (reverse_iterator other) const noexcept { return M_position != other.M_position; }
    constexpr int64_t operator * () const noexcept { return M_position; }

  };
  
private:
  const iterator M_first, M_last;

public:
  constexpr range(int64_t first, int64_t last) noexcept: M_first(first), M_last(std::max(first, last)) { }
  constexpr iterator begin() const noexcept { return M_first; }
  constexpr iterator end() const noexcept { return M_last; }
  constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(*M_last - 1); } 
  constexpr reverse_iterator rend() const noexcept { return reverse_iterator(*M_first - 1); } 

};

/**
 * @title Range
 */
#line 2 "/Users/kodamankod/Desktop/Programming/Library/other/rev.cpp"

#include <type_traits>
#include <iterator>
#line 6 "/Users/kodamankod/Desktop/Programming/Library/other/rev.cpp"

template <class T>
class rev_impl {
public:
  using iterator = typename std::decay<T>::type::reverse_iterator;

private:
  const iterator M_begin;
  const iterator M_end;

public:
  constexpr rev_impl(T &&cont) noexcept: M_begin(std::rbegin(cont)), M_end(std::rend(cont)) { }
  constexpr iterator begin() const noexcept { return M_begin; }
  constexpr iterator end() const noexcept { return M_end; }

};

template <class T>
constexpr decltype(auto) rev(T &&cont) {
  return rev_impl<T>(std::forward<T>(cont));
}

/**
 * @title Reverser
 */
#line 16 "main.cpp"

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  i32 X;
  std::cin >> X;
  std::cout << 10 - X / 200 << '\n';
  return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a[2000], cost[2000];
	int n;
	long long x;
	cin >> n >> x;
	rep(i, n)cin >> a[i];
	rep(i, n)cost[i] = a[i];

	long long ans = 1LL<<60;
	rep(k,n) {
		rep(i, n)cost[i] = min(cost[i] ,a[(i - k + n) % n]);
		long long c = x*k;
		rep(i, n)c += cost[i];
		ans = min(ans, c);
	}

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

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		String n = as.next();

		String[] strArray = n.split("");

		int pcount = 0;



		for(int i=0;i<strArray.length;i++) {

			if(strArray[i].equals("+")){
				pcount += 1;
			}else if(strArray[i].equals("-")) {
				pcount -= 1;
			}
		}

		System.out.println(pcount);
	}
}

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#include <cmath>
#include<string>
#define ll long long
int main(){
      ll a,b,h,m;
      cin>>a>>b>>h>>m;
     long double ag=30*h+0.5*m-6*m;
  //cout<<m<<endl;
      long double rd=ag* (M_PI/180);
      long double val=cos(rd);
     // cout<<val<<endl;
     long double ans=a*a+b*b-2*a*b*val;
      ans=sqrt(ans);
     // cout<<=pow(a,(double)2)<<endl;
      cout << fixed << setprecision(20) << ans << endl; 
     return 0;
  //4.56425719433005561143

     
    
}


Measured memory_bytes: 4160