akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){
    int n , k , c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> L,R;
    for(int i = 0; i < n && L.size() < k;){
        if(s[i]=='o'){
            L.push_back(i);
            i += c+1;
        }else{
            i++;
        }
    }
    for(int j = n-1; j > -1 && R.size() < k;){
        if(s[j]=='o'){
            R.push_back(j);
            j -= c+1;
        }else{
            j--;
        }
    }
    reverse(R.begin(),R.end());
    
    for(int i=0; i<k ; i++){
        if(L[i]==R[i])cout << L[i]+1 << endl;
    }
	return 0;
}


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int x;cin>>x;
    int g=__gcd(360ll,x);
    int ans=360/g;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
// typedef vector<ll> vec;
// typedef vector<vec> mat;

using namespace std;

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

    ll N;
    cin >> N;
    ll ans = 0;
    ll i = 1;
    while (i < N-i) {
        ans++;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include<string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+4;
int main(){
    int x1,y1,x2,y2;
    while(cin>>x1>>y1>>x2>>y2){
    	int dx=x2-x1;
    	int dy=y2-y1;
    	int x3=x2-dy;
    	int y3=y2+dx;
    	int x4=x3-dx;
    	int y4=y3-dy;
    	printf("%d %d %d %d\n",x3,y3,x4,y4);
	}
}

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

int main() {
  int a,sum;
  cin >> a;
  for(int i = 0; i < a;i++){
    int x,y;
    cin >> x >> y;
    sum += y - x + 1; 

  }
  
   cout << sum << endl;
  
}
 
  
  
  
 


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b)
  {
    if(b==c)
    {
      cout<<"No";
      return 0;
    }
    else
    {
      cout<<"Yes";
      return 0;
    }
  }
  else
  {
    if(b==c)
    {
      cout<<"Yes";
      return 0;
    }
    else
    {
      if(a==c)
      {
        cout<<"Yes";
        return 0;
      }
      else
      {
        cout<<"No";
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import copy

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)
n =ip()
s = 0
a = 0
while s<n:
    a+=1
    s+=a
print(a)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
#include <cassert>
#include <cmath>
#include <unordered_map>
#include <unordered_set>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// Там еще некоторые особенности есть. Подробнее https://codeforces.com/blog/entry/11080?locale=ru

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll mod = (ll) 1e9 + 7;

ll binpowmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= a;
            res %= mod;
        }
        n >>= 1ll;
        a *= a;
        a %= mod;
    }
    return res;
}

inline ll inv(ll a) {
    return binpowmod(a, mod - 2);
}

void solve() {
    int n, k;
    cin >> n >> k;

    vll a(n);
    for (auto &i : a) {
        cin >> i;
    }

    if (k == 1) {
        cout << 0;
        return;
    }

    sort(all(a));

    vll facts(n + 1, 1);
    for (ll i = 2; i <= n; i++) {
        facts[i] = facts[i - 1] * i;
        facts[i] %= mod;
    }

    vll invfacts(n + 1, 1);
    for (ll i = 2; i <= n; i++) {
        invfacts[i] = inv(facts[i]);
    }

    vll C(n + 1, 1);
    for (int i = k - 2; i <= n; i++) {
        C[i] = ((facts[i] * invfacts[k - 2]) % mod * invfacts[i - (k - 2)]) % mod;
    }

    ll ans = 0;

    int step = 0;
    ll sum = 0;
    for (int i = k - 1; i < n; i++) {
        sum += C[k - 2 + step++];
        sum %= mod;
        ll val = (a[i] + mod) % mod;
        ans = (ans + (val * sum) % mod) % mod;
    }

    step = 0;
    sum = 0;
    for (int i = n - k; i >= 0; --i) {
        sum -= C[k - 2 + step++];
        sum = (sum + mod) % mod;
        ll val = (a[i] + mod) % mod;
        ans = (ans + (val * sum) % mod) % mod;
    }

    cout << ans;
}

