akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<vector<int>> G(n);
    vector<pair<int, int>> vp;

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    } 
    
    int K = 0;
    map<pair<int, int>, int> mp;
    vector<int> cs(n);  // color of edge between its parent
    vector<int> used(n);
    queue<int> Q;
    Q.emplace(0);
    used[0] = 1;
    while(!Q.empty()) {
        int v = Q.front();
        Q.pop();
        if(K < (int)G[v].size()) {
            K = G[v].size();
        }
        int cur = 1;
        for(auto u : G[v]) {
            if(used[u]) {
                continue;
            }
            if(cur == cs[v]) {
                cur++;
            }
            cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = cur++;
            used[u] = 1;
            Q.emplace(u);
        }
    }

    cout << K << "\n";

    for(auto p : vp) {
        cout << mp[p] << "\n";
    }

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
vector<pair<ll, pair<ll,ll> > > V;
typedef long double ld;
typedef pair<ld, ll> pi;

priority_queue<pi, vector<pi>, greater<pi> >pq;

ld dst[1010];

ld find_d(ll a, ll b){
  ll w = V[a].s.f;
  ll x = V[b].s.f;
  ll y = V[a].s.s;
  ll z = V[b].s.s;

  return max((ld)0, sqrt( (ld) ((w-x) * (w-x) + (y-z)*(y-z))) -V[a].f - V[b].f);
}

ll N,a,b,c,d,e,f;
int main(){
  // freopen("in.txt","r",stdin);
  cin >> a >> b >> c >> d;
  V.pb(mp(0, mp(a,b)));
  cin >> N;
  for (ll i=0;i<N;++i){
    cin >> a >> b >> e;
    V.pb(mp(e,mp(a,b)));
  }
  V.pb(mp(0,mp(c,d)));

  memset(dst, -1,sizeof(dst));
  dst[0] = 0;
  pq.push(mp(0,0));
  while(pq.size()){
    pi c = pq.top();
    pq.pop();
    ll x = c.s;
    ld d = c.f;
    if (dst[x] < d)continue;
    for (ll i=1;i<=N+1;++i){
      ld t = d + find_d(x,i);
      if (dst[i] != -1 && dst[i] <= t)continue;
      dst[i] = t;
      pq.push(mp(t, i));
    }
  }
  printf("%.11Lf",dst[N+1]);
}


Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define int long long
#define double long double

//main.cpp-Sample


namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
}


using namespace std;
signed main (){
	int age;
	cin >> age;
	if (age == 1)
	{
		cout << "Hello World"<<endl;
	}else{
		int a,b;
		cin >> a >> b;
		cout<<a+b<<endl;
	}
	return 0;
}




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

int main() {
	string S;
	int K;
	cin >> S >> K;
	set<string> ans;
	for (int i = 0; i < S.length(); i++) {
		for (int j = 1; i + j - 1 < S.length(); j++) {
			string sub = S.substr(i, j);
			if (ans.size() < K) ans.insert(sub);
			else {
				if (ans.find(sub) != ans.end()) continue;
				auto itr = ans.begin();
				for (int k = 0; k < K - 1; k++) itr++;
				if (*itr > sub) ans.insert(sub);
				else break;
			}
		}
	}
	auto itr = ans.begin();
	for (int k = 0; k < K - 1; k++) itr++;
	cout << *itr << endl;
}

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

using namespace std;

typedef long long int64;
const int mod = 1e9 + 7;

void prime_factor(int64 n, map< int64, int > &ret)
{
  for(int64 i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n]++;
}

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

  map< int64, int > pp;
  for(int i = 1; i <= N; i++) prime_factor(i, pp);

  int64 ret = 1;
  for(auto &k : pp) (ret *= k.second + 1) %= mod;

  cout << ret << endl;
}





Measured memory_bytes: 384
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll>> pqls;
priority_queue <P,vector<P>,greater<P>> pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 
ll i,j,k,ii,jj;
ll n,m,num,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w;
 
