akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int d, n;
        read d >> n;
        if ( n == 100 ) n++;
        if ( d == 0 ) echo n fin;
        elif ( d == 1 ) echo n * 100 fin;
        else echo n * 10000 fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int a,b,c,x,y;
	int tmp,res=0,res2=0,res3=0;
	cin >> a >> b >> c >> x >> y;
		
		if(x>=y)	tmp = y;
		else tmp = x;
		res += c*2*tmp;
		if(x>=y){
			tmp = x-y;
			res+= a*tmp;
			res3 = x*c*2;
		}else{
			tmp = y-x;
			res+= b*tmp;
			res3 = y*c*2;
		}

		res2+=a*x;
		res2+=b*y;
	if(res>res2)	res=res2;
	if(res>res3)	res=res3;
	
	cout << res;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

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

  vector<int> h(N);

  REP(i,N){
    cin >> h[i];
  }

  vector<ll> dp(N, INF);
  dp[0] = 0;

  REP(i, N-1){
    FOR(j, 1, K+1){
      if (i+j >= N) continue;
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }

  cout << dp[N-1] << endl;

}


Measured memory_bytes: 1408
import math
def II(): return int(input())
N=II()
ans=0
Ceiling=math.floor((N-1)**0.5)
#print(Ceiling)
for i in range(1,Ceiling+1):  
    Sq=i*i
    A=N-Sq
    if A>i:
      ans+=int(2*math.ceil(A/i)-1)
      #print(ans,1)
    else:
      ans+=1
      #print(ans,2)
print(ans)

Measured memory_bytes: 9272
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	int n,now=0,mx=0;
	char ch;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ch;
		ch=='I'?now++:now--;
		mx=max(mx,now);
	}
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 256
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def gcd(a,b):
    while b % a:
        a,b = b, a % b
    return a

N,K = IL()

if N == 1:
    if K == I():
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
else:
    l = IL()
    l.sort(reverse=True)

    if K <= l[0]:
        num = gcd(l[0],l[1])
        for i in l:
            if i%num == 0:
                continue
            else:
                num = gcd(num,i)
        if K%num == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 23112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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


int main() {

	int N, X, Y;
	cin >> N >> X >> Y;
	X--;
	Y--;

	vector<vector<int>> A(N, vector<int>(N, 0));

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

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int len = 0;
			len = A[i][X] + 1 + A[Y][j];
			if (len < A[i][j]) {
				A[i][j] = len;
				A[j][i] = len;
			}
		}
	}

	vector<int> count(N, 0);
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			count[A[i][j]]++;
		}
	}

	rep(i, N-1) {
		cout << count[i + 1] << endl;
	}
}

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

int main(){

    int a,b,c;
    cin >> a >>b >>c;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int L;
	cin >> L;
	LD a = (LD)L / 3;
	cout << setprecision(12) << a * a * a << "\n";
	return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define REV(i,a,b) for(i=a-1;i>=b;i--)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define mp make_pair
#define ord(v) sort(v.begin(),v.end());
const ll MAXN=2*1e5+10;
#define MAX 2*1e9
#define fi first
#define se second
#define pi 3.141592653589793238
#define rem 1000000007
#define eps 1e-9
// fflush(stdout);
//lower_bound,upper_bound,equal_range
int main()
{
//	#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
	string s,t;
	cin>>s>>t;
	int m = s.size();
	int n = t.size();
	vector<vector<int>>dp(m+1,vector<int>(n+1));
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i==0||j==0)dp[i][j]=0;
			else if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string f="";
    int x=m,y=n;
	while(x>0&&y>0)
	{
		if(s[x-1]==t[y-1]){
			f+=s[x-1];
			x--;y--;
		}
        else if(dp[x-1][y]>dp[x][y-1])x--;
		else
			y--;
	}
	rev(f);
	cout<<f;
	return 0;
}

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

const int MAX_N = 200000;
const int MOD = 2019;

ll dp[2][MOD + 5];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int t = s[i] - '0';
        dp[(i + 1) % 2][0] = 1;
        for (int j = 0; j < MOD; j++) {
            int m = (j * 10 + t) % MOD;
            dp[(i + 1) % 2][m] += dp[i % 2][j];
            dp[i % 2][j] = 0;
        }
        ans += dp[(i + 1) % 2][0] - 1;
    }
    cout << ans << endl;
}

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

