akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

template <class T>
T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}

/* (identity element, operation) */
template <class T>
using Monoid = pair<T, function<T(T, T)>>;

template <class T, ul K>
class SegmentTree {
  const Monoid<T> monoid;
  const ul N = (1 << K);
  T tree[2 * (1 << K) - 1];

  ui parent(ui i) {
    if (i == 0) {
      return 0;
    }
    return (i - 1) / 2;
  }

  ui child1(ui i) {
    return i * 2 + 1;
  }

  ui child2(ui i) {
    return i * 2 + 2;
  }

  bool is_leaf(ui i) {
    return (N - 1 <= i);
  }

  void propagate_from_leaf(ui i) {
    ui cur = N - 1 + i;
    while (cur != 0) {
      cur = parent(cur);
      auto x1 = tree[child1(cur)];
      auto x2 = tree[child2(cur)];
      tree[cur] = monoid.second(x1, x2);
    }
  }

  T query_impl(ui a, ui b, ui k, ui l, ui r) {
    if (r <= a || b <= l) {
      return monoid.first;
    } else if (a <= l && r <= b) {
      return tree[k];
    } else {
      auto ta = query_impl(a, b, child1(k), l, (l + r) / 2);
      auto tb = query_impl(a, b, child2(k), (l + r) / 2, r);
      return monoid.second(ta, tb);
    }
  }
public:
  /* Initialize Segment Tree with Monoid `_monoid` */
  SegmentTree(const Monoid<T>& _monoid) : monoid(_monoid) {
    FOR0(i, 2 * (1 << K) - 1) {
      tree[i] = monoid.first;
    }
  }

  void update(ui i, T x) {
    tree[N - 1 + i] = x;
    propagate_from_leaf(i);
  }

  // [a, b)
  T query(ui a, ui b) {
    return query_impl(a, b, 0, 0, N);
  }
};

const static ul NMAX = 100000;
const static ul KMAX = 1000000000;
const static ul QMAX = 100000;

static ul N, K, Q;
static sl Ai[QMAX];
static bool Bi[QMAX];
static sl Ci[QMAX];

void solve(void) {
  FOR0(i, Q) {
    Ci[i] = 0;
    Bi[i] = true;
  }
  FOR0(i, Q) {
    Ci[Ai[i] - 1]++;
  }
  FOR0(i, N) {
    cout << ((Q - Ci[i] >= K) ? "No" : "Yes") << endl;
  }
}

