akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define MOD 1000000007
int n,m;
const int mxn = 2e5 + 1;
vector<vector<int>> adj(mxn);
int vis[mxn]={0};
int d[mxn]={0};

void bfs(int u){
    queue<int> q;
    q.push(u);
    while(!q.empty()){
    int parent = q.front();
    vis[parent] = 1;
    q.pop(); 
    for(int e : adj[parent]){
        if(!vis[e]){
            q.push(e);
            vis[e] = 1;
            d[e] = parent;
        }
    }
    }
}

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

    cin>>n>>m;
    for(int i = 0; i<m; i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    if(adj[1].size() == 0){
        cout<<"No\n";
        return 0;
    }
    bfs(1);
    cout<<"Yes\n";
    for(int i = 2; i<=n; i++){
        cout<<d[i]<<"\n";    
    }

}

Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int a[5140],b[5140],c[5140];
ll dis[3000];
vector<ll> loop;
int n,m,p;
void find_negative_loop(){
	for(int i=1;i<=n;i++)dis[i]=inf;
	dis[1]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(dis[b[j]]>dis[a[j]]+c[j]){
				dis[b[j]] = dis[a[j]]+c[j];
				if( i == n-1 ){
					loop.pb(a[j]);
				}
			}
		}
	}
}
void shortest_path(int s){
	for(int i=1;i<=n;i++)dis[i]=inf;
	dis[s]=0;
	for(int i=0;i<=n;i++){
		bool update = false;
		for(int i=0;i<m;i++){
			if( dis[a[i]]!=inf && dis[b[i]] > dis[a[i]]+c[i]){
				dis[b[i]] = dis[a[i]]+c[i];
				update = true;
			}
		}
		if(!update)break;
	}
}
bool rb[3000];
int isr[3000][3000];
vector<int> to[3000];
bool isre(ll st, ll gl){
	if(isr[st][gl]==1)return false;
	if(isr[st][gl]==2)return true;
	for(int i=0;i<3000;i++){
		rb[i]=false;
	}
	rb[st] = true;
	queue<int> que;
	que.push(st);
	while(!que.empty()){
		int cur = que.front();que.pop();
		for(int i=0;i<to[cur].size();i++){
			if(rb[to[cur][i]] == false){
				rb[ to[cur][i] ] = true;
				que.push(to[cur][i]);
			}
		}
	}
	for(int i=0;i<n;i++){
		if(rb[i])isr[st][i]=2;
		else isr[st][i]=1;
	}
	return rb[gl];
}
int main(){
	cin>>n>>m>>p;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i]>>c[i];
		c[i] = p-c[i];
		to[a[i]].pb(b[i]);
	}
	find_negative_loop();
	for(int i=0;i<loop.size();i++){
		int cur = loop[i];
		if( isre(1,cur) && isre(cur,n) ){
			cout<<-1<<endl;
			return 0;
		}
	}
	shortest_path(1);
	cout<<max(-dis[n],(ll)0)<<endl;
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
    cin >> (a)[i]

ll lcm(ll x, ll y)
{
    return (x * y) / __gcd(x, y);
}