ll x[800005],y[800005],z[900005];
ll l[500005],r[500005];

int main(){	
	cin>>n>>k;
	p(n+1-k);
	

	return 0;
}

Measured memory_bytes: 5632
class UnionFind:
    def __init__(self, n):
        self.p = [i for i in range(n)]
        self.components = n  # 連結成分の数

    def root(self, x):
        if self.p[x] == x:
            return x
        else:
            self.p[x] = self.root(self.p[x])
            return self.p[x]
    
    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            self.p[x] = y
            self.components -= 1
    
    def same(self, x,y):
        return (self.root(x) == self.root(y))

N = int(input())
MAX = 100010
UF = UnionFind(2*MAX)

for _ in range(N):
    x, y = map(int,input().split())
    UF.unite(x,y+MAX)


cnt_x, cnt_y = [0]*(2*MAX), [0]*(2*MAX)

for i in range(MAX):
    cnt_x[UF.root(i)] += 1

for i in range(MAX,2*MAX):
    cnt_y[UF.root(i)] += 1

print(sum([cnt_x[i]*cnt_y[i] for i in range(2*MAX)]) - N)

Measured memory_bytes: 99748
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class AtCoder
{
    const int MOD = 1000000007;
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        var stones =
            Enumerable.Range(0, n)
            .Select(x => Console.ReadLine())
            .Select(int.Parse)
            .Select(x => x - 1)
            .ToList();
        foreach(int i in Enumerable.Range(0, n).Skip(1).Reverse())
        {
            if(stones[i] == stones[i - 1])
                stones.RemoveAt(i);
        }
        var bef = 
            Enumerable.Range(0, stones.Max() + 1)
            .Select(x => -1).ToArray();
        n = stones.Count;
        int[] dp = new int[stones.Count];
        foreach(int i in Enumerable.Range(0, n).Skip(0))
        {
            if(i != 0)
                dp[i] = dp[i - 1];
            if(bef[stones[i]] != -1)
            {
                dp[i] += dp[bef[stones[i]]] + 1;
            }
            bef[stones[i]] = i;
            if(dp[i] >= MOD)
                dp[i] %= MOD;
        }
        System.Console.WriteLine((dp[n - 1] + 1) % MOD);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

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

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

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

    int n, h;
    cin >> n >> h;

    int a, b[n];
    int max_a = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a >> b[i];
        max_a = max(max_a, a);
    }

    sort(b, b +n, greater<>());
    // sort(b, b +n, [](int x, int y) { return x > y;});

    int count = 0;
    for (auto sub_b: b) {
        if (h <= 0) {
            cout << count << '\n';
            return 0;
        }
        if (sub_b < max_a) break;
        h -= sub_b;
        count++;
    }

    cout << count + (int) ceil(h * 1.0 / max_a) << '\n';
    
    return 0;
}


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

int main() {
  int N, count = 0;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++){
    cin >> p.at(i);
  }
  for (int i = 0; i < N; i++){
    if (p.at(i) != i+1){
      count++;
    }
  }
  if (count <= 2){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b, c;
	char op;
	
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op == '?'){
			break;
		}
		if(op == '+'){
			c=a+b;
		}
		if(op == '-'){
			c=a-b;
		}
		if(op == '*'){
			c=a*b;
		}
		if(op == '/'){
			c=a/b;
		}
		
		printf("%d\n", c);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

struct Edge {
  int to, cost;

  Edge() {}
  Edge(int to, int cost) : to(to), cost(cost) {}
};

void bfs(std::vector<std::vector<Edge> >& g, long long d[], int k) {
  std::fill(d, d + 100000, (long long)(1e15));

  d[k] = 0;

  std::priority_queue<std::pair<long long, int> > que; // cost, vertex
  que.push({0, k});

  while (!que.empty()) {
    auto p = que.top();
    que.pop();

    for (auto nextv : g[p.second]) {
      if (d[nextv.to] <= p.first + nextv.cost) {
	continue;
      }

      d[nextv.to] = p.first + nextv.cost;
      que.push({d[nextv.to], nextv.to}); 
    }
  }

}