using ll = long long int;
using P = pair<int,int>;
using P3 = pair<int,P>;
using PP = pair<P, P>;
constexpr int INF = 1<<30;
constexpr int MOD = 10000;
constexpr int di[] = {0,1,0,-1};
constexpr int dj[] = {1,0,-1,0};

vector<P> gen(){
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    x--; y--;
    vector<vector<int> > lv(h, vector<int>(w));
    vector<int> ord;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> lv[i][j];
            ord.emplace_back(lv[i][j]);
        }
    }
    sort(ord.begin(),ord.end());
    ord.erase(unique(ord.begin(),ord.end()),ord.end());
    vector<P> res = {P(0,0)};
    priority_queue<P3,vector<P3>,greater<P3> > que;
    vector<vector<bool> > used(h, vector<bool>(w));
    int cnt = 0;
    used[y][x] = true;
    que.push(P3(1,P(y,x)));
    for(auto l : ord){
        bool update = false;
        while(!que.empty()){
            auto p = que.top();
            int i = p.second.first, j = p.second.second;
            if(lv[i][j] > l) break;
            que.pop();
            cnt++;
            update = true;
            for(int k=0;k<4;k++){
                int ni=i+di[k], nj=j+dj[k];
                if(ni<0 || ni>=h) continue;
                if(nj<0 || nj>=w) continue;
                if(used[ni][nj]) continue;
                used[ni][nj] = true;
                que.push(P3(lv[ni][nj],P(ni,nj)));
            }
        }
        if(update){
            res.emplace_back(P(cnt,l));
        }
    }
    return res;
}

bool solve(){
    int r;
    cin >> r;
    if(r == 0) return false;
    vector<P> v1, v2;
    v1 = gen();
    v2 = gen();
    int n = v1.size(), m = v2.size(), ans = INF;
    for(int i=0,j=m-1;i<n;i++){
        while(j>0 && v1[i].first+v2[j-1].first >= r) j--;
        if(v1[i].first+v2[j].first >= r){
            ans = min(ans, v1[i].second+v2[j].second);
        }
    }
    cout << ans << endl;
    return true;
}

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



Measured memory_bytes: 8112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
#include <atcoder/all>
using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
//**AC Libraryリスト**//
//pow_mod, inv_mod, floor_sum, convolution, convolution_ll, //
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
//***********//
int main() {
	cin >> K;
	string S;
	for (i = 0; i < K; i++) {
		S += "ACL";
	}
	cout << S;
}


Measured memory_bytes: 3636
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

S = input()
N = len(S)-1
ans = 0
for n in range(2**N):
	b = Base_10_to_n(n,2).rjust(N,'0')
	tmp = []
	ind = 0
	for i in range(N):
		if b[i] == '1':
			tmp.append(int(S[ind:i+1]))
			ind = i+1
	tmp.append(int(S[ind:]))
	ans += sum(tmp)

print(ans)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - (h - 1)) * (n - (w - 1));	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

map<long long, long long> prime_factorize(long long n) {
    map<long long, long long> res;
    for (long long p = 2; p * p <= n; ++p) {
        while (n % p == 0) { ++res[p]; n /= p; }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll gcd = __gcd(a, b);
    auto mp = prime_factorize(gcd);
    cout << mp.size() + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int h,w,o[2333][2333],d[2333];
char ms[2333][2333];
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;++i) scanf("%s",ms[i]+1);
	--w;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j) o[i][j]=(ms[i][j]==ms[i][j+1]);
	ll ans=h;
	for(int i=h;i>=1;--i)
	{
		for(int j=1;j<=w;++j)
			if(o[i][j]!=o[i+1][j]&&i!=h) d[j]=1;
			else d[j]++;
		static int ss[2333]; int sn=0;
		for(int j=1;j<=w;++j)
		{
			while(sn&&d[ss[sn]]>d[j])
				ans=max(ans,(ll)(j-ss[sn-1])*d[ss[sn]]),--sn;
			ss[++sn]=j;
		}
		while(sn)
			ans=max(ans,(ll)(w+1-ss[sn-1])*d[ss[sn]]),--sn;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 24960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int n, W;
const int maxn = 1e5 + 5;
ll w[111], v[111];
ll f[maxn];
ll ans, sum;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),	cout.tie(0);
	cin >> n >> W;
	for(int i = 1; i <= n; ++i){
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	for(int i = 1; i <= sum; ++i) f[i] = 1e18;
	for(int i = 1; i <= n; ++i){
		for(int j = sum; j >= 0; --j){
			if(j >= v[i]) f[j] = min(f[j], f[j-v[i]] + w[i]);
		}
	}
	for(int i = 1; i <= sum; ++i){
		if(f[i] <= W) ans = i;
	}
	printf("%d", ans);
}