int main() {
    int t = 1;
    for (int i = 0; i < t; i++) {
        solve();
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
# frozen_string_literal: true

class Node
  attr_accessor :name, :weight

  def initialize(name, weight)
    @name = name
    @weight = weight
  end
end

N = gets.to_i
graph = Array.new(N + 1) { [] }

(N - 1).times do
  u, v, w = gets.split.map(&:to_i)
  graph[u] << Node.new(v, w)
  graph[v] << Node.new(u, w)
end

dist = Array.new(N + 1) { -1 }
dist[1] = 0
queue = [1]

while queue.any?
  v = queue.shift
  graph[v].each do |node|
    next if dist[node.name] != -1

    dist[node.name] = dist[v] + node.weight
    queue << node.name
  end
end

dist[1..-1].each do |i|
  puts i % 2
end

Measured memory_bytes: 27516
m, dp = gets.to_s.to_i, [0]
(1..m).each {|i|
  cans = (0..6).to_a.map{|j| [6 ** j, 9 ** j] }.flatten.select {|j| i - j >= 0 }.map{|j| i - j }.uniq
  dp.push(cans.map{|j| dp[j] }.min + 1)
}
p dp.last

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 100010
#define debug(x) cerr << #x << " " << x << endl
using namespace std;

inline int read() { int x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

const int MOD = 1e9 + 7;int n;
int p[MAXN];
int k;
int main() {
    n = read();
    k = read();
    for(int i = 1; i <= n; ++i) {
        p[i] = read();

    }
    sort(p + 1, p + n + 1);
    int minn = MOD;
    for(int i = 1; i <= n - k + 1; ++i) {
        minn = min(minn, p[i + k - 1] - p[i]);
    }
    cout << minn << endl;
    return 0;
}


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

void Main() {
    // input
    int K;
    string S;
    cin >> K;
    cin >> S;

    // translate
    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
  while (1) {
    int len, i;
    long sum = 0;
    char N[1000];
    scanf("%s\n", N);
    if (!strcmp(N, "0")) break;
    len = strlen(N);
    for (i = 0; i < len; i++)
      sum = sum + (N[i] - 0x30);
    printf("%ld\n", sum);
  }
  return 0;
}

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

int main() {
	int counter;
	cin >> counter;
	for (int n = 0; n < counter; n++) {
		int gx, gy, p;
		cin >> gx >> gy;
		cin >> p;
		int x1, x2, y1, y2, t[16][16] = {}, up[16][16] = {} ,left[16][16] = {};
		for (int m = 1; m <= p; m++){
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 == x2)
				up[x1][max(y1, y2)] = 1;
			if (y1 == y2)
				left[max(x1, x2)][y1] = 1;
		}
		for (int j = 0; j <= 15; j++)
			left[0][j] = 0;
		for (int i = 0; i <= 15; i++)
			up[i][0] = 0;
		t[0][0] = 1;
		for (int j = 0; j <= gy; j++) {
			for (int i = 0; i <= gx; i++) {
				if (left[i][j] == 0 && i > 0) 
					t[i][j] += t[i-1][j];
				if (up[i][j] == 0 && j > 0) 
					t[i][j] += t[i][j-1];
			}
		}
		if (t[gx][gy] == 0)
			cout << "Miserable Hokusai!" << endl;
		else
			cout << t[gx][gy] << endl;
	}
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int count = 0;
	rep(i,3){
		if(s[i] == '1'){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector<int64_t> ss(a + 2), ts(b + 2);
    for (int i = 1; i <= a; i++)
    {
        cin >> ss[i];
    }
    ss[0] = -1e12;
    ss[a + 1] = 1e12;
    for (int i = 1; i <= b; i++)
    {
        cin >> ts[i];
    }
    ts[0] = -1e12;
    ts[b + 1] = 1e12;
    for (int i = 0; i < q; i++)
    {
        int64_t x;
        cin >> x;

        int64_t min_distance = numeric_limits<int64_t>::max();

        //  s -> t
        for (int j = 0; j < 2; j++)
        {
            auto s = lower_bound(ss.begin(), ss.end(), x);
            s -= j;

            for (int k = 0; k < 2; k++)
            {
                auto t = lower_bound(ts.begin(), ts.end(), x);
                t -= k;

                min_distance = min(min_distance, abs(x - *s) + abs(*s - *t));
                min_distance = min(min_distance, abs(x - *t) + abs(*s - *t));
            }
        }
        cout << min_distance << endl;
    }
}

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

using namespace std;

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    string ans = "";
    while (n > 26) {
        char t = 'a';
        if (n % 26 == 0) {
            t = 'z';
            n--;
        }
        else {
            t += (n % 26) - 1;
        }
        ans += t;
        n /= 26;
    }
    ans += ('a' + n % 27 - 1);
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, L; 
  cin >> N >> L;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int pos = -1;
  REP(i, N-1){
    if(A[i]+A[i+1] >= L) pos = i+1;
  }
  if(pos == -1){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  FOR(i, 1, pos){
    cout << i << endl;
  }
  RFOR(i, pos, N){
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    int a,b;
    cin >> a >> b;
    cout << max(0,a - 2* b) << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
	return a*a + b*b;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>x[i]>>y[i];
		X += x[i]; Y += y[i];
	}
	X /= n; Y /= n;
	double P = 0.1;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = dist(X - x[0], Y - y[0]);
		for (int j = 1; j < n; j++) {
			e = dist(X - x[j], Y - y[j]);
			if (d < e) { d = e; f = j; }
		}
		X += (x[f] - X)*P;
		Y += (y[f] - Y)*P;
		P *= 0.999;
	}
    cout<<sqrt(d)<<endl;
	//printf("%.3lf %.3lf\n%.3lf", X, Y, sqrt(d));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S << endl;
  }else{
    REP(i, K) { cout << S[i]; }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Elm
{
  int val;
  Elm *prev, *next;
};

Elm *nil;

void newList()
{
  nil = (Elm *)malloc(sizeof(Elm));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int val)
{
  Elm *x = (Elm *)malloc(sizeof(Elm));
  x->val = val;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

void del(Elm *e)
{
  if (e == nil)
    return;
  e->prev->next = e->next;
  e->next->prev = e->prev;
  free(e);
}

void dropHead()
{
  del(nil->next);
}

void dropLast()
{
  del(nil->prev);
}

Elm *find(int val)
{
  Elm *cur = nil->next;
  while (cur != nil && cur->val != val)
    cur = cur->next;
  return cur;
}

void remove(int val)
{
  del(find(val));
}

void print()
{
  Elm *cur = nil->next;
  while (cur != nil)
  {
    if (cur->next == nil)
      printf("%d\n", cur->val);
    else
      printf("%d ", cur->val);
    cur = cur->next;
  }
}

int main()
{
  int n, val;
  char order[12];
  scanf("%d", &n);
  newList();

  for (int i = 0; i < n; i++)
  {
    scanf("%s", order);
    if (order[6] == 'F') dropHead();
    else if (order[6] == 'L') dropLast();
    else
    {
      scanf("%d", &val);
      if (order[0] == 'i') insert(val);
      else remove(val);
    }
  }

  print();
  return 0;
}

Measured memory_bytes: 33880
function Main(input){
	input=input.split("\n");
	var n=input[0];
	var arr=[];
	for(var i=0;i<3;i=(i+1)|0){arr[n.charAt(i)]=true;}
	if(arr["a"]==true&&arr["b"]==true&&arr["c"]==true){console.log("Yes");}
	else{console.log("No");}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int find(int x){
        if(d[x]<0)return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y){
        x = find(x);y = find(y);
        if(x == y)return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x; 
        return true;
    }
    bool same(int x,int y){ return find(x) == find(y); }
    int size(int x){ return -d[find(x)]; }
};

int main(){
    int n,m,k;cin>> n >> m >> k;
    UnionFind uf(n);
    vector<int> frnd(n,0);
    vector<int> blck(n,0);
    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
        frnd[a]++;
        frnd[b]++;
    }
    rep(i,k){
        int c,d;cin>>c>>d;
        c--;d--;
        if(uf.same(c,d)){
            blck[c]++;
            blck[d]++;
        }
    }
    rep(i,n){
        int ans=0;
        ans += uf.size(i);
        ans--;
        ans -= frnd[i];
        ans -= blck[i];
        cout<<ans<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

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

char fi[220][220];
int d[220][220];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int h,w; cin >> h >> w;
	pair<int,int> s,g;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> fi[i][j];
			if(fi[i][j]=='@')g=make_pair(i,j);
			if(fi[i][j]=='%')s=make_pair(i,j);
			d[i][j]=1e9;
		}
	}
	queue<pair<int,int>> q;
	q.push(s);
	d[s.first][s.second]=0;
	while(q.size()){
		auto p=q.front(); q.pop();
		int x=p.first,y=p.second;
		for(int i=0;i<4;i++){
			int nx=x+dx[i],ny=y+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&fi[nx][ny]!='#'&&d[nx][ny]>d[x][y]+1){
				d[nx][ny]=d[x][y]+1;
				q.push(make_pair(nx,ny));
			}
		}
	}
	int mi=1e9;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(fi[i][j]=='$')mi=min(mi,d[i][j]);
		}
	}
	if(mi>d[g.first][g.second])printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 3416
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 255;
const int MAXM = 505;
const int INF  = 1e9;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, Q, P;
int dp[MAXM][MAXN];
pair <int, int> a[MAXM];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(Q), P = INF / Q * Q;
	int p = 2 * n - 1, q = 2 * n - 1;
	for (int i = 0; i <= 2 * n - 1; i++) {
		while (i * i + p * p > (2 * n) * (2 * n) && p >= 0) p--;
		while (i * i + q * q >= n * n && q >= 0) q--;
		if (q == -1) a[++m] = make_pair(p + 1, 0);
		else a[++m] = make_pair(q + 1, p + 1);
	}
	sort(a + 1, a + m + 1);
	int ans = 0;
	for (int k = 0; k <= n; k++) {
		memset(dp, 0, sizeof(dp)), dp[0][0] = 1;
		for (int i = 1, f = 0, g = 0; i <= m; f += a[i].second != 0, g += a[i].second == 0, i++)
		for (int j = 0; j <= k; j++) {
			int tmp = dp[i - 1][j];
			if (a[i].second == 0) update(dp[i][j], 1ll * tmp * (a[i].first - j - g) % P);
			else {
				if (j != k) update(dp[i][j + 1], 1ll * tmp * (a[i].first - j - g) % P);
				update(dp[i][j], 1ll * tmp * (a[i].second - k - n - (f - j)) % P);
			}
		}
		int now = dp[m][k];
		if (k & 1) update(ans, P - now);
		else update(ans, now);
	}
	writeln(ans % Q);
	return 0;
}

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