int main() {
  int N, Q, K;
  long long d[100001];
  std::vector<std::vector<Edge> > g;

  cin >> N;
  g.resize(N);

  for (int i = 0; i < N - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c, a--, b--;

    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }

  cin >> Q >> K, K--;

  bfs(g, d, K);

  for (int i = 0; i < Q; ++i) {
    int x, y;
    cin >> x >> y, x--, y--;

    cout << d[x] + d[y] << endl;
  }

  return 0;
}


Measured memory_bytes: 9460
def is_prime(n):
    if n==1:
        return False
    
    for i in range(2, int(n**0.5)+1):
        if n%i==0:
            return False
    
    return True

X = int(input())

for i in range(X, 10**6):
    if is_prime(i):
        print(i)
        exit()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int A[303030];
int ma[303030];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	map<int,int> M;
	FOR(i,N) {
		cin>>x;
		M[x]++;
	}
	vector<int> V;
	FORR(m,M) V.push_back(m.second);
	sort(ALL(V));
	int over=0;
	ll sum=N;
	for(i=N;i>=1;i--) {
		
		ll tot=1LL*over*i+sum;
		ma[tot/i]=max(ma[tot/i],i);
		
		while(V.size() && V.back()>=i) {
			sum-=V.back();
			V.pop_back();
			over++;
		}
	}
	for(i=N;i>=1;i--) ma[i]=max(ma[i],ma[i+1]);
	FOR(i,N) cout<<ma[i+1]<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll X, K, D; cin >> X >> K >> D; X = abs(X);
  if (K%2==1) { X = abs(X+D)>=abs(X-D) ? abs(X-D) : X+D; K--; }
  K /= 2; D *= 2;


  ll result = 0;
  ll need = X / D;
  if (K>need) result = min(X%D, D-X%D);
  else result = X - D * K;
  // cout << X << " " << K << " " << D << endl;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int n, ct=0,mx=0;
    cin >> n;
    int h[n];
    FOR(i,0,n){
        cin >> h[i];
        if(h[i]>=mx){ct += 1;}
        mx = max(mx,h[i]);
    }
    cout << ct << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class topological_sort {
private:
	int V;
	vector<vector<int>> edges;
	vector<int> used;
public:
	topological_sort(int n) :V(n), edges(n), used(n) {}
	topological_sort(vector<vector<int>> &edges) :V(edges.size()), used(edges.size()) { this->edges = edges; }

	void add_edge(int from, int to) { edges[from].emplace_back(to); }

	vector<int> build() {

		vector<int> res, in(V);
		for (int i = 0; i < V; i++) for (const auto &e : edges[i]) in[e]++;

		res.reserve(V);
		queue<int> que;

		for (int i = 0; i < V; i++) {
			if (in[i] == 0 && !used[i]) {
				used[i] = 1;
				que.emplace(i);
			}
		}

		while (!que.empty()) {
			int now = que.front();
			DMP(now, in);
			que.pop();
			res.emplace_back(now);
			for (const auto &e : edges[now]) {
				in[e]--;
				if (in[e] == 0) {
					if (used[e]) return vector<int>(); // unable to sort
					used[e] = used[now] + 1;
					que.emplace(e);
				}
			}
		}

		return res;
	}

	int longest_path() {
		if (none_of(used.begin(), used.end(), [](int u) { return u > 0; })) build();
		return *max_element(used.begin(), used.end());
	}

};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	auto id = [&](int l, int r) { return min(l, r)*N + max(l, r); };

	topological_sort ts(N * N);
	for (int i = 0; i < N; i++) {
		vector<int> A(N - 1);
		for (int j = 0; j < N - 1; j++) cin >> A[j];
		for (int j = 0; j < N - 2; j++) ts.add_edge(id(i, A[j] - 1), id(i, A[j + 1] - 1));
	}

	if (ts.build().size() != N * N) cout << -1 << "\n";
	else cout << ts.longest_path() << "\n";

	return 0;
}


