akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


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

	int ans1 = 0; //全て足したもの
	int ans2 = 0; //先頭を１減らしてそれ以外を９として足したもの
	for (int i = 0; i < s.size(); i++) {
		ans1 += (s[i] - '0');
	}

	ans2 = (int)(s[0] - '0') - 1;
	ans2 += 9 * (s.size() - 1);

	cout << max(ans1, ans2) << endl;
	return 0;
}

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

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

    int w, a, b;
    cin >> w >> a >> b;

    if((a<=b && b<=a+w) || (a<=b+w && b+w<=a+w)) cout << 0 << endl;
    else cout << min(abs(b+w-a), abs(a+w-b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned long long u64;
const int N=50;
int n, k, s, t, a[N], cnt;
u64 set[2*N], com[N+1][N+1], ans;
void dfs(int x, int nmust, int nmay, u64 must, u64 may) {
	if(nmust>k) return;
	while(x<cnt && (set[x]&must)) ++x;
	if(x==cnt) {
		int tmp=std::min(k, nmay)-nmust;
		ans+=com[nmay-nmust][tmp];
		return;
	}
	u64 cur=set[x]&may;
	if(cur==0) return;
	u64 j;
	for(; cur; cur^=j) {
		j = cur&-cur;
		dfs(x+1, nmust+1, nmay, must|j, may);
		--nmay;
		may^=j;
	}
}
void gg() {
	puts("0");
	exit(0);
}
int main() {
	std::random_device dev;
	std::mt19937 rng(dev());
	scanf("%d%d%d%d", &n, &k, &s, &t);
	for(int i=0; i<n; ++i) {
		scanf("%d", a+i);
		if((a[i]&s)!=s || (a[i]|t)!=t) {
			--i;
			--n;
		}
	}
	if(n==0) gg();
	for(int i=0; i<=n; ++i) {
		com[i][0]=com[i][i]=1;
		for(int j=1; j<i; ++j)
			com[i][j]=com[i-1][j-1]+com[i-1][j];
	}
	for(int i=0; i<=n; ++i) {
		for(int j=1; j<=i; ++j)
			com[i][j]+=com[i][j-1];
	}
	for(int i=0; i<18; ++i) {
		int ss=s>>i&1, tt=t>>i&1;
		if(ss!=tt) {
			u64 cur=0;
			for(int j=0; j<n; ++j) {
				if(~a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
			cur=0;
			for(int j=0; j<n; ++j) {
				if(a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
		}
	}
	dfs(0, 0, n, 0, (1llu<<n)-1);
	printf("%llu\n", ans);
	return 0;
}



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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 1000000007;

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

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

  int a,b,v,w,t;
  cin >> a >> v;
  cin >> b >> w;
  cin >> t;

  if (v <= w)cout << "NO" << endl;
  else{
    int _t = abs(a-b) / (v-w);
    if(abs(a-b)%(v-w) != 0)_t++;
    if(_t <= t)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 3612
package main

import "fmt"

func main() {
	var a int
	var b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Println("a > b")
	} else if a == b {
		fmt.Println("a == b")
	} else {
		fmt.Println("a < b")
	}
}


Measured memory_bytes: 1124
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Int
import qualified Data.IntMap                 as IM
import           Data.List
import qualified Data.Map                    as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  a <- readInt
  print $ solve n a

solve n a
  | b = ans
  | otherwise = 0
  where
    ans = 2 `power` (n `div` 2) `mod` (10 ^ 9 + 7)
    b = sum a == sum [n - 1,n - 3 .. 0] * 2

power x n
  | n == 0 = 1
  | even n = power (x * x) (n `div` 2)
  | otherwise = x * power x (n - 1)


Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 A,B,C;

i64 K;

int main(){
  cin >> A >> B >> C >> K;
  if(K & 1){
    cout << -A + B << endl;
  }
  else{
    cout << A - B << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
T, A = [int(s) for s in input().split(' ')]
Ht = [T - int(s) * 0.006 - A for s in input().split(' ')]
#for i, ta in zip(range(1, len(Ht)+1), Ht):
ret = min(zip(range(1, len(Ht)+1), Ht), key=(lambda x: abs(x[1])))
print(ret[0])


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	int r; cin >> r;
	double pi = 3.141592;
	cout << pi * r * 2 << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  vll p(n);
  rep(i,n) cin>>p[i];
  vsort(p);
  ll sum=0;
  rep(i,k) sum+=p[i];
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3684
import fractions
a,b,c,d = map(int,input().split())	
lcm = c * d // fractions.gcd(c, d)
#print(lcm)
def divisor(x):
	
	x_c = x//c
	x_d = x//d
	#print(x_c,x_d)
	x_lcm = x//lcm
	#print(x_c,x_d,x_lcm)
	return x-x_c-x_d+x_lcm
#print(divisor(b),divisor(a))
ans = divisor(b)-divisor(a-1)
print(ans)

Measured memory_bytes: 5048
n = int(input())
lst = list(map(int, input().split()))

if n <= 2:
  print(0)
  exit()
  
ans = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      a = lst[i]
      b = lst[j]
      c = lst[k]
      A = max(a, max(b, c))
      if a!=b and b!=c and c!=a:
        if 2*A < a+b+c:
          ans += 1
               
print(ans)

Measured memory_bytes: 68532
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

vector<int> G[1000];
bool used[1000];
int trans[1000];

int goal;
vector<int> vs;
bool dfs(int id) {
	rep(j, G[id].size()) {
		int to = G[id][j];
		if (to == goal) {
			vs.push_back(id); return true;
		}
		if (used[to])continue;
		used[to] = true;
		if (dfs(to)) {
			vs.push_back(id); return true;
		}
	}
	return false;
}
void solve() {
	int n, m; cin >> n >> m;
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
	}
	rep(i, n) {
		fill(used, used + n, false);
		goal = i;
		used[i] = true;
		dfs(i);
		if (vs.size() == 0)continue;
		reverse(vs.begin(), vs.end());
		while (vs.size()>2) {
			fill(trans, trans + n, -1);
			rep(j, vs.size()) {
				trans[vs[j]] = j;
			}
			bool chen = false;
			rep(j, vs.size()) {
				int id = vs[j];
				rep(k, G[id].size()) {
					int to = G[id][k];
					if (trans[to] < 0)continue;
					if (trans[to] != (j + 1) % vs.size()) {
						//cout << j << " " << trans[to] << endl;
						chen = true;
						vector<int> nex;
						int cur = trans[to];
						while (cur != j) {
							nex.push_back(vs[cur]);
							cur = (cur + 1) % vs.size();
						}
						nex.push_back(vs[j]);
						vs = nex;
						break;
					}
				}
				if (chen)break;
			}
			if (!chen)break;
		}
		cout << vs.size() << endl;
		rep(i, vs.size()) {
			cout << vs[i] + 1 << endl;
		}
		return;
	}
	cout << -1 << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 384
def main():
    A, B, C, D = map(int, input().split())
    while A > 0 or C > 0:
        C = C - B
        if C <= 0:
            break
        A = A - D
    if A <= 0:
        print('No')
    elif C <= 0:
        print('Yes')
main()

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  if(a>b){
    cout<<0<<endl;
    return 0;
  }
  cout<<max(0LL,(a+(n-1)*b)-((n-1)*a+b)+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a, b = 1, 1
for i in range(N):
    x, y = map(int, input().split())
    c = max(-(-a // x), -(-b // y))
    #マイナスの//は切り上げになる（math.ceil()でも良い）
    a, b = c* x, c* y
print(a + b)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> W(N);
	for (auto &x : W) {
		cin >> x;
	}

	const int sum = accumulate(W.begin(), W.end(), 0);

	int ans = sum;
	int acc1 = W[0];
	for (int mid = 1; mid < N; ++mid) {
		int acc2 = sum - acc1;
		ans = min(ans, abs(acc1 - acc2));
		acc1 += W[mid];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
anum, bnum, cnum = 0, 0, 0
for i in range(len(s)):
    si = s[i]
    if si == 'a':
        anum += 1
    elif si == 'b':
        bnum += 1
    else:
        cnum += 1
mini = min(anum, bnum, cnum)
anum, bnum, cnum = anum-mini, bnum-mini, cnum-mini

lst = [anum, bnum, cnum]
lst.sort()
dai = lst[2]
sho = lst[0]
mid = lst[1]

if dai==0 and mid==0:
    ans = 'YES'
elif dai>0 and mid==0:
    if dai == 1:
        ans = 'YES'
    else:
        ans = 'NO'
elif dai>0 and mid>0:
    if dai == 1:
        ans = 'YES'
    else:
        ans = 'NO'
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      int n,m;
      cin >> n >> m;
      int h[n + 1];
      for(int i=1; i<=n; i++){
            cin >> h[i];
      }
      vector<int> v[n + 1];
      int ans =0; 
      for(int i=0; i<m; i++){
            int a, b;
            cin >> a >> b;
            v[a].pb(b);
            v[b].pb(a);
      }
      for(int i=1; i<=n; i++){
            bool flag = false;
            for(auto x: v[i]){
                  if(h[i] <= h[x]){
                        flag= true;
                        break;
                  }
            }
            if(flag == false){
                  ans++;
            }
      }
      cout << ans;
      return 0;      
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    ll yokin = 100;
    ll i = 0;

    while(yokin<N){
        i++;
        yokin *= 1.01;
    }
    cout << i << endl;
}


Measured memory_bytes: 3652
import java.util.*

val ns: MutableList<Int> = MutableList(45) { -1 }

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val fn = getFibonacciNumber(n)
    println(fn)
}

fun getFibonacciNumber(n: Int): Int = calcFibonacciNumber(n)

fun calcFibonacciNumber(n: Int): Int {
    if (n < 0) {
        return 0;
    }
    if (n == 0 || n == 1) {
        return 1;
    }
    if (ns[n] != -1) {
        return ns[n]
    }
    val fn = calcFibonacciNumber(n - 1) + calcFibonacciNumber(n - 2)
    ns[n] = fn
    return fn
}



Measured memory_bytes: 25548
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define F first
#define S second

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (s.length() <= n)
		cout << s << "\n";
	else
	{
		for (int i = 0; i < n; i++)
			cout << s[i];
		cout << "...\n";
	}
	return 0;
}


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


int main()
{
  ll n;
  cin >> n;
  ll a[200000];
  for(ll i = 0;i < n;i++){
    cin >> a[i];
    a[i] = a[i] - i - 1;
  }
  sort(a,a+n);
  ll b = a[n/2];
  ll sum = 0;
  for(int i = 0;i < n;i++){
    sum += abs(a[i] - b);
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    int num, i, j, result;
    
    scanf("%d", &num);
    
    int va[num];
    
    for(i = 0; i < num; i++) {
        scanf("%d", &va[i]);
        
        printf("Case %d:\n", i + 1);
        
        for(j = 0; j < 10; j++) {
            result = va[i] * va[i] / 100 % 10000;
            va[i] = result;
            printf("%d\n", result);
        }
    }
    
    return(0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
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 long long INF = 1LL<<60;
int N;
long long K;
vector<int> P;
vector<long long> C;

long long solve() {
    long long res = -INF;

    // 順列を各サイクルに分解する
    vector<bool> used(N, false);
    vector<vector<long long>> ss;
    for (int i = 0; i < N; ++i) {
        if (used[i]) continue;
        int cur = i;
        vector<long long> s;
        while (!used[cur]) {
            used[cur] = true;
            s.push_back(C[cur]);
            cur = P[cur];
        }
        ss.push_back(s);
    }

    // 各サイクルごとに考える
    for (auto vec : ss) {
        long long M = vec.size();

        // サイクルを二週したものの累積和
        vector<long long> sum(M*2+1, 0);
        for (int i = 0; i < M*2; ++i) sum[i+1] = sum[i] + vec[i%M];

        // amari[r] := 連続する r 個の総和の最大値
        vector<long long> amari(M, -INF);
        for (int i = 0; i < M; ++i) {
            for (int j = 0; j < M; ++j) {
                chmax(amari[j], sum[i+j] - sum[i]);
            }
        }

        // 余りの長さで場合分け
        for (int r = 0; r < M; ++r) {
            if (r > K) continue;
            long long q = (K - r) / M;
            //if (r == 0 && q == 0) continue;

            if (sum[M] > 0) chmax(res, amari[r] + sum[M] * q);
            else if (r > 0) chmax(res, amari[r]);
        }
    }
    return res;
}

int main() {
    cin >> N >> K;
    P.resize(N); C.resize(N);
    for (int i = 0; i < N; ++i) cin >> P[i], --P[i];
    for (int i = 0; i < N; ++i) cin >> C[i];
    cout << solve() << endl;
}

Measured memory_bytes: 3844
using System;
using System.Linq;

class GcdAndLcm 
{
    static void Main()
    {
        var q =
            from nums in
                from line in GetProblems()
                select line.Split( ' ' )
                    .Select( long.Parse )
                    .ToArray()
            let gcd = GetGcd( nums[0], nums[1] )
            let lcm = ( nums[0] * nums[1] ) / gcd
            select string.Format("{0} {1}\n", gcd, lcm );
        Console.Write( new string( q.SelectMany( _ => _ ).ToArray() ) );
    }

    static System.Collections.Generic.IEnumerable<string> GetProblems()
    {
        var buffer = "";
        while ( !string.IsNullOrEmpty( buffer = Console.ReadLine() ) )
            yield return buffer;
    }

    static long GetGcd(long a, long b)
    {   // Euclidean Algorithm
        var rem = 0L;
        while ( ( rem = a % b ) != 0 )
        {
            a = b;
            b = rem;
        } 
        return b;
    }
}

Measured memory_bytes: 6064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, d;
    long result;
    list<int> OISHISA;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> d;
        OISHISA.insert(OISHISA.end(), d);
    }

    for (int i = 0; i < N - 1; i++)
    {
        int t = i;
        for (int i = 1; i < N - t; i++)
        {
            result += *next(OISHISA.begin(), t) * *next(OISHISA.begin(), t + i);
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${5PL2kn!5WHLRAEt*Sc1xnT$EfZ{QXc?Aiev-A^w7S(i%nyvdjV!=XLlAI+=#&ld75G{_6BK2??S|=#!1Dp(1{?w<EOJH&jTL@HQY%)aC=jklvR4;?)gb_s~ORZjk+vkuQcd-eLbh>;LBp^Q+bAC!>}aqjLG~crz;}Y^;(EQ@m_@lgV(U`W`;{yfWm0_EAQ}z^94c0uVBHK)Qq=(wdqwaiA+n#riW!1890MrFbt7Fmc{I(I_&yge_+@XXFrmPb^(T}@+K-OoQG<gI?wg5kYx8Fx996n97i-67Aq_^Fd5`{Y9X@l*7Q3aqT3`=MAG4pQ0gciq0}v|&@A`T&U#x^bc@>E@Z#6j>-vxWYSJk30!ifgSr*IRrv-diT7V=sza4$2?E")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9808
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;
main(){
    int a=in(),b=in();
    a--;
    b--;
    cout<<(b+a-1)/a<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int x1, x2, x3, x4, x5;

  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if(x1==0) cout << '1';
  else if(x2==0) cout << '2';
  else if(x3==0) cout << '3';
  else if(x4==0) cout << '4';
  else if(x5==0) cout << '5';

  cout << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
using std::swap;

int main()
{
	string s;
	int u=0, t=0;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s.substr(i, 1) == "0")++t;
		else ++u;
	}
	if (t > u)cout << u * 2 << "\n";
	else cout << t * 2 << "\n";
	return 0;	
}

Measured memory_bytes: 512
// 服部　舜也 hatochun

#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    int num[n];
    for(int i=0;i<n;i++){
        
        cin>>num[i];
    }
    int m;
    cin>>m;
    vector<int> a;
   for(int i=0;i<m;i++){
       int tmp;
       cin>>tmp;
       a.push_back(tmp);
   }
   for(int i=0;i<a.size();i++){
       int idx=a[i]-1;
    //    cout<<"idx:"<<idx<<"\n";
        if((num[idx]+1)!=num[idx+1]&&num[idx]!=2019)num[idx]++;
   }

   for(int i=0;i<n;i++){
       cout<<num[i];
       if(i!=n)cout<<"\n";
   }

}


Measured memory_bytes: 3156
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Edge struct {
	s, t, w int
}

func main() {
	V, E := ReadInt(), ReadInt()
	edges := make([]*Edge, E)
	for i := 0; i < E; i++ {
		edges[i] = &Edge{
			s: ReadInt(),
			t: ReadInt(),
			w: ReadInt(),
		}
	}
	sort.Slice(edges, func(i, j int) bool {
		return edges[i].w < edges[j].w
	})
	uf := MakeUnionFind(V)
	sum := 0
	for _, edge := range edges {
		if uf.Connected(edge.s, edge.t) {
			continue
		}
		uf.Unite(edge.s, edge.t)
		sum += edge.w
	}
	fmt.Println(sum)
}

type UnionFind []int

func MakeUnionFind(size int) UnionFind {
	parent := make([]int, size)
	for i := 0; i < size; i++ {
		parent[i] = i
	}
	return parent
}
func (uf UnionFind) Unite(x, y int) {
	if x, y = uf.Root(x), uf.Root(y); x != y {
		uf[x] = y
	}
}
func (uf UnionFind) Connected(x, y int) bool { return uf.Root(x) == uf.Root(y) }
func (uf UnionFind) Root(x int) int {
	if uf[x] == x {
		return x
	}
	uf[x] = uf.Root(uf[x])
	return uf[x]
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }



Measured memory_bytes: 7492
#include <iostream>

using namespace std;

int main(){
    int n, i, c;
    cin >> n;
    int v[n];
    for(i=0;i<n;i++){
        cin >> v[i];
    }
    int dif=0;

    for(i=0;i<n;i++){
        cin >> c;
        if(dif+v[i]-c > dif){
            dif+=v[i]-c;
        }
    }
    cout << dif << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b, c, count = 0, tmp;
	int s1, s2, s3;
	std::cin >> a >> b >> c;

	if(a < b)
	{
		tmp = b;
		b = a;
		a = tmp;
	}
	if(a < c)
	{
		tmp = c;
		c = a;
		a =tmp;
	}
	if(b < c)
	{
		tmp = c;
		c = b;
		b = tmp;
	}

	while(1)
	{
		if(a == b &&  a == c)
		{
			break;
		
		}else{
			s1 = a - b;
			s2 = a - c;
			if(b < a && c < a){
				b = b + 1;
				c = c + 1;
				count++;
			}else if (a == b){
				s3 = a - c;
				if(s3 % 2  == 0)
				{
					c = c + 2;
					count++;
				}else{
					b++;
					a++;
					count++;
				}
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	long ans = 0;
	for(long i=0; i < (1 << (s.size()-1)); i++) {
		long pre = 0;
		string post = "";
		post += s.at(0);
		for(int j=1; j < s.size(); j++) {
			if(i & (1 << (j-1))) {
				pre += stoll(post);
				post = "";
			}
			post += s.at(j);
		}
		ans += pre + stoll(post);
	}
	cout << ans << endl;
}


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

int main(){
  int N;
  int rates[8] = {399,799,1199,1599,1999,2399,2799,3199};
  bool colors[8] = {false,false,false,false,false,false,false,false};

  cin >> N;
  int rate;
  int tnum=0;
  int cnum=0;
  for(int i=0;i<N;++i){
    cin >> rate;
    for(int j=0;j<9;++j){
      if(j==8){
	tnum++;
	break;
      }else if(rate <= rates[j]){
	if(colors[j] == false){
          colors[j] = true;
          cnum++;
	}
        break;
      }
    }
  }
  cout<<max(cnum, tnum > 0 ? 1 : 0 )<<" "<<cnum+tnum;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int m = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		br.close();

		int n = (int) Math.pow(2, m);
		if (k >= n) {
			System.out.println(-1);
			return;
		}

		if (k == 0) {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.append(i).append(' ');
			}
			for (int i = n - 1; i >= 0; i--) {
				sb.append(i).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());

		} else {
			int xor = 0;
			for (int i = 0; i < n; i++) {
				if (i != k) {
					xor ^= i;
				}
			}
			if (xor != k) {
				System.out.println(-1);
				return;
			}

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				if (i != k) {
					sb.append(i).append(' ');
				}
			}
			sb.append(k).append(' ');
			for (int i = n - 1; i >= 0; i--) {
				if (i != k) {
					sb.append(i).append(' ');
				}
			}
			sb.append(k);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 37980
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int p = m + f;
            if (m == -1 && f == -1 && r == -1) {
                break;
            }
            if (m == -1 || f == -1) {
                System.out.printf("F\n");
            } else if (80 <= p) {
                System.out.printf("A\n");
            } else if (65 <= p) {
                System.out.printf("B\n");
            } else if (50 <= p || r >= 50) {
                System.out.printf("C\n");
            } else if (30 <= p) {
                System.out.printf("D\n");
            } else if (0 <= p) {
                System.out.printf("F\n");
            }
        }
    }
}


Measured memory_bytes: 26232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
  int n;
  cin >> n;
  vector<ll> A(n), B(n), C(n);
  rep(i,n) cin >> A[i];
  rep(i,n) cin >> B[i];
  rep(i,n) cin >> C[i];
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  ll ans = 0;
  rep(i,n) {
    auto it1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    auto it2 = lower_bound(C.begin(), C.end(), B[i]+1) - C.begin();
    ans += (it1) * (n - it2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,Y;
  	cin >> N >> Y;
	int residue = 0;
  	int res10000 = -1,res5000 = -1,res1000 = -1  ;
  	for(int x = 0;x <= N;x++){
    	for(int y = 0;y <= N-x;y++){
          	int z = N-x-y;
          	int total = 10000*x +5000*y +1000*z;
            if(total == Y){
            res10000 = x;
            res5000 = y;
            res1000 = z;
            }
        }	
    }
  	cout << res10000 << " " << res5000 <<  " " << res1000 << endl;    
}

Measured memory_bytes: 256
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>

using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}


int main()

  {
      zaroorat();


        ll n;
        cin>>n;
        ll arr[n];
        ll hash[100005]={0};
        unsigned ll su=0;
        for (ll i = 0; i < n; i++) {
          cin>>arr[i];
          hash[arr[i]]++;
          su+=arr[i];
        }
        ll q;
        cin>>q;
        while(q>0){
          ll a,b;
          cin>>a>>b;
          su+=b*hash[a]- a*hash[a];
          hash[b]+=hash[a];
          hash[a]=0;
          cout<<su<<endl;
          q--;
        }





    return 0;
  }


Measured memory_bytes: 5220
package main

import (
	"container/list"
	"fmt"
)

func main() {
	var N, K int
	var S string
	fmt.Scan(&N, &K)
	fmt.Scan(&S)

	l := list.New()
	l.PushBack(S[0:1])
	for i := 1; i < N; i++ {
		if l.Back().Value != S[i:i+1] {
			l.PushBack(S[i : i+1])
		}
	}
	s := l.Len()
	for i := 0; i < K; i++ {
		if 3 <= s {
			s -= 2
		} else if s == 2 {
			s = 1
		}
	}
	fmt.Println(N - s)
}


Measured memory_bytes: 7296
h, n = map(int,input().split())
ablist=[]
hplist=[10**9]*(h+1)
hplist[0]=0
for i in range(n):
    a, b = map(int,input().split())
    ablist.append([a,b])


for i in range(n):
    now=ablist[i]
    for j in range(h+1):
        if j<=now[0]:
            hplist[j]=min(now[1], hplist[j])
        else:
            hplist[j]=min(hplist[j], hplist[j-now[0]]+now[1])

print(hplist[-1])

Measured memory_bytes: 42348
#include <iostream>

using namespace std;


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

    int current_h = 0;
    int previous_h = 0;

    int current_step = 0;
    int max_step = 1;
    for (int i = 0; i < n; i++) {
        cin >> current_h;
        if (current_h <= previous_h) {
            current_step++;
        } else {
            current_step = 1;
        }
        max_step = max(current_step, max_step);
        previous_h = current_h;
    }

    cout << max_step - 1;

}

Measured memory_bytes: 256
S=input()
N=len(S)

def kaibun_checker(s):
    rev_s = s[::-1]
    len_s = len(s)
    for i in range(len_s//2):
        if s[i]!=rev_s[i]:
            return False
    return True

if N==3:
    print('Yes' if S[0]==S[2] else 'No')
else:
    if kaibun_checker(S[:]) and kaibun_checker(S[(N+3)//2]) and kaibun_checker(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, l, r, ans = 0;

	cin >> N;
	rep(i, N) {
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a <= c && b <= c){
	  printf("%d",a+b);
  }else if(a <= b && c <= b){
	  printf("%d",c+a);
  }else if(b <= a && c <= a){
	  printf("%d",b+c);
  }
  return 0;
}

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

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

int main(){
    int n, m;
    while( cin >> n >> m, n||m ){
        int sn[100], sm[100], diff=0;
        rep(i,n){
            cin >> sn[i];
            diff += sn[i];
        }
        rep(i,m){
            cin >> sm[i];
            diff -= sm[i];
        }
        int mn=10000, mm=10000;
        rep(i,n){
            rep(j,m){
                if( (sn[i]-sm[j])*2 == diff ){
                    if( mn+mm > sn[i]+sm[j] ){
                        mn = sn[i];
                        mm = sm[j];
                    }
                }
            }
        }
        if( mn == 10000 )
            cout << "-1" << endl;
        else
            cout << mn << " " << mm << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int (i) = 0; i < (n); i++)
#define REP(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF LLONG_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);

	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];

	sort(all(a));
	sort(all(b));
	sort(all(c));

	int res = 0;

	rep(i, n) {
		int A = upper_bound(all(a), b[i] - 1) - a.begin();
		int C = c.end() - lower_bound(all(c), b[i] + 1);

		res += A * C;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2560
import sys 


class Tree:
    def __init__(self):
        self.children = {}
        self.end = False

    def __contains__(self, key):
        if len(key) == 0:
            return self.end

        k, *rest = key 
        if k not in self.children:
            return False

        return rest in self.children[k]

    def add(self, key):
        if len(key) > 0:
            k, *rest = key 
            if k not in self.children:
                self.children[k] = self.__class__()

            self.children[k].add(rest)
        else:
            self.end = True


class Dictionary:
    def __init__(self):
        self.tree = Tree()

    def insert(self, word):
        self.tree.add(word)

    def find(self, word):
        return word in self.tree


def run():
    _ = int(input())  # flake8: noqa
    words = Dictionary()

    for command in sys.stdin:

        if command.startswith('insert'):
            words.insert(command[7:])
        elif command.startswith('find'):
            if words.find(command[5:]):
                print('yes')
            else:
                print('no')
        else:
            raise ValueError()


if __name__ == '__main__':
    run()



Measured memory_bytes: 258308
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
	int X, Y, A, B, C;
	priority_queue< int, vector<int>, greater<int> > qA;
	priority_queue< int, vector<int>, greater<int> > qB;
	priority_queue<int> qC;
	int v;
	long long res = 0;

	scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
	for ( int i=0; i < A; ++i ){
		scanf("%d", &v);
		res += v;
		qA.push(v);
	}
	for ( int i=0; i < B; ++i ){
		scanf("%d", &v);
		res += v;
		qB.push(v);
	}
	for ( int i=0; i < C; ++i ){
		scanf("%d", &v);
		qC.push(v);
	}
	
	while ( (int)qA.size() > X ){ 
		res -= qA.top();
		qA.pop();
	}
	while ( (int)qB.size() > Y ){ 
		res -= qB.top();
		qB.pop();
	}
	
	while ( !qC.empty() ){
		if ( qC.top() <= min( qA.top(), qB.top() ) )
			break;
		if ( qA.top() <= qB.top() ){
			res -= qA.top();
			qA.pop();
			qA.push( qC.top() );
		}
		else {
			res -= qB.top();
			qB.pop();
			qB.push( qC.top() );
		}
		res += qC.top();		
		qC.pop();
	}	
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>

int main(void) {
	int N, c = 0;
	unsigned long long a, ans = 1;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%llu", &a);

		if (a == 0) {
			printf("0");
			return 0;
		}

		if ((1000000000000000000 / ans) < a) {
			c = 1;
		}
		else if (ans > 1000000000000000000) {
			c = 1;
		}
		else {
			ans = ans * a;
		}
	}

	if ((ans > 1000000000000000000) || (c > 0)) {
		printf("-1");
		return 0;
	}
	else {
		printf("%llu", ans);
		return 0;
	}
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    string S;
    cin >> N >> S;
    ll white = 0;
    ll ans = numeric_limits<ll>::max();
    iter(c, S) {
        if(c == '.') white++;
    }
    ll w = 0;
    rep(i, N + 1) {
        ans = min(ans, i - w + white - w);
        if(i != N && S[i] == '.') w++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1000000000;

int main() {
    int D, G;
    cin >> D >> G;

    vi p(D);
    vi c(D);

    rep (i, D) {
        cin >> p[i] >> c[i];
    }

    int ans = INF;
    rep (i, 1 << D) {
        int s = 0, n = 0, m = -1;
        rep (j, D) {
            if ((i >> j) & 1) {
                s += 100*(j+1)*p[j]+c[j];
                n += p[j];
            } else {
                m = j;
            }
        }

        if (s < G) {
            rep (j, p[m]) {
                s += 100*(m+1);
                n++;
                if (s >= G) {
                    ans = min(ans, n);
                    break;
                }
            }
        } else {
            ans = min(ans, n);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
#include <functional>
template<class T, class Lazy> struct LazySegTree {
  private:
  public:
    int size;
    vector<T> v; vector<Lazy> lazy;
    vector<int> seg_size;
    using F = function<T(T,T)>;
    using G = function<Lazy(Lazy,Lazy)>;
    using H = function<T(T,Lazy,int)>;
    F f; G g; H h;
    T default_value; Lazy default_lazy;
  public:
    LazySegTree(int n, T default_value, Lazy default_lazy, F f, G g, H h)
      : default_value(default_value), default_lazy(default_lazy), f(f), g(g), h(h) {
      size = 1;
      while (size < n) size *= 2;

      v.resize(2 * size - 1, default_value);
      lazy.resize(4 * size - 1, default_lazy);
      seg_size.resize(2 * size - 1, 1);

      for (int i = 0; i < size - 1; ++i) {
        int j = size - 2 - i;
        seg_size[j] = seg_size[2 * j + 1] + seg_size[2 * j + 2];
      }
    }
    void update(int index, T val) {
      update(index, index+1, default_lazy);
      index = index + size - 1;
      v[index] = val;
      while (index > 0) {
        index = (index - 1) / 2;
        v[index] = f(v[2 * index + 1], v[2 * index + 2]);
      }
    }
    void eval(int index) {
      v[index] = h(v[index], lazy[index], seg_size[index]);

      lazy[2 * index + 1] = g(lazy[index], lazy[2 * index + 1]);
      lazy[2 * index + 2] = g(lazy[index], lazy[2 * index + 2]);

      lazy[index] = default_lazy;
    }
    T query(int l, int r) { return query(l, r, 0, size, 0); }
    T query(int l, int r, int cur_l, int cur_r, int index) {
      // [l, r)に対するクエリ
      eval(index);
      if (cur_r <= l || r <= cur_l) return default_value;
      if (l <= cur_l && cur_r <= r) return v[index];

      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      return f(
          query(l, r, cur_l, mid, 2 * index + 1),
          query(l, r, mid, cur_r, 2 * index + 2));
    }
    void update(int l, int r, Lazy x) { update(l, r, x, 0, size, 0); }
    void update(int l, int r, Lazy x, int cur_l, int cur_r, int index) {
      // [l, r)に対して操作する

      eval(index);
      if (cur_r <= l || r <= cur_l) return;
      if (l <= cur_l && cur_r <= r) {
        lazy[index] = x;
        eval(index);
        return;
      }
      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      update(l, r, x, cur_l, mid, 2 * index + 1);
      update(l, r, x, mid, cur_r, 2 * index + 2);
      v[index] = f(v[2 * index + 1], v[2 * index + 2]);
    }
};

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int in(N); int in(Q);

  // 範囲和
  LazySegTree<int, int> T(N, 0, 1001,
      [](int a, int b) {return a + b;},
      [](int a, int b) {return a == 1001 ? b : a;},
      [](int a, int b, int size) {return b == 1001 ? a : b * size;});

  rep(i, Q) {
    int in(com);
    if (com == 0) {
      int s, t, x;
      ins(s, t, x);
      ++t;
      T.update(s, t, x);
    } else {
      int s, t;
      ins(s, t);
      ++t;
      cout << T.query(s, t) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 7088
import std.stdio, std.string, std.array, std.conv;

struct Dice6 {
    int[string] dice6;
    int[] _dice6 = new int[6];

    this(int[] _dice6) {
        dice6["top"] = _dice6[0];
        dice6["front"] = _dice6[1];
        dice6["right"] = _dice6[2];
        dice6["left"] = _dice6[3];
        dice6["back"] = _dice6[4];
        dice6["bottom"] = _dice6[5];
    }

    void roll(char c) {
        int tmp = dice6["top"];
        if (c == 'E') {
            dice6["top"] = dice6["left"];
            dice6["left"] = dice6["bottom"];
            dice6["bottom"] = dice6["right"];
            dice6["right"] = tmp;
        } else if (c == 'N') {
            dice6["top"] = dice6["front"];
            dice6["front"] = dice6["bottom"];
            dice6["bottom"] = dice6["back"];
            dice6["back"] = tmp;
        } else if (c == 'S') {
            dice6["top"] = dice6["back"];
            dice6["back"] = dice6["bottom"];
            dice6["bottom"] = dice6["front"];
            dice6["front"] = tmp;
        } else {
            dice6["top"] = dice6["right"];
            dice6["right"] = dice6["bottom"];
            dice6["bottom"] = dice6["left"];
            dice6["left"] = tmp;
        }
    }

    void clockwise() {
        int tmp = dice6["front"];
        dice6["front"] = dice6["right"];
        dice6["right"] = dice6["back"];
        dice6["back"] = dice6["left"];
        dice6["left"] = tmp;
    }

    int surface(string dir) {
        int result;
        if (dir == "top") {
            result = dice6["top"];
        } else if (dir == "front") {
            result = dice6["front"];
        } else if (dir == "right") {
            result = dice6["right"];
        } else if (dir == "left") {
            result = dice6["left"];
        } else if (dir == "back") {
            result = dice6["back"];
        } else {
            result = dice6["bottom"];
        }
        return result;
    }
}

bool areIdentical(Dice6 x, Dice6 y) {
    string[] dirs = ["top", "front", "right", "left", "back", "bottom"];
    foreach (dir; dirs) {
        if (x.surface(dir) != y.surface(dir)) return false;
    }
    return true;
}

void main() {
    int[] _dice1 = readln.chomp.split.to!(int[]);
    Dice6 dice1 = Dice6(_dice1);
    int[] _dice2 = readln.chomp.split.to!(int[]);
    Dice6 dice2 = Dice6(_dice2);
    bool check = false;
    foreach (i; 0 .. 6) {
        foreach (j; 0 .. 4) {
            if (areIdentical(dice1, dice2)) check = true;
            dice2.clockwise;
        }
        i % 2 == 0 ? dice2.roll('E') : dice2.roll('N');
    }
    writeln(check ? "Yes" : "No");
}


Measured memory_bytes: 2560