akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using graph = std::vector<std::vector<int>>;

bool dfs(graph const& g, int v, std::vector<int>& match, std::vector<bool>& used) {
    used[v] = true;
    for(auto u : g[v]) {
        int w = match[u];
        if(w < 0 || !used[w] && dfs(g, w, match, used)) {
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(graph const& g) {
    const int V = g.size();
    std::vector<int> match(V, -1);
    std::vector<bool> used(V);
    int res = 0;
    for(int v=0; v<V; ++v) {
        if(match[v] < 0) {
            std::fill(used.begin(), used.end(), false);
            if(dfs(g, v, match, used)) {
                ++res;
            }
        }
    }
    return res;
}

constexpr double eps = 1e-8;

int main() {
    int N, M;
    while(cin >> N >> M, N) {
        vector<double> tx(N), ty(N), v(N);
        for(int i=0; i<N; ++i) {
            cin >> tx[i] >> ty[i] >> v[i];
        }
        vector<double> bx(M), by(M);
        for(int i=0; i<M; ++i) {
            cin >> bx[i] >> by[i];
        }
        double lb = -1, ub = 1e9;
        while(abs(ub - lb) > eps) {
            double m = (ub + lb) / 2;
            graph g(N+M);
            for(int i=0; i<N; ++i) {
                for(int j=0; j<M; ++j) {
                    if(hypot(tx[i]-bx[j], ty[i]-by[j]) - eps <= v[i] * m) {
                        g[i].push_back(N+j);
                        g[N+j].push_back(i);
                    }
                }
            }
            if(bipartite_matching(g) == M) {
                ub = m;
            } else {
                lb = m;
            }
        }
        cout << fixed << setprecision(10) << ub << endl;
    }
}


Measured memory_bytes: 3396
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	string s;
	cin >> s;
	string ans = "";
	REP(i, s.size()) {
		if (s[i] == 'B' && !ans.empty())ans = ans.substr(0, ans.size() - 1);
		else if (s[i] == '0')ans = ans + '0';
		else if (s[i] == '1')ans = ans + '1';
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

vector<int> input(){
	vector<int> hills = vector<int>(10);
	
	for (int i = 0; i < 10; i++) cin >> hills[i];
	
	return hills;
}

void output(vector<int> hills){
	for (int i = 0; i < 3; i++) cout << hills[i] << endl;
}

int main(){
	vector<int> hills;
	
	hills = input();
	sort(hills.begin(), hills.end(), greater<int>());
	output(hills);
	
	return 0;
}


Measured memory_bytes: 3120
(loop :for (an xn yn) :in (loop :repeat (read) :collect (list (read) (read) (read)))
      :for a := an :then (- an a)
      :for x := xn :then (abs (- xn x))
      :for y := yn :then (abs (- yn y))
      :if (not (and (<= (+ x y) a) (= (mod (+ x y) 2) (mod a 2))))
        :return (princ "No")
      :finally (princ "Yes"))

Measured memory_bytes: 64096
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, m, l, i, j, k, a, b, c, d[303][303][303] = {};
	bool lt[303][303] = { false };
	vector<P> g[303];

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		g[a - 1].push_back(P(b - 1, c));
		g[b - 1].push_back(P(a - 1, c));
	}

	for (i = 0; i < n; i++) for (j = 0; j < n; j++) for (k = 0; k < n; k++) {
		d[i][j][k] = -1;
	}

	for (i = 0; i < n; i++) {
		int pv, nv, nc;
		PP p;
		P prr, nrr;
		priority_queue<PP> pq;
		pq.push(PP(P(0, l), i));
		d[i][i][0] = l;
		lt[i][i] = true;
		while (!pq.empty()) {
			p = pq.top();
			pq.pop();
			prr = p.first;
			pv = p.second;
			if (d[i][pv][-prr.first] > prr.second) {
				continue;
			}
			if (prr.second < l && -prr.first + 1 <= n && d[i][pv][-prr.first + 1] < l) {
				d[i][pv][-prr.first + 1] = l;
				pq.push(PP(P(prr.first - 1, l), pv));
			}
			for (j = 0; j < g[pv].size(); j++) {
				nv = g[pv][j].first;
				nc = g[pv][j].second;
				if (prr.second >= nc) {
					nrr = P(prr.first, prr.second - nc);
					if ((!lt[i][nv] || d[i][nv][-nrr.first] >= 0) && d[i][nv][-nrr.first] < nrr.second) {
						d[i][nv][-nrr.first] = nrr.second;
						pq.push(PP(nrr, nv));
						lt[i][nv] = true;
					}
				}
			}
		}
	}

	int q, s, t;

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d%d", &s, &t);
		j = 0;
		for (j = 0; j < n; j++) {
			if (d[s - 1][t - 1][j] >= 0) {
				break;
			}
		}
		if (j == n) {
			printf("-1\n");
		}
		else {
			printf("%d\n", j);
		}
	}

	return 0;
}

Measured memory_bytes: 111036
from sys import stdin, stdout
import math

n = int(stdin.readline().strip())

reserved = 1
maxspeed = 1

while True:
    if reserved + maxspeed * 3 > n:
        break
    maxspeed *= 3
    reserved += maxspeed * 2

ans = 1
n -= 1

i = 3
while i < maxspeed:
    ans += 2
    n -= i * 2
    i *= 3
n -= maxspeed

i = maxspeed
while i:
    ans += n // i
    n -= n // i * i
    i //= 3
stdout.writelines(str(ans + 1) + '\n')



Measured memory_bytes: 5656
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin >> h >> w;
    if(h==0&&w==0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(j==0||j==w-1){
	  cout << "#";
	}else if(i==0||i==h-1){
	  cout << "#";
	}else{
	cout << ".";
	}
      }
      cout << endl;
    }
    cout << endl;
  }
  return(0);
}



Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <map>
#include <utility>
#include <climits>
using namespace std;