Measured memory_bytes: 53032
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll c[30],s[370][30];
int a[370],last[30];

unsigned seed=chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(seed);

ll f(int d)
{
    ll x=0;
    memset(last,-1,sizeof(last));
    for(int i=0;i<d;i++){
        x+=s[i][a[i]];
        last[a[i]]=i;
        for(int j=0;j<26;j++){
            x+=c[a[i]]*(i-last[a[i]]);
        }
    }
    return x;
}

int main()
{
    auto start=chrono::high_resolution_clock::now();
    ll x=0,sc=0;
    int d,ans[370];
    scanf("%d",&d);
    for(int i=0;i<26;i++){
        scanf("%lld",&c[i]);
        sc+=c[i];
    }
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            scanf("%lld",&s[i][j]);
        }
    }
    if(sc==0){
        for(int i=0;i<d;i++){
            int mx=-1,j=-1;
            for(int k=0;k<26;k++){
                if(s[i][k]>mx) mx=s[i][k],j=k;
            }
            printf("%d\n",j+1);
        }
        return 0;
    }
    while(true){
        for(int i=0;i<d;i++) a[i]=rng()%26;
        ll y=f(d);
        if(y>x) copy(a,a+d,ans),x=y;
        auto stop=chrono::high_resolution_clock::now();
        int duration=chrono::duration_cast<chrono::microseconds>(stop-start).count();
        if(2000000-duration<100000) break;
    }
    for(int i=0;i<d;i++){
        printf("%d\n",a[i]+1);
    }
    return 0;
}

Measured memory_bytes: 3920
import collections

N=int(input())
S=input()

lenR=S.count("R")
lenG=S.count("G")
lenB=S.count("B")

count=0
for i in range(N-2):
    for j in range(i,N-1):
        k=2*j-i
        if k>=N:
            continue
        else:
            if (S[i] != S[j]) and (S[i]!=S[k]) and (S[j]!=S[k]):
                count+=1
    
print(lenR*lenG*lenB-count)

Measured memory_bytes: 9460
import java.util.*;

class Main {
	public static boolean contest (int required, int accepted) {
		if (required == accepted) {
			return true;
		}
		else return false;
	}
	
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int required = input.nextInt();
		int accepted = input.nextInt();
		if (contest(required, accepted) == true) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
from sys import exit
N, M, X = map(int,input().split())
CA = []
for i in range(N): CA.append(list(map(int,input().split())))
ans = 10 ** 9
for i in range(2 ** N):
    buy = []
    cost = 0
    flag = 0
    for j in range(N):
        if (i >> j) & 1:
            buy.append(CA[j])
    for i in range(M):
        if sum(skill[i + 1] for skill in buy) < X:
            flag = 1
            break
    if flag != 1:
        cost = sum(skill[0] for skill in buy)
        ans = min(ans,cost)
if ans == 10 ** 9: print(-1)
else: print(ans)


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

int main() {
//	cout<<"GfG!";
    int n;
    string s;
    string t;
    cin>>n;
    cin>>s>>t;
    for(int i=0;i<n;i++)
    {
        cout<<s[i]<<t[i];
    }
	return 0;
}

Measured memory_bytes: 256
/**
  @file a.cpp
  @title A - +-x
  @url https://atcoder.jp/contests/abc137/tasks/abc137_a
**/

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int A, B;
  cin >> A >> B;

  cout << max({A + B, A - B, A * B}) << endl;
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];

    int i = n-1;
    while(i >= 0){
      cout << a[i] << " ";
      i -= 2;
    }

    if(n % 2 == 0)
      i = 0;
    else
      i = 1;
    while(i < n){
      cout << a[i] << " ";
      i += 2;
    }
  
  cout << endl;
}