int main() {
	
	int n , m , x , y ;
	
	cin >> n >> m ;
	
	int arr[n];
	int visit[n];
	
	for( int i=0 ; i<n ; i++ ){
	    arr[i] = 1;
	    visit[i] = 0;
	}
	
	visit[0] =1 ;
	
	for( int i=0 ; i<m ; i++ ){
	    
	    cin >> x >> y;
	    
	    if( visit[x-1]==1 ){
	        visit[y-1] = 1;
	    }
	    
	    arr[x-1]--;
	    arr[y-1]++;
	    
	    if( arr[x-1]==0 ){
	        visit[x-1] = 0;
	    }
	}
	
	int sum =0;
	
	for( int i=0 ; i<n ; i++ ){
	    sum += visit[i];
	}
	
	cout << sum << endl ;
	
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
    
typedef struct
{
  double x;
  double y;
}koch;
  
void fractal(int, koch, koch);
   
int main()
{    
  koch p1, p2;
  int n;
    
  p1.x = 0;
  p2.x = 100;
  p1.y = 0;
  p2.y = 0;
    
  scanf("%d", &n);
    
  printf("%f %f\n", p1.x, p1.y);
  fractal(n, p1, p2);
  printf("%f %f\n", p2.x, p2.y);
    
  return 0;
}
  
void fractal(int n, koch p1, koch p2)
{   
  if(n == 0) return;
  koch s, t, u;
    
  s.x = (p2.x-p1.x)/3+p1.x;
  s.y = (p2.y-p1.y)/3+p1.y;
  t.x = 2*(p2.x-p1.x)/3+p1.x;
  t.y = 2*(p2.y-p1.y)/3+p1.y;
  u.x = (t.x-s.x)/2-sqrt(3)/2*(t.y-s.y)+s.x;
  u.y = (t.y-s.y)/2+sqrt(3)/2*(t.x-s.x)+s.y;
    
  fractal(n-1, p1, s);
  printf("%f %f\n", s.x, s.y);
      
  fractal(n-1, s,u);
  printf("%f %f\n", u.x, u.y);
      
  fractal(n-1, u, t);
  printf("%f %f\n", t.x, t.y);
    
  fractal(n-1, t, p2);
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int K;
  cin>>K;
  string S;
  cin>>S;

  Int N = S.size();
  S = S.substr(0, K);
  if(N > K) S += "...";
  cout<<S<<endl;

  return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    ll x;
    cin >> x;

    ll cnt = 0;
    for (ll i = 1; i < mod; i++) {
        cnt += i;
        if(cnt>=x){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3600
#include <iostream>

int main() {
  int n, k, s;
  std::cin >> n >> k >> s;
  int other = s + 1;
  if (s == (int)1e9) other = s - 1;
  for (int i = 0; i < n; ++i) {
    if (i < k) std::cout << s << " ";
    else std::cout << other << " ";
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> color(9);
  for (size_t i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    ++color[std::min(a/400, 8)];
  }

  int min = 0;
  for (size_t i = 0; i < 8; ++i)
    min += (color[i]? 1:0);
    
  int max = min;
  min = std::max(min, 1);
  max += color[8];

  printf("%d %d\n", min, max);
}

Measured memory_bytes: 256
#include <stdio.h>
#define LONG long

int N, S;
int array[100];

int done[100][21];
LONG memo[100][21];

LONG num(int i, int s)
{
	if (s < 0 || s > 20){
		return (0);
	}
	
	
	if (done[i][s]){
		return (memo[i][s]);
	}
	
	if (i == N){
		return (s == S);
	}
	
	done[i][s] = 1;
	memo[i][s] = num(i + 1, s + array[i]) + num(i + 1, s - array[i]);
	
	return (memo[i][s]);
}

int main(void)
{
	int i;
	
	scanf("%d", &N);
	N -= 1;
	
	for (i = 0; i < N; i++){
		scanf("%d", &array[i]);
	}
	scanf("%d", &S);
	
	printf("%ld\n", num(1, array[0]));
	
	return (0);
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,c;
    cin >> a >> b >>c;
    
    if (a == b)cout << c << endl;
    else if (a == c)cout << b << endl;
    else cout << a << endl;
    
    return 0;
}



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

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

    ll ans = 0;

    for(ll i = 1; i <= n; i++) {
        if(i%15 == 0) continue;
        else if(i%3 == 0) continue;
        else if(i%5 == 0) continue;
        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3676
def isMonth(num):
    return (1 <= num and num <= 12)

if __name__ == '__main__':
    s = input()
    s1 = int(s[:2])
    s2 = int(s[2:])

    if(isMonth(s1)):
        if(isMonth(s2)):
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if(isMonth(s2)):
            print("YYMM")
        else:
            print("NA")
    
    


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
//const int N = 1e5 + 5;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    string s,t;
    cin>>s>>t;
    t+=s;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


A,B,C,D = nm()
x = (C+B-1)//B
y = (A+D-1)//D

# print(x,y)
if x <= y: 
    print('Yes')
else:
    print('No')



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

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

    int a;
    int sum = 0;
    int cur = 1;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        if (a == cur) {
            ++cur;
        } else {
            ++sum;
        }
    }

    if (sum == N) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << sum << std::endl;
    }

    return 0;
}


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

int *v,m,n,ans=0;

int main(){
	while(true){
		std::cin >> n >> m;
		if(!n && !m)
			return 0;
		v = new int[n];
		for(int i=0 ;i<n; i++)
			std::cin >> v[i];
		std::sort(v,v+n,std::greater<int>());
		if(m!=1)
			for(int i=0; i<n; i++)
				if(!((i+1)%m == 0 && (i+1) >= m))
					ans += v[i];
		std::cout << ans << std::endl;
		delete[] v;
		ans = 0;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	double rad=c*M_PI/180.0;
	cout<<fixed<<setprecision(8)<<a*b*sin(rad)/2<<endl<<a+b+sqrt(a*a+b*b-2*a*b*cos(rad))<<endl<<b*sin(rad)<<endl;
	return 0;
}



Measured memory_bytes: 3516
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
    int n;
    long long d;
    long long x,y;
    int ans=0;
    scanf("%d %lld",&n,&d);
    for(int i=0;i<n;i++) {
        scanf("%lld %lld",&x,&y);
        if(x*x+y*y<=d*d) ans++;
    }
    printf("%d",ans);
	return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
signed main(){
  long long b[100],c=0,d=0,e,f=1000000,t,g[100000];
  int a[100];
  for(int i=0;i<5;i++){
     cin>>c;
    if(c%10==0) b[i]=0;
    else b[i]=abs(10-(c%10));
    a[i]=c;
  }
  sort(b,b+5);
  for(int i=0;i<5;i++){
    d+=a[i]+b[i];
  }
  cout<<d-b[4]<<"\n";
}


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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(N+1);
  int m,sum1=0,sum2=0;
  for(int i=0;i<M;++i){
    cin >> m;
    A.at(m)=1;
  }
  for(int i=X-1;i!=0;--i){
    sum1+=A.at(i);
  }
  for(int i=X+1;i!=N+1;++i){
    sum2+=A.at(i);
  }
  cout << min(sum1,sum2) << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> map(n+1, 0);
    for (int i = 0; i < n-1; i++) {
        int temp;
        cin >> temp;
        map[temp]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << map[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3996
n = int(input())
a, b = map(int, input().split())
p = sorted(map(int, input().split()))
max_contest = n // 3
count = 0
for i in range(max_contest):
    # print(p[0], p[1], p[-1])
    # print(p[0] <= a , p[-1] >= b+1 , a+1 <= p[1] <= b)
    can_b = [i for i in p if a+1 <= i <= b]
    if p[0] <= a and p[-1] >= b+1 and len(can_b) != 0:
        count += 1
        del p[0]
        p.remove(can_b[0])
        del p[-1]
    else:
        break
print(count)


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

long long gcm(long long x, long long y){
    if(y == 0) return x;
    else return gcm(y, x % y);
}

int main() {
    int N;
    cin >> N;
    long long T[N];
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }
    sort(T, T + N);

    long long ans = T[N-1];
    for (int i = N - 2; i >= 0; i--)
    {
        ans = ans / gcm(ans, T[i]) * T[i];
    }

    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;
    if(D > T*S) PR("No");
    else PR("Yes");

    return 0;
}

/*



*/

Measured memory_bytes: 3596
n = int(input())
a = list(int(i) for i in input().split())
ans = 1
ans2 = 1
for i in a:
  if i%2 == 0:
   ans = ans *3
   ans2 = ans2 *2
  else:
   ans = ans*3
   ans2 = ans2*1
print(ans-ans2)

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

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  int A[N];
  rep(i, N){
    A[i] = K - Q;
  }
  int a;
  rep(i, Q){
    cin >> a;
    A[a - 1]++;
  }
  rep(i, N){
    if (A[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
vector<ll> b(n);
ll sum=0;
rep(i, n){
  cin >> a[i] >> b[i];
  sum+=a[i];
}
rep(i,n){
  if(a[i]>b[i])ans=min(ans,b[i]);
}
if(ans==10000000000)ans=sum;
cout << sum-ans << endl;
return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

string t[4]={"dream","dreamer","erase","eraser"};
bool dp[100010];

signed main()
{
    string s; cin>>s;
    int N=s.length();

    dp[0]=true;
    REP(i,N){
        if(!dp[i]) continue;
        for(auto u:t){
            if(s.substr(i,u.size())==u) dp[i+u.size()]=true;
        }
    }
    cout<<(dp[N]? "YES":"NO")<<endl;
}


Measured memory_bytes: 512
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 100, inf = 1000;

int a[N];

int main() {
	fast_cin();
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	vector<int> moves;
	int free = -1;
	a[0] = inf;
	++k;
	while (k--) {
		// if (free != -1) {
		// 	moves.pb(free);
		// }
		int next_free = 0;
		for (int i = 1; i <= n; ++i) {
			if (i != free and a[i] < a[next_free]) {
				next_free = i;
			}
		}
		if (!a[next_free]) {
			cout << -1 << endl;
			return 0;
		}
		--a[next_free];
		for (int i = 1; i <= n; ++i) {
			if (i != free and i != next_free) {
				--a[i];
				moves.pb(i);
			}
		}
		moves.pb(next_free);
		free = next_free;
	}
	cout << moves.size() << endl;
	for (auto &i : moves) {
		cout << i << ' ';
	}
}

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

int main() {
  ll n;
  cin >> n;
  cout << (n + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <vector>
using namespace std;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);

    int n;
    scanf("%d", &n);

    vector<int> colors;
    for (int ai = 0; ai < n; ai++) {
        int num_a;
        scanf("%d", &num_a);
        for (int ni = 0; ni < num_a; ni++) {
            colors.push_back(ai + 1);
        }
    }

    int grid[h][w];
    int ci = 0;

    for (int hi = 0; hi < h; hi++) {
        int w_begin, w_dir;
        if (hi % 2 == 0) {
            w_begin = 0;
            w_dir = 1;
        } else {
            w_begin = w - 1;
            w_dir = -1;
        }
        for (int wi = w_begin; 0 <= wi && wi < w; wi += w_dir) {
            grid[hi][wi] = colors[ci];
            ci++;
        }
    }

    for (int hi = 0; hi < h; hi++) {
        for (int wi = 0; wi < w; wi++) {
            if (wi) { printf(" "); }
            printf("%d", grid[hi][wi]);
        }
        printf("\n");
    }

    return 0;
}

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

bool isEvenNumber(string s)
{
	return !(s.length() % 2);
}

bool hasSameTopAndBottom(string s)
{
	return s[0] == s[s.length() - 1];
}

int main()
{
	string s;
	cin >> s;
	if(isEvenNumber(s) ^ hasSameTopAndBottom(s)) cout << "Second" << endl;
	else cout << "First" << endl;

	return 0;
}

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

int N, M, Q, L, R;
int A[501][501], C[501][501];

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

  for(int i=1; i<=M; i++) {
    cin >> L >> R;
    A[L][R]++;
  }
  
  for(int i=1; i<=N; i++) {
    for(int j=1; j<=N; j++){
      C[i][j] = C[i][j-1] + A[i][j];
    } 
  }
  
  for(int k=1; k<=Q; k++) {
    int p, q, sum;
    cin >> p >> q;
    sum =0;
    for(int i=p; i<=q; i++){
      sum += C[i][q] - C[i][p-1];
    }
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2944
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int A[100000];
int main(){
  char s[11];
  cin >> s;
  bool ans = strncmp(s, "YAKI", 4) == 0;
  puts(ans ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC128().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  
  class ABC128
    {
        public void SolveA(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var p = cin.ReadInt;
            WriteLine(((a*3)+p)/2);
            ReadLine();
        }
    }
}


Measured memory_bytes: 11220
object Main{
  def ok(s:String,t:String) : Boolean = {
    if(s.length != t.length){
      return false
    }else{
      for(i <- 0 to s.length-1){
        if(s(i)!=t(i) && s(i)!='?') return false
      }
      true
    }
  }
  def gen(s:String,t:String,idx:Int) : String = {
    var sc = s.toCharArray
    for(i <- 0 to t.length-1) sc(idx+i) = t(i)
    for(i <- 0 to sc.length-1) if(sc(i) == '?') sc(i) = 'a'
    sc.mkString
  }


  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val s,t = sc.nextLine
    val n = s.length
    val m = t.length
    val end = "z" * 100

    val ar = for(i <- 0 to n-1) yield {
      val sub = s.slice(i,i+m)
      val isok = ok(sub,t)
      if(isok) gen(s,t,i)
      else end
    }
    val ans = ar.filter(x=>x.length>0).min
    if(ans.length <= 50) println(ans)
    else println("UNRESTORABLE")
  }
}


Measured memory_bytes: 26048
# -*- coding: utf-8 -*-
import numpy
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
answer = []
for i in range(n):
    answer.append(uf.size(i))
print(max(answer))

Measured memory_bytes: 40424
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
void get_combination(vs& comb, string s, int n){
    vector<char> vc;
    for (char c : s) vc.push_back(c);

    sort(vc.begin(), vc.end());
    set<string> st;
    do {
        string t = "";
        REP(i, n) t += vc[i];
        sort(t.begin(), t.end());
        st.insert(t);
    } while (next_permutation(vc.begin(), vc.end()));

    for (string s : st) comb.push_back(s);
}
#endif


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

    int N; cin >> N;
    vs S(N); REP(i, N) cin >> S[i];

    string ptn = "MARCH";
    map<char, ll> mp;
    for(string s : S) {
        if (ptn.find(s[0]) != string::npos) mp[s[0]]++;
    }
    
    ll ans = 0;
    if (mp.size() >= 3) {
        vs comb;
        get_combination(comb, ptn, 3);

        for(string s : comb) {
            ans += mp[s[0]] * mp[s[1]] * mp[s[2]];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
// :) 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
int d[MAXN];
ll p[MAXN];
ll power(int k) {
	p[0] = 1;
	for (int i = 1; i < MAXN; i++)
		p[i] = p[i-1] * 2 % MOD;
	return p[k];
}
int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		d[x]++;
	}
	if (n % 2 == 1) {
		bool ok = true;
		for (int k = n-1; k > 0; k-=2)
			if (d[k] != 2)
				ok = false;
		if (d[0] != 1)
			ok = false;
		if (!ok) {
			cout << "0\n";
			return 0;
		}
		cout << power(n/2) << "\n";
		return 0;
	} else {
		bool ok = true;
		for (int k = n-1; k >= 1; k-=2)
			if (d[k] != 2)
				ok = false;
		if (!ok) {
			cout << "0\n";
			return 0;
		}
		cout << power(n/2) << "\n";
		return 0;
	}

}

Measured memory_bytes: 1408