#define FOR(i, a, b) for( int i = (a); i < (b); i++)
#define MAX 100100
#define INF INT_MAX

bool flag = true;

void search(vector<vector<pair<int, int>>> &G, int D[MAX], int x, int N, int d) {
	D[x] = d;
	if (G[x].empty()) return;

	auto it = G[x].begin();
	for (; it != G[x].end(); it++) {
		if (D[it->first] == INF) search(G, D, it->first, N, d + it->second);
		else if (D[it->first] != d + it->second) flag = false;
	}
}

int main() {
	int N, M; scanf("%d%d", &N, &M);
	vector<vector<pair<int, int>>> G(MAX);
	int D[MAX]; FOR(i, 0, MAX) D[i] = INF;

	FOR(i, 0, M) {
		int l, r, d; scanf("%d%d%d", &l, &r, &d);
		G[l].push_back(make_pair(r, d)); G[r].push_back(make_pair(l, -d));
	}

	FOR(i, 1, N + 1) {
		if (D[i] == INF) search(G, D, i, N, 0);
	}

	if (flag) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using G = vector<vector<int>>;
    
int main(){
    string t;
    cin >> t;
   
    replace(t.begin(), t.end(), '?', 'D');
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x;
  cin >> a >> b;
 
  x = a * b;	//a*bの積 
  
  if (x % 2 == 0) {	//あまりがなかったら
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
C = []
for _ in range(3):
	C.append(list(map(int, input().split())))

flag = True
for i in range(2):
	if C[0][i+1] - C[0][i] != C[1][i+1] - C[1][i]:
		flag = False
		break
	elif C[1][i+1] - C[1][i] != C[2][i+1] - C[2][i]:
		flag = False
		break

if flag:
	for i in range(2):
		if C[i+1][0] - C[i][0] != C[i+1][1] - C[i][1]:
			flag = False
			break
		elif C[i+1][1] - C[i][1] != C[i+1][2] - C[i][2]:
			flag = False
			break

if flag:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define vi vector<int>
#define lvi vector<long long>
#define pi pair<int,int>
#define lpi pair<long long ,long long>
#define mp make_pair
#define pb push_back
#define ll long long 
#define N 100005
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define mod1 1000000000000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>multiordered_set;
ll int pw(ll int a, ll int b,ll md) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2,md);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
vector<int> pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.push_back(p);
}
bool cmp(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    if(a.first==b.first)return a.second<b.second;
    return a.first<b.first;
}
ll int gcd(ll int a,ll int b)
{
    if(!a)return b;
    return gcd(b%a,a);
}
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
    return true; 
} 
map<int,int>pa;
int find(int i){
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}     
void join(int i,int j){
    int a=find(i);
    int b=find(j);
    if(b>=a)pa[b]=a;
    else pa[a]=b;
}               
int ddx[]={-1,-1,-1,0,1,1,1,0};
int ddy[]={-1,0,1,1,1,0,-1,-1};
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int n,m;
ll p[N],h[N],x[N],y[N];
vector<int>ed[N];
int main()
{
    faltu;
    int t=1;
   // cin>>t;
    while(t--)
    {
        int k;
        cin>>k;
        vector<int>rem;
        int mk[k];
        memset(mk,0,sizeof(mk));
        mk[7%k]=1;
        int cur=7;
        int ans=1;
        while(1)
        {
            if(cur%k==0){cout<<ans;break;}
            ans++;
            cur=(cur*10+7)%k;
            if(mk[cur]){cout<<-1;break;}
            mk[cur]=1;
        }
    }
}

