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

#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 

int siz, curr, x;
string s;
stack<int> st[3];

int main(int argc, char const *argv[])
{

  cin>>s;
  siz = s.size();

  for(int i = siz- 1 ; i > -1 ; i--)
  {
  	st[0].push(s[i] - 'a');
  }

  cin>>s;
  siz = s.size();

  for(int i = siz- 1 ; i > -1 ; i--)
  {
  	st[1].push(s[i] - 'a');
  }

  cin>>s;
  siz = s.size();

  for(int i = siz- 1 ; i > -1 ; i--)
  {
  	st[2].push(s[i] - 'a');
  }

  curr = 0;

  while(!st[curr].empty())
  {
  	x = st[curr].top();
  	st[curr].pop();
  	curr = x;  	
  }

  cout<<(char)('A' + curr);

return 0;

} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int mod = 1000000007;

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return (bit[i] + sum(i-(i&-i))) % mod;
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        bit[i] %= mod;
        add(i+(i&-i), x);
    }
};

signed main(){

    int N, A, B; cin >> N >> A >> B;
    if(A > B) swap(A, B);
    vec S(N); readv(S);
    REP(i, N - 2) if(S[i + 2] - S[i] < A){
        cout << 0;
        return 0;
    }
    BIT dp(N + 1);
    dp.add(1, 1);
    int i0 = 0;
    REP(i, N){
        int i1 = Upper_bound(S, S[i] - B);
        if(i0 <= i1) dp.add(i + 2, dp.sum(i1 + 1) - dp.sum(i0) + mod);
        if(i > 0 && S[i] - S[i - 1] < A) i0 = i;
    }
    int ans = (dp.sum(N + 1) - dp.sum(i0) + mod) % mod;
    cout << ans << endl;
    
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


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

	REP(i, s.size()) {
		if (!(i & 1))cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 592
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

// 約数の列挙O(sqrt(n))
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.emplace_back(i);
      if (i * i != n)
        res.emplace_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll dn1 = divisor(n-1);
  vll dn = divisor(n);
  set<ll> ans;
  for(auto&& e: dn1){
    if(e == 1) continue;
    ans.emplace(e);
  }
  for(auto&& e: dn){
    if(e == 1) continue;
    ll tmp = n;
    while(tmp >= e){
      if(tmp%e == 0){
        tmp /= e;
      }else{
        tmp %= e;
      }
    }
    if(tmp == 1) ans.emplace(e);
  }
  print(SZ(ans));
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	int[][] cost;
	boolean[] visit;
	int[] dist;
	int n;
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			n = scan.nextInt();
			cost = new int[n][n];
			for(int i = 0;i < n;i++){
				Arrays.fill(cost[i], 100000);
			}
			for(int i = 0;i < n;i++){
				int r = scan.nextInt() - 1;
				int k = scan.nextInt();
				for(int j = 0;j < k;j++){
					int t = scan.nextInt() - 1;
					cost[r][t] = 1;
				}
			}
			int p = scan.nextInt();
			for(int i = 0;i < p;i++){
				int s = scan.nextInt() - 1;
				int d = scan.nextInt() - 1;
				int v = scan.nextInt();
				visit = new boolean[n];
				dist = new int[n];
				Arrays.fill(dist, 1000000);
				dijkstra(s);
				System.out.println((dist[d]+1 <= v)?Math.min(dist[d]+1,v):"NA");
			}
		}
	}
	public void dijkstra(int start){
		dist[start] = 0;
		while(true){
			int min = 1000000;
			int next = -1;
			for(int u = 0;u < n;u++){
				if(visit[u]){
					continue;
				}
				dist[u] = Math.min(dist[u],dist[start] + cost[start][u]);
				if(dist[u] < min){
					min = dist[u];
					next = u;
				}
			}
			visit[start] = true;
			start = next;
			if(start == -1){
				break;
			}
		}
	}
}

Measured memory_bytes: 26104
from itertools import permutations
from math import factorial

N = int(input())

x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())

i = 0
length = []
for comb in permutations(range(1, N+1), N):
    tmp = 0
    for i in range(len(comb)-1):
        tmp += ((x[comb[i+1]-1] - x[comb[i]-1])**2 + (y[comb[i+1]-1] - y[comb[i]-1])**2)**(1/2)
    length.append(tmp)
print(sum(length)/factorial(N))



Measured memory_bytes: 4456
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int DP[1005][1005];