Measured memory_bytes: 3712
from operator import mul
from functools import reduce

def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

for i in range(1, K + 1):
    # 青い玉をi個のグループに分けるためには、赤い玉は(i - 1)個必要
    if i - 1 > N - K:
        ans = 0
    else:
        # 青い玉の間(K - 1)から(i - 1)個を選んで青い玉をi個のグループに分ける
        # 青い玉のそれぞれのグループを、赤い玉の間(両端を含む)に入れる
        ans = nCr(K - 1, i - 1) * nCr(N - K + 1, i) % MOD
    print(ans)


Measured memory_bytes: 3944
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 木の繋がりと長さ
connect = [[] for _ in range(N+1)]
for u, v, w in data:
    connect[u].append([v,w])
    connect[v].append([u,w])

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

que = deque([])
que.append(data[0][0])
is_visited = [False] * (N+1)

# BFSで根からの距離を求めていく
while len(que) != 0:
    #print(que)
    u = que.popleft()

    is_visited[u] = True

    for v, w in connect[u]:
        if not is_visited[v]:
            que.append(v)
            dist[v] = dist[u] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Measured memory_bytes: 123608
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b;
  cout << (a<=8&&b<=8 ? "Yay!" : ":(") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;
using mat2d_t = std::vector<std::vector<int64_t>>;

int main(int argc, char **argv) {
    int n;
    cin >> n;
    std::map<std::string, int> m;

    for (int i=0; i<n; ++i) {
        std::string s;
        cin >> s;
        auto it = m.find(s);
        if (it == m.end()) m.insert(make_pair(s, 1));
        else ++(it->second);
    }

    std::set<std::string> ans;
    int mx{0};
    for (auto kv: m) {
        if (kv.second > mx) {
            ans.clear();
            ans.insert(kv.first);
            mx = kv.second;
        } else if(kv.second == mx) {
            ans.insert(kv.first);
        }
    }

    for (auto it = ans.begin(); it != ans.end(); ++it) {
        cout << *it << endl;
    }

    return 0;
}

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

#define LL long long
#define LD long double

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	LL odd = 0;
	for (LL i = 1; i <= n; i++)
		odd += i%2;
	LD res = odd;
	res /= n;
	cout << fixed << setprecision(10) << res << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;


class Event
{
public:
	int add;
	string time;

	Event(int a)
	{
		add = a;
		cin >> time;
	}

	bool operator<(const Event & a)const
	{
		if (time == a.time)return add < a.add;
		return time < a.time;
	}
};


bool solve()
{
	int n; cin >> n;
	if (n == 0)return false;

	list<Event> eLst;

	for (int i = 0; i < n; ++i)
	{
		eLst.emplace_back(1);
		eLst.emplace_back(-1);
	}
	eLst.sort();

	int ans = 0, num = 0;
	while (!eLst.empty())
	{
		num += eLst.front().add;
		ans = max(ans, num);
		eLst.pop_front();
	}

	cout << ans << endl;

	return true;
}


int main()
{
	while (solve());

	return 0;
}


Measured memory_bytes: 4928
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
typedef long long ll;
int n,q,top;
ll a[MAXN],op[MAXN],t[MAXN],d[MAXN];
inline int getnext(ll k,int r)
{
	int l=1,mid,ret=-1;
	while(l<=r){
		mid=(l+r)>>1;
		if(op[mid]<=k)l=mid+1,ret=mid;
		else r=mid-1;
	}
	return ret;
}
int main()
{
	scanf("%d%d",&n,&q);
	op[++top]=n;
	for(int i=1;i<=q;++i){
		scanf("%lld",a+i);
		while(top && op[top]>=a[i])--top;
		op[++top]=a[i];
	}
	ll k;
	t[top]=1;
	for(int i=top;i;--i){
		k=op[i];
		while(k){
			int p=getnext(k,i-1);
			if(p==-1)break;
			t[p]+=k/op[p]*t[i];
			k%=op[p];
		}
		d[1]+=t[i],d[k+1]-=t[i];
	}
	for(int i=1;i<=n;++i)
		printf("%lld\n",d[i]+=d[i-1]);
	return 0;
}