Measured memory_bytes: 9824
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

			int i;
			int j;

			int array1[][] = new int[3][10];
			int array2[][] = new int[3][10];
			int array3[][] = new int[3][10];
			int array4[][] = new int[3][10];

			for(i = 0; i < 3; i++) {
				for(j = 0; j < 10; j++) {
					array1[i][j] = 0;
					array2[i][j] = 0;
					array3[i][j] = 0;
					array4[i][j] = 0;
				}
			}

			int n = sc.nextInt();
			for(i = 0; i < n; i++) {

				int b = sc.nextInt();
				int f = sc.nextInt();
				int r = sc.nextInt();
				int v = sc.nextInt();

				if(b == 1) {
					array1[f - 1][r - 1] += v;

					if(array1[f - 1][r - 1] < 0) {
						array1[f - 1][r - 1] = 0;
					}

					if(array1[f - 1][r - 1] > 9) {
						array1[f - 1][r - 1] = 9;
					}
				}

				if(b == 2) {
					array2[f - 1][r - 1] += v;

					if(array2[f - 1][r - 1] < 0) {
						array2[f - 1][r - 1] = 0;
					}

					if(array2[f - 1][r - 1] > 9) {
						array2[f - 1][r - 1] = 9;
					}
				}

				if(b == 3) {
					array3[f - 1][r - 1] += v;

					if(array3[f - 1][r - 1] < 0) {
						array3[f - 1][r - 1] = 0;
					}

					if(array3[f - 1][r - 1] > 9) {
						array3[f - 1][r - 1] = 9;
					}
				}

				if(b == 4) {
					array4[f - 1][r - 1] += v;

					if(array4[f - 1][r - 1] < 0) {
						array4[f - 1][r - 1] = 0;
					}

					if(array4[f - 1][r - 1] > 9) {
						array4[f - 1][r - 1] = 9;
					}
				}

			}

			for(i = 0; i < 3; i++) {
				for(j = 0; j < 10; j++) {
					System.out.print(" " + array1[i][j]);
				}
				System.out.println();
			}
			System.out.println("####################");

			for(i = 0; i < 3; i++) {
				for(j = 0; j < 10; j++) {
					System.out.print(" " + array2[i][j]);
				}
				System.out.println();
			}
			System.out.println("####################");

			for(i = 0; i < 3; i++) {
				for(j = 0; j < 10; j++) {
					System.out.print(" " + array3[i][j]);
				}
				System.out.println();
			}
			System.out.println("####################");

			for(i = 0; i < 3; i++) {
				for(j = 0; j < 10; j++) {
					System.out.print(" " + array4[i][j]);
				}
				System.out.println();
			}

	}
}

Measured memory_bytes: 29588
#include<bits/stdc++.h>
#define ll long long
const double PI= 3.141592653589793238;
using namespace std;
void solve()
{	int n;cin>>n;
	vector<int> h(n+1);
	int x;
	for(int i=0;i<n-1;i++)
	{
		cin>>x;
		h[x]++;
	}
	for(int i=1;i<=n;i++)
	cout<<h[i]<<"\n";
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 4048
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int a=0;
  string S,T;
  cin>>S>>T;
  for(int i=0;i<=S.size();i++){
  if(S[i]!=T[i])a++;
  }
  cout<<a<<endl;
  return 0;
}


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