Measured memory_bytes: 4556
use std::io::Read;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut graph: Vec<Vec<(usize, usize)>> = vec![Vec::new(); n];
    for _ in 0..n {
        let u: usize = iterator.next().unwrap().parse().unwrap();
        let k: usize = iterator.next().unwrap().parse().unwrap();
        for _ in 0..k {
            let v: usize = iterator.next().unwrap().parse().unwrap();
            let c: usize = iterator.next().unwrap().parse().unwrap();
            graph[u].push((v, c));
        }
    }

    // let mut color: Vec<Color> = vec![Color::WHITE; n];
    // let mut d: Vec<usize> = vec![INF; n];
    // d[0] = 0;
    //
    // let mut pq: BinaryHeap<(isize, usize)> = BinaryHeap::new();
    // pq.push((0, 0));
    //
    // while !pq.is_empty() {
    //     let pair = pq.pop().unwrap();
    //     let u = pair.1;
    //
    //     color[u] = Color::BLACK;
    //
    //     if d[u] < (-pair.0) as usize {
    //         continue;
    //     }
    //
    //     for &edge in &graph[u] {
    //         let v = edge.0;
    //         if color[v] == Color::BLACK {
    //             continue;
    //         }
    //         if d[v] > d[u] + edge.1 {
    //             d[v] = d[u] + edge.1;
    //             pq.push((d[v] as isize * -1, v));
    //             color[v] = Color::GRAY;
    //         }
    //     }
    // }

    let mut color: Vec<Color> = vec![Color::WHITE; n];
    let mut d: Vec<usize> = vec![INF; n];
    let mut p: Vec<isize> = vec![-1; n];
    d[0] = 0;

    loop {
        let mut min_cost = INF;
        let mut u = 0;
        for i in 0..n {
            if color[i] != Color::BLACK && d[i] < min_cost {
                min_cost = d[i];
                u = i;
            }
        }

        if min_cost == INF {
            break;
        }

        color[u] = Color::BLACK;

        for &edge in &graph[u] {
            let v = edge.0;
            if color[v] == Color::BLACK {
                continue;
            }
            if d[u] + edge.1 < d[v] {
                d[v] = d[u] + edge.1;
                p[v] = u as isize;
                color[v] = Color::GRAY;
            }
        }
    }

    let mut result = String::new();
    for i in 0..n {
        result.push_str(&format!("{} {}\n", i, d[i]));
    }
    return result.trim().to_string();
}

const INF: usize = 1_000_000_000;