Measured memory_bytes: 4864
import sys

def warn(*m):
    print(m, file=sys.stderr)

D,*CS = map(int, open(0).read().split())
C = CS[:26]
S = [CS[26*i:26*(i+1)] for i in range(1, D+1)]

def imax(xs):
    m = -1
    i = 0
    for j, x in enumerate(xs):
        if x > m:
            i = j
            m = x
    return i

def ratio(xs):
    s = sum(xs)
    return [x / s for x in xs]

ds = [0] * 26

def pick(d, w):
    ss = ratio(S[d])
    cc = ratio([(1 + d - ds[i]) * x for i, x in enumerate(C)])
    return imax([(s * w) + c for s, c in zip(ss, cc)])

w = 0.5
for d in range(D):
    i = pick(d, w)
    w += (1 / 365)
    ds[i] = d + 1
    print(i + 1)


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

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

ll n,k;
ll a[200010];
ll sum[200010];
ll sum2[200010];

ll bit[200010];
ll sum_bit(ll i){
    ll ret = 0;
    for(--i; i>=0; i=(i&(i+1))-1) ret += bit[i];
    return ret;
}
void add(ll i, ll x) { for(; i <= n; i|=i+1) bit[i] += x; }

int main() {
    std::cin >> n>>k;
    sum[0]=0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        sum[i+1]=sum[i]+a[i]-k;
    }
    ll result =0;
    memcpy(sum2,sum,sizeof(sum));

    sort(sum2,sum2+n+1);
    
    for (int i = 0; i <= n; i++) {
        // sortした順番を新しい値にする→大小関係を維持
        ll new_value = distance(sum2,lower_bound(sum2,sum2+n+1,sum[i]));
        add(new_value,1);
        result+=sum_bit(new_value+1)-1;
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var ok = false;
        for (int i = 1; i <= 9; i++)
        {
            for (int j = 1; j <= 9; j++)
            {
                if (i * j == n)
                {
                    ok = true;
                }
            }
        }

        Console.WriteLine(ok ? "Yes" : "No");
    }
}

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

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

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)

const int INF = 1e9;
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 main(void){
  ios::sync_with_stdio(false);

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

  ll ans = 0;
  REP(i, N){
    FOR(j, i+1, N){
      int val = d[i] * d[j];
      ans += val;

    }
  }

  cout << ans << endl;




  return 0;
}



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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;

    int sum = 0;
    sum += min( a + b, 2 * c ) * min( x, y );
    if( x < y ) sum += min( b, 2 * c ) * ( y - x );
    if( x > y ) sum += min( a, 2 * c ) * ( x - y );

    cout << sum << endl;
}


Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

__attribute__((constructor)) static void init()
{
    ios::sync_with_stdio(false);
    std::cin.tie(0);
}

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> res(n - 1, 0);

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            res[min(j - i - 1, min(abs(x - i) + abs(j - y), abs(y - i) + abs(j - x)))]++;
        }
    }

    for (auto&& r : res) {
        cout << r << "\n";
    }
}


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