int main(void) {
  cin >> N >> K >> Q;
  FOR0(i, Q) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 2176
l = int(input())
n = 0
while 2**n <= l:
  n += 1
p = []
for i in range(1, n):
  p.append((i, i + 1, 0))
  p.append((i, i + 1, 2**(i-1)))
  if l // (2**(i-1)) % 2 == 1:
    p.append((i, n, l // 2**i * 2**i))
m = len(p)
print(n, m)
for i in p:
  print(*i)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;
int a, b;
int main()
{
	cin >> a >> b;
	if (a == b){
		cout << "Draw";
	}else if(a == 1 || a > b && b > 1){
		cout << "Alice";
	}else {
		cout << "Bob";
	}
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations
import math
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n = int(readline())
m = map(int,read().split())
points = [(x, y) for x, y in zip(m, m)]

if n == 2:
    [(a, b), (c, d)] = points
    print(math.hypot(a - c, b - d) / 2)
    quit()


def center(a, b, c):
    M = pow(a[0], 2) - pow(b[0], 2) + pow(a[1], 2) - pow(b[1], 2)
    N = pow(a[0], 2) - pow(c[0], 2) + pow(a[1], 2) - pow(c[1], 2)
    Yab = a[1] - b[1]
    Xab = a[0] - b[0]
    Yac = a[1] - c[1]
    Xac = a[0] - c[0]
    d = Yac * Xab - Yab * Xac
    if d == 0:
        return None
    x = (M * Yac - N * Yab) / (2 * d)
    y = - (M * Xac - N * Xab) / (2 * d)
    r = math.hypot(x - a[0], y - a[1])
    return (x, y, r)


centers = []
for a, b, c in combinations(points, 3):
    cen = center(a, b, c)
    if cen is None:
        continue
    centers.append(cen)

r = 0
for a, b in combinations(points, 2):
    tr = math.hypot(a[0] - b[0], a[1] - b[1]) / 2
    if r > tr:
        continue
    r = tr
    cen = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, r)
centers.append(cen)

res = 1000
for cx, cy, cr in centers:
    for x, y in points:
        tr = math.hypot(x - cx, y - cy)
        if tr > cr + 10e-6:
            break
    else:
        if cr < res:
            res = cr
print(res)


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

int main()
{
	int i;
	string word;
	
	getline(cin, word);
	
	for(i = 0; i < word.size(); i++)
	{
		if(islower(word[i]) != 0)
		{
			word[i] = toupper(word[i]);
		}
		else if(isupper(word[i]) != 0)
		{
			word[i] = tolower(word[i]);
		}
		
		cout << word[i];
	}
	cout << endl;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n;
  long long sum = 0, x = 0;
  cin >> n;
  
  vector<long long> a(n), b(n + 1), ans(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[a[i]]++;
  }
  for(int i = 1; i <= n; i++){
    if(b[i] > 1){
      x = b[i]*(b[i] - 1)/2;
      sum +=x ;
    }
  }
  
  for(int i = 0; i < n; i++){
    if(b[a[i]] > 1){
      ans[i] = sum - (b[a[i]] - 1);
    }else{
      ans[i] = sum;
    }
  }
  
  
  
  for(int i = 0; i < n; i++){
    cout << ans[i] <<endl;
  }
  
  
  
}


Measured memory_bytes: 7296
#include<stdio.h>

int main(void){
  int a,b,c,k,i,pa,pb,pc,flag;
  int ab,bc,ac;
  scanf("%d",&k);
  
  for(i=1;i<=k;i++){
    scanf("%d %d %d",&a,&b,&c);
    pa=a*a;
    pb=b*b;
    pc=c*c;
    ab=pa+pb;
    bc=pb+pc;
    ac=pa+pc;
    
    if(pa==bc){
      flag=1;
    }
    if(pb==ac){
      flag=1;
    }
    if(pc==ab){
      flag=1;
    }
    
    if(flag==1){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
    flag=0;
  }
  return 0;
}

Measured memory_bytes: 0
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, cnt[3];

int main () {
    scanf("%d", &n);
    fto(i, 1, n) {
        int x; scanf("%d", &x);
        int p = 0;
        while (x%2 == 0) {
            ++p;
            if (p == 2) break;
            x /= 2;
        }
        ++cnt[p];
    }

    int cur = 2;
    fto(i, 1, n) {
        bool ok = false;
        fto(j, 0, 2) {
            if (cnt[j] && cur+j >= 2) {
                --cnt[j];
                cur = j;
                ok = true;
                break;
            }
        }
        if (!ok) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
int main(){
    string s;
    cin >> s;

    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
        return 0;
    }

    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

#define MAXN 200200
#define MAXE 400400

typedef pair<int, int> pii;
#define X first
#define Y second
const LL INF = (1LL << 62) | 3;
#define Debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> inline void read(T &x) {
    int ch = getchar();
    bool fg = false;
    for (x = 0; !isdigit(ch); ch = getchar()) {
        if (ch == '-') {
            fg = true;
        }
    }
    for (; isdigit(ch); ch = getchar()) {
        x = x * 10 + ch - '0';
    }
    if (fg) {
        x = -x;
    }
}

template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }

priority_queue<long long> q;
int k;
long long a[MAXN], b[MAXN], c[MAXN];

signed main() {
	int x, y, z; read(x), read(y), read(z), read(k);
	k = min(k, x * y * z);
	for(int i = 1; i <= x; i++) read(a[i]);
	for(int i = 1; i <= y; i++) read(b[i]);
	for(int i = 1; i <= z; i++) read(c[i]);
	sort(a + 1, a + x + 1); reverse(a + 1, a + x + 1);
	sort(b + 1, b + y + 1); reverse(b + 1, b + y + 1);
	sort(c + 1, c + z + 1); reverse(c + 1, c + z + 1);
	for(int i = 1; i <= x; i++) {
		for(int j = 1; j <= y; j++) {
			q.push(a[i] + b[j]);
		}
	}
	for(int i = 1; i <= k; i++) {
		if(!q.empty()) a[i] = q.top(), q.pop();
		else break;
	}
	while(!q.empty()) q.pop();
	for(int i = 1; i <= k; i++) {
		for(int j = 1; j <= z; j++) {
			q.push(a[i] + c[j]);
		}
	}
	for(int i = 1; i <= k; i++) {
		printf("%lld\n", q.top()); q.pop();
	} 
	return 0;
}

Measured memory_bytes: 36964
#include <cstdio>
#include <cctype>
#include <utility>
#include <array>
#include <vector>
#include <string>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_DEF(bool, scan, int &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	const array<int, 5> t{5, 7, 5, 7, 7};
	string s;
	for (int n; (n = in());) {
		vector<int> p(n);
		for (int &i: p) {
			scan(s);
			i = s.size();
		}
		outl([&] {
			 for (int i: range(n))
				if([&](int j) {
					for (int k: t) {
						int l {};
						for (; l < k; j++)
							l += p[j];
						if (l > k)
							return false;
					}
					return true;
				}(i))
					return i;
			return 0;}() + 1);
	}
}


Measured memory_bytes: 2628
/**
*    created: 10.05.2020 09:20:55
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    int n;
    ll c, k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    sort(t.begin(), t.end());
    //おそらくgreedyでいいけど確証ない
    vector<int> bus;
    int l = 0;
    bool f=1;
    
    rep(i,n){
        if(i==0){
            bus.push_back(t[i] + k);
            l = i;
        }
        if(bus.back()<t[i]||i-l+1>c){
            bus.push_back(t[i] + k);
            l = i;
        }
        //bus[0]=t[0]+K
        //bus[j]=t[i]+K
        //bus[j]<=t[i]&&i-l<=cなら乗車可能
        //bus[j]>k+t[i]||i-l>cのときbus.push
    }
    cout << bus.size() << endl;
}

Measured memory_bytes: 1660
import java.util.*;
class Main{
  public static void main(String[] arg){
    Scanner stdIn=new Scanner(System.in);
    int A=stdIn.nextInt();
    int B=stdIn.nextInt();
    int C=stdIn.nextInt();
    int max=Math.max(A,Math.max(B,C));
    int min=Math.min(A,Math.min(B,C));
    if(A+B+C==17&&max==7&&min==5){
    	System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}
    

Measured memory_bytes: 21588
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    vector<string> WEATHER = {"Sunny", "Cloudy", "Rainy"};

    string s;
    cin >> s;
    int i = find(WEATHER.begin(), WEATHER.end(), s) - WEATHER.begin();
    i = (i + 1) % WEATHER.size();
    cout << WEATHER[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio

    int h,w,k;
    cin>>h>>w>>k;
    char mat[h][w];
    int bc=0;
    fora(i,h) {
        fora(j,w) {
            cin>>mat[i][j];
            bc+=(mat[i][j]=='#');
            
        }
    }  
    // cout<<bc<<"\n"; 
    if(k>bc) {
        cout<<0;
        return 0;
    }
    // map<int,int> rw,cl;

    int ans=0;
    for(int i=0;i<(1<<h);i++) {
    for(int j=0;j<(1<<w);j++) {
        int cnt=0;
        fora(rw,h) {
        fora(cl,w) {
            if(mat[rw][cl]=='#') {
                if(((1<<rw)&i)||((1<<cl)&j)) cnt++;
            }
        }
        }
        // cout<<i<<" "<<j<<" "<<cnt<<"\n";
        if(bc-cnt==k) ans++;


        }
    }
    cout<<ans;
    return 0;


}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){

    int h,n = 0;
    int i,a = 0;

    scanf("%d %d",&h,&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        h -= a;
    }

    if(h <= 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
import numpy as np
A, B, H, M = map(int, input().split())
aH = H / 12.0 * 2 * np.pi + M / (12 * 60) * 2 * np.pi
aM = M / 60.0 * 2 * np.pi
print(np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(np.abs(aH - aM))))


Measured memory_bytes: 27172
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e3 + 4;

int n, k, kv, ke;
vector<int> g[N];

void read() {
    cin >> n >> k;
    kv = k / 2;
    ke = (k - 1) / 2;
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].em_back(b);
        g[b].em_back(a);
    }
}

bool used[N];

void dfs(int u, int d, int board) {
    used[u] = 1;
    if (d == board) {
        return;
    }
    for (int to : g[u]) if (!used[to]) {
        dfs(to, d + 1, board);
    }
}

int calcVertex(int u) {
    memset(used, 0, sizeof used);

    used[u]  = 1;
    dfs(u, 0, kv);

    return accumulate(used, used + N, 0);
}

int calcEdge(int u, int v) {
    memset(used, 0, sizeof used);

    used[u] = used[v] = 1;
    dfs(u, 0, ke);
    dfs(v, 0, ke);

    return accumulate(used, used + N, 0);
}

void solve() {
    read();

    int ans = 1e9;
    for (int i = 1; i <= n; ++i) {
        ans = min(ans, n - calcVertex(i));
    }
    for (int u = 1; u <= n; ++u) {
        for (int to : g[u]) {
            ans = min(ans, n - calcEdge(u, to));
        }
    }
    cout << ans << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


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

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    
    // 2. 数列の全パターン.
    int all = 1;
    for(int i = 0; i < N; i++) all *= 3;
    
    // 3. 積が奇数となるもの.
    int odd = 1, a;
    for(int i = 0; i < N; i++){
        scanf("%d", &a);
        if(a % 2 == 0) odd *= 2;
    }
    
    // 4. 出力.
    printf("%d\n", all - odd);
    return 0;
    
}

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

int main(){
  ll x;
  cin >> x;
  ll now = 100;
  ll cnt = 0;
  while(now<=1000000000000000000){
    cnt ++;
    now += now*0.01;
    if(now >= x) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;

// 適当な区切りを入れて足したものを返す
// vector<string>& _sで参照渡ししてたせいで3日躓いてた
lint cut_sum(vector<string> _s, int _at){
  lint sum = 0;
  if(_at < _s.back().size()){
    //_atで区切らない場合
    sum += cut_sum(_s, _at+1);
    //_atで区切る場合
    string tmp = _s.back().substr(_at);
    _s.back().erase(_s.back().begin()+_at, _s.back().end());
    _s.push_back(tmp);
    sum += cut_sum(_s, 1);
  }else{
    for(int i = 0;i < _s.size(); i++){
      // stoi(),stol()では数が大きくなった時に対応できない
      sum += stoll(_s[i]);
    }
  }
  return sum;
}

int main()
{
  std::vector<string> v(1);
  cin >> v[0];

  cout << cut_sum(v, 1) << "\n";
  return 0;
}


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

int N;
int W;
long long w[110];
long long v[110];
long long dp[110][100010];

int main ()
{
    cin >> N >> W;
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    //memset(dp, 0, sizeof(dp));
    for(int i = 0; i < 110; i++) for(int j = 0; j < 100010; j++) dp[i][j] = 1LL<<60;
    dp[0][0] = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 100010; j++)
        {
            if(j - v[i] >= 0)
            {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    long long res = 0;
    for (int j = 0; j < 100010; j++)
    {
        if(dp[N][j] <= W) res = max(res, (long long)j);
    }
    cout << res << endl;
}

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

int dp[100005][3];

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

  int a[n + 1][3];
  rep (i, n) rep (j, 3) cin >> a[i + 1][j];

  dp[1][0] = a[1][0];
  dp[1][1] = a[1][1];
  dp[1][2] = a[1][2];

  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      
      rep (k, 3) {
        if (j == k) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
      }

    }
  }

  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
  return 0;
}



Measured memory_bytes: 2560
l,r = map(int,input().split())
min_num = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        min_num = min(min_num,(i*j)%2019)
        if min_num == 0:
            break
    if min_num == 0:
        break
print(min_num)

Measured memory_bytes: 3060
import math
h,w=map(int, input().split())
cnt1=math.ceil(h/2)
cnt2=math.ceil((h-1)/2)
ans=0
if h==1 or w==1:
  ans=1
else:
  if w%2==0:
    ans=int((cnt1+cnt2)*w/2)
  else:
    ans=int((cnt1+cnt2)*(w-1)/2+cnt1)
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N;
  cin >> N;
  vector<int>a(N);
  cin >> a.at(0);
  //int done=0;
  for(int i = 1 ; i < N ; i++){
  	cin >> a.at(i);
    //done += (a.at(i) - a.at(0));
  }
  
  /*if(done == 0){
  	cout << 0 << endl;
    return 0;
  }*/
  
  int min = 1000000;
  int cal = 0;
  
  for(int i = -100 ; i <= 100 ; i++){
  	int y = i;
      for(int j = 0 ; j < N ; j++){
  	 		cal += (y - a.at(j))*(y - a.at(j));
  	  }
    
    if(min > cal)min = cal;
    cal = 0;
  }
  cout << min << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
long long n,a[100010],kq[100010],x;
main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    kq[2]=abs(a[2]-a[1]);

    kq[3]=min(abs(a[3]-a[1]),kq[2]+abs(a[3]-a[2]));
    for (int i=4;i<=n;i++)
        kq[i]=min(kq[i-1]+abs(a[i]-a[i-1]),kq[i-2]+abs(a[i]-a[i-2]));
    cout<<kq[n];
}


Measured memory_bytes: 1792
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = LI()
ret = 0
for i in A:
    ret ^= i

for j in A:
    print(ret ^ j)

Measured memory_bytes: 112840
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int D, N;
  cin >> D >> N;
  int k = 1;
  for(int i = 0;i < D;i++) k *= 100;
  cout << k * (N+(N==100?1:0)) << endl;
  return 0;
}

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

ll dp[3010][3010];

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N;i++)cin >> a[i];


    for(int i = 0 ;i <N ;i++)dp[i][i] = 0;

    for(int len = 1; len <= N; len++){
        for(int i = 0; i + len <= N; i++){
            int j = i+len;
            if((N-len)%2==0){
                dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
            }else{
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
            }
        }
    }
    cout << dp[0][N] << endl;
    return 0;
}