#[derive(Clone, PartialEq)]
enum Color {
    WHITE, GRAY, BLACK,
}



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

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> l(n, 0);
	for (int i = 0; i < n; ++i) scanf("%d", &l[i]);
	sort(l.begin(), l.end());
	int a = 0;
	for (int i = 0; i < n; ++i) for (int j = i+1; j < n; ++j) if (l[i] != l[j])
		for (int k = j+1; k < n; ++k) if (l[k] != l[j] && l[k] != l[i]) a += (l[i]+l[j]>l[k]);
	printf("%d\n", a);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww
{
  cww()
  {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n, 0);
  rep(i, n) cin >> a[i];
  Int ans = 0;
  sort(a.begin(), a.end());
  vector<int> che(1000100, 0);
  for (int i = 0; i < n; i++)
  {
    if(che[a[i]]!=0) {
      che[a[i]]=2;
      continue;
    }
    else{
      for(int j=a[i]; j<1000100; j+=a[i]){
        che[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    if (che[a[i]] == 1)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int cals[6];
int rows[6];

char mat[6][6];


int main()
{

    int n,m,k;
    cin >> n >> m >> k;

    int ans = 0;
    int all = 0;

    for (int i = 0 ; i < n ; i++){
        for (int j = 0 ; j < m ; j++){
            cin >> mat[i][j];
            if (mat[i][j] == '#'){cals[j]++ ; rows[i]++; all++;}
        }
    }


    for (int i = 0 ; i < pow(2, n) ; i++){
        vector<int> rowsin;
        for (int shifti = 0 ; shifti < n ; shifti++){
            if (i >> shifti & 1){
                rowsin.push_back(shifti);
            }
        }

        for (int j = 0 ; j < pow(2, m) ; j++){
            vector<int> calsin;
            for (int shiftj = 0 ; shiftj < m ; shiftj++){
                if (j >> shiftj & 1){
                    calsin.push_back(shiftj);
                }
            }

            int pos = 0;

            for (int p : rowsin){
                pos+= rows[p];
            }
            for (int p : calsin){
                pos+= cals[p];
            }

            for (int p1 : rowsin){
                for (int p2 : calsin){
                    if (mat[p1][p2] == '#'){
                        pos--;
                    }
                }
            }

            if (all  - pos == k){
                ans++;
            }


        }

    }


    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3960
//In the name of GOD
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define pb push_back
#define Mp make_pair
#define pll pair<ll, ll>
#define F first
#define S second

ll n, a[maxn], b[maxn];

int main(){
	fast_io;
	
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n, greater<ll>());
	if(n & 1){
		cout << b[n / 2] - a[n / 2] + 1;
		return 0;
	}
	cout << b[n / 2 - 1] + b[n / 2] - a[n / 2 - 1] - a[n / 2] + 1;
	
	return 0;
}


Measured memory_bytes: 6764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = nextInt()
	}
	return ints
}
func calcEV(max int) float64 {
	total := (1 + max) * max / 2
	return float64(total) / float64(max)
}

func calcTotalEV(k int, dices []int) float64 {
	l := len(dices)

	total := 0

	start := 0
	end := start + k
	ds := dices[start:end]
	for _, d := range ds {
		total += d
	}
	max := total

	for start+k < l {
		s := dices[start]
		next := dices[end]
		total = total - s + next
		if max < total {
			max = total
		}
		start++
		end = start + k
	}

	return float64(max+k) / 2.0
}

func main() {
	n, k := nextInt(), nextInt()
	dices := nextInts(n)
	t := calcTotalEV(k, dices)
	fmt.Println(t)
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,c,m=0;
  cin>>n;
/*  int ar[n],j=1;
  ar[1]=n;
  for(int i=2;i<=n;i++){
    ar[i]=j;
    j++;
  }
  for(int k=1;k<=n;k++) 
    m=m+ar[k]%k;*/
  m=n*(n-1)/2;
  cout<<m;
}


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

int main() {
   int N, K, R, S, P;
   cin >> N >> K >> R >> S >> P;
   string T;
   cin >> T;

   vector<char> t(N);
   rep(i, N){
       t[i] = T.at(i);
   }
   ll score = 0;
   vector<bool> didr(N,false), dids(N,false), didp(N,false);
   rep(i, K){
       if(t[i] == 'r'){
           score += P;
           didp[i] = true;
       }
       else if(t[i] == 's'){
           score += R;
           didr[i] = true;
       }
       else{
           score += S;
           dids[i] = true;
       }
   }
   for(int i = K; i < N; ++i){
       if(t[i] == 'r'){
           if(!didp[i-K]){
               score += P;
               didp[i] = true;
           }
           else if(didp[i-K]){
               continue;
           }
       }
        if(t[i] == 's'){
           if(!didr[i-K]){
               score += R;
               didr[i] = true;
           }
           else if(didr[i-K]){
               continue;
           }
       }
        if(t[i] == 'p'){
           if(!dids[i-K]){
               score += S;
               dids[i] = true;
           }
           else if(dids[i-K]){
               continue;
           }
       }
   }
   

   cout << score << endl;
}

Measured memory_bytes: 512
N,K = map(int, input().split())
l = list(map(int,input().split()))
 
def E(n):
  return (1 + n) / 2
 
j = sum(l[0:0+K])
m = 0
if N == 1:
  l2 = list(map(E, l))
  print(sum(l2))
elif N == K:
  l2 = list(map(E, l))  
  print(sum(l2))
else:
  for i in range(1,len(l)-(K-1)):
      j = j - l[i-1] + l[i+K-1]
      if l[i] < l[i-1]:
          continue
      elif m < j:
          m = j
          t = l[i:i+K]

  l2 = list(map(E, t))
 
  print(sum(l2))

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

using namespace std;

#define int long long

int H, W;
int A[33][33];

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

using Tapris = tuple<int, int, int, int>;

int mincost[1001][33][33];

signed main() {
  scanf("%lld %lld", &H, &W);
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      scanf("%lld", &A[i][j]);
    }
  }

  auto in = [&](int i, int j) {
    return 0<=i&&i<H&&0<=j&&j<W;
  };

  priority_queue<Tapris, vector<Tapris>, greater<Tapris> > que;
  fill((int*)mincost[0], (int*)mincost[1001], 1LL<<55);
  que.emplace(0, 0, 0, 0);
  mincost[0][0][0] = 0;
  while(!que.empty()) {
    int cost, dist, y, x;
    tie(cost, dist, y, x) = que.top(); que.pop();
    if(y == H-1 && x == W-1) {
      //printf("%lld\n", cost);
      //return 0;
      break;
    }
    if(mincost[dist][y][x] < cost) continue;
    for(int i = 0; i < 4; ++i) {
      int ny = y+dy[i], nx = x+dx[i];
      if(!in(ny, nx)) continue;
      int nd = dist+1;
      int nc = cost+(2*dist+1)*A[ny][nx];
      if(nd <= 1000 && nc < mincost[nd][ny][nx]) {
	que.emplace(nc, nd, ny, nx);
	mincost[nd][ny][nx] = nc;
      }
    }
  }
  //assert(false);
  int ans = 1LL<<55;
  for(int i = 0; i < 1001; ++i) ans = min(ans, mincost[i][H-1][W-1]);
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 19716
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF (1e9+1)

int n,W;
int dp[MAX];

int main(){
  fill(dp,dp+MAX,-INF);
  dp[0]=0;
  
  cin>>n>>W;
  for(int i=0;i<n;i++){
    int v,w,m;
    cin>>v>>w>>m;

    for(int k=0;m>0;k++){
      int key= min( m, (1<<k) );
      m-=key;

      int nv=key*v;
      int nw=key*w;
      for(int j=W;j>=nw;j--){
        dp[j]=max(dp[j],dp[j-nw]+nv);
      }


    }
    
  }
  int ans=0;
  for(int i=0;i<=W;i++)
    ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3468
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> a(100010, 0);
	rep(i, N)
	{
		ll tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		a[tmp1] += tmp2;
	}

	ll ind = 0;
	while(true)
	{
		K -= a[ind];
		if (K <= 0)break;
		ind++;
	}
	co(ind);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>

using namespace std;
//debug

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

#define pb push_back

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;



#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()



int main() {
	string S;
	int w;
	cin >> S >> w;
	int len = S.length();
	string out = "";
	rep(i, (len-1) / w + 1) {
		out += S[w*i];
	}
	cout << out;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char *argv[])
{
  int N;
  scanf("%d", &N);

  long long int M = 0, a;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a);    
    for (int j = 1; j <= 64; j++) {
      if (((a >> j) << j) == a) {
        M++;
      } else {
        break;
      }
    }
  }

  printf ("%d\n",M);
  return 0;
}


Measured memory_bytes: 128
import std.stdio, std.string, std.conv;

immutable hurui = (int n){
    bool[] table = new bool[](n + 1);
    table[] = true;
    table[1] = false;
    for(int i = 2; i * i <= n; ++i)
    {
        for(int j = i + i; j <= n; j += i)
        {
            table[j] = false;
        }
    }
    return table;
}(60000);

void main()
{
    while(true)
    {
        string line = readln.chomp;
        if(line is null)break;
        auto num = line.chomp.to!int;
        for(int i = num - 1; i >= 0; --i)
        {
            if(hurui[i])
            {
                write(i, " ");
                break;
            }
        }

        for(int i = num + 1; i <= 60000; ++i)
        {
            if(hurui[i])
            {
                i.writeln;
                break;
            }
        }
    }
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> b[i][j];
            b[i][j] = abs(a[i][j]-b[i][j]);
            //cout << b[i][j] << endl;
        }
    }

    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(6401, false)));
    dp[0][0][b[0][0]] = true;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            for(int k=0; k<=6400; k++){
                if(i-1 >= 0){
                    if(k+b[i][j] <= 6400)      dp[i][j][k+b[i][j]]      = dp[i-1][j][k] | dp[i][j][k+b[i][j]];
                    if(abs(k-b[i][j]) <= 6400) dp[i][j][abs(k-b[i][j])] = dp[i-1][j][k] | dp[i][j][abs(k-b[i][j])];
                }
                if(j-1 >= 0){
                    if(k+b[i][j] <= 6400)      dp[i][j][k+b[i][j]]      = dp[i][j-1][k] | dp[i][j][k+b[i][j]];
                    if(abs(k-b[i][j]) <= 6400) dp[i][j][abs(k-b[i][j])] = dp[i][j-1][k] | dp[i][j][abs(k-b[i][j])];
                }
            }
        }
    }
    for(int k=0; k<=6400; k++){
        if(dp[h-1][w-1][k] == true){
            cout << k << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define FRU                                  freopen("out.txt","w",stdout);
#define FRO                                  freopen("in.txt","r",stdin);
#define pb                                   push_back
#define pf                                   push_front
#define ppb                                  pop_back()
#define ppf                                  pop_front()
#define mp                                   make_pair
#define ff                                   first
#define ss                                   second
#define flash                                ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mem(ara,n)                           memset(ara,n,sizeof ara)
#define fr(i,j,n)                            for(i=j;i<n;i++)
#define rf(i,j,n)                            for(i=n;i>=j;i--)
#define inf                                  2147483647
#define ll                                   long long
#define ull                                  unsigned long long
#define pii                                  pair<int,int>
#define vi                                   vector<int>
#define vll                                  vector <long long>
#define vch                                  vector <char>
#define itr                                  ::iterator
#define msi                                  map<string,int>
#define psi                                  pair <string,int>
#define vii                                  vector <pair<int,int> >
#define all(n)                               n.begin(),n.end()
#define INF                                  10000000000000000LL
#define pi                                   3.1415926535897932384626434
#define sii                                  set <int>
#define max3(a,b,c)                          max(a,max(b,c))
#define min3(a,b,c)                          min(a,min(b,c))
#define mid3(a,b,c)                          min(max(a,b),max(b,c),max(a,b))
#define max4(a,b,c,d)                        max(max(a,b),max(c,d))
#define min4(a,b,c,d)                        min(min(a,b),min(c,d))
#define endl                                 '\n'
#define endll                                cout<<"\n";
#define spc                                  ' '
#define ld                                   long double

using namespace std;



int main()
{
    flash
    string s,st;
    int n,t,T,i,j,J,I,k,m;
    char ch;
    cin>>n;
    cin>>m;
    fr(i,0,m)
    {
        cin>>k;
        n-=k;
    }
    if(n<0) n=-1;
    cout<<n;
    return 0;
}




Measured memory_bytes: 3632
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#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 pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char c;
    cin >> c;
    cout << (char)(c+1);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>x(n);
  for (int i = 0; i < n; i+=1){
    cin >> x.at(i);
  }
  int sum = 0;
  int min = 100000000;
  for (int p=0; p<100; p+=1){
    sum = 0;
    for(int i=0; i<n ;i+=1){
      sum += pow(x.at(i) - p, 2);
    }
    if (min > sum) min = sum;
  }
  cout << min << endl;
}


Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> aEven = new ArrayList<>(); 
		for(int i = 0; i < n; i++) {
			int ai = sc.nextInt();
			
			if((ai % 2) == 0) {
				aEven.add(ai);
			}
		}
		
		aEven.sort(null);
		
		int count = 0;
		System.out.println(operation(aEven, count));
		
		
	}
	
	static int operation(ArrayList<Integer> al, int count) {
		if(al.size() == 0) {
			return count;
		}else {
			
			int target = al.get(al.size() - 1);
			target = target / 2;
			count++;
			
			if((target % 2) == 0) {
				al.set(al.size() - 1, target);
			}else {
				al.remove(al.size() - 1);
			}
			
			count = operation(al, count);
			
			return count;
		}
		
	}
}

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