int main() {
int N,b,c;cin>>N>>b>>c;
int v[N]={};
int k=0;
for(int i=1;i<N;i++){
for(int j=i+1;j<=N;j++){
k=min(j-i,1+abs(b-i)+abs(c-j));
v[k]++;}}
for(int i=1;i<N;i++){
cout<<v[i]<<endl;}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ull unsigned long long int
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 1200005
#define MOD 1000000007
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define precise cout<<fixed<<setprecision(10)
using namespace std;
const double PI = atan(1.0)*4;
const int64_t INF=100000000000000003;
const int32_t LOG=21;
const int BIG=pow(2,20);
int32_t main(){
         getFaster;
         int a,b,x;
         cin>>a>>b>>x;
         double t=(a*b*b*1.00000)/(2*x);
         double ans=atan(t)*(180.0000/PI);
         double t1=(2.0000*b)-((2.0000*x)/(a*a));
         double ans1=atan(t1/a)*(180.0000/PI);
         int vol=a*a*b;
         if(2*x<=vol)precise<<ans<<endl;
         else precise<<ans1<<endl;
         return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
class tower:
    def __init__(self, H):
        self.H = H
        self.neighbors = []
        self.checked = False
    def add_path(self, a):
        self.neighbors.append(a)
N, M = [int(i) for i in input().split()]
Hs = [int(i) for i in input().split()]
T = {}
for i in range(N):
    T[i+1] = tower(Hs[i])
for i in range(M):
    A, B = [int(i) for i in input().split()]
    T[A].add_path(B)
    T[B].add_path(A)
items_sorted = sorted(T.items(), key = lambda x : x[1].H, reverse=1)
counter = 0
for each in items_sorted:
    i = each[0]
    t = each[1]
    if t.checked:
        continue
    else:
        t.checked = True
        flag = True
        for a in t.neighbors:
            T[a].checked = True
            if t.H <= T[a].H:
                flag = False

        if flag:
            counter += 1
print(counter)

Measured memory_bytes: 112828
/*{{{*/
#include <bits/stdc++.h>
#ifdef DBG
int c_;
#define cout (c_?cerr:cout)
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_;\
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[96;1m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define dprt(...) dbg(prt(__VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define drprt(...) dbg(rprt(__VA_ARGS__))
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
#define rdmp(...) dbg(cerr<<#__VA_ARGS__<<": ";rprt(__VA_ARGS__))
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void prt(const t& a){cout<<a<<'\n';}
template< typename t, typename... v > void prt(const t& a, v&&... b)
{cout<<a<<' ';prt(b...);}
template< typename t > void rprt(t a, const t& b){while(a!=b)cout<<(*a++)<<' ';cout << '\n';}
/*}}}*/



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

    V< ll > tb(3);
    for (ll& i : tb) cin >> i;

    sort(all(tb));

    ll res = LLONG_MAX;
    do
    {
        res = min(res, (tb[0] % 2? tb[1] * tb[2] : 0));
    } while (next_permutation(all(tb)));

    prt(res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int n,k;
    cin>>n >>k;
    vector<int>a(n);
    vector<ll>tasu(n);
    vector<ll>hiku(n);
    if(k>500)k=501;
    rep(i,n)
    {
        cin>>a[i];
        tasu[i]=0;
        hiku[i]=0;
    }
    if(n<=k){
        rep(i,n)cout<<n<<" ";
        cout<<endl;
        return 0;
    }
    rep(t,k)
    {    
        rep(i,n)
        {
            
            tasu[max(0,i-a[i])]++;
            int hikuin=i+a[i]+1;
            if(hikuin<n)hiku[hikuin]++;
        }
        ll now=0;
        bool finish=true;
        rep(i,n)
        {
            now+=(tasu[i]-hiku[i]);
            tasu[i]=hiku[i]=0;
            a[i]=now;
            if(a[i]<n&&finish)finish=false;
        }
      
        if(finish)break;
    }
    rep(i,n)cout<<a[i]<<" ";
    cout<<endl;
    return 0;

}


Measured memory_bytes: 7140
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int res;
    int x,y;

    cin >> N;
    res = N / 15;
    x = 800 * N;
    y = 200 * res;

    cout << x - y << endl;


}

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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;

    int sx, sy, ex, ey;
    int cnt = 0;
    vector<int> x, y;
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            if(s[i][j] == 's'){
                sx = i;
                sy = j;
            }
            if(s[i][j] == 'e'){
                ex = i;
                ey = j;
            }
            if(s[i][j] == 'a'){
                ++cnt;
                x.emplace_back(i);
                y.emplace_back(j);
            }
        }

    x.emplace_back(sx);
    x.emplace_back(ex);
    y.emplace_back(sy);
    y.emplace_back(ey);

    vector<int> dx{1, 0, -1, 0};
    vector<int> dy{0, 1, 0, -1};

    vector<vector<int>> graph(cnt + 2, vector<int>(cnt + 2, MOD));
    for(int i = 0; i < cnt + 2; ++i){
        queue<pair<int,int>> que;
        vector<vector<int>> range(h, vector<int>(w, MOD));
        range[x[i]][y[i]] = 0;
        que.emplace(x[i], y[i]);
        while(!que.empty()){
            int x, y;
            tie(x, y) = que.front();
            que.pop();
            for(int d = 0; d < 4; ++d){
                int nx = x + dx[d];
                int ny = y + dy[d];
                if(nx < 0 || ny < 0 || nx >= h || ny >= w || s[nx][ny] == '#')
                    continue;
                if(chmin(range[nx][ny], range[x][y] + 1))
                    que.emplace(nx, ny);
            }
        }
        for(int j = 0; j < cnt + 2; ++j)
            graph[i][j] = range[x[j]][y[j]];
    }

    vector<vector<i64>> dp(1 << cnt, vector<i64>(cnt, INF));
    for(int i = 0; i < cnt; ++i)
        dp[(1 << i)][i] = graph[cnt][i];

    for(int i = 0; i < (1 << cnt); ++i){
        for(int j = 0; j < cnt; ++j){
            for(int k = 0; k < cnt; ++k){
                chmin(dp[i | (1 << k)][k], dp[i][j] + graph[j][k]);
            }
        }
    }

    i64 ans = INF;
    for(int i = 0; i < (1 << cnt); ++i){
        int cn = __builtin_popcount(i);
        if(cn >= k){
            for(int j = 0; j < cnt; ++j){
                chmin(ans, dp[i][j] + graph[j][cnt + 1]);
            }
        }
    }
    if(ans >= 1e7){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}




Measured memory_bytes: 208740
#include<iostream>
using namespace std;
int main() {

	int H, W;
	cin >> H >> W;

	while (H != 0){

		int j, k;
		for (j = 0; j < H; j++){
			for (k = 0; k < W; k++){

				if (j == 0 || j == H - 1 || k == 0 || k == W - 1)
					cout << "#";
				else cout << ".";

			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	return 0;
}


Measured memory_bytes: 3084
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	gifts <- map ( mp . words ) <$> replicateM n getLine
	printf "%.20f\n" $ sum $ map solve gifts

solve :: ( String, String ) -> Double
solve ( x, u )
	| u == "JPY" = read x
	| otherwise = 380000.0 * ( read x )

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

int binarySort(int A[], int key, int n){
	int left = 0;
	int right = n; 
	int mid;
	while(left<right){
		mid = (left+right)/2;
		if(key==A[mid])
			return 1;
		if(key>A[mid])
			left = mid+1;
		else if(key<A[mid])
			right = mid;
	}
	return 0;
}

int main(){
	
	int sum=0;
	int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	int m;
	cin>>m;
	int B[m];
	for(int i=0;i<m;i++)
		cin>>B[i];
	
	for(int i=0;i<m;i++){
		if(binarySort(A, B[i], n)){
			sum++;
//			break;
		}
	}
	cout<<sum<<endl;	
	
	return 0;
} 


Measured memory_bytes: 3636
import heapq as h

N=int(input())
hen=[[] for i in range(0,N)]
for i in range(0,N-1):
    a,b=map(int,input().split())
    hen[a-1].append(b-1)
    hen[b-1].append(a-1)

c=list(map(int,input().split()))
c.sort(reverse=True)

ans=[-1 for i in range(0,N)]

q=[]
q.append(0)
h.heapify(q)
sub=[]
h.heapify(sub)
count=0
while q!=[]:
    while q!=[]:
        x=h.heappop(q)
        ans[x]=c[count]
        count+=1
        for p in hen[x]:
            if ans[p]==-1:
                h.heappush(sub,p)
        #何らかの操作
        #ここでsubキューに次に使うものを格納
        if q==[]:
            q=sub
            sub=[]
            h.heapify(sub)
            break

print(sum(c)-c[0])
print(*ans)

Measured memory_bytes: 57688
fun main(args: Array<String>) {
    var n = readLine()!!.toInt() % 10
    when (n) {
        3 -> println("bon")
        2 -> println("hon")
        4 -> println("hon")
        5 -> println("hon")
        7 -> println("hon")
        9 -> println("hon")
        else -> println("pon")
    }

}

Measured memory_bytes: 34424
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    string S;
    long long K;
    long long ans = 0;
    cin >> S;
    cin >> K;
    
    vector<int> renzoku(100, 0);
    int num = 0;
    
    
    renzoku[num] = 1;
    for (int i = 1; i < S.length(); ++i) { 
        if (S[i] == S[i -1]){
            renzoku[num]++;
        } else {
            if (renzoku[num]){
                num++;
            }
            renzoku[num] = 1;
        }
    }
    num++;
    
    //for (int i = 0; i < num; i++){
    //    fprintf(stderr, "%d, %d\n", i, renzoku[i]);
    //}

    
    if (num == 1){
        ans = S.length() * K/2;
    } else if (S[0] != S[S.length() - 1]){
        for (int i = 0; i < num; i++){
            ans += renzoku[i]/2;
        }
        ans *= K;
    } else {
        long long tmp = 0;
        for (int i = 1; i < num - 1; i++){
            tmp += renzoku[i]/2;
        }
        ans = tmp * K + renzoku[0]/2 + renzoku[num - 1]/2;
        ans += (renzoku[0] + renzoku[num - 1])/2 * (K - 1);
    }
    cout << ans << 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;

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    int mn_a = *min_element(a.begin(), a.end());
    int mn_b = *min_element(b.begin(), b.end());
    int ans = mn_a + mn_b;
    while(M--) {
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        int t = a[x] + b[y] - c;
        ans = min(ans, t);
    }
    cout << ans << '\n';
    return 0;
}


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

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

    int c = 0;
    for(int  i = 0; i < 3; i++)
    {
        if(s[i] == '1')
            c++;

    }
    cout << c << endl;
         
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

mod=10**9+7

A.sort()
f=True
if N%2==1:
    if A[0]!=0:
        f=False
    else:
        for i in range(1,N,2):
            if not (A[i]==2*(i+1)//2 and A[i+1]==2*(i+1)//2):
                f=False
                break
elif N%2==0:
    for i in range(0,N,2):
        if not (A[i]==2*(i//2)+1 and  A[i+1]==2*(i//2)+1):
            f=False
            break

if f:
    print(2**(N//2)%mod)
else:
    print(0)


Measured memory_bytes: 14008
fn read<T: std::str::FromStr>() -> Vec<T>
where
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).unwrap();
    b.split_whitespace()
        .map(|x| x.trim().parse::<T>().unwrap())
        .collect()
}

fn main() {
    let _ = read::<u64>()[0];
    let vi = read::<u64>();
    let ci = read::<u64>();
    let mut ans = 0;
    for i in 0..vi.len() {
        if vi[i] >= ci[i] {
            ans += vi[i] - ci[i];
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
data = []
for i in xrange(4):
	tou = []
	data.append(tou)
	for j in xrange(3):
		kai = [0 for k in xrange(10)]
		tou.append(kai)
n = int(raw_input())
for i in xrange(n):
	b,f,r,v = map(int, raw_input().split(" "))
	data[b-1][f-1][r-1] = max(0, data[b-1][f-1][r-1] + v)
for tou in data:
	if not tou is data[0]:
		print "#" * 20
	for kai in tou:
		print " " + " ".join(map(str, kai))

Measured memory_bytes: 4240
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, R = list(map(int, sys.stdin.buffer.readline().split()))

if N >= 10:
    print(R)
else:
    print(R + 100 * (10 - N))


Measured memory_bytes: 24184
import sys
from itertools import permutations


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    a, b = 0, 0
    for i, e in enumerate(permutations(range(1, n + 1))):
        if e == p:
            a = i
        if e == q:
            b = i
    print(abs(a - b))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9140
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()


Measured memory_bytes: 42716
#!/usr/bin/rdmd
import std.cstream;

int main(){
	int n,k,m,r,i;
	for(;din.readf(&n,&k,&m),n;printf("%d\n",(r+m)%n+1))for(r=i=0;++i<n;r%=i)r+=k;
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int count = 0;
			char prev = ' ';
			for (char c : s) {
				if (c != prev) {
					count++;
				}
				prev = c;
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 28340
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9+21;
const long long LINF = (long long) 1e18;
const long double PI = 2 * acos((long double)0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define Mahmud main()
#define endl "\n"
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define alla(arr,n) arr,arr+n
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define pb push_back
///Debug
#define dbg1(x) std::cerr<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<','<<#z<<"="<<(z)<<endl;
#define dbgArr(arr,n) cerr<<#arr<<"=["; printArray(arr,n,0,93); cerr<<endl;
///traversing
#define rep(n) for(int i=0;i<n;++i)
#define trv(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();++i)
///necessary functions
inline ll Int()
{
    ll _x=0,_tmp=1;
    char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar(), _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}
inline long double Double()
{
    long double d;
    scanf("%Lf",&d);
    return d;
}
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int ton(string x)
{
    int y;
    std::istringstream ss(x);
    ss >> y;
    return y;
}
template<typename T>
string tostring(T x)
{
    ostringstream ss;
    ss << x ;
    return ss.str();
}

///Current Code vars
#define N 100010
long long n,a,b,c,d;
int arr[N+1],brr[N+1];
///Current Code functions

string s;

void solve()
{
    cin>>n>>a>>b;
    int a1 = min(a,b);
    int rest = n - (a+b);
    dbg2(rest, n);
    if(rest >= 0){
        cout<<a1 << " "<<0<<endl;
    }
    else{
        cout<<a1<<" "<<(-rest)<<endl;
    }
}

int Mahmud
{
    // ios_base::sync_with_stdio(0); //cin.tie(0);
  //#ifdef _LOCAL_
    //freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
  //while(1)
    solve();
  //#ifdef _LOCAL_
    //printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
  //#endif
    return 0;
}


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

int main() {
    long long int n, m, ans = 0;
    cin >> n >> m;
    int diff = abs(n-m);
    if (diff < 2) {
        long long int x = 1, y = 1;
        for(int i = 2; i <= n; ++i) {
            x *= i;
            x %= MOD;
        }
        for(int i = 2; i <= m; ++i) {
            y *= i;
            y %= MOD;
        }
        ans = (x*y)%MOD;
        if(diff == 0) ans = (ans*2)%MOD;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
        return -Parent[root(A)];
    }
    bool connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }
        if (size(A) < size(B)) swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;
        return true;
    }
};
int main() {
    int n, m; cin >> n >> m;
    int a[m], b[m];
    rep(i, m) cin >> a[i] >> b[i];
    UnionFind uni(n + 1);
    ll d = (ll)n * (n - 1) / 2;
    vector<ll> v;
    v.push_back(d);
    for (int i = m - 1; i >= 1; --i) {
        int tmpa = uni.size(a[i]), tmpb = uni.size(b[i]);
        if (uni.root(a[i]) == uni.root(b[i])) {
            v.push_back(d);
            continue;
        }
        uni.connect(a[i], b[i]);
        d -= (ll)tmpa * tmpb;
        v.push_back(d);
    }
    for (int i = (int)v.size() - 1; i >= 0; --i) {
        cout << v[i] << endl;
    }
}


Measured memory_bytes: 3444
import sys
sys.setrecursionlimit(500000)
 
N,Q = map(int,input().split())
G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1 #頂点を0indexに
  G[a].append(b);G[b].append(a)
query = {}
for i in range(Q):
  p,x = map(int,input().split())
  p-=1
  if p not in query:
    query[p] = x
  else:
    query[p] += x
ans = [0 for _ in range(N)]
def dfs(v,par): #vが今いる頂点、parが親。
  if v in query:
    ans[v] += query[v]
  for u in G[v]:
    if u != par:
      ans[u] += ans[v]
      dfs(u,v)
dfs(0,-1)
print(*ans)

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int inf = 1e8;

int dp[21][50001];

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

    int c[m];
    rep(i, m) cin >> c[i];

    rep(j, 50001) dp[0][j] = inf;
    dp[0][0] = 0;

    rep(i, m)
    {
        for (int j = 0; j <= n; j++)
        {
            if (j - c[i] >= 0)
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - c[i]] + 1);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }

    OP(dp[m][n]);

    return 0;
}


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

int main()
{
    int n; cin>>n;
    map<string, long> mp;
    for(int i=0; i<n; ++i) {
        string s; cin>>s;
        sort(begin(s), end(s));
        mp[s]++;
    }
    long res=0;
    for(auto& e: mp) res+=e.second*(e.second-1);
    cout<<res/2<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;


ll A,B,C,D,E,F;
ll ans1,ans2;
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	ans1=inf;

	for(int i=0;i<=F;i+=A*100){
		for(int j=0;j<=F-i;j+=B*100){
			if(i==0&&j==0) continue;
			for(int k=0;k<=F-i-j;k+=C){
				for(int l=0;l<=(i+j)/100*E-k;l+=D){
					if(i+j+k+l>F) continue;
					if(ans2*(i+j+k+l) <= (k+l)*(ans1+ans2)) {
						ans2=(k+l);
						ans1=(i+j);
					}
				}
			}

		}
	}

	cout<<ans1+ans2<<" "<<ans2<<endl;
	return 0;
}


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

int main() {
    int N, t, maxL = -1, sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> t;
        maxL= max(maxL, t);
        sum += t;
    }
    if (sum - maxL > maxL) { 
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
H_list = list(map(int, input().split()))[::-1]
ans = "Yes"
for i in range(0, N-1):
    if H_list[i+1]>H_list[i]:
        if H_list[i+1]-H_list[i]>=2:
            ans = "No"
            break
        else:
            H_list[i+1]-=1
print(ans)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string s;
    cin >> N >> s;
    long long triplets = 0;
    int r[4000] = {}, g[4000] = {}, b[4000] = {};
    int R = 0, G = 0, B = 0;
    for (int i = 0; i < N; ++i) {
        if (s[i] == 'R') ++R;
        else if (s[i] == 'G') ++G;
        else ++B;
        r[i] = R;
        g[i] = G;
        b[i] = B;
    }

    for (int i = 0; i < N - 3; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            char target = '?';
            if (s[i] == 'R' && s[j] == 'G') target = 'B';
            else if (s[i] == 'G' && s[j] == 'R') target = 'B';
            else if (s[i] == 'R' && s[j] == 'B') target = 'G';
            else if (s[i] == 'B' && s[j] == 'R') target = 'G';
            else if (s[i] == 'G' && s[j] == 'B') target = 'R';
            else if (s[i] == 'B' && s[j] == 'G') target = 'R';
            else continue;

            int d = j - i;
            int t = 0;
            if (target == 'R') {
                t = R - r[j];
                if (s[j + d] == 'R') --t;
            } else if (target == 'G') {
                t = G - g[j];
                if (s[j + d] == 'G') --t;
            } else {
                t = B - b[j];
                if (s[j + d] == 'B') --t;
            }
            triplets += t;
        }
    }
    std::cout << triplets << '\n';
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll a;
  long double b;
  cin >> a >> b;
  long double tmp = a * b;
  ll  ans = static_cast<ll>(tmp);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int N;
    cin >> N;
    map<int64_t, int>d;
    for (int i=0; i<N; i++) {
        int64_t n;
        cin >> n;
        if (d.count(n) > 0) {
            d[n] = d[n] + 1;
        } else {
            d[n] = 1;
        }
    }
    int64_t sum = 0;
    for (auto c: d) {
        if (c.second % 2 != 0) {
            sum += 1;
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 9760
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
                    .map(|e| e.parse().ok().unwrap())
                    .collect()
}


fn main() {
    let s = read::<String>();
    let t = read::<String>();

    let mut s_d = s.chars().collect::<Vec<char>>();
    let mut t_d = t.chars().collect::<Vec<char>>();

    s_d.sort();
    t_d.sort();
    t_d.reverse();

    if s_d < t_d {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {

		Scanner sc = new Scanner(System.in);
		long x =  Long.parseLong(sc.next());
		
		int ans = 0;
		long money = 100;
		while(x > money) {
			long temp = (long) (money *0.01);
			money += temp;
			ans++;
		}
		
		System.out.println(ans);
	}
	
}

Measured memory_bytes: 27012
k = int(input())

x = [0]

while(k > 0):
    len_x = len(x)

    if len_x == 1:
        if x[0] != 9:
            x[0] = x[0] + 1
        else:
            x[0] = 1
            x.append(0)
    elif len_x == 2:
        if (x[0] == 9 and x[1] == 9):
            x = [0] * len(x)
            x.insert(0, 1)
        elif x[1] - x[0] < 1:
            x[1] += 1
        else:
            x[0] += 1
            x[1] = x[0] - 1
    else:
        for i in range(len_x):
            if sum(x) == 9 * len_x:
                x = [0] * len(x)
                x.insert(0, 1)
                break
            elif i == len_x - 1:
                x[0] += 1
                temp = x[0]
                x = [temp - i if temp - i >= 0 else 0 for i in range(len_x)]
                break
            elif x[-1 - i] - x[-2 - i] < 1:
                if x[-1 - i] == 9:
                    continue
                x[-1 - i] = x[-1 - i] + 1
                temp = x[-1 - i]
                for j in range(i):
                    j = i - j
                    x[-j] = x[-1 -j] - 1 if x[-1 -j] - 1 >= 0 else 0
                break
    k -= 1

print("".join([str(x) for x in x]))

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

int n;
vector<int> a1, a2;
int main()
{
    cin >> n;
    a1.resize(n);
    a2.resize(n);
    for (int i = 0; i < n; i++) cin >> a1[i];
    for (int i = 0; i < n; i++) cin >> a2[i];

    vector<int> dp1(n, 0);
    vector<int> dp2(n, 0);
    dp1[0] = a1[0];
    dp2[0] = a1[0] + a2[0];
    for (int i = 1; i < n; i++)
    {
        dp1[i] = dp1[i - 1] + a1[i];
        dp2[i] = max(dp1[i], dp2[i - 1]) + a2[i];
    }

    cout << dp2[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<pii> ta(n);
    for(auto &x:ta)
        cin >> x.first >> x.second;
    
  /*  ll ans=2;
    for(auto x:ta){
        for(ll count=0;count<=ans*(x.first+x.second);count++){
            if(ans%(x.first+x.second)==0){
                break;
            }
            ans++;
        }
    }*/
    ll t=1,a=1;
    for(auto x:ta){
        ll gcd=max(t%x.first==0?t/x.first:t/x.first+1,a%x.second==0?a/x.second:a/x.second+1);
        t=gcd*x.first;
        a=gcd*x.second;
    }

    cout << t+a << endl;

    return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	for(int i=0;i<n;i++)
	{
		
		if(a[i]%2==0)
		{
			if(a[i]%3!=0 && a[i]%5!=0)
			{
				cout<<"DENIED";
				return 0;
			}
			
		}
	}
	cout<<"APPROVED";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main(){
	int n;
	cin >> n;
	int tmp;
	int a=0;
	int b=0;
	for(int i=0;i<n;i++){
		cin >> tmp;
		if(tmp%4==0){
			a+=1;
		}else if(tmp%2==0){
			b+=1;
		}
	}
	if(n<=2*a+1 || n<=b+2*a){
		cout << "Yes" << endl;
	}else{
		cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
program main
implicit None
	integer(8)::n,p,q,i
	
	read *,n,p
	
	if(n >= 40)then
		print 101,1
		stop
		else if(n ==1)then
			print 101,p
			stop
	endif 
	
	q = int(real(p)**(1.0/real(n))+0.00001)
	
	do i =  q,2,-1
		if(mod(p,i**n) == 0)then
			print 101,i
			stop
		endif
	enddo
	
	print 101,1
101 format(i0)
end program main


Measured memory_bytes: 512
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    (26)
#define EPS         (1e-10)
#define INF         (1000000005LL)
#define MOD         (1000000007LL)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
// ciling(x/y) = (x+y-1)/y

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    string s;cin >> s;
    string ans = "";
    for(auto c : s){
        switch(c){
            case '0':
            case '1':
                ans.push_back(c);
                break;
            case 'B':
                if(ans.size() > 0){
                    ans.pop_back();
                }
                break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256