Measured memory_bytes: 70016
x,y,a,b,c=map(int,input().split())

a_list=list(map(int,input().split()))
a_list=sorted(a_list)
b_list=list(map(int,input().split()))
b_list=sorted(b_list)
a_list=a_list[-x:]
b_list=b_list[-y:]
c_list=list(map(int,input().split()))
for i in range(c):
    c_list[i]=-c_list[i]
import heapq
heapq.heapify(a_list)
heapq.heapify(b_list)
heapq.heapify(c_list)

flag=True
while flag and c_list:
    x=heapq.heappop(c_list)
    x=x*(-1)
    #ｃ_listの中でのもっとも大きい値
    min_a=heapq.heappop(a_list)
    min_b=heapq.heappop(b_list)
    if min(min_a,min_b)>=x:
        flag=False
        heapq.heappush(a_list,min_a)
        heapq.heappush(b_list,min_b)
    else:
        if min_a>=min_b:
            heapq.heappush(a_list,min_a)
            heapq.heappush(b_list,x)
         
        elif min_a<min_b:
            heapq.heappush(b_list,min_b)
            heapq.heappush(a_list,x)

sum_a=sum(list(a_list))
sum_b=sum(list(b_list))

print(sum_a+sum_b)
            

    



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

int main(){
    string s;
    vector<char> ans;

    cin >> s;
    int nm = s.size();

    for (int i = 0; i < nm; i++){
        if(s.at(i) == 'B'){
            if(!ans.empty()){
                ans.pop_back();
            }
        }
        else{
            ans.push_back(s.at(i));
        }
    }

    for (int i = 0; i < ans.size(); i++) cout << ans.at(i);

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    ll x; cin >> x;
    ll cnt = 0;
    ll a = 100;
    while (a < x) {
        a += a / 100;
        ++cnt;
    }

    cout << cnt << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    // cin >> t;
    while (t--) solve();
    return 0;
}


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

