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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, K, S;
	cin >> N >> K >> S;

	if(S == 1){
		for(int i=0; i<N; i++){
			if(i<K){
				printf("1");
			}
			else{
				printf("2");
			}
			if(i!=N-1){
				printf(" ");
			}
			else{
				printf("\n");
			}
		}
		return 0;
	}
	if(K == N){
		for(int i=0; i<N; i++){
			printf("%lld", S);
			if(i!=N-1){
				printf(" ");
			}
			else{
				printf("\n");
			}
		}
		return 0;
	}
	if(K == 0){
		if(S == 2){
			for(int i=0; i<N; i++){
				printf("%lld", 3LL);
				if(i!=N-1){
					printf(" ");
				}
				else{
					printf("\n");
				}
			}
		}
		else{
			for(int i=0; i<N; i++){
				printf("%lld", S-1);
				if(i!=N-1){
					printf(" ");
				}
				else{
					printf("\n");
				}
			}
		}
		return 0;
	}

	for(int i=0; i<N; i++){
		if(i < K){
			if((i % 2) == 0){
				printf("1");
			}
			else{
				printf("%lld", S-1);
			}
		}
		if(i == K){
			printf("%lld", S);
		}
		if(i > K){
			printf("%lld", S-1);
		}
		if(i!=N-1){
			printf(" ");
		}
		else{
			printf("\n");
		}
	}
	return 0;
}



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

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

int main(){
    ll Q;
    cin >> Q;

    ull f = 0;

    while(Q--){
        ll a;
        cin >> a;

        ll i;
        if(a<=3){
            cin >> i;
        }
        
        switch(a){

            // test
            case 0:
            if((f>>i)&1){
                p(1);
            }else{
                p(0);
            }
            break;

            // set
            case 1:
            f |= 1LL<<i;
            break;

            // clear
            case 2:
            {
                ll mask = ~(1LL<<i);
                f &= mask;
            }
            break;

            // flip
            case 3:
            {
                ll mask = 1LL<<i;
                f ^= mask;
            }
            break;

            // all
            case 4:
            {
                ull all_one = -1;
                if(f==all_one){
                    p(1);
                }else{
                    p(0);
                }

            }
            break;

            // any
            case 5:
            if(f==0){
                p(0);
            }else{
                p(1);
            }
            break;

            // none
            case 6:
            if(f==0){
                p(1);
            }else{
                p(0);
            }
            break;

            // count
            case 7:
            {
                ll count = 0;
                ull temp = f;
                while(temp){
                    if(temp&1){
                        count++;
                    }
                    temp = temp>>1;
                }
                p(count);
            }
            break;

            // val
            case 8:
            p(f);
            break;
        }
    }

    return 0;
}


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

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

    if (a >= k)
    {
        cout << k << endl;
        
    }else if ((a+b)>=k)
    {
        cout << a << endl;
    }
    else
    {
        cout << a-(k-(a+b)) << endl;
    }
}