int main() {
    int n,l;
	int sum;
    cin >> n >> l;
	sum = n*(n-1)/2+l*n;
	
	if(0<=l){
		cout << sum -l;
		return 0;
	}
	
	if(1-l>=n){
		cout << sum - (l+n-1);
		return 0;
	}
	else{
		cout << sum;
	}
	
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

A = [(list(map(int, input().split()))) for _ in range(n)]
b = [int(input()) for _ in range(m)]

for i in range(n):
    ans = 0
    for j in range(m):
        ans += A[i][j] * b[j]
    print(ans)



Measured memory_bytes: 6020
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << i << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define ceil(a,b) (a%b?a/b+1:a/b)

signed main() {
  int n;
  std::cin >> n;
  int a = 1;
  int b = 1;
  rep(i,n) {
    int aa,bb;
    std::cin >> aa >> bb;
    int mul = std::max(ceil(a,aa),ceil(b,bb));
    a=mul*aa;
    b=mul*bb;
  }
  std::cout << a+b << ENDL;
  return 0;
}

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

int main() {
  int X,Y,Z,A,B,C,ans,a,b,c,d,e,t;
  cin>>A>>B;
  ans=0;
  for(int i=A;i<B+1;i++){
    a=i%10;
      b=(i%100-a)/10;
    c=(i%1000-10*b-a)/100;
        d=(i%10000-100*c-10*b-a)/1000;
        e=(i-1000*d-100*c-10*b-a)/10000;
    if(a==e&&b==d){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n, k, q = map(int,input().split())
A = [int(input()) for i in range(q)]
B = [k] * n

for i in A:
    B[i-1] = B[i-1] + 1



for k in range(n):
    if B[k]-q > 0:
        print('Yes')
    else:
        print('No')

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


int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int n = 3;
	if (a[1] == a[2]) {
		n = n - 1;
	}
	if(a[0]==a[1])
	{
		n = n - 1;
	}
	cout << n << endl;
	return 0;
}

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

int main() {
    int K; cin >> K;
    string S; cin >> S;
    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-

#define lop(i,n) for(int i=0;i<n;++i)
ll n,m,k,t,mod,y;
 const int N=200005;
map<ll,ll>ss;
ll dp[N];ll a[N];
int main()
{
   
  
cin>>n;ll ans=0;
for(ll i=0;i<n;i++){
   cin>>a[i]; ss[a[i]]++;
   ans+=(ss[a[i]]-1);
}for(ll i=0;i<n;i++){
  cout<<ans-(ss[a[i]]-1)<<endl;
   
}

}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1e9 + 7;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }


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

    int S;
    cin >> S;
    vecll dp(S + 1);
    dp[0] = 1;
    for(int i = 0;i < S;i++) {
        vecll tot(S + 1);
        tot[0] = dp[0];
        for(int j = 1;j <= S;j++) {
            tot[j] = tot[j - 1] + dp[j];
            tot[j] %= MOD;
        }
        for(int j = S;j >= 3;j--) {
            dp[j] = tot[j - 3];
            dp[j] %= MOD;
        }
    }
    cout << dp[S] << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int N = Integer.parseInt(sc.next());
		int Ma = Integer.parseInt(sc.next());
		int Mb = Integer.parseInt(sc.next());

		int[] a = new int[N];
		int[] b = new int[N];
		int[] c = new int[N];
		//key is cost, value is id number.
		for(int i=0;i<N;i++) {
			a[i] = Integer.parseInt(sc.next());

			b[i] = Integer.parseInt(sc.next());

			c[i] = Integer.parseInt(sc.next());
		}
		sc.close();


		//using material from 0 to i, ratio is (a,b), mean cost.
		int[][][] dp = new int[N][10*N+1][10*N+1];
		for(int i=0;i<N;i++) {
			for(int j=0;j<10*N+1;j++) {
				for(int k=0;k<10*N+1;k++) {
					dp[i][j][k] = 10000;
				}
			}
		}
		dp[0][0][0] = 0;

		for(int i=0;i<N;i++) {
			for(int j=0;j<10*N+1;j++) {
				for(int k= 0;k<10*N+1;k++) {

					if(j-a[i] >= 0 && k-b[i] >= 0) {
						if(i!=0) {
							dp[i][j][k] = Math.min(dp[i][j][k], Math.min(dp[i-1][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]));
						}
						else{
							dp[i][a[i]][b[i]] = c[i];
						}
					}
					else {
						if(i!=0) {
							dp[i][j][k] = Math.min(dp[i][j][k], dp[i-1][j][k]);
						}
						else {
							dp[i][a[i]][b[i]] = c[i];
						}
					}
				}
			}
		}
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for(int j=1;j<10*N+1;j++) {
			for(int k=1;k<10*N+1;k++) {
				if(j*Mb==k*Ma) {
					queue.add(dp[N-1][j][k]);
				}
			}
		}
		int result = queue.poll();
		if(result < 10000) {
			out.println(result);
		}
		else {
			out.println(-1);
		}
		out.flush();
	}
}

Measured memory_bytes: 54864
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n, k, h, a = 0;
    cin>>n>>k;
    REP(i,n) {
        cin>>h;
        if (h >= k)
            a++;
    }
    cout<<a<<endl;

    return 0;
}