int main()
{
   int N; cin>>N;
   string s,t; cin>>s>>t;
   string ans;
   for(int i=0;i<N;i++){
      ans+=s[i];
      ans+=t[i];
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int H, W, N;
  cin>>N>>H>>W;
  int ans = (N+1-H)*(N+1-W);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N,ans=0,maxi=100000000,T,A,H,ondo[1000];
	cin>>N>>T>>A;
	T*=1000;
	A*=1000;
	for(int i=0;i<N;i++)
	{
		cin>>H;
		ondo[i]=T-H*6;
	}
	for(int i=0;i<N;i++)
	{
		if(abs(ondo[i]-A)<maxi){
			ans=i+1;
			maxi=abs(ondo[i]-A);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<pair<ll, int>> bc(m);
    rep(i, m) {
        int b;
        ll c;
        cin >> b >> c;
        bc[i] = {c, b};
    }
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    int l = 0;
    int i = 0;
    ll ans = 0;
    while(1) {
        if ( l == n || i == m ) break;
        int idx = lower_bound(a.begin()+l, a.end(), bc[i].first) - ( a.begin() + l );
        idx = min(bc[i].second, idx);
        ans += bc[i].first * (ll)idx;
        l += idx;
        ++i;
    }
    for ( int i = l; i < n; ++i ) {
        ans += a[i];
    } 
    cout << ans << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Scanner cin = new Scanner();
            int d = cin.nextInt();

            if (d == 25) Console.WriteLine("Christmas");
            else if (d == 24) Console.WriteLine("Christmas Eve");
            else if (d == 23) Console.WriteLine("Christmas Eve Eve");
            else Console.WriteLine("Christmas Eve Eve Eve");
            Console.ReadLine();
        }

        static int BinarySearch<T>(T[] array, T target) where T : IComparable<T> //2分探索
        {
            int min = 0;
            int max = array.Length - 1;

            while (true)
            {
                // 範囲内に見つからなかった
                if (max < min) return -1;
                // 範囲内の中央値と比較する
                int mid = min + (max - min) / 2;
                switch (target.CompareTo(array[mid]))
                {
                    case -1:    // 中央値より小さい
                        max = mid - 1;
                        break;
                    case 1:     // 中央値より大きい
                        min = mid + 1;
                        break;
                    case 0:     // 見つかった
                        return mid;
                }
            }
        }

        static void Swap<T>(ref T a, ref T b)
        {
            T tmp = a;
            a = b;
            b = tmp;
        }
    }

    class Scanner //標準入力
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1) {
        ans += 300000;
    }
    if(y == 1) {
        ans += 300000;
    }
    if(x == 2) {
        ans += 200000;
    }
    if(y == 2) {
        ans += 200000;
    }
    if(x == 3) {
        ans += 100000;
    }
    if(y == 3) {
        ans += 100000;
    }
    if(x == 1 && y == 1) {
        ans += 400000;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

h,w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
elif (h%2==1) and (w%2==1):
    print(int((h * w // 2)+1))
else:
    print(int(h*w/2))


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

using namespace std;

int main()

{
    int n,x,t,ans;
    scanf("%d%d%d",&n,&x,&t);
    if(n%x){
        ans=(n/x)+1;
    }
    else{
        ans=n/x;
    }
    printf("%d\n",ans*t);
    return 0;
}

Measured memory_bytes: 3716
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  /*
  cout<< ("onion">"potato") <<endl;

  return 0;
  */
  int h,i,j;
  int y[50],z[50],n,p,a,b,c,d,e,f,s,m;
  string l[50];
  while(cin>>n&&n){
    for(i=0;i<n;i++){
      cin>>l[i]>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      y[i]=f*s*m-p;
      z[i]=a+b+c+(d+e)*m;
    }
    h=1;
    for(i=0;h;i++){
      h=0;
      for(j=1;j<n-i;j++){
	if(y[j-1]*z[j]<y[j]*z[j-1]){
	  swap(y[j-1],y[j]);
	  swap(z[j-1],z[j]);
	  swap(l[j-1],l[j]);
	  h=1;
	}else if(y[j-1]*z[j]==y[j]*z[j-1]){
	  if(l[j-1]>l[j]){
	    swap(y[j-1],y[j]);
	    swap(z[j-1],z[j]);
	    swap(l[j-1],l[j]);
	    h=1;
	  }
	}
      }
    }
    for(i=0;i<n;i++)
      cout<<l[i]<<endl;
    cout<<"#"<<endl;
  }
  return 0;
}

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

struct st {
	int s, e, cnt;
};
int main() {
	int n; scanf("%d", &n);
	deque<st>s;
	rep(i, n) {
		int d; scanf("%d", &d);
		if (!s.empty() && s.back().e != d) {
			s.back().cnt++;
			s.back().e = d;
		}
		else s.push_back({ d,d,1 });
	}
	int Max = 0;
	rep(i, s.size()) {
		Max = max(Max, s[i].cnt);
		if (i < (int)s.size() - 1)Max = max(Max, s[i].cnt + s[i + 1].cnt);
		if (i < (int)s.size() - 2)Max = max(Max, s[i].cnt + s[i + 1].cnt + s[i + 2].cnt);
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}


vector<int>Z_Algorithm(const string&s) {
    int n=s.size();
    vector<int>z(n);
    int l = 0, r = 0;
    for (int i=1; i<n; i++) {
	if (i > r) {
	    l = r = i;
	    while (r<n && s[r-l] == s[r]) r++;
	    z[i] = r-l; r--;
	} else {
	    int k = i-l;
	    if (z[k] < r-i+1) z[i] = z[k];
	    else {
		l = i;
		while (r<n && s[r-l] == s[r]) r++;
		z[i] = r-l; r--;
	    }
	}
    }
    return z;
}
const int LEVEL = 100;
const LL INF = 1LL<<61;
int N;
char S[200011];
LL C[LEVEL][26];
LL len[LEVEL];
LL ans[26];

void F(LL R, int sgn) {
    for (int i=LEVEL-1; i>=2; i--) {
	if (len[i] <= R) {
	    REP (t, 26) ans[t] += C[i][t] * sgn;
	    R -= len[i];
	}
    }

    assert(R <= N);
    REP (i, R) ans[S[i]-'a'] += sgn;
}

void MAIN() {
    scanf("%s", S);
    N = strlen(S);
    N /= 2;
    VI z = Z_Algorithm(string(S, S+N));
    
    int pos = N;
    for (int i=1; i<N; i++) if (i + z[i] == N) {
	pos = i;
	break;
    }

    len[0] = pos;
    len[1] = N;
    REP (i, N) {
	if (i < pos) C[0][S[i]-'a']++;
	C[1][S[i]-'a']++;
    }
    for (int i=2; i<LEVEL; i++) {
	len[i] = min(INF, len[i-1] + len[i-2]);
	REP (t, 26) C[i][t] = C[i-1][t] + C[i-2][t];
    }
//    puts(S);

    LL l, r;
    scanf("%lld%lld", &l, &r);
    assert(len[LEVEL-1] > r);
    F(r, 1);
    F(l-1, -1);

    //puts(S);
    //printf("%d %d\n", sep, pos);
    rprintf("%lld", ans, ans+26);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 896
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    h, n = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(n)]

    dp = [INF]*(h+1)
    dp[0] = 0

    for i in range(h):
        for j in range(n):
            dp[min(h,i+AB[j][0])] = min(dp[min(h,i+AB[j][0])], dp[i] + AB[j][1])

    print(dp[-1])
resolve()

Measured memory_bytes: 42992
#include <bits/stdc++.h>
    #define ll long long
    #define pb push_back
     
    using namespace std;
     
    const int e = 2e5 + 69;
     
    vector<ll>adj[e];
    ll par[e];
    bool vs[e];
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        int n, m;
        cin >> n >> m;
        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        for(int i=1; i<=n; i++){
            vs[i] = true;
        }
        queue<ll>q;
        q.push(1);
        vs[1] = false;
        while(q.size() != 0){
            ll cur = q.front();
            q.pop();
            for(auto j : adj[cur]){
                if(vs[j] == true){
                    /*if(par[j] != 0 && par[j] != cur){
                        cout << "No";
                        return 0;
                    }*/
                    par[j] = cur;
                    vs[j] = false;
                    q.push(j);
                }
            }
        }
        for(int i=2; i<=n; i++){
            if(par[i] == 0){
                cout <<"No";
                return 0;
            }
        }
        cout << "Yes" <<"\n";
        for(int i=2; i<=n; i++){
            cout << par[i] <<"\n";
        }
     
    }

Measured memory_bytes: 15436
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FDistinctNumbers {
public:

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> c(n+1);
      rep(i, n) {
        int a; cin >> a;
        c[a]++;
      }

      vector<int> d(n+1);
      for(int i=1; i<=n; i++) {
        d[c[i]]++;
      }

      vector<ll> sumkd(n+1);
      vector<ll> sumd(n+1);
      rep(i, n) {
        sumkd[i+1] += sumkd[i] + (i+1)*d[i+1];
        sumd[i+1] += sumd[i] + d[i+1];
      }

      vector<ll> f(n+1);
      for(int i=1; i<=n; i++) {
        f[i] = sumkd[i]/i + (sumd[n] - sumd[i]);
      }
      vector<int> ans(n+1);
      int p = 1;
      vector<int> ret(n);
      for(int i=n; i>=1; i--) {
        while(p <= n && i <= f[p]) {
          p++;
        }
        ret[i-1] = p-1;
      }

      for(auto& e: ret) {
        cout << e << '\n';
      }
    }
};

signed main() {
  FDistinctNumbers solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

  ll n, at, aa, t, a;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> t >> a;
    if(!i)
      at = t, aa = a;
    else {
      ll x = max((at + t - 1) / t, (aa + a - 1) / a);
      at = t * x, aa = a * x;
    }
  }
  cout << at + aa << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

b = [0,(h[1]-h[0]).abs]

(2..n-1).each do |i|
  b[i] = [b[i-1]+(h[i-1]-h[i]).abs, b[i-2]+(h[i-2]-h[i]).abs].min()
end

puts b[n-1]

Measured memory_bytes: 11908
import math
n = int(input())
c = [list(map(int, input().split())) for i in range(n)]
dis = 0
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        else:
            dis += math.sqrt((c[i][0] - c[j][0])**2 + (c[i][1] - c[j][1])**2)

print(dis / n)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N];
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=k+1;i<=n;i++){
		if(a[i]>a[i-k]) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  
  int ans=0;
  
  rep(i,s.size()){
  	if(s[i]!=t[i]){
    	ans++;
    }
  }

  cout << ans <<endl;
  
}

Measured memory_bytes: 3880
#include <iostream>
using namespace std;
int main(void){
    
    int r,g,b;
    cin >> r >> g >> b;
    
    if (((100 * r) + (10 * g) + b) % 4 == 0){
        cout << "YES" << endl;
    }
    
    else cout << "NO" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 105;

ll modexp(ll x, ll n)
{
    if(n==0)
        return 1LL;
    if(n%2==0)
    {
        ll y = modexp(x,n/2)%mod;
        return (y*y)%mod;
    }
    return (x*modexp(x,n-1)%mod)%mod;
}

ll powr(ll x, ll n)
{
    ll ans = 1;
    for(int i=1;i<=n;i++)
        ans=ans*x;
    return ans;
}

vector<pair<int,ll> > v;

ll dp[MAX][MAX*1000];

ll solve(int n,int w)
{
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==0)
            {
                if(j==v[i].first)
                    dp[i][j] = v[i].second;
                dp[i][j] = max(dp[i][j],dp[i][j-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
                if(j>=v[i].first)
                    dp[i][j] = max(dp[i][j],v[i].second+dp[i-1][j-v[i].first]);
            }
        }
    }
    // for(int i=0;i<n;i++)
    // {
    //     for(int j=1;j<=w;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    return dp[n-1][w];
}

int main()
{
    int n,w;
    si(n),si(w);
    for(int i=0;i<n;i++)
    {
        int x,y;
        si(x),si(y);
        v.pb(mp(x,y));
    }
    sort(v.begin(),v.end());
    pfl(solve(n,w));
    return 0;
}

Measured memory_bytes: 84224
DIV = 1_000_000_007
n = gets.to_i
l = n.times.map{ gets.chomp }
l.delete('-')
s = l.size
pos_u = [0]*s
pos_d = [0]*s
u = l.count('U')
d = l.count('D')
l.each_with_index do |str, i|
  if str == 'U' then (i+1...s).each{ |j| pos_u[j]+= 1 }
  else               (0...i).each{   |j| pos_d[j]+= 1 }
  end
end
dp = (s+1).times.map{ [0]*(s+1) }
dp[0][0] = 1
for i in (1..s)
  for j in (0..i)
    dp[i][j] = dp[i-1][j-1]*(pos_u[i-1]-j+1) if j > 0
    dp[i][j] += dp[i-1][j]*(pos_d[i-1]-d+(i-j)) if j < i
    dp[i][j] %= DIV
  end
end
p dp[s][u]

Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[1000000];
vector<int> vec;
int has[1000000];
vector<int> adj[1000000];
int vis[1000000];
int T;
void dfs(int v) {
    vec.push_back(v);
    vis[v]=1;
    has[a[v]]=T;
    for (auto u:adj[v]) {
        if (vis[u])continue;
        dfs(u);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    int ret=0;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i=1;i<=n;i++) {
        if (!vis[i]) {
            vec.clear();
            T++;
            dfs(i);
            for (auto x:vec){
                if (has[x]==T)ret++;
            }
        }
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 36092
a,b,c = map(int,input().split())
aa,bb,cc = map(int,input().split())
aaa,bbb,ccc = map(int,input().split())

ans = "No"
if a-aa == b-bb and b-bb == c-cc:
  if aa-aaa == bb-bbb and bb-bbb == cc-ccc:
    if a-b == aa-bb and aa-bb == aaa-bbb:
      if b-c == bb-cc and bb-cc == bbb-ccc:
        ans = "Yes"
        
print(ans)

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


const int MAX_N = 100005;

char S[MAX_N];

int main()
{
	scanf(" \n%s", S);

	int len = -1;
	while(S[++len]);

	int res0 = 0, res1 = 0;


	for(int i = 0; i < len; ++i)
	{
		if(S[i] == '0')
		{
			if(i & 1)
			{
				++res1;
			}
			else
			{
				++res0;
			}
		}
		else
		{
			if(i & 1)
			{
				++res0;
			}
			else
			{
				++res1;
			}
		}
	}

	printf("%d\n", res0 < res1 ? res0 : res1);


	return 0;
}

Measured memory_bytes: 384