int main() {
    int N;
    cin>>N;
    string S, T;
    int ans[N];
    for(int i=0;i<N;++i){
        cin>>S>>T;
        for(int j=0;j<S.size();++j){
            for(int k=0;k<T.size();++k){
                DP[j][k] = 0;
            }
        }
        if(S[0]==T[0]) DP[0][0] = 1;
        for(int j=1;j<S.size();++j){
            if(S[j]==T[0]) DP[j][0] = 1;
            DP[j][0] = max(DP[j-1][0], DP[j][0]);
        }
        for(int j=1;j<T.size();++j){
            if(S[0]==T[j]) DP[0][j] = 1;
            DP[0][j] = max(DP[0][j-1], DP[0][j]);
        }
        for(int j=1;j<S.size();++j){
            for(int k=1;k<T.size();++k){
                if(S[j]==T[k]) DP[j][k] = DP[j-1][k-1] + 1;
                else DP[j][k] = max(DP[j-1][k], DP[j][k-1]);
            }
        }
        ans[i] = DP[S.size()-1][T.size()-1];
    }
    for(int i=0;i<N;++i){
        cout<<ans[i]<<endl;
    }
}




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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


auto solve() {
    int N;
    cin >> N;
    vi A(N);
    for (auto &&a : A) {
        cin >> a;
    }

    ll res = 0;
    bool rem = false;
    for (auto &&a : A) {
        if (rem && a > 0) {
            res++;
            a--;
        }
        res += a / 2;
        rem = a % 2 == 1;
    }

    return res;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

ll F[2100010];

ll Mul(ll a, ll b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
ll square(ll x) {
	return (x * x) % mod;
}

ll power(ll x, ll y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

ll Div(ll a, ll b) {
	return Mul(a, power(b, mod - 2));
}
ll p(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

ll C(ll n, ll r) {
	if (n < r || n < 0 || r < 0) return 0;
	ll ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}

ll H(ll n, ll r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}
int A[100010];
int main()
{
	fact();
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	ll ans = 0;
	for (int i = N - 1; i >= 0; i--) {
		ans = (ans + A[i] * C(i, K - 1)) % mod;
	}
	for (int i = 0; i < N; i++) {
		ans = (ans - A[i] * C(N - i - 1, K - 1)) % mod;
		if (ans < 0) ans += mod;
	}
	cout << ans << endl;
}

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

int main () {
    int N, K; cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    int ans = 0;
    rep(i, N) ans += 2*min(x[i], K-x[i]);
    
    cout << ans << endl;
}


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

int main()
{
    int x, y, flag_1=0, flag_2=0, flag_3=0, flag_4=0;
    cin >> x>>y;

    vector<int> a{1, 3, 5, 7, 8, 10, 12};
    vector<int> b{4, 6, 9, 11};

    for (int i = 0; i < a.size();i++){
        if(a.at(i) == x){
            flag_1 = 1;
        }
        if(a.at(i)==y){
            flag_2 = 1;
        }
    }

    for (int i = 0; i < b.size(); i++)
    {
        if (b.at(i) == x)
        {
            flag_3 = 1;
        }
        if (b.at(i) == y)
        {
            flag_4 = 1;
        }
    }

    if (flag_1 == 1 && flag_2 == 1)
    {
        cout << "Yes" << endl;
    }
    else if (flag_3 == 1 && flag_4 == 1){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
ans_array = [[0] * W for i in range(H)]
block_array = []
for i in range(H):
    block_str = input().rstrip()

    block_array.append([1 if s == "#" else 0 for s in block_str])
# print(block_array)

for i in range(H):
    start = 0
    count = 0
    for j in range(W):
        if block_array[i][j] == 1:
            for k in range(start, j):
                ans_array[i][k] += count
            start = j + 1
            count = 0
        else:
            count += 1
    else:
        for k in range(start, W):
            ans_array[i][k] += count

# print(ans_array)

for i in range(W):
    start = 0
    count = 0
    for j in range(H):
        if block_array[j][i] == 1:
            for k in range(start, j):
                ans_array[k][i] += count
            start = j + 1
            count = 0
        else:
            count += 1
    else:
        for k in range(start, H):
            ans_array[k][i] += count

# print(ans_array)

ans = 0
for ar in ans_array:
    ans = max(ans, max(ar) - 1)
print(ans)


Measured memory_bytes: 113372
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H == 0 && W == 0){
         break;
      }
         for(int i =0; i<H; i++){
           for(int j=0; j<W; j++){
             System.out.printf("#");
           }
             System.out.printf("\n");
         }
System.out.printf("\n");
    }
  }
}

Measured memory_bytes: 62400
use std::io::stdin;

fn read() -> (i8, i8, i8, i8) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let vec: Vec<i8> = s
        .trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn main() {
    let (a, b, c, d) = read();
    let mut x = c / b;
    if c % b != 0 {
        x += 1
    }
    let mut y = a / d;
    if a % d != 0 {
        y += 1
    }

    if x <= y {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2100
def main():
    from functools import lru_cache
    N = int(input())
    MOD = 10**9 + 7

    def is_ok(last4):
        for i in range(4):
            t = list(last4)
            if i >= 1:
                t[i-1], t[i] = t[i], t[i-1]
            if "".join(t).count("AGC") >= 1:
                return False
        return True

    @lru_cache(maxsize=10000)
    def dfs(cur, last3):
        if cur == N:
            return 1
        ret = 0
        for c in "AGCT":
            if is_ok(last3 + c):
                ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
        return ret

    print(dfs(0, "TTT"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, S;
  cin >> K >> S;
  long long count = 0;
  for(int i = 0; i < K + 1; i++) {
    for(int j = i; j < K + 1; j++) {
      for(int h = j; h < K + 1; h++) {
        if(i + j + h == S) {
          if(i == j && j == h) {
            count++;
          }
          else if(i == j || j == h) {
            count += 3;
          }
          else {
            count += 6;
          }
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
long long n, t, a, z, s;
int main() {
	scanf("%lld%lld", &n, &t);
	while(n--) {
		scanf("%lld", &a);
		s += t;
		if(a<z) s -= z-a;
		z = a+t;
	}
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 128
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int64 N, K;
    cin >> N >> K;

    if (!N) {
        cout << "0\n";
    } else {
        auto res = N % K;
        cout << min(res, abs(res - K)) << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
// F - Three Variables Game
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n);
	vector<int> ab, ac, bc;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == "AB") ab.push_back(i);
		else if (s[i] == "AC") ac.push_back(i);
		else bc.push_back(i);
	}

	vector<char> ans(n);
	if (a + b + c == 0) {
		if (n > 0) ans.clear();
	} else if (a + b + c == 1) {
		for (int i = 0; i < n && ans.size() > 0; i++)
			if (s[i] == "AB") {
				if (a + b == 0) ans.clear();
				else {
					if (a) ans[i] = 'B', b++, a--;
					else ans[i] = 'A', a++, b--;
				}
			} else if (s[i] == "AC") {
				if (a + c == 0) ans.clear();
				else {
					if (a) ans[i] = 'C', c++, a--;
					else ans[i] = 'A', a++, c--;
				}
			} else {
				if (b + c == 0) ans.clear();
				else {
					if (b) ans[i] = 'C', c++, b--;
					else ans[i] = 'B', b++, c--;
				}
			}
	} else {
		for (int i = 0; i < n && ans.size() > 0; i++) {
			if (s[i] == "AB") {
				if (a + b == 0) {
					ans.clear();
				} else if (a + b + c == 2 && a == 1 && b == 1) {
					if (i + 1 < n && s[i + 1] == "BC") ans[i] = 'B', b++, a--;
					else ans[i] = 'A', a++, b--;
				} else {
					if (a + b + c == 2 && a == 1 && b == 1) {
					}
					else if (a == 0) ans[i] = 'A', a++, b--;
					else if (b == 0) ans[i] = 'B', b++, a--;
					else if (a > b) ans[i] = 'B', b++, a--;
					else ans[i] = 'A', a++, b--;
				}
			} else if (s[i] == "AC") {
				if (a + c == 0) {
					ans.clear();
				} else if (a + b + c == 2 && a == 1 && c == 1) {
					if (i + 1 < n && s[i + 1] == "AB") ans[i] = 'A', a++, c--;
					else ans[i] = 'C', c++, a--;
				} else {
					if (a == 0) ans[i] = 'A', a++, c--;
					else if (c == 0) ans[i] = 'C', c++, a--;
					else if (a > c) ans[i] = 'C', c++, a--;
					else ans[i] = 'A', a++, c--;
				}
			} else {
				if (b + c == 0) {
					ans.clear();
				} else if (a + b + c == 2 && b == 1 && c == 1) {
					if (i + 1 < n && s[i + 1] == "AC") ans[i] = 'C', c++, b--;
					else ans[i] = 'B', b++, c--;
				} else {
					if (b == 0) ans[i] = 'B', b++, c--;
					else if (c == 0) ans[i] = 'C', c++, b--;
					else if (b > c) ans[i] = 'C', c++, b--;
					else ans[i] = 'B', b++, c--;
				}
			}
			if (a < 0 || b < 0 || c < 0) ans.clear();
		}
	}

	if (ans.size() > 0) {
		cout << "Yes" << endl;
		for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 7284
/*
Dear ToM,
Congratulations on your graduation!
You did a great job!
     ☆ﾟ*＠*ﾟ☆
　　(＠*｡☆｡*＠
　 /☆｡*＠ﾟ*☆
▲/／｡＠｡*☆＠*
　▼―ｰ｡*＠ﾟ*☆
*/

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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int main(){
	ll v, e;
	cin >> v >> e;
	vector<vector<int>> g(v);
	char cs[v];
	rep(i, v){
		cin >> cs[i];
	}
	rep(i, e){
		int s, t;
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}

	rep(i, v){
		if(cs[i] != '?') continue;
		vector<bool> f(26, true);
		rep(j, (int)g[i].size()){
			if(cs[g[i][j]] == '?') continue;
			f[cs[g[i][j]] - 'a'] = false;
		}
		rep(j, (int)f.size()){
			if(f[j]){
				cs[i] = char('a' + j);
				break;
			}
		}
	}

	rep(i, v) cout << cs[i];
	cout << endl;

	return 0;
}



Measured memory_bytes: 9760
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define PII pair<int, int>
using namespace std;
int main(){
    int t;sc(t);
    if(t>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;
                   
ll n;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  for(int i=1;i<=3500;i++){
    for(int j=1;j<=3500;j++){
      if(4*i*j-n*(i+j)<=0)continue;
      if(n*i*j%(4*i*j-n*(i+j))!=0)continue;
      else {
        cout<<i<<" "<<j<<" "<<n*i*j/((ll)4*i*j-n*(i+j))<<endl;
        return 0;
      }
    }
  }
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vector<vi> g(n);
    vpii el;
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].pb(b);
        g[b].pb(a);
        el.emplace_back(a, b);
    }
    map<pii, int> col;
    queue<int> q;
    vector<bool> used(n);
    vi pcol(n);
    q.push(0);
    used[0] = true;
    while (!q.empty()) {
        int v = q.front(); q.pop();
        int nc = 1;
        for (int to : g[v]) {
            if (used[to]) continue;
            if (nc == pcol[v]) ++nc;
            q.push(to);
            used[to] = true;
            pcol[to] = nc;
            col[{v, to}] = nc;
            ++nc;
        }
    }
    int dmx = 0;
    rep(i, n) dmx = max(dmx, sz(g[i]));
    cout << dmx << endl;
    rep(i, n-1) cout << col[el[i]] << endl;
    return 0;
}


Measured memory_bytes: 16428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long X[] = new long[10000];
		long sum = 0;
		long max, min;
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for (int i = 0; i < n; i++) {
			long temp = scan.nextLong();
			X[i] = temp;
			sum = X[i] + sum;
		}
		max = X[0];
		min = X[0];
		for (int i = 1; i < n; i++) {
			if (max < X[i]) {
				max = X[i];
			}
		}
		for (int i = 1; i < n; i++) {
			if (min > X[i]) {
				min = X[i];
			}
		}

		System.out.printf("%d %d %d\n", min, max, sum);

	}

}



Measured memory_bytes: 42300
/*
    author: JioFell
    ahihi
*/
#include<bits/stdc++.h>
using namespace std;

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define fi first
#define se second
#define int long long

typedef pair<int,int> ii;
typedef pair<ii, int> pii;
const int N = 4e5 + 10;
int n, suma, sumb;
int a[N], b[N], pre[N], posa[N], posb[N];
vector<pii> tmp;

signed main() {
    //freopen("test.inp", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i, 1, n)    {
        cin >> a[i] >> b[i];
        tmp.pb({{a[i], i}, 0});
        tmp.pb({ {b[i], i}, 1});
        suma += a[i];
        sumb += b[i];
	}
	int ans = min(suma, sumb);
	sort(tmp.begin(), tmp.end());
	FOR(i, 0, tmp.size() - 1)   {
	    if(tmp[i].se == 0) posa[tmp[i].fi.se] = i;
	    else posb[tmp[i].fi.se ] = i;
        pre[i] = tmp[i].fi.fi;
        if(i > 0) pre[i] += pre[i - 1];
	}
	FOR(i, 1, n)    {
        int sum = pre[n - 1];
        int cur = n - 1;
        if(posa[i] > cur) {
            if(tmp[cur].fi.se != i) {
                sum -= tmp[cur].fi.fi;
                sum += a[i];
                cur --;
            } else {
                sum -= tmp[cur - 1].fi.fi;
                sum += a[i];
            }
        }
        if(posb[i] > cur)   {
            if(tmp[cur].fi.se != i) {
                sum -= tmp[cur].fi.fi;
                sum += b[i];
            } else {
                sum -= tmp[cur - 1].fi.fi;
                sum += b[i];
            }
        }
        ans = min(ans, sum);
	}
	cout << ans;
}


Measured memory_bytes: 15340
# coding: utf-8
# Your code here!
eng_li = []
removed_list = []
all_letter = 26
for i in range (97,97+all_letter):
    eng_li.append(chr(i))
 
string = list(raw_input().strip())
length = len(string)
if length < all_letter:
    for i in string:
        eng_li.remove(i)
    string.append(eng_li[0])
    answer = "".join(string)
else:
    for i in range(all_letter-1):
        if ord(string[-1]) < ord(string[-2]) :
            removed_list.append(string[-1])
            string.pop()
        else:
            removed_list.append(string[-1])
            string.pop()
            removed_list=filter(lambda x:x>string[-1],sorted(removed_list))
            string.pop()
            string.append(removed_list[0])
            answer ="".join(string)
            break
    else:
        answer = -1
print answer

Measured memory_bytes: 2696
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
int NOEL(){
    cout<<1<<endl;
    return 0;
}
#define N 200010

ll fact[N],inv[N],ivf[N];
void init(){
    inv[1]=fact[0]=ivf[0]=1;
    for(ll i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fact[i]=fact[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
}
ll c(ll n,ll k){
    return fact[n]*ivf[n-k]%mod*ivf[k]%mod;
}
vector<ll> v[N];
ll n,x,y;
int main(){
    init();
    cin>>n>>x>>y;
    lol(i,n){
	ll c,w;cin>>c>>w;
	v[c].push_back(w);
    }
    vector<ll> ms;
    lol(i,N){
	if(v[i].size()==0)continue;
	sort(v[i].begin(),v[i].end());
	ms.push_back(v[i][0]);
    }
    sort(ms.begin(),ms.end());
    if(ms.size()<=1)return NOEL();
    if(ms[0]+ms[1]>y)return NOEL();
    
    vector<ll> co;
    lol(i,N){
	if(v[i].size()==0)continue;
	ll surf=0;
	
	ll xr=x-v[i][0];
	auto it=upper_bound(v[i].begin(),v[i].end(),xr);
	surf=it-v[i].begin();
	
	ll yr=y-ms[0];
	if(v[i][0]==ms[0])yr=y-ms[1];
	if(v[i][0]>yr)continue;
	auto ie=upper_bound(v[i].begin(),v[i].end(),yr);
	ll su=ie-v[i].begin();
	
	surf=max(surf,su);
	if(surf>0)co.push_back(surf);
    }
    if(co.size()==0)return NOEL();
    ll sum=0;
    for(auto x:co)sum+=x;
    ll ans=fact[sum];
    for(auto x:co){
	ans=ans*ivf[x]%mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

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

  auto data = std::array<std::array<std::array<int, 10>, 3>, 4>{};
  for (auto i = 0; i < n; i++)
  {
    int b, f, r, v = 0;
    cin >> b >> f >> r >> v;

    data[b - 1][f - 1][r - 1] += v;
  }

  for (auto bitr = data.begin(); bitr != data.end(); bitr++)
  {
    for (auto floor_itr = bitr->begin(); floor_itr != bitr->end(); floor_itr++)
    {
      for (auto room_itr = floor_itr->begin(); room_itr != floor_itr->end(); room_itr++)
      {
        cout << " " << *room_itr;
      }

      cout << endl;
    }

    if (distance(bitr, data.end()) > 1)
    {
      cout << "####################" << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3092
n = int(input())
v = list(map(int,input().split()))
v1 = sorted(v[0::2])
v2 = sorted(v[1::2])
s1 = set(v1)
s2 = set(v2)

## 偶数項・奇数項ごとに最大数および次点の値を保持
eve = [[0,0]]
odd = [[0,0]]
cnt_eve = 1
cnt_odd = 1

for i in range(1,n//2):
    ## 偶数
    if v1[i] == v1[i-1]:
        cnt_eve += 1
    else:
        eve.append([cnt_eve, v1[i-1]])
        cnt_eve = 1
    if v2[i] == v2[i-1]:
        cnt_odd += 1
    else:
        odd.append([cnt_odd, v2[i-1]])
        cnt_odd = 1
    if i == n//2 - 1:
        eve.append([cnt_eve, v1[i]])
        odd.append([cnt_odd, v2[i]])


eve.sort(key=lambda x: x[0], reverse=True)
odd.sort(key=lambda x: x[0], reverse=True)

if eve[0][1] != odd[0][1]:
    ans = n - eve[0][0] - odd[0][0]
    print(ans)
else:
    ans = n - max(eve[0][0] + odd[1][0], eve[1][0] + odd[0][0])
    print(ans)


Measured memory_bytes: 23012
from collections import Counter
N = int(input())
li = list(map(int, input().split()))
c = Counter(li)
a = 1
M = 998244353
if li[0] != 0 or c[0] != 1:
  print(0)
else:
  for i in range(1, max(li)):
    a *= (c[i]**c[i+1])
  print(a%M)

Measured memory_bytes: 19928
def solve():
    N = int(input())
    h = list(map(int,input().split()))

    dp = [float('inf')] * N
    dp[0] = 0

    for i in range(N-1):
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
        if i != N-2:
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]))
    
    print(dp[-1])

if __name__ == '__main__':
    solve()


Measured memory_bytes: 52208
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
	
	int H,W,i,j;
	
	while(1){
	
	scanf("%d %d",&H,&W);
	
	if(H==0 && W==0)break;
	
	else{
		for(i=0;i<H;i++){
		
		for(j=0;j<W;j++){
			
			if(j==0 || j==W-1 || i==0 || i==H-1)printf("#");
			else printf(".");
			
			
			}
		printf("\n");
		}
	}
	
	printf("\n");
	
	}
	
return 0;}

Measured memory_bytes: 572
#include <iostream>

using namespace std;
int die[7][7] = {
	{0, 0, 0, 0, 0, 0, 0},
	{0, 0, 1, 1, 1, 1, 0},
	{0, 1, 0, 1, 1, 0, 1},
	{0, 1, 1, 0, 0, 1, 1},
	{0, 1, 1, 0, 0, 1, 1},
	{0, 1, 0, 1, 1, 0, 1},
	{0, 0, 1, 1, 1, 1, 0}
};

typedef long long ll;

int main(int argc, char *argv[]) {

	ll x;
	while(cin >> x) {
		ll current_index = 2, sums = 0;
		ll step = 0;

		step = x / 11 * 2;
		if(x % 11 > 6)
			step += 2;
		else if(x % 11)
			step += 1;
		cout << step << endl;
	}
		
}

Measured memory_bytes: 256
from sys import stdin
def main():
  readline = stdin.readline
  N = int(readline())
  L = [list(map(int, readline().split())) for _ in range(N)]
  cnt = 0
  for l in L[::-1]:
    a = l[0] + cnt
    b = l[1]
    if a % b != 0:
      cnt += b - a % b
  print(cnt)
if __name__ == "__main__":
  main()

Measured memory_bytes: 28112
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N, X = inpl()

ALL, P = [1], [1]
for _ in range(N):
    ALL.append(ALL[-1] * 2 + 3)
    P.append(P[-1] * 2 + 1)


# | B (X = ALL[N])
# |
# | N - 1バーガー(上)
# |
# | P (X = ALL[N] // 2 + 1)
# |
# | N - 1バーガー(下)
# |
# | B (X = 1)
def func(N, X):
    if N == 0:
        return 1
    if X == 1:
        return 0
    elif X == ALL[N]:
        return P[N]
    elif X == ALL[N] // 2 + 1:
        return P[N] // 2 + 1
    else:
        if X < ALL[N] // 2 + 1:  # 下のN - 1バーガー
            return func(N - 1, X - 1)
        else:  # 上のN - 1バーガー
            return func(N - 1, X - ALL[N] // 2 - 1) + P[N] // 2 + 1


print(func(N, X))


Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
s = input()
n = len(s)
ok = 0
while ok == 0:
    ok = 1
    i = 0
    while i < len(s) - 1:
        str = s[i] + s[i+1]
        j = 0
        while str == "01" or str == "10":
            s = s[:i-j] + s[i+2-j:]
            ok = 0
            j += 1
            if i > j + 1:
                str = s[i-j] + s[i-j+1]
            else:
                break
        i += 1
print(n - len(s))

Measured memory_bytes: 3444
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[600005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[20000];

ll ha[2];

ll x, y;

int main() {
	cin >> a >> b >> c;
	cout << max(c - (a - b), (ll)0) << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 14464
import math

def main():
    num, length = map(int, input().split())
    data = list(map(int, input().split()))

    ind = data.index(1)
    left = ind
    ans = math.ceil(left / (length - 1))
    right = num - (ans * (length - 1) + 1)
    if right > 0:
        ans += math.ceil(right / (length - 1))
    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 52476
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

vector<ll> A;

// {value, count}
map<int, int> m;

ll comb(const ll n, const ll k) {
    if (n <= 0 || k <= 0) return 0;
    if (k == 1) return n;
    return (n * (n - 1)) / (k * (k - 1));
}

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }

    ll sum = 0;
    for (auto &p : m) {
        ll cnt = p.second;
        sum = sum + comb(cnt, 2);
    }

    for (int i = 0; i < N; i++) {
        ll x = A[i];
        ll cnt = m[x];
        ll ans = sum - comb(cnt, 2) + comb(cnt - 1, 2);
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
  int M,N,i,j;
  cin>>N;
  vector<int> a(N);
  for(i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end(),greater<int>());
  int A=0;
  int B=0;
  for(i=0;i<N;i++){
    if(i%2==0)A+=a.at(i);
    else B+=a.at(i);
  }
  cout<<(A-B)<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner

/**
  * Created by micchon1 on 2016/09/29.
  */
object Main extends App {
  val sc = new Scanner(System.in)
  val str = sc.next()
  val (head , tail) = str.splitAt(4)
  val ans = head ++ " " ++ tail
  println(ans)
}

Measured memory_bytes: 22340
import random
D = int(input())
last = [0 for i in range(26)]
s = [[0 for j in range(26)] for i in range(D)]
c = list(map(int, input().split(" ")))
result = []
for i in range(D):
    a = list(map(int, input().split(" ")))
    score = [0 for i in range(26)]
    for j, k in enumerate(a):
        s[i][j] = int(k)
    for j in range(26):
        score[j] = s[i][j]
        for k in range(26):
            if j != k:
                score[j] -= (i + 1 - last[k]) * c[k]
    score_sort = sorted(score,reverse=True)
    score_max = random.choice(score_sort[:1])
    for j in range(26):
        if score_max == score[j]:
            result.append(j)
            last[j] = i

for i in range(D):
    print(result[i]+1)




Measured memory_bytes: 9744
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> c(n);
  for (int _ = 0; _ < n; ++_) {
    int a; cin >> a, --a;
    ++c[a];
  }
  sort(begin(c), end(c));
  auto d = c;
  d.push_back(0);
  for (int i = n - 1; i >= 0; --i) {
    d[i] += d[i + 1];
  }
  for (int k = 1; k <= n; ++k) {
    auto chk = [&](int x) -> bool {
      int i = lower_bound(begin(c), end(c), x) - begin(c);
      int s = d[0] - d[i] + (n - i) * x;
      return k * x <= s;
    };
    int ok = 0, ng = n / k + 1;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      (chk(mid) ? ok : ng) = mid;
    }
    cout << ok << '\n';
  }
}

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

int main() {
	ios :: sync_with_stdio(false);
	for(int n, s; cin >> n >> s; ) if(n || s) {
		int p[10];
		iota(p, p + 10, 0);
		int ans = 0;
		do {
			if(accumulate(p, p + n, 0) == s)
				ans ++;
		}while(next_permutation(p, p + 10));
		for(int i = 1; i <= 10 - n; i ++)
			ans /= i;
		for(int i = 1; i <= n; i ++)
			ans /= i;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;

int main(){
    int W,H,i,j;
    while (true){
        cin >> H >> W;
        if (W == 0 && H == 0)
            break;
        for (i = 0; i < H; i++){
            for (j = 0; j < W; j++){
                if (i == 0 || i == H - 1){
                    cout << "#";
                }
                else {
                    if (j == 0 || j == W - 1){
                        cout << "#";
                    }
                    else{ cout << "."; }
                }
            }
            cout << endl;
        }cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import sys
import itertools
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,A,B,C=map(int,input().split())
    l=[int(input()) for _ in range(N)]
    ps=itertools.permutations(l)
    ans=INF
    for p in ps:
        for i in range(N-2):
            for j in range(N-1-(i+1)):
                for k in range(N-(i+1)-(j+1)):
                    tmp=0
                    a=sum(p[:i+1])
                    b=sum(p[i+1:i+1+j+1])
                    c=sum(p[i+1+j+1:i+1+j+1+k+1])
                    tmp=(i+j+k)*10+abs(A-a)+abs(B-b)+abs(C-c)
                    ans=min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int a = in.nextInt();
            final int b = in.nextInt();
            final int c = in.nextInt();
            if (a + b >= c) out.println("Yes");
            else out.println("No");
        }

    }
}



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

int main() {
    int n, k, d, a;
    cin >> n >> k;

    vector<bool> snk(n,true);
    for (int i = 0; i < k; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            snk[a-1] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (snk[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 16;
const ll INF = 1LL<<60;
#define bit(n) (1 << (n))


int n;
ll a[N][N];
ll dp[bit(N)];
ll sum[bit(N)];

#define NEXT(m) (((m) - 1) & mask)
ll rec(int mask) {
    if(dp[mask] != INF)  return dp[mask];

    ll ma = -INF;
    for(int sub = NEXT(mask); sub != 0 ; sub = NEXT(sub)) {
        ma = max(ma, rec(sub) + rec(mask & ~sub));
    }
    return dp[mask] = max(ma, sum[mask]);
}

void init() {
    fill(dp, dp+bit(N), INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++)  dp[bit(i)] = a[i][i];

    for(int mask = bit(0); mask < bit(n); mask++) {
        vector<int> pop;
        for(int i = 0; i < n; i++)  if(mask & bit(i))  pop.push_back(i);
        for(auto i : pop)  for(auto j : pop)  sum[mask] += a[i][j];
        sum[mask] /= 2;
    }
}

int main() {
    cin >> n;
    for(int j = 0; j < n; j++)  for(int i = 0; i < n; i++)  cin >> a[i][j];
    init();
    cout << rec(bit(n)-1) << endl;
}

Measured memory_bytes: 1408
n,k=map(int,input().split())
num=[0]*k
for i in range(1,n+1):
    num[i%k]+=1
res=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)


Measured memory_bytes: 40560
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n, ans = 0;
    cin >> n;
    map<int, int> cnt;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    for(auto p: cnt){
        int a = p.first;
        if(p.second > 1) continue;
        bool flg = true;
        for(int i=2;i*i <= a; i++){
            if(a%i == 0){
                if(cnt.find(i) != cnt.end() || cnt.find(a/i) != cnt.end()){
                    flg = false;
                    break;
                }
            }
        }

        if(flg) ans++;
    }
    if(cnt[1] > 0){
        if(cnt[1] == 1){
            ans = 1;
        }else{
            ans = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 12564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = inf;

	// 結局白と黒に分けられる

	// どこで分けるか

	// 累積和
	vector<int> whiteNum(n + 1, 0);
	vector<int> blackNum(n + 1, 0);

	Rep(i, 1, n + 1) {
		int white = 0;
		int black = 0;
		if (s[i - 1] == '.') {
			white++;
		}
		else {
			black++;
		}
		whiteNum[i] = whiteNum[i - 1] + white;
		blackNum[i] = blackNum[i - 1] + black;
	}


	// 全通り試す
	Rep(i, 0 , n + 1) {
		int tmp = 0;
		tmp = blackNum[i] + whiteNum[n] - whiteNum[i];
		ans = min(tmp, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2196
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;

int main(){
	ll n;
	cin >> n;
	map<ll, ll> a,b;
	ll in;
	REP(i,n){
		cin >> in;
		a[i+1+in]++;
		b[i+1-in]++;
	}
	ll ans=0;
	for(auto x: a){
		ans += x.second*b[x.first];
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 37904
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n) inp(k) inp(s)
	fo(i,k)
		cout<<s<<' ';
	fo(i,n-k)
		if(s==1000000000)
			cout<<3<<' ';
		else
			cout<<1000000000<<' ';
	cout<<'\n';
	printclock;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,x,a,ans=0,b;
  	int i;
  	cin>>n>>a>>b;
  	for(i=0;i<n;i++)
    {
      cin>>x;
      if(x<a || x>=b)
        ans++;
    }
  	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256