Measured memory_bytes: 256
package main

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

func main() {
	s := nextLine()
	fmt.Printf("%c%d%c\n", s[0], len(s[1:len(s)-1]), s[len(s)-1])
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 640
//by sdfzchy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010;
inline int in()
{
	char ch=getchar();
	int f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}
char s[10][10];

bool ok()
{
	for(int i=1;i<=3;i++)
		if(s[1][i]!=s[2][4-i])
			return 0;
	return 1;
}
int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	for(int i=1;i<=2;i++)
		scanf("%s",s[i]+1);
	puts(ok()?"YES":"NO");
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > graph(n, vector<int>(n, 0));
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        u--;
        rep(i, k)
        {
            int v;
            cin >> v;
            v--;
            graph[u][v]++;
        }
    }

    rep(i, n)
    {
        rep(j, n)
        {
            if (j == n - 1)
            {
                cout << graph[i][j];
            }
            else
            {
                cout << graph[i][j] << ' ';
            }
        }
        cout << endl;
    }

    return 0;
}



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

using namespace std;

typedef unsigned long long ull;

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

    int arr[3] = {0};
    string s;
    cin >> s;

    for (char t : s){
        if (t == 'a')
            arr[0] ++;
        if (t == 'b')
            arr[1] ++;
        if (t == 'c')
            arr[2] ++;
    }
    
    int pr = 1;
    for (int i = 0; i < 3; i ++)
        pr *= arr[i];
    
    if (pr == 1)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

typedef long long int64;

const int mod = 1000000007;
int64 gcd(int64 a,int64 b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
    int64 a,b;
    cin >> a >> b;
    int64 GCD = gcd(a,b);
    int64 ans = a*b/GCD;
    cout << ans << endl;
}

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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int A = int.Parse(input[0]); int B = int.Parse(input[1]); int X = int.Parse(input[2]);

            if (A <= X)
            {
                if((A + B)>=X)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k,count=0;
  int q[105];
  cin>>a>>b>>k;
  int m=min(a,b);
  while(m>0){
    if(a%m==0 && b%m==0){
      q[count]=m;
      count++;
    }
    m--;
  }
  cout<<q[k-1]<<'\n';
  return 0;
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
S = []
for i in range(H):
    s = input()
    S.append(s)

black = 0
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            black += 1

if black < K:
    print(0)
else:
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            watched = [[False for _ in range(W)] for __ in range(H)]
            for h in range(H):
                if 1 << h & i:
                    for w in range(W):
                        if S[h][w] == "#":
                            cnt += 1
                            watched[h][w] = True

            for w in range(W):
                if 1 << w & j:
                    for h in range(H):
                        if S[h][w] == "#" and watched[h][w] == False:
                            cnt += 1
                            watched[h][w] = True

            if black - cnt == K:
                ans += 1

    print(ans)


Measured memory_bytes: 9252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    double A[n];
    REP(i,n) cin >> A[i];
    double sum = 0;
    REP(i,n) sum += 1 / A[i];
    cout << fixed << setprecision(10) << 1 / sum << endl; 

}

Measured memory_bytes: 256