Measured memory_bytes: 3616
/***************************************************
 * Problem Name : B.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-02-16
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    int n;
    cin >> n;
    bool f = false;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;

        if (! (x & 1) ) {
            if (x % 3 == 0 || x % 5 == 0) {
            } else {
                f = true;
            }
        }
    }

    if (!f) cout << "APPROVED";
    else cout << "DENIED\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  
  if( (s.substr(2,1) == s.substr(3,1) ) && (s.substr(4,1) == s.substr(5,1) ) ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
       
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N)
{
    ll ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ll cnt = 0;
        if (i % 2 == 0)
            continue;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
                cnt++;
        }
        if (cnt == 8)
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int k, x;
    cin >> k >> x;

    if(k * 500 >= x){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;

}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#include"atcoder/all"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace atcoder;
typedef long long ll;
int main(){
  ll N,Q,i,a,t,l,r;scanf("%lld%lld",&N,&Q);
  fenwick_tree<ll> B(N);
  for(i=0;i<N;i++){
    scanf("%lld",&a);
    B.add(i,a);
  }
  for(i=0;i<Q;i++){
    scanf("%lld%lld%lld",&t,&l,&r);
    if(t == 0) B.add(l,r);
    else printf("%lld\n",B.sum(l,r));
  }
}

Measured memory_bytes: 8220
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	string S, T; cin >> S >> T;
	int sz = S.length();
	int res = 0;
	for (int i = 0; i < sz; ++i)
		res += (S[i] != T[i]);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3860
s = input()
k = int(input())

lst = []
ch = ''
cnt = 0
for c in s:
    if c == ch:
        cnt += 1
    else :
        lst.append([ch, cnt])
        ch = c
        cnt = 1
lst.append([ch, cnt])
ans = 0
if len(lst) == 2:
    print((lst[1][1] * k) // 2)
    exit()
for ch, cnt in lst:
    ans += cnt // 2
# print(lst, lst[-1][0], lst[1][0])
if lst[-1][0] == lst[1][0] and (lst[-1][1] + lst[1][1]) % 2 == 0:
    print(ans * k + k -1)
else :
    print(ans * k)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
long  n;
int  ans = 100;
int f(long a) { int r = 0;
  for (; a;r++)
    a /= 10;
  return r;
}
int main()
{
  cin >> n;
  for (long i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      ans = min(ans, max(f(i), f(n / i)));
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;

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

//                  9876543210
constexpr int mod = 1000000007;
class mint {
private:
    std::int64_t m_x;
public:
    mint(std::int64_t m_x = 0) : m_x(m_x% mod) {}
    std::int64_t get() { return m_x; }
    mint& operator+=(const mint a) {
        if ((m_x += a.m_x) >= mod) m_x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((m_x += mod - a.m_x) >= mod) m_x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (m_x *= a.m_x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(const std::int64_t t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

mint dp[1005][1005];

void Main() {
    rep(i, 1005)rep(j, 1005)dp[i][j] = 0;
    int h, w;
    cin >> h >> w;
    vstr a(h);
    rep(i, h) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    rep(i, h) {
        rep(j, w) {
            if (i < h - 1 && a[i + 1][j] == '.')dp[i + 1][j] += dp[i][j];
            if (j < w - 1 && a[i][j + 1] == '.')dp[i][j + 1] += dp[i][j];
        }
    }
    cout << dp[h - 1][w - 1].get() << endl;
}

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


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

template<ll mod> struct GF {
	ll v;
	GF(ll v = 0) : v((v % mod + mod) % mod) {}
	GF operator+(GF x) const { return v + x.v; }
	GF operator-(GF x) const { return v - x.v; }
	GF operator*(GF x) const { return v * x.v; }
	GF operator/(GF x) const { return x.inverse() * v; }
	GF operator+=(GF x) { return (*this) = (*this) + x; }
	GF operator*=(GF x) { return (*this) = (*this) * x; }
	GF operator-=(GF x) { return (*this) = (*this) - x; }
	GF operator/=(GF x) { return (*this) = (*this) / x; }
	GF inverse() const { // http://topcoder.g.hatena.ne.jp/iwiwi/20130105/1357363348
		ll a = v, b = mod, x = 1, y = 0;
		while (b) {
			ll t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return x;
	}
	GF pow(ll n) const {
		ll x = v, r = 1;
		for (; n > 0; n >>= 1) {
			if (n & 1) (r *= x) %= mod;
			(x *= x) %= mod;
		}
		return r;
	}

	static vector<GF> fact;
	static void fact_init(ll n) {
		fact.resize(n + 1); fact[0] = 1;
		REP(i, n) fact[i + 1] = fact[i] * (i + 1);
	}

	static GF nCr(ll n, ll r) { return fact[n] / fact[r] / fact[n - r]; }
	static GF nPr(ll n, ll r) { return fact[n] / fact[n - r]; }
};
template<ll mod> vector<GF<mod>> GF<mod>::fact;

const ll mod = TEN(9) + 7;
int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);


	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	GF<mod>::fact_init(h + w + 1);

	GF<mod> sum = 0;
	REP(i, h-a) {
		sum += GF<mod>::nCr(b-1+i, i) * GF<mod>::nCr(w-b-1 + h-i-1, h-i-1);
	}

	cout << sum.v << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define N 405
#define M 100005
using namespace std;
int pt[N][N],alive[N];
int f[M],t[M];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&f[i],&t[i]);
	for(int i=1;i<=n;i++)
		pt[i][i]=1;
	for(int i=1;i<=n;i++)
		for(int j=m;j>=1;j--){
			if(pt[i][f[j]]+pt[i][t[j]]!=0){
				if(pt[i][f[j]]+pt[i][t[j]]==2) {alive[i]=-1;break;}
				if(pt[i][f[j]]==1) pt[i][t[j]]=1;
				else pt[i][f[j]]=1;
			}
		}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(alive[i]==-1||alive[j]==-1) continue;
			bool fl=true;
			for(int k=1;k<=n;k++)
				if(pt[i][k]+pt[j][k]==2){
					fl=false;break;
				}
			if(fl) ans++;
		}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    while(1){
        s.pop_back();
        int t=s.size();
        if(t%2!=0)continue;
        if(s.substr(0,t/2)==s.substr(t/2,t/2))break;
    }
    cout<<s.size()<<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++) 

int main() {
    int n;
    cin >> n;
    vector<int> b(n - 1);
    rep(i, n - 1) cin >> b[i];

    vector<int> a(n, 0);
    a[0] = b[0];
    a[n - 1] = b[n - 2];

    for (int i = 1; i < n - 1; i++){
        a[i] = min(b[i - 1], b[i]);
    }

    long long int sum = 0;
    rep(i, n) sum += a[i];

    cout << sum << endl;
}

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

int main(){
    int V, E;
    cin >> V >> E;
    vector<pair<int, int> > edge(E);
    for (int i = 0; i < E; i++) {
        cin >> edge[i].first >> edge[i].second;
    }
    vector<int> ans;
    vector<int> state(V, 1);
//0: edge[i].secondに載っているため設定できない
//1: 設定できる状態
//2: すでに設定済みなので除外

    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            if (state[i] != 2) state[i] = 1;
        }
        for (int i = 0; i < edge.size(); i++) {
            state[edge[i].second] = 0;
        }
        for (int i = 0; i < V; i++) {
            if (state[i] == 1) {
                ans.push_back(i);
                state[i] = 2;
                for (int j = 0; j < edge.size(); j++) {
                    if (edge[j].first == i) {
                        edge.erase(edge.begin() + j);
                        j--;
                    }
                }
                break;
            }
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3472
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(args: Array<String>) {
    val (s, t) = readStrings()
    var (a, b) = readInts()
    val u = readLn()
    if (u == s) {
        a--
    } else {
        b--
    }
    println(listOf(a, b).joinToString(" "))
}

Measured memory_bytes: 37720
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
vector<ll> vect[200000];
ll vis[200000];
ll dp[200000];
void dfs(ll v)
{
    vis[v]=true;
    for(auto u:vect[v])
    {
        if(!vis[u])
        {
            dfs(u);
        }
        dp[v]=max(dp[v],dp[u]+1);
    }
}
int main()
{
    IO
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        vect[x].pb(y);
    }
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    ll mi=0;
    for(ll i=1;i<=n;i++)
    {
        mi=max(mi,dp[i]);
    }
    cout<<mi<<lc;
    return 0;
}

Measured memory_bytes: 15784
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    void init(int n) {
        vy.resize(n);
        x = n;
        y = n;
    }
    int get_y(int x1) {
        return x1 < x ? y : vy[x1];
    }
    void f(int x1, int y1) {
        if (y1 < y) {
            for (int j = x1; j < x; j++) {
                vy[j] = y;
            }
            x = x1;
            y = y1;
        }
    }
    vector<int> vy;
    int x, y;
};

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

    int n, q;
    cin >> n >> q;
    n -= 2;

    P p[2];
    for (int t = 0; t < 2; t++) {
        p[t].init(n);
    }

    ll s = (ll)n * n;
    while (q--) {
        int t, x;
        cin >> t >> x;
        t--; x -= 2;

        int y = p[t].get_y(x);
        s -= y;
        p[t ^ 1].f(y, x);
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 4776
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#include <bits/stdc++.h>

#define mod 104857601
#define pb push_back
#define ep emplace_back
#define fr first
#define sc second
#define linf  (((1ll << 62) - 1) << 1)
#define inf (((1 << 30) - 1) << 1)

const double eps = 0.000000001;
#define ll long long
#define leps 1e-18
#define mkp make_pair
#define mpi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) begin(v), end(v)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

// Utils
random_device rd;
mt19937 mt(rd());

const int N_ = 100001;
vector<int> primes;
int *least_prime;
void cieve() {
  least_prime = new int[N_];
  fill(least_prime, least_prime + N_, -1);

  for (int i = 2; i < N_; i++) {
    if (least_prime[i] == -1) {
      least_prime[i] = i;
      primes.pb(i);
    }
    for (auto &c: primes) {
      if (c * i >= N_ || c > least_prime[i]) break;
      least_prime[c * i] = c;
    }
  }
}

template<typename NType>
NType gcd(NType a, NType b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template<typename NType>
NType lcm(NType a, NType b) { return a / gcd(a, b) * b; }
template<typename NType>
NType phi(NType n_) {
  NType ans = n_;
  for (NType i = 2; i * i <= n_; i++) {
    if (n_ % i == 0) {
      while (n_ % i == 0) n_ /= i;
      ans -= ans / i;
    }
  }
  if (n_ > 1) ans -= ans / n_;
  return ans;
}

int binpow(ll a, int n, const int M = mod) {
  ll res = 1;
  while (n) {
    if (n & 1) {
      res = (a * res) % M;
      n--;
    } else {
      a = (a * a) % M;
      n >>= 1;
    }
  }
  ((res %= M) += M) %= M;
  return res;
}
// End of Utils

//ofstream cout("/Users/user/Desktop/test.txt");

void solve(int T) {
  int n;
  cin >> n;
  if(n >= 30){
    cout << "Yes";
  } else cout << "No" << endl;
}

#define MULTIPLE_TEST 0
#define PRECALC_CIEVE 0
int main(int argc, char const *argv[]){
  if (PRECALC_CIEVE) cieve();
  int t{1};
  if (MULTIPLE_TEST) scanf("%d\n", &t);
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int i = 1;
  while (t-- > 0) {
    solve(i++);
  }
}


Measured memory_bytes: 3640
import math

isPrime = [True] * 10001
primes = []
def eratos(n):
    isPrime[0] = isPrime[1] = False
    for i in range(2,int(math.sqrt(n))):
        if isPrime[i]:
            j = 2 * i
            while j <= n:
                isPrime[j] = False
                j = j + i
    for i in range(2,10000):
        if isPrime[i]:
            primes.append(i)
eratos(10000)

while True:
    try:
        n = int(input())
        if n == 0:
            break
        for i in range(n,2,-1):
            if isPrime[i]:
                if isPrime[i - 2]:
                    print(i - 2,i)
                    break
    except EOFError:
        break
            


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

typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

ll a[200][200000];


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

  ll n,w,i,j;
  cin>>n>>w;

  vector< pair<ll,ll> > vp;
  vp.pb(mp(0LL,0LL));

  for(i=0;i<n;i++)
  {
    ll x,y;
    cin>>x>>y;
    vp.pb(mp(x,y));
  }

  for(i=1;i<=n;i++)
  {
    for(j=0;j<=w;j++)
    {   
        if(j>=vp[i].first)
        a[i][j]=max(a[i-1][j],a[i-1][j-vp[i].first]+vp[i].second);
        else
        {
            a[i][j]=a[i-1][j];
        }
    }
  }

  cout<<a[n][w];
  return 0;
 }

Measured memory_bytes: 156416
import sys
input = sys.stdin.readline
N,H = map(int,input().split())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i], B[i] = map(int,input().split())
B.sort()
ma = max(A)
from bisect import bisect_left, bisect_right
r = bisect_right(B, ma) # 5が入るべき境目のうち最も右側の境目を返す
C = B[r:]
ans = 0
for i in range(len(C)-1,-1,-1):
  H -= C[i]
  ans +=1
  if H<= 0:
    break
if H>0:
  ans += H//ma
  if H%ma!=0:
    ans+=1
print(ans)
  

Measured memory_bytes: 11688
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define E endl
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
     
     
bool isprime(ll n)
{
	if(n==1 || (n!=2 && n%2==0))
	return false; 
	if(n==2)
	return true; 
	for(ll i=3;i<=sqrt(n);i+=2)
	if(n%i==0)
	return false; 
	return true; 
}   
int main()
{
	ll x;
	cin>>x;
	for(ll i=x;i<=1e5+10;i++)
	{
		if(isprime(i)==true)
		{
		  cout<<i;
		  break;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ipair = pair<int, int>;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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

const int INF = 1001001001;

int main(){
  int K;
  cin >> K;
  string s;
  cin >> s;

  cout << s.substr(0, K);

  if(sz(s) > K) cout << "...";

  cout << endl; 


  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int A=sc.nextInt();
    if(N%500<=A){
      System.out.println("Yes");}
    else{System.out.println("No");}
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };

int main() {
	int n, z, w, a[2000];
	std::cin >> n >> z >> w;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	if (n == 1) {
		std::cout << abs(a[0] - w) << std::endl;
	}
	else {
		std::cout << max(abs(a[n - 1] - w), abs(a[n - 2] - a[n - 1])) << std::endl;
	}
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    long double l, a, c, b;
    cin >> l;

    long double ans = l / 3 * l / 3 * l / 3;


    printf("%Lf\n", ans);
    // cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void selectionSort(int A[], int N);
int main(){
  int i, j ,A[100];

  scanf("%d",&i);
  for(j = 0; j < i; j++) scanf("%d",&A[j]);
  selectionSort(A ,i);
  
  return 0;
}

void selectionSort(int A[], int N){
  int i, j, minj, change, count = 0;
  for(i = 0; i < N-1; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(A[j] < A[minj]) minj = j;
    }
    change = A[i];
    A[i] = A[minj];
    A[minj] = change;
    if(i != minj) count++;
  }
  
  for(j = 0; j < N; j++){
    printf("%d",A[j]);
    if(j != N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
}



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

int main(){
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if(S-i-j >= 0 && S-i-j <= K) ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    vector<vector<int>> cnt(h, vector<int>(w, 0));
    //よこ
    rep(i,h) {
        vector<int> seen(w, 0);
        rep(j,w) {
            if(field[i][j]=='#') continue;
            if(seen[j]) continue;
            int g = 0;
            while(j+g<w) {
                if(field[i][j+g]=='#') break;
                g++;
            }

            rep(k,g) {
                cnt[i][j+k]+=g;
                seen[j+k] = 1;
            }
        }
     
    }
    
    //たて
    rep(j,w) {
        vector<int> seen(h, 0);
        rep(i,h) {
            if(field[i][j]=='#') continue;
            if(seen[i]) continue;
            int g = 0;
            while(g+i<h) {
                if(field[i+g][j]=='#') break;
                g++;
            }
            rep(k,g) {
                cnt[i+k][j] += g;
                seen[i+k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w) ans = max(ans, cnt[i][j]-1);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F            first
#define S            second
#define pb(x)        push_back(x)
#define mp(a,b)      make_pair(a,b)
#define mt(a,b,c)    make_tuple(a,b,c)
#define sz           size()
#define all(A)       A.begin(), A.end()
#define mem(a, b)    memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)      for(ll i=0;i<(b);i++)
#define f1(i,b)      for(ll i=1;i<=(b);i++)
#define f2(i,a,b)    for(ll i=(a);i<=(b);i++)
#define f3(i,b,a)    for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))

#define mod          10000007
#define PI           acos(-1.0)
#define MAX3(a,b,c)  max(a,max(b,c))

#define whilee(i,t)  while(i!=t)
#define  sl(a)       scanf("%lld",&a)
#define  pl(a)       printf("%lld\n",a)

//x = 1e18 means 10^18
//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end()); //sort(A, +n, greater<int>());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//printf("%I64d\n", a);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

// int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1};  // 4 Direction
// int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1};  // 8 Direction
// int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1};  // Knight Direction
// int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1};  // Hexagonal Direction

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//unordered_map <ll, ll> A;
//pair <ll,ll> A ;
//tuple <ll, ll, ll> A;
//vector <pair <ll,ll>> A;
//bitset<32> bset1;
//bool ok = true;
//char ch;
//string S, T, U;

ll i=0, j=0, k=0, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, flag=0, cnt=0;

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

    cin>>k>>n;

    if(k*500>=n)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const int inf=100000;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int n;
	cin>>n;
	vector<int> a(n);
	map<int,int> p{};
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
		p[a[i]-1]=i+1;
	}
	for(int i=0;i<n;++i)
	{
		cout<<p[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 8232
#include <iostream>

int main() {
    std::string s;
    bool flag = true;
    std::cin >> s;
    for (int i=0; i<3; ++i) {
        if (s[i] == s[i+1]) flag = false;
    }
    std::cout << (flag ? "Good" : "Bad") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(k,a,b) for(int k=(a); k < (b); k++)
#define FORE(k,a,b) for(int k=(a); k <= (b); k++)
#define REP(k,a) for(int k=0; k < (a); k++)

#define ALL(c) (c).begin(), (c).end()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define RANGE(lb, x, ub) ((lb) <= (x) && (x) < (ub))

#define dump(x) cerr << #x << ": " << (x) << endl;

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INF = 1000000000;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main(void) {
  int l; cin >> l;

  printf("%.8lf\n", pow(l/3.0, 3));


    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    vector<pair<int, int>> c(m);
    cin >> c;

    const int N = 1e5 + 5;
    map<int, int> cnt[N];

    vector<pair<int, int>> d = c;
    sort(d.begin(), d.end(), [] (auto a, auto b) { return a.second < b.second; });
    each (i, d) {
      int x = cnt[i.first].size();
      cnt[i.first][i.second] = x;
    }

    each (i, c) {
      printf("%06d%06d\n", i.first, cnt[i.first][i.second] + 1);
    }
  }
  
  return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H,W,N;
	cin >> H >> W >> N;
	if (N%(max(H,W)) == 0){
		cout << N/max(H,W);
	}else{
		cout << N/(max(H,W)) + 1;
	}
}
	



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, n,k, mai = 0, ant, p;

void solve(){
    scanf("%d%d", &k,&n);
    scanf("%d",&ant);
    p = ant;
    for(int v,i=1;i<n;i++){
        scanf("%d",&v);
        mai = max(mai,v-ant);
        ant = v;
    }
    mai = max(mai,k-ant+p);
    printf("%d\n", k-mai);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3852
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int m, int d) {
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            int d1 = j % 10;
            int d10 = j / 10;
            if (d1 >= 2 && d10 >= 2 && i == d1 * d10) {
                ans++;
            }
        }
    }
    return ans;
}

void main() {
    int m, d; scan(m, d);
    writeln(calc(m, d));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1024];
int main()
{
	int i=0,n,flag=1;
	scanf("%d",&n);
	do
	{
		if(n%2)
		{
			a[i++]=1;
			if(flag)
				n--;
			else
				n++;
		}
		else
			a[i++]=0;
		n/=2;
		if(flag)
			flag=0;
		else
			flag=1;
	}while(n);
	for(i--;i>=0;i--)
		printf("%d",a[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
using namespace std;

int main() {
	int n, m, count = 0, s[10001];
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> m;
	for(int i = 0; i < m; i++) {
		int t, j=0;
		cin >> t;
		s[n] = t;
		while(s[j] != t) j++;
		if(j != n) count++;
	}
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <stdbool.h>


typedef long long int lint;
typedef struct _tag_attak{
    lint damage;
    lint cost;
} attack_t;


void optimize_graph_init(lint *graph, lint H, attack_t attack){
    lint index = attack.damage;
    lint count = 1;
    while(index < H){
        if(graph[index] > count * attack.cost)
            graph[index] = count * attack.cost;
        index += attack.damage;
        count++;
    }
}

bool optimize_graph(lint * graph, lint H, attack_t attack){
    bool update_flag = false;
    for(lint i = attack.damage; i < H; i++){
        if(graph[i - attack.damage] != LLONG_MAX){
            if(graph[i] > graph[i - attack.damage] + attack.cost){
                graph[i] = graph[i - attack.damage] + attack.cost;
                update_flag = true;
            }
        }
    }
    return update_flag;
}


int main(){
    lint H, N;
    lint H_max;
    attack_t *attack_list;
    lint max_damage = 0;
    lint min_cost = LLONG_MAX;
    lint *graph;
    scanf("%lld %lld", &H, &N);
    attack_list = (attack_t*)malloc(sizeof(attack_t) * N);

    // input
    for(lint i = 0; i < N; i++){
        scanf("%lld %lld", &attack_list[i].damage, &attack_list[i].cost);
        max_damage = (attack_list[i].damage > max_damage)? attack_list[i].damage : max_damage;
    }
    H_max = H + max_damage;

    //gen graph
    graph = (lint*) malloc(sizeof(lint) * H_max);
    for(lint i = 0; i < H_max; i++){ graph[i] = LLONG_MAX; }

    // optimize graph
    for(lint i = 0; i < N; i++){
        optimize_graph_init(graph, H_max, attack_list[i]);
    }

    bool update_flag = true;
    while(update_flag){
        update_flag = false;
        for(lint i = 0; i < N; i++){
            if(optimize_graph(graph, H_max, attack_list[i])){
                update_flag = true;
            }
        }
    }
    


    for(lint i = H; i < H_max; i++){
            min_cost = (min_cost > graph[i]) ? graph[i] : min_cost;
    }
    printf("%lld\n", min_cost);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N,K;
 string S;
 cin>>N>>S>>K;
 char a=S[K-1];
 for(int i=0;i<N;i++){
   if(S[i]!=a){S[i]='*';}
 }
 cout<<S<<endl;
 return 0;
}

Measured memory_bytes: 3632
import sys

mod = 10 ** 9 + 7

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

A.sort(reverse = True)

if A[0] < 0 and K % 2 == 1:
    ans = 1
    for i in range(K):
        ans *= A[i]
        ans %= mod
    print(ans)
    sys.exit()

l = 0
r = N-1

ans = 1
if K % 2 == 1:
    ans *= A[0]
    l += 1

for _ in range(K // 2):
    if A[l] * A[l+1] > A[r] * A[r-1]:
        ans *= A[l] * A[l+1]
        ans %= mod
        l += 2
    else:
        ans *= A[r] * A[r-1]
        ans %= mod
        r -= 2

print(ans)

Measured memory_bytes: 31644
n, m = gets.split.map(&:to_i)
stores = []
money = 0
count = 0

n.times do
  stores << gets.split.map(&:to_i)
end

(stores.sort_by{|a| a[0]}).each do |store|
  if count + store[1] >= m
    money += store[0] * (m - count)
    break
  else
    count += store[1]
    money += store[0] * store[1]
  end
end

puts money

Measured memory_bytes: 12664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int n, m, q; cin >> n >> m >> q;
    vector<VI> imos(n, VI(n, 0));
    FOR(i, 0, m) {
        int l, r; cin >> l >> r;
        l--, r--;
        imos[l][r]++;
    }

    FOR(i, 0, n)FOR(j, 0, n - 1)imos[i][j + 1] += imos[i][j];
    FOR(i, 0, n - 1)FOR(j, 0, n)imos[i + 1][j] += imos[i][j];

    FOR(i, 0, q) {
        int l, r; cin >> l >> r;
        l--, r--;
        int ans = imos[r][r];

        if (0 < l) {
            ans += imos[l - 1][l - 1];
            ans -= imos[l - 1][r];
            ans -= imos[r][l - 1];
        }
        cout << ans << "\n";
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int DIM=1010;
long A[DIM];
long B[DIM];
long C[DIM];
long ANS[DIM];

     
     
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    long p;
    int i,j,k;
    int X,Y,Z,K;
    long min=0; 
    priority_queue<long> pq;
    cin >> X >> Y >> Z >> K; 
    // cout << X << " " << Y << " " << Z << " " << K << "\n"; 
    for(i=1; i<= X; i++){ cin >> p; A[i]=p;}
    for(j=1; j<= Y; j++){ cin >> p; B[j]=p; }
    for(k=1; k<= Z; k++){ cin >> p; C[k]=p; }
    
    sort(A+1,A + 1+ X, greater<>());
    sort(B+1,B + 1+ Y, greater<>());
    sort(C+1,C + 1+ Z, greater<>());

    /* 
    for(i=1; i<= X; i++){ cout << A[i] << " "; }
    cout << "\n";
    for(j=1; j<= Y; j++){ cout << B[j] << " "; }
    cout << "\n";
    for(k=1; k<= Z; k++){ cout << C[k] << " "; }
    cout << "\n";
    */

    

    long maxBC = B[1] + C[1];
    long maxC = C[1];


    for(i=1; i<= X; i++){
        // cout << "check A: " << A[i] << "\n";
        if (A[i] + maxBC < min){break;}
        for(j=1; j<= Y; j++){
            if (A[i] + B[j] + maxC < min){break;}
            for(k=1; k<= Z; k++){
                if (A[i] + B[j] + C[k] < min){break;}
                // cout << "size " << pq.size() << " push " << A[i] + B[j] + C[k] << "\n";
                pq.push( -(A[i] + B[j] + C[k]) );
                // cout << "top " << -pq.top() << "\n";
                if (pq.size()>K){
                    // cout << "drop " << - pq.top();
                    pq.pop();
                    min = - pq.top();
                    // cout << " min " << min << "\n";
                }
            }
        }
    }
    //exit(0);
    for(i=1;i<=K;i++){
         ANS[K+1-i]= -pq.top(); 
         pq.pop(); 
    }
    for(i=1;i<=K;i++){
        cout << ANS[i] <<  "\n"; 
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<array>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

// struct Node{
// 	int my_cost = 0;
// 	vector<int> edges;
// };

template<typename T,size_t N>
void warshallFloyd(array<array<T,N>,N>& distance_matrix,int M){
	
	for(int k = 0; k < M; k++){
		for(int i = 0; i < M; i++){
			for(int j = 0; j < M; j++){

				distance_matrix[i][j] = min(distance_matrix[i][j],distance_matrix[i][k] + distance_matrix[k][j]);
			}
		}
	}

}

constexpr size_t sizes = 250;
array<array<int,sizes>,sizes> dist;


int main(){
	
	int N,M,R;
	vector<int> arr;

	cin>>N>>M>>R;
	
	REP(i,N)
		REP(j,N){
			if(i != j)dist[i][j] = INF;
			else dist[i][j] = 0;
		}

	arr.resize(R);
	
	REP(i,R){
		cin>>arr[i];
	}

	REP(i,M){
		int a,b,c;
		cin>>a>>b>>c;
		dist[a-1][b-1] = c;
		dist[b-1][a-1] = c;
	}

	warshallFloyd(dist,N);
	
	sort(arr.begin(),arr.end());	
	
	int max_n = INF;
	do {
		int sum = 0;
		for(int i = 0;i < R - 1; i++){
			sum += dist[arr[i]-1][arr[i+1]-1];
		}
		max_n = min(max_n,sum);
	}while(next_permutation(arr.begin(),arr.end()));

	cout<<max_n<<endl;
	return 0;
}


Measured memory_bytes: 384