int main()
{
    ll N, M, ans = 0;
    cin >> N >> M;
    vll a(N);
    rep(i, N)
    {
        cin >> a[i];
        a[i] /= 2;
    }
    ll G = a[0];
    rep(i, N)
    {
        G = lcm(G, a[i]);
    }
    /*   bool flag = true;
 /*
    for (ll i = 0; (2*i+1) * G <= M; i++)
    {
        for (int j = 0; j < N;j++)
        {
            ll B = (G * (2*i+1));
            if ((B/ a[j]) % 2 == 0)
            {
                flag = false;
                break;
            }
        }
        if(flag)
            ans++;
        flag = true;
    }
    */
    bool flag2 = true;
    for (int j = 0; j < N; j++)
    {
        if ((G / a[j]) % 2 == 0)
        {
            flag2 = false;
            break;
        }
    }
    if (!flag2)
        cout << 0;
    else
    {
        if((M/G-1)>=0)
        ans = (M / G - 1) / 2 + 1;
        else
        {
            ans = 0;
        }

        cout << ans;
    }

    return 0;
}


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

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

  for (int i = 1; i < 10; i++) {
    int k = i * 100 + i * 10 + i;
    if (k >= N) {
      cout << k << endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
const int MAXN = (1<<16)+10, MAXM = 18;

ll MOD = 1e9+7;

ll fac[MAXN], fnv[MAXN];

ll comb(ll n, ll k) {
    if (n<0||k<0||k>n) return 0;
    return fac[n]*fnv[k]%MOD*fnv[n-k]%MOD;
}

ll power(ll a, ll n) {
    if (!n) return 1;
    ll t = power(a,n/2);
    return t*t%MOD*((n%2)?a:1)%MOD;
}

void init() {
    int i;
    fac[0] = 1;
    for (i=1;i<MAXN;i++) fac[i] = fac[i-1]*i%MOD;
    for (i=0;i<MAXN;i++) fnv[i] = power(fac[i],MOD-2);
}

int n, m, N;
int A[MAXM];
bool obit[MAXN];
ll D[MAXM][MAXN];

int main() {
    int i;

    init();
    scanf("%d%d",&n,&m); N = 1<<n;
    for (i=1;i<=m;i++) scanf("%d",&A[i]);
    for (i=1;i<N;i++) obit[i] = !obit[i^(i&-i)];
    reverse(A+1,A+m+1);
    D[0][0] = 1;
    for (i=1;i<=m;i++) {
        for (int bit=0;bit<N;bit++) {
            D[i][bit] = D[i-1][bit];
            int tb = bit;
            for (;tb;tb-=(tb&-tb)) D[i][bit] += D[i-1][bit^(tb&-tb)]*comb(N-A[i]-(bit^(tb&-tb)),(tb&-tb)-1)%MOD*fac[tb&-tb]%MOD;
            D[i][bit]%=MOD;
        }
    }
    ll res = fac[N-1];
    int sgn[] = {1,-1};
    for (int bit=1;bit<N;bit++) {
        res+=sgn[obit[bit]]*D[m][bit]*fac[N-1-bit]%MOD;
    }
    res = (res%MOD+MOD)%MOD;
    printf("%lld\n",res*N%MOD);

    return 0;
}


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

int main() {
  string n;
  cin >> n;
  int sum = 0;
  int a;
  
  for (int i = 0; i < n.size(); i++){
    a = n[i] - '0';
    sum += a;
  }
  
  if (sum % 9 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3720
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 sum = m + f;
            if(m == -1 && f == -1 && r == -1){
                break;
            }
            if(m == -1 || f == -1){
                System.out.println("F");
            }else if(sum >= 80){
                System.out.println("A");
            }else if(sum >= 65){
                System.out.println("B");
            }else if(sum >= 50){
                System.out.println("C");
            }else if(sum >= 30){
                if(r >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            }else if(sum < 30){
                System.out.println("F");
            }
        }
    }
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head
const int nax = 5e5+10;
ll fact[nax];
ll inv(ll a) {
    return powmod(a, mod - 2);
}
ll choose(ll a, ll b) {
    return fact[a] * inv(fact[b]) % mod * inv(fact[a-b]) % mod;
}
ll perm(ll a, ll b) {
    return fact[a] * inv(fact[a - b]) % mod;
}

ll mult(ll a, ll b) {
    return (a % mod) * (b % mod) % mod;
}
ll sub(ll a, ll b) {
    ll xd = a - b;
    if(xd < 0) xd += mod;
    return xd;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    fact[0] = 1;
    for(ll i = 1; i < nax; i++) {
        fact[i] = i * fact[i-1] % mod;
    }

    int n, m;
    cin >> n >> m;
    
    ll ans = mult(fact[m], inv(fact[m - n]));
    ans = mult(ans, ans);

    ll sum = 0;
    for(int i = 0; i <= n; i++) {
        ll sign = -1;
        if(i % 2 == 0) sign = 1;
        ll xd = 1;
        xd = mult(choose(n, i), sign);
        xd = mult(xd, perm(m, i));
        xd = mult(xd, mult(perm(m - i, n - i), perm(m - i, n - i)));
        if(xd < 0) xd += mod;
        sum += xd;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 7564
#include <cmath>
#include <random>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
mt19937 mt(2007111352);
int rand_rng(int l, int r) {
	uniform_int_distribution<int> p(l, r - 1);
	return p(mt);
}
double randouble() {
	uniform_real_distribution<double> p(0.0, 1.0);
	return p(mt);
}
long long calc(int N, vector<int> X, vector<int> Y, vector<int> P, vector<int> xrail, vector<int> yrail) {
	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		int mindist = (1 << 30);
		for (int j : xrail) {
			mindist = min(mindist, abs(X[i] - j));
		}
		for (int j : yrail) {
			mindist = min(mindist, abs(Y[i] - j));
		}
		ans += 1LL * mindist * P[i];
	}
	return ans;
}
int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N), P(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i] >> P[i];
	}
	vector<int> xinc, yinc;
	for (int i = 0; i < N; ++i) {
		if (X[i] != 0) xinc.push_back(X[i]);
		if (Y[i] != 0) yinc.push_back(Y[i]);
	}
	sort(xinc.begin(), xinc.end()); xinc.erase(unique(xinc.begin(), xinc.end()), xinc.end());
	sort(yinc.begin(), yinc.end()); yinc.erase(unique(yinc.begin(), yinc.end()), yinc.end());
	int candx = xinc.size();
	int candy = yinc.size();
	vector<long long> ans(N + 1);
	int limit = min(candx, candy);
	vector<bool> flag(candx + candy, false);
	function<long long()> get_score = [&]() {
		vector<int> xrail = { 0 }, yrail = { 0 };
		for (int i = 0; i < candx + candy; ++i) {
			if (flag[i]) {
				if (i < candx) xrail.push_back(xinc[i]);
				else yrail.push_back(yinc[i - candx]);
			}
		}
		return calc(N, X, Y, P, xrail, yrail);
	};
	ans[0] = get_score();
	for (int i = 1; i < limit; ++i) {
		int u = -1;
		do {
			u = rand_rng(0, candx + candy);
		} while (flag[u]);
		flag[u] = true;
		// --- hill climbing! --- //
		long long current_score = get_score();
		long long best_score = current_score;
		int repeat = 100000;
		for (int j = 1; j <= repeat; ++j) {
			int u1 = -1, u2 = -1;
			do {
				u1 = rand_rng(0, candx + candy);
				u2 = rand_rng(0, candx + candy);
			} while (!flag[u1] || flag[u2]);
			flag[u1] = false; // true -> false
			flag[u2] = true; // false -> true
			double temperature = double(max(repeat - (j % (repeat / 4)) * 5, 1)) / repeat * ans[i - 1] * 2.0;
			long long new_score = get_score();
			if (randouble() < exp((current_score - new_score) / temperature)) {
				if (best_score > new_score) {
					cerr << "Repeat #" << j << ": Score " << best_score << " -> " << new_score << endl;
					best_score = new_score;
				}
				current_score = new_score;
			}
			else {
				// revert
				flag[u1] = true;
				flag[u2] = false;
			}
		}
		ans[i] = best_score;
	}
	for (int i = 0; i <= N; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4212
def no_of_500(X):
  return X/500

def rem(X):
  return X%500

def no_of_5(X):
  return rem(X)/5

def happiness_points(X):
  return (no_of_500(X)*1000)+(no_of_5(X)*5)

X=input()
print(happiness_points(X))

Measured memory_bytes: 2568
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int a, b, c;
	cin >> a >> b >> c;
	c -= min(c, a - b);
	dump(c);
	return 0;
}


Measured memory_bytes: 892
from sys import stdin, stdout
from collections import defaultdict
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()

def brute(S):
	ans = 0
	for i in range(len(S)):
		for j in range(i+1, len(S)):
			for k in range(j+1, len(S)):
				if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
					if k - j != j - i:
						ans += 1
	return ans

def main():
	n = int(rl())
	s = rll()[0]
	cnt = [[0, 0, 0] for _ in range(len(s))]
	d = {"R": 0, "G": 1, "B": 2}
	for i in range(len(s)):
		if i == 0:
			for c in d.keys():
				if s[i] == c:
					cnt[0][d[c]] += 1
					break
		else:
			for j in range(3):
				cnt[i][j] = cnt[i-1][j] 
			for c in d.keys():
				if s[i] == c:
					cnt[i][d[c]] += 1
					break
	ans = 0
	for k in range(3, len(s)):
		color = s[k]
		for j in range(1, k):
			second_color = s[j]
			if second_color == color: continue
			diff = k - j
			third_color = [x for x in ["R", "G", "B"] if x != color and x != second_color][0]
			choices = cnt[j-1][d[third_color]]
			crit_i = (2*j) - k
			if crit_i >= 0 and crit_i < j:
				choices -= 1 if s[crit_i] == third_color else 0
			ans += choices
	stdout.write(str(ans));stdout.write("\n")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 75112
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

type dk struct {
	P, X int
}

type dks []dk

func (p dks) Len() int {
	return len(p)
}

func (p dks) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p dks) Less(i, j int) bool {
	if p[i].P != p[j].P {
		return p[i].P < p[j].P
	}
	return p[i].X < p[j].X
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	T := make([]int, N)
	for i := 0; i < N; i++ {
		T[i] = getInt()
	}
	M := getInt()
	p := make([]int, M)
	m := make([]int, M)
	for i := 0; i < M; i++ {
		p[i], m[i] = getInt()-1, getInt()
	}

	for i := 0; i < M; i++ {
		ans := 0
		for j := 0; j < N; j++ {
			if p[i] == j {
				ans += m[i]
			} else {
				ans += T[j]
			}
		}
		out(ans)
	}
}


Measured memory_bytes: 640
sx, sy, tx, ty = map(int, input().split())

nowx, nowy = sx, sy

ans = ''

for i in range(ty-sy):
    ans += 'U'
for i in range(tx-sx):
    ans += 'R'
for i in range(ty-sy):
    ans += 'D'
for i in range(tx-sx):
    ans += 'L'
ans += 'L'
for i in range(ty-sy):
    ans += 'U'
ans += 'U'
for i in range(tx-sx):
    ans += 'R'
ans += 'R'
ans += 'D'
ans += 'R'
for i in range(ty-sy):
    ans += 'D'
ans += 'D'
for i in range(tx-sx):
    ans += 'L'
ans += 'L'
ans += 'U'

print(ans)

Measured memory_bytes: 3064
n, m, x = map(int, input().split())
CA = [list(map(int, input().split())) for i in range(n)]
C = [CA[i][0] for i in range(n)]
A = [CA[i][1:] for i in range(n)]
MC = []
for s in range(1 << n):
    X = [0 for j in range(m)]
    c = 0
    for i in range(n):
        if (s >> i) & 1 == 1:
            for j in range(m):
                X[j] += A[i][j]
            c += C[i]
    if all([X[j] >= x for j in range(m)]):
        MC.append(c)
if MC == []:
    print(-1)
else:
    print(min(MC))


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

int main() {
    int n; cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> t(n);

    rep(i, n) cin >> p.at(i);
    rep(i, n) {
        cin >> q.at(i);
        t.at(i) = i + 1;
    }
    int i = 0;
    int p_ans = -1;
    int q_ans = -1; 
    do {
        int j = 0;
        for (j = 0; j < n; j++) {
            if (p.at(j) != t.at(j))
                break;
        }
        if (j == n)
            p_ans = i;

        for (j = 0; j < n; j++) {
            if (q.at(j) != t.at(j))
                break;
        }
        if (j == n)
            q_ans = i;

        if (p_ans >= 0 && q_ans >= 0)
            break;
        i++;
    } while (next_permutation(t.begin(), t.end()));
    //cout << p_ans << " " << q_ans << endl;
    cout << abs(p_ans+1 - (q_ans+1)) << endl;
    return 0;
}

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

map<int,int> m;

int main(){
int n;
scanf("%d",&n);
int mn = 1000000005;
int mx = -1;
for (int x = 0; x<n; x++){
    int a;
    scanf("%d",&a);
    mn = min(mn,a);
    mx = max(mx,a);
    m[a]++;
}
if (mx%2==0){
    if (m[mn]!=1){
        printf("Impossible");
        return 0;
    }
}
else{
    if (m[mn]!=2){
        printf("Impossible");
        return 0;
    }
}
if (m[mx]<2){
    printf("Impossible");
    return 0;
}
if (mn!=(mx+1)/2){
    printf("Impossible");
    return 0;
}
for(int x = mn+1; x<=mx; x++){
    if (m[x]<2){
        printf("Impossible");
        return 0;
    }
}
printf("Possible");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e9;
/************************  DEFINE  ****************************/
int match[10] = {0,2,5,5,4,5,6,3,7,6};
int dp[100010];
////////////////////////  MAIN //////////////////////////////////

int main(void){

    int n,m; cin >> n >> m;
    vector<int> a(m); rep(m) cin >> a[i];
    sort(all(a)); reverse(all(a));
    rep(n+1) dp[i] = -1*INF;
    dp[0] = 0;
    for(int i = 1;i <= n;i++){
        int lyn = -1*INF;
        for(int j = 0;j < m;j++){
            if(i - match[a[j]] >= 0){
                lyn = max(lyn,dp[i - match[a[j]]] + 1);
            }
        }
        dp[i] = lyn;
    }
    vector<int> ans;
    int rn = n;
    for(int i = dp[n];i > 0;i--){
        for(int j = 0;j < m;j++){
            if(rn - match[a[j]] >= 0 && dp[rn] == dp[rn - match[a[j]]] + 1){
                rn -= match[a[j]];
                ans.pb(a[j]);
                break;
            }
        }
    }
    rep(dp[n]) cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>


int main() {

    int N;
    std::cin >> N;
    double x, y;
    std::vector<std::tuple<double, double>> vs;
    for (int i = 0; i < N; ++i) {
        std::cin >> x >> y;
        vs.emplace_back(x, y);
    }
    std::vector<int> ps;
    for (int j = 0; j < N; ++j) {
        ps.push_back(j);
    }

    double sum = 0;
    double n = 0;
    do {
        for (int i = 0; i < N - 1; ++i) {
            int p1 = ps[i];
            int p2 = ps[i + 1];
            double xi = std::get<0>(vs[p1]);
            double yi = std::get<1>(vs[p1]);
            double xi2 = std::get<0>(vs[p2]);
            double yi2 = std::get<1>(vs[p2]);
            sum += sqrt((xi - xi2) * (xi - xi2) + (yi - yi2) * (yi - yi2));
        }
        n += 1;
    } while (std::next_permutation(ps.begin(), ps.end()));


    std::cout << std::fixed << std::setprecision(6) << (sum / n) << "\n";

    return 0;
}


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

int main() {
    int N, T, A;

    cin >> N;
    cin >> T >> A;

    vector <int> H(N);
    vector <float> temp(N);
    vector <float> dif(N);

    for (int i = 0; i < N; i++){
        cin >> H[i];
    }

    for (int i = 0; i < N; i++){
        temp[i] = float(T) - float(H[i]) * 0.006;   //正直余計な書き方
        dif[i] = abs(temp[i] - float(A));
    }

    int min = *min_element(dif.begin(), dif.end()); //別にいらない
    int min_ind = min_element(dif.begin(), dif.end()) - dif.begin();    //この2つの書き方の違いがよく分からん

    cout << min_ind + 1 << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    vector<vector<int>> a(3,vector<int>(3));
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    
    bool flag[3][3];
    
    int n;
    cin >> n;
    vector<int>b(n);
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            flag[i][j] = false;
            for(int k = 0;k < n;k++){
                if(b[k] == a[i][j]){
                    flag[i][j] = true;
                    }
            }
        }
    }
    
    bool ans = false;
    for(int i = 0;i < 3;i++){
        if(flag[i][0] && flag[i][1] && flag[i][2]){
            ans = true;
        }
        if(flag[0][i] && flag[1][i] && flag[2][i]){
            ans = true;
        }
    }
    if(flag[0][0] && flag[1][1] && flag[2][2]){
        ans = true;
    }
    if(flag[0][2] && flag[1][1] && flag[2][0]){
        ans = true;
    }
    cout << ((ans) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char AFN[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char ars[27]="abcdefghijklmnopqrstuvwxyz";
  char s1,c='a';
  int i,j=0,data[27]={0};
  while(scanf("%c",&s1)!=EOF){
    if(s1>=97){
      for(j=0;j<26;j++){
	if(s1==ars[j]){
	  data[j]=data[j]+1; 
	}
      }
    }
    if(s1>=65&&s1<=90){
      for(j=0;j<26;j++){
	if(s1==AFN[j]){
	  data[j]=data[j]+1;
	}
      }
    }
    j=0;
  }
  for(i=0;i<26;i++){
    printf("%c : %d\n",c+i,data[i]);
  }
  return(0);
}

Measured memory_bytes: 968
/*
    # Gir bhi gyaa bhai tera uthke phir machaayega
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
//#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define se second
#define fi first
#define pai acos(-1)
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x,s) for(i=x;i>=s;i--)
#define fit(itr,s) for(itr=s.begin();itr!=s.end();itr++)
#define W while
#define pp pair<ll,ll>
#define ppi pair<int,int>
#define vl vector<ll>
#define vll vector<pp >
#define vi vector<int>
#define vii vector<ppi>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define debug(x) cerr<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define boost  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const ll MAX=1e4;
const ll MM=1e18;
const ll mod=1e9+7;

ll expo(ll x,ll n,ll M=mod)
{
    ll ans=1;
    while(n>0)
    {
        if(n&1){ans=(ans*x)%M;}
                x=(x*x)%M;
                n>>=1;
    }
    return ans;
}


void solve()
{
   ll k,a,b;
   cin>>k;
   a=100;
   ll t=0;
   while(a<k)
   {

       if((MM-a)<(a/100))
       {t++;break;}
        a=(a+(a/100));
        t++;
   }
   cout<<t<<endl;

}


int main()
{
  boost;
  int t=1;
  //cin>>t;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int n,a[N],b[N],f[N],si[N],fa[N];
int find(int x){
	return f[x]?f[x]=find(f[x]):x;
}
struct each{
	int x,y,id;
	each (int xx=0,int yy=0,int dd=0){
		x=xx,y=yy,id=dd;
	}
	bool operator < (const each k) const{
		return 1LL*x*k.y<1LL*k.x*y;
	}
};
priority_queue<each>que;
long long ans;
int main(){
	//freopen("1.out","w",stdout);
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=2;i<=n;i++)	fa[i]=read();
	for(int i=1;i<=n;i++)	a[i]=read();
	for(int i=1;i<=n;i++)	si[i]=1;
	for(int i=2;i<=n;i++)
		if(!a[i])	f[i]=find(fa[i]),si[f[i]]+=si[i];
	for(int i=1;i<=n;i++)	if(a[i])	b[i]=1,ans+=(--si[i]);
	for(int i=2;i<=n;i++)	if(a[i])	que.push(each(si[i],b[i],i));
	for(int i=1;i<=n;i++)	fa[i]=find(fa[i]);
	for(int i=1;i<=n;i++)	f[i]=0;
	while(!que.empty()){
		each x=que.top();	que.pop();
		int k=x.id,y=find(fa[k]);
		if(!y||x.x!=si[k])	continue;
		ans+=1LL*b[y]*x.x,si[y]+=si[k],b[y]+=b[k],f[k]=y;
		que.push(each(si[y],b[y],y));
	}
	printf("%lld\n",ans);
	return 0;
}


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

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


Measured memory_bytes: 256
def c_Otoshidama_C(N, Y):
    yen = Y // 1000
    """
    変数x,y,z(それぞれ1万円札、5千円札、千円札の枚数)は以下の条件を満たす。
    a. x + y + z = N      <=> x + y = N - z      (1)
    b. 10x + 5y + z = yen <=> 2x + y = (yen-z)/5 (2)
    c. 0 <= z <= min(N,yen)       (方程式1,2より)
    d. z ≡ yen (mod 5)            (方程式2の右辺が整数となるため)
    e. N-z <= (yen-5)/2 <= 2(N-z) (方程式1,2より)
    cdeを満たすzを1つ見つけたのち、連立方程式を解けばよい。
    """
    for z in range(min(N, yen) + 1):
        if (z % 5 == yen % 5) and (N - z <= (yen - z) / 5 <= 2 * (N - z)):
            noguchi = z
            tmp1 = -5 * N + yen + 4 * noguchi
            tmp2 = 10 * N - yen - 9 * noguchi
            if tmp1 % 5 == 0 and tmp2 % 5 == 0:
                yukichi = tmp1 // 5
                higuchi = tmp2 // 5
                if yukichi >= 0 and higuchi >= 0:
                    return '{} {} {}'.format(yukichi, higuchi, noguchi)
    return '-1 -1 -1'

N,Y=[int(i) for i in input().split()]
print(c_Otoshidama_C(N, Y))

Measured memory_bytes: 3064
n,k = map(int, input().split())
list_a = list(map(int, input().split()))
dict_a = {}
for i in range(n):
    try:
        dict_a[list_a[i]] += 1
    except KeyError:
        dict_a[list_a[i]] = 1
list_val = []
for value in dict_a.values():
    list_val.append(value)
list_val.sort()
list_val.reverse()
ans = 0
for i in range(k,len(list_val)):
    ans += list_val[i]
print(ans)


Measured memory_bytes: 33152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Solve());
            return;
        }

        private static int Solve()
        {
            var strN = Console.ReadLine();
            var n = int.Parse(strN);
            var len = n.ToString().Length;
            var ans = 0;
            for (int i = 3; i < len; i++) ans += Solve2(i);

            var e = Enumerate(new char[] { '3', '5', '7' }, len)
                .Where(x => int.Parse(x) <= n)
                .Except(Enumerate(new char[] { '3', '5' }, len))
                .Except(Enumerate(new char[] { '5', '7' }, len))
                .Except(Enumerate(new char[] { '3', '7' }, len)).Count();
            return ans + e;
        }

        private static int Solve2(int len)
        {
            var ans = (int)Math.Pow(3, len) - 3 * (int)Math.Pow(2, len) + 3;
            return ans < 0 ? 0 : ans;
        }

        public static IEnumerable<string> Enumerate(IEnumerable<char> items, int k)
        {
            if (k == 1)
            {
                foreach (var item in items)
                    yield return item.ToString();
                yield break;
            }
            foreach (var l in items)
            {
                foreach (var r in Enumerate(items, k - 1))
                {
                    yield return $"{l}{r}";
                }
            }
        }
    }
}


Measured memory_bytes: 23636
q=int(input())
dic={}
for i in range(q):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)
  

Measured memory_bytes: 35600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <list>
using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 2; i < n; i++)
    {
        if (((a[i - 2] < a[i - 1]) && (a[i - 1] < a[i])) || ((a[i] < a[i - 1]) && (a[i - 1] < a[i - 2])))
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;

int main() {

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

  vector<vector<int>> maze(H+2, vector<int>(W+2));
  vector<vector<int>> dist(H+2, vector<int>(W+2));

  REP(h,H+2){
    REP(w,W+2){
      dist[h][w] = H*W*1000;
      maze[h][w] = 1;
    }
  }
  dist[1][1] = 1;


  REP(h,H){
    REP(w,W){
      char ctmp;
      cin >> ctmp;
      if (ctmp == '.') maze[h+1][w+1] = 0;
    }
  }

  deque<vector<int>> deq;
  vector<int> vtmpinitial(2);
  vtmpinitial[0] = 1;
  vtmpinitial[1] = 1;
  deq.push_back(vtmpinitial);

  //  Breadth First Search
  while(! deq.empty()){
    vector<int> vtmp(2);
    int x, y;

    x = deq[0][0];
    y = deq[0][1];
    deq.pop_front();

    int nextx, nexty;
    nextx = x-1;
    nexty = y;
    if (maze[nextx][nexty] == 0){
      if(dist[nextx][nexty] > dist[x][y]+1){
        dist[nextx][nexty] = dist[x][y]+1;
        vtmp[0] = nextx;
        vtmp[1] = nexty;
        deq.push_back(vtmp);
      }
    }

    nextx = x+1;
    nexty = y;
    if (maze[nextx][nexty] == 0){
      if(dist[nextx][nexty] > dist[x][y]+1){
        dist[nextx][nexty] = dist[x][y]+1;
        vtmp[0] = nextx;
        vtmp[1] = nexty;
        deq.push_back(vtmp);
      }
    }

    nextx = x;
    nexty = y-1;
    if (maze[nextx][nexty] == 0){
      if(dist[nextx][nexty] > dist[x][y]+1){
        dist[nextx][nexty] = dist[x][y]+1;
        vtmp[0] = nextx;
        vtmp[1] = nexty;
        deq.push_back(vtmp);
      }
    }

    nextx = x;
    nexty = y+1;
    if (maze[nextx][nexty] == 0){
      if(dist[nextx][nexty] > dist[x][y]+1){
        dist[nextx][nexty] = dist[x][y]+1;
        vtmp[0] = nextx;
        vtmp[1] = nexty;
        deq.push_back(vtmp);
      }
    }

  }



  if (dist[H][W] == H*W*1000){
    cout << -1 << endl;
  } else{
    int ans = H*W;
    REP(h,H){
      REP(w,W){
        if (maze[h+1][w+1] == 1) ans-=1;
      }
    }
    ans -= dist[H][W];
    cout << ans << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    ll N, M;
    std::cin >> N >> M;

    std::priority_queue<ll> prices;

    for (ll i = 0; i < N; ++i)
    {
        ll tmp;
        std::cin >> tmp;
        prices.push(tmp);
    }

    while (!prices.empty() && M > 0)
    {
        int price = prices.top();
        prices.pop();

        price /= 2;

        if (price > 0)
            prices.push(price);

        --M;
    }

    ll sum = 0;

    while (!prices.empty())
    {
        sum += prices.top();
        prices.pop();
    }

    return sum;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
int main()
{
    int a1,a2,a3,sum=0;
    scanf("%d%d%d",&a1,&a2,&a3);
    sum=a1+a2+a3;
    if(sum>=22)
        printf("bust");
    else
        printf("win");
    return 0;
}

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

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

    char c=S[0];
    int ct=0;
    for(int i=0;i<S.size();i++){
        if(c==S[i]) continue;
        else{
            c=S[i];
            ct++;
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 512
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    num_list = i_list()

    num_list.sort()

    min = 0
    for i in range(1,3):
        min += num_list[i] - num_list[i-1]

    print(min)
     

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<29
vector<vector<int> > G;
int d[101];
int V;
void dijkstra(int s){
  bool used[101];
  fill(d,d+101,INF);
  memset(used,false,sizeof(used));
  d[s]=0;
  while(1){
    int id=-1;
    for(int i=0;i<=V;++i){
      if(!used[i] && (id==-1||d[id]>d[i]))
        id=i;
    }
    if(id==-1) break;
    used[id]=true;
    for(int i=0;i<=V;++i){
      d[i]=min(d[i],d[id]+G[id][i]);
    }
  }
}
int main(){
  int k;
  while(cin>>V>>k,V){
    G=vector<vector<int> >(V+1,vector<int>(V+1,INF));
    for(int i=0;i<k;++i){
      int x; cin>>x;
      if(x){
        int a,b,c; cin>>a>>b>>c;
        G[a][b]=G[b][a] = min(G[a][b], c);
      }else{
        int a,b; cin>>a>>b;
        dijkstra(a);
        cout<<(d[b]==INF?-1:d[b])<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3176
#include<bits/stdc++.h>
const unsigned int M = 1000000007; 
#define all(v) (v).begin(), (v).end()
#define rall(v) v.rbegin(),v.rend()
#define  pb push_back
#define int  long long
#define N 998244353
#define endl "\n"
#define fr(i,n) for(int i=0;i<n;i++)
int power(int x,int y){int res=1;while(y>0){if(y&1)res=x*res; y=y>>1;x=x*x;}return res;}
int power(int x,int y,int mod){int res=1;while(y>0){if(y&1)res=x*res%mod; y=y>>1;x=x*x%mod;}return res;}

using namespace std;

void nik()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
}


#define F first
#define S second

#define PI 3.141592653589793238



 signed main()
{
//nik();

int test=1;
//cin>>test;

while(test--)
{	
int n,r[4005]={0},g[4005]={0},b[4005]={0};
cin>>n;
string s;
cin>>s;

if(s[0]=='R')r[0]=1;
if(s[0]=='G')g[0]=1;
if(s[0]=='B')b[0]=1;
for(int i=1;i<n;i++)
{
	r[i]=r[i-1]+(s[i]=='R');
	g[i]=g[i-1]+(s[i]=='G');
	b[i]=b[i-1]+(s[i]=='B');

}
int ans=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<n-1;j++)
	{
		if(s[i]==s[j])continue;
		int ok=0;
		int x=j-i;
		if(j+x>=n)ok=1;

		if(s[i]!='R' and s[j]!='R'){ans+=r[n-1]-r[j];if(!ok and s[j+x]=='R')ans--;}
		if(s[i]!='G' and s[j]!='G'){ans+=g[n-1]-g[j];if(!ok and s[j+x]=='G')ans--;}
		if(s[i]!='B' and s[j]!='B'){ans+=b[n-1]-b[j];if(!ok and s[j+x]=='B')ans--;}


	}
}
cout<<ans;

}
 return 0;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
int main(){
  int N;
  cin>>N;
  vector<int> L(2*N);
  rep(i,2*N) cin>>L[i];
  sort(all(L));
  int ans=0;
  rep(i,N) ans+=L[2*i];
  cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i <= N; ++i){
    int x = i*(1.08);
    if(x == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    for(int i=0;i<n;i++){
	char[] s = readln().chomp().to!(char[]);
	if(s.length>=6){
	    for(int j=0;j<s.length-6;j++){
		if(s[j]=='H'&&s[j+1]=='o'&&s[j+2]=='s'&&s[j+3]=='h'&&s[j+4]=='i'&&s[j+5]=='n'&&s[j+6]=='o') s[j+6] = 'a';
	    }
	}
	s.writeln();
    }
}

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

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

    cout << max(max(a + b, a - b), a * b) << ln;

    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int arr[100005];
int n,k,x;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);

} 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    bool u=false;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        if(i==1) x=arr[1];
        else x=gcd(x,arr[i]);
        if(arr[i]==k){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
        if(arr[i]>k) u=true;
    }
    if(!u){
        cout<<"IMPOSSIBLE"<<endl;
        return 0;
    }
    if(k%x==0){
        cout<<"POSSIBLE"<<endl;
    }
    else cout<<"IMPOSSIBLE"<<endl;

}

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

int main(){
    string s;
    string t;
    cin>>s>>t;
    map<char,set<char>>mps;
    map<char,set<char>>mpt;
    rep(i,s.size()){
        mps[s[i]].insert(t[i]);
        mpt[t[i]].insert(s[i]);
    }
    for(auto p: mps){
        if(p.second.size()>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(auto p: mpt){
        if(p.second.size()>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

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

int main(void){
    long long N;cin>>N;
    long long H[N];
    for(long long i=0;i<N;i++){
        cin>>H[i];
    }
    long long ans=0;
    long long tmp=0;
    for(long long i=1;i<N;i++){
        if(H[i]<=H[i-1]){
            tmp++;
        }
        else{
            ans=max(ans,tmp);
            tmp=0;
        }
    }
    ans=max(ans,tmp);
    cout<<ans<<endl;
    return 0;
}

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

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];

  vector<vector<ll>> path(n);
  rep(i,m){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }

  ll ans = 0;
  rep(i,n){
    bool ok = true;
    rep(j,path[i].size()){
        if(h[i] <= h[path[i][j]]){
          ok = false;
          break;
        }
    }
    if(ok) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    vector<ll> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end(),greater<>());
    ll ans;
    ll left=p-1, right=n;

    while (right-left>1) {
        ll mid=left+(right-left)/2;
        ll r=m*(v-(n-mid)-(p-1));
        ll c=0;
        for (int i=p-1;i<mid;i++) c+=a[mid]+m-a[i];
        if (r<=c && a[p-1]<=a[mid]+m) left = mid;
        else right = mid;
    }
    ans=left+1;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d=0,e=0,i,j,n;
    int T[100];
    cin>>a>>b;
    int A[a][b];
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cin>>A[i][j];
        }
    }
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cout<<A[i][j]<<" ";
            d+=A[i][j];
        }
        cout<<d<<endl;
        d=0;
    }
    for(i=0;i<b;i++){
        for(j=0;j<a;j++){
            d+=A[j][i];
            e+=A[j][i];
        }
        cout<<d<<" ";
        d=0;
    }
    cout<<e<<endl;
    
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300100;
int n;
pair<int,int> seg[maxn], ans[maxn];
void upd(int p, int v){
	for(seg[p += n] = {v, p}; p > 1; p >>= 1)
		seg[p>>1] = min(seg[p], seg[p ^ 1]);
}
pair<int,int> qry(int l, int r){
	pair<int,int> ans = {1<<30, 1<<30};
	for(l += n, r += n; l < r; l >>= 1, r >>= 1){
		if(l&1) ans = min(ans, seg[l++]);
		if(r&1) ans = min(ans, seg[--r]);
	}
	return ans;
}
int main(){
	int m; cin >> n >> m;
	string s; cin >> s;
	n++;
	upd(n - 1, 0);
	for(int i = n - 2; i >= 0; i--){
		pair<int,int> b = {1<<30, 1<<30};
		if(s[i] == '0'){
			b = qry(i + 1, min(i + m + 1, n));
		}
		b.first++;
		upd(i, b.first);
		ans[i] = b;
	}
	if(ans[0].first >= (1<<30)) cout << -1 << endl;
	else {
		int p = 0;
		while(p != n - 1){
			cout << ans[p].second - p << " ";
			p = ans[p].second;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cmath>

using namespace std;

bool check_prime(int n) {
	if (n == 2) return true;
	if (n == 3) return true;
	if (n % 2 == 0) return false;
	

	int r = sqrt(n);
	for (int i = 3; i <= r; i+=2) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;;
}

int main() {
	int n,counter = 0;
	cin >> n;
	while (n--) {
		int a;cin >> a;
		if (check_prime(a)) counter++;
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 1160
import math
n,k = map(int,input().split())
sumlist = []
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log(k/i,2)
    if s == int(s):
      sumlist.append((1/2)**(int(s)))
    else:
      sumlist.append((1/2)**(int(s)+1))
  else:sumlist.append(1)
print(round(sum(sumlist)/n,10)-10**(-10))

Measured memory_bytes: 44784
f1::String->Int->Int->[Int]
f1 "" _ _ =[]
f1 "L" p1 p2=[0]
f1 "RL" p1 p2=[(p2-p1) `div` 2+1,(p2-p1+1) `div` 2+1]
f1 "LL" _ _=[0,0]
f1 (c1:c2:cs) p1 p2
        |c1=='L' && c2=='L'=0:f1 (c2:cs) p1 (p2+1)
        |c1=='R' && c2=='R'=0:f1 (c2:cs) p1 (p2+1)
        |c1=='L' && c2=='R'=0:f1 (c2:cs) (p2+1) (p2+1)
        |c1=='R' && c2=='L'=((p2-p1) `div` 2+1):((p2-p1+1) `div` 2+1):f1 cs (p2+2) (p2+2)

f2::String->Int->Int->[Int]
f2 "" _ _ =[]
f2 "L" p1 p2=[0]
f2 "RL" p1 p2=[div (p2-p1) 2,div (p2-p1+1) 2]
f2 "LL" _ _=[0,0]
f2 (c1:c2:cs) p1 p2
        |c1=='L' && c2=='L'=0:f2 (c2:cs) p1 (p2+1)
        |c1=='R' && c2=='R'=0:f2 (c2:cs) p1 (p2+1)
        |c1=='L' && c2=='R'=0:f2 (c2:cs) (p2+1) (p2+1)
        |c1=='R' && c2=='L'=p4:p3:f2 cs (p2+2) (p2+2)
        where p3=div (p2-p1+1) 2
              p4=div (p2-p1) 2
        
f3::[Int]->[Int]->[String]
f3 [] []=[]
f3 (x:xs) (y:ys)=(show (x+y)):f3 xs ys

main = do
       x<-getLine
       putStrLn $ unwords $ f3 (f1 x 0 0) (reverse (f2 (map (\e->if e=='L' then 'R' else 'L') (reverse x)) 0 0))

Measured memory_bytes: 19196