using namespace std;

int main(){
	char s[10], t[10]; int ans = 0;
	scanf("%s%s", s + 1, t + 1);
	int n = strlen(s + 1), m = strlen(t + 1);
	for(int i = 1; i <= n; ++i) 
		ans += (s[i] == t[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;

ll n;
ll d[100005];
vector<pair<ll, ll> > v;
const ll mod = 998244353;

ll pow_mod(ll x, ll y) {
	ll ret = 1;
	
	while (y > 0) {
		if (y & 1) {
			ret *= x;
			ret %= mod;
		}
		
		y >>= 1;
		x *= x;
		x %= mod;
	}
	
	return ret;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	
	if (d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	
	sort(d, d + n);
	v.push_back({0, 1});
	for (int i = 1; i < n; i++) {
		if (d[i] != d[i - 1]) {
			v.push_back({d[i], 1});
		}
		else {
			v.back().second++;
		}
	}
	
	if (v[0].second > 1) {
		cout << 0 << endl;
		return 0;
	}
	
	ll ans = 1;
	for (int i = 1; i < v.size(); i++) {
		if (v[i].first - v[i - 1].first > 1) {
			cout << 0 << endl;
			return 0;
		}
		
		ans *= pow_mod(v[i - 1].second, v[i].second);
		ans %= mod;
	}
	
	cout << ans << endl;
}

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


int main()
{    
    
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;

    vector<int> P, Q, R;
    int p, q, r;
    for  (int  i = 0; i < A; ++i) {
        cin >> p;
        P.push_back (p);
    }

    for  (int  i = 0; i < B; ++i) {
        cin >> q;
        Q.push_back (q);
    }

    for  (int  i = 0; i < C; ++i) {
        cin >> r;
        R.push_back (r);
    }

    std::sort(P.begin(), P.end());
    std::sort(Q.begin(), Q.end());
    std::sort(R.begin(), R.end());


    long long ans=0;
    for  (int  i = A-1; i > A-X-1; --i) {
        ans+=P[i];
    }

    for  (int  i = B-1; i > B-Y-1; --i) {
        ans+=Q[i];
    }

    for  (int  i = C-1; i > -1; --i) {
        if (X>0 && Y>0){
            if (P[A-X] >= R[i] && Q[B-Y] >= R[i]){break;}
            if (P[A-X] > Q[B-Y]){
                if (Q[B-Y]<R[i]){
                    ans+=R[i]-Q[B-Y];
                    Y-=1;
                }
            } else {
                if (P[A-X]<R[i]){
                    ans+=R[i]-P[A-X];
                    X-=1;
                }
            }
        } else if (Y>0) {
            if (Q[B-Y]<R[i]){
                ans+=R[i]-Q[B-Y];
                Y-=1;
            } else {break;}
        } else if (X>0) {
            if (P[A-X]<R[i]){
                ans+=R[i]-P[A-X];
                X-=1;
            } else {break;}
        } else {break;}
    }

    cout << ans << endl;
    return 0;

}

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


int main() {
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if ((h*w) % 2 == 1 && (x + y) % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){return (a%mod * b%mod)%mod;}
inline int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n,k,x,y;
     cin>>n>>k>>x>>y;
     if(k<=n)
     cout<<(k*x+n*y-k*y)<<endl;
     else
     cout<<n*x<<endl;
     time();
     return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(x) x.begin(),x.end()
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main(){
  string s;
  ll c=1;
  cin>>s;
  sort(ALL(s));
  for(int i=0;i<s.size();i+=2){
    if(s[i]!=s[i+1]){
      c=0;
    }
  }
  if(c){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int N, K;
int A[300], B[300];
int64_t dp[600][600];
int freedom[600][600];
int64_t g[601];

int main(){
    int i, j, k;
    cin >> N >> K;
    for(i=0; i<K; i++){
        int a, b;
        cin >> a >> b;
        if(a>b) swap(a, b);
        A[i] = a-1; B[i] = b-1;
    }

    g[0] = 1;
    for(i=2; i<=2*N; i++) g[i] = g[i-2] * (i-1) % MOD;
    int64_t ans = 0;

    for(int d=2; d<=2*N; d+=2){
        for(int l=0; l+d-1<2*N; l++){
            int r = l+d-1;
            int inner = 0;
            bool ok = true;
            for(int k=0; k<K; k++){
                if(l <= A[k] && B[k] <= r){
                    inner++;
                }else if((l <= A[k] && A[k] <= r) || (l <= B[k] && B[k] <= r)){
                    ok = false;
                    break;
                }
            }
            if(!ok) continue;

            freedom[l][r] = d - 2*inner;
            dp[l][r] = g[freedom[l][r]];
            for(int r2=l+1; r2<r; r2+=2){
                int64_t sub = dp[l][r2] * g[freedom[r2+1][r]] % MOD;
                add(dp[l][r], MOD - sub);
            }

            int outer_freedom = 2*N-d - 2*(K-inner);
            add(ans, dp[l][r] * g[outer_freedom] % MOD);
        }
    }

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

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

int main() {
  int N, K;
  cin >> N >> K;
  int dis = 1;
  for(int i=0;i<N;i++){
    if(dis *2 < dis+K){
      dis *=2;
    }
    else{
      dis += K;
    }

  }

  cout << dis << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,k[6];
	string a;
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<6;i++)
		k[i]=i+1;
	int count=1;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a=="North"){
			int tmp=k[0];
			k[0]=k[1];
			k[1]=k[5];
			k[5]=k[4];
			k[4]=tmp;
		}
		if(a=="East"){
			int tmp=k[0];
			k[0]=k[3];
			k[3]=k[5];
			k[5]=k[2];
			k[2]=tmp;
		}
		if(a=="West"){
			int tmp=k[0];
			k[0]=k[2];
			k[2]=k[5];
			k[5]=k[3];
			k[3]=tmp;
		}
		if(a=="South"){
			int tmp=k[0];
			k[0]=k[4];
			k[4]=k[5];
			k[5]=k[1];
			k[1]=tmp;
		}
		if(a=="Right"){
			int tmp=k[1];
			k[1]=k[2];
			k[2]=k[4];
			k[4]=k[3];
			k[3]=tmp;
		}
		if(a=="Left"){
			int tmp=k[1];
			k[1]=k[3];
			k[3]=k[4];
			k[4]=k[2];
			k[2]=tmp;
		}
		count+=k[0];
	}
	cout<<count<<endl;
	}
	return 0;
}

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

vector<pair<ll, ll>> pf(ll n){
    vector<pair<ll, ll>> res;
    for (ll i = 2; i*i <= n; i++){
        if (n%i != 0){
            continue;
        }
        else{
            ll ex = 0;
            while (n%i == 0){
                ex++;
                n /= i;
            }
            res.push_back({i, ex});
        }
    }
    if (n != 1){
        res.push_back({n, 1});
    }
    return res;
}

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

    ll n;
    cin >> n;
    vector<pair<ll, ll>> res = pf(n);
    ll ans = 0;
    for (auto p : res){
        ll c = 0;
        while (c*(c+1)/2 <= p.second){
            c++;
        }
        ans += c-1;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3652
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    a=LIST()
    q=INT()
    temp=sum(a)
    cnt=[0]*(10**5+1)
    for i in a:
        cnt[i]+=1
    
    for i in range(q):
        #print(cnt[:10])
        b,c=INTM()
        temp=temp+(c-b)*cnt[b]
        cnt[c]+=cnt[b]
        cnt[b]=0
        print(temp)

                
if __name__ == '__main__':
    do()

Measured memory_bytes: 20984
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let y = read::<i64>();
  let mut cnt = 0;

  let mut a = x;
  while a <= y {
    cnt += 1;
    a = a * 2;
  }

  println!("{}", cnt);
}



Measured memory_bytes: 4352