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

void solve(long long N, long long M){
  long long ans = 0;
	if (N * 2 <= M) {
    ans += N;
    M -= N * 2;
    N = 0;
    ans += M / 4;
    cout << ans << endl;
  } else {
    ans = M / 2;
    cout << ans << endl;
  }
}

int main(){	
	long long N;
	long long M;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = True

p = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]]

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == True:
        print('Yes')
        exit()

for i in range(3):
    if a[0][i] == a[1][i] == a[2][i] == True:
        print('Yes')
        exit()

if a[0][0] == a[1][1] == a[2][2] == True:
    print('Yes')
    exit()
elif a[0][2] == a[1][1] == a[2][0] == True:
    print('Yes')
    exit()
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = ll>T in(){
    T x;
    cin >> x;
    return (x);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    cout << (in()+1)/2 << "\n";
}

Measured memory_bytes: 256
S=list(input())

def judge(S):
    if S[0]==S[1] and S[2]==S[3] and S[0]==S[3]:
        return 'No'        
    elif S[0]==S[1] and S[2]==S[3]:
        return 'Yes'
    elif S[0]==S[2] and S[1]==S[3]:
        return 'Yes'
    elif S[0]==S[3] and S[1]==S[2]:
        return 'Yes'
    else:
        return 'No'

print(judge(S))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

const string YES = "Yes";
const string NO = "No";

int main(){
    string s, t;
    cin >> s >> t;
    REP(i, s.size()){
        if(s.at(i) != t.at(i)){
            cout << NO << endl;
            return 0;
        }
    }
    cout << YES << endl;
    return 0;
}


Measured memory_bytes: 3600
X, K, D = map(int, input().split())
if abs(X) > K*D:
    print(abs(X)-K*D)
else:
    a = abs(X)%D
    b = abs(X)//D
    if (K-b) % 2 == 0:
        print(a)
    else:
        print(abs(a-D))


Measured memory_bytes: 61724
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)

using namespace std;

#define MAX_N 1401

Int H, W;
bool S[MAX_N][MAX_N];
Int A[MAX_N][MAX_N];

void input() {
  cin >> H >> W;
  loop(h,0,H) {
    loop(w,0,W) {
      cin >> S[h][w];
      A[h][w] = -1;
    }
  }
}

void solve() {
  Int max_ = 0;
  loop(h,0,H) {
    A[h][0] = (S[h][0]) ? 0 : 1;
    max_ |= A[h][0];
  }
  loop(w,0,W) {
    A[0][w] = (S[0][w]) ? 0 : 1;
    max_ |= A[0][w];
  }
  
  loop(h,1,H) {
    loop(w,1,W) {
      if (S[h][w]) {
        A[h][w] = 0;
        continue;
      }
      
      A[h][w] = min(A[h-1][w], min(A[h][w-1], A[h-1][w-1])) + 1;
      if (A[h][w] > max_) max_ = A[h][w];
    }
  }
  
  cout << max_*max_ << endl;
}

void dump() {
  loop(h,0,H) {
    loop(w,0,W) {
      cout << A[h][w] << " ";
    }
    cout << endl;
  }
}

int main(void) {
  input();
  solve();
  // dump();
}


Measured memory_bytes: 12636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r; cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

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

using namespace std;

int D[31][31] = {{0}};
int T[3][31] = {{0}};

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

  int N, C;
  cin >> N >> C;
  for (int i = 1; i <= C; ++i) {
    for (int j = 1; j <= C; ++j) {
      cin >> D[i][j];
    }
  }
  int color;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      cin >> color;
      T[(i + j) % 3][color]++;
    }
  }

  int ans = INT_MAX;
  for (int i = 1; i <= C; ++i) {
    for (int j = 1; j <= C; ++j) {
      if (i == j) continue;
      for (int k = 1; k <= C; ++k) {
        if (j == k || i == k) continue;

        int w = 0;
        for (int l = 1; l <= C; ++l) w += D[l][i] * T[0][l];
        for (int l = 1; l <= C; ++l) w += D[l][j] * T[1][l];
        for (int l = 1; l <= C; ++l) w += D[l][k] * T[2][l];
        ans = min(ans, w);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>
#include<iomanip>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod%i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

struct S{
    int A;
    int B;
    double v;

    S(int A, int B){
        this->A = A;
        this->B = B;
    }

    bool operator<(const S &l) const{
        return static_cast<double>(B)/A < static_cast<double>(l.B)/l.A;
    };
};

struct P{
    int x;
    int y;

    P(int x, int y){
        this->x = x;
        this->y = y;
    }
};

int main() {
    int K,X;

    cin >> K >> X;

    cout << (K*500>=X?"Yes":"No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct UnionFind {
    UnionFind() {}
    UnionFind(int n) {
        resize(n);
    }
    
    void resize(int n) {
        par.resize(n, -1);
    }
    
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    
    bool merge(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }
    
    bool is_same(int x, int y) {
        return (root(x) == root(y));
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
private:
    vector<int> par;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    set<int> used;
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.merge(x, y);
        used.insert(x);
        used.insert(y);
    }
    vector<int> group;
    for (auto u : used) {
        bool f = false;
        rep(ii, sz(group)) {
            if (uf.root(group[ii]) == uf.root(u)) {
                f = true;
                break;
            }
        }
        if (!f) group.push_back(u);
    }
    cout << (sz(group) + (n - sz(used))) << endl;
    return 0;
}


Measured memory_bytes: 6528
s = gets.chomp
len = s.length
ans = Array.new(len,0)
odd = 0
even = 0
pre = -1
for i in 0..len-1
  if s[i] == "R"
    odd,even = even,odd
    odd += 1
  else
    if odd != 0
      pre = i
      odd,even = even,odd
      odd += 1
      ans[i-1] += even
      ans[i] += odd
      odd = 0
      even = 0
    else
      ans[pre-1] += 1 if (i-pre)%2 == 1
      ans[pre] += 1 if (i-pre)%2 == 0
    end
  end
end
ans.each do |i|
  print "#{i} "
end

Measured memory_bytes: 2940
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  [a, b] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    q = b `div` k :: Int
  putStrLn $ if a <= k * q then "OK" else "NG"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 3780
// Abhishek Chaturvedi- abhishekchaturvedi10oct //

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define inf             2e18+1
#define ninf            -2e18+1
#define mod             1000000007
#define eps             1e-9
#define ff              first
#define ss              second
#define int             long long
#define ld              long double
#define str             string 
#define pb              emplace_back
#define mp              make_pair
#define vi              vector<int>
#define si              set<int>
#define pii             pair<int,int>
#define psi             pair<str,int>
#define mii             map<int,int>
#define msi             map<str,int>
#define maxheap         priority_queue<int>
#define minheap         priority_queue<int,vi,greater<int>>
#define sz(x)           (int)x.size()
#define all(x)          x.begin(),x.end()
#define allr(x)         x.rbegin(),x.rend()
#define gcd(x,y)        __gcd(x, y)
#define arrsz(x)        sizeof(x)/sizeof(x[0])
#define sp(x,y)         fixed<<setprecision(y)<<x
#define tc(x)           int x; cin>>x; while(x--)
#define loopf(i,x,y)    for(int i=x;i<=y;i++)
#define loopb(i,x,y)    for(int i=x;i>=y;i--)
#define in(x,n)         int x[n];loopf(i,0,n-1) cin>>x[i];
#define out(x)          for(auto i:x) cout<<i<<" "; cout<<endl;
#define init(x,n,y)     int x[n];loopf(i,0,n-1) x[i]=y;

void fastIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int dp[105][100005];

void solve(){  
}

int32_t main(){
    
    fastIO();

    //tc(t){
        int n,w; cin>>n>>w; int weight[n],val[n]; loopf(i,0,n-1){cin>>weight[i]; cin>>val[i];}
        loopf(i,0,n){
            loopf(j,0,w){
                if(i==0 || j==0) dp[i][j]=0;
                else{
                    dp[i][j]=dp[i-1][j];
                    if(j>=weight[i-1]){
                        dp[i][j]=max(dp[i][j],dp[i-1][j-weight[i-1]]+val[i-1]);
                    }
                }
            }
        }
        cout<<dp[n][w];
    //}

    return 0;
}

Measured memory_bytes: 80128
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[100005];

int n;

bool check(int ps) {
	ll sum = arr[ps];

	for (int i = 1; i <= n; ++i) {
		if (i == ps) {
			continue;
		}

		if (arr[i] > sum * 2) {
			return 0;
		}

		sum += arr[i];
	}

	return 1;
}

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    sort(arr + 1, arr + n + 1);
    int l = 1, r = n, ans = n + 1;

    while (l <= r) {
    	int mid = (l + r) >> 1;

    	if (check(mid)) {
    		r = mid - 1;
    		ans = mid;
    	}
    	else {
    		l = mid + 1;
    	}
    }

    printf("%d\n", n - ans + 1);
}

int main() {    
    int tt = 1;

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

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int X, N;
  cin >> X;
  cin >> N;
  
  vector <int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
  }
  
  int cand = X;
  int abs = 0;
  int sign = 1;
  while (true) {
    bool b = false;
    cand = cand + abs * sign;
    abs++;
    sign = -sign;
    
    for (int i = 0; i < N; ++i) {
      if (p[i] == cand) {
        b = true;
        break;
      }
    }
    if (b) continue;
    break;
  }
  
  cout << cand << endl;
  return 0;
}


Measured memory_bytes: 3216
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
x0=sum(A)//2
j=1
for _ in range(N//2):
    x0-=A[j%N]
    j+=2
ans=[]
ans.append(2*x0)
for i in range(N-1):
    ans.append(2*(A[i]-ans[-1]//2))
lprint(ans,' ')

Measured memory_bytes: 96972
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
string a[30000];
signed main(){
	string s;
	int k;
	cin>>s>>k;
	int n=s.size(),memo=0;
	rep(i,n){
		for(int j=1;j<=k;j++){
			if(i+j>n)continue;
			a[memo]=s.substr(i,j);
			memo++;
		}
	}
	sort(a,a+memo);
	int p=0;
	rep(i,memo){
		if(a[i]==a[i+1])continue;
		p++;
		if(p==k){
			cout<<a[i]<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1664
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t X;
	std::cin >> X;

	int64_t quotient = X / 100;

	for (int64_t i = 100 * quotient; i <= 105 * quotient; i++) {
		if(i == X) {
			std::cout << "1" << std::endl;
			return;
		}
	} 
	std::cout << "0" << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 256
public class Main {
  public static void main(String[] args) {
    String N = new java.util.Scanner(System.in).nextLine();
    if (N.charAt(0) == '7' || N.charAt(1) == '7' || N.charAt(2) == '7') {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35600
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

is = {}
count = 0

A.each.with_index do |a, index|
  test = index - a
  if is[test]
    count += is[test].length
  end
  is.push(a+index, index)
end

puts count


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

#define ll long long
#define MOD 1000000007

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

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

Measured memory_bytes: 13024
import numpy
import math
a,b,h,m=(input().split())
a=int(a)
b=int(b)
h=int(h)
m=int(m)

jik=float(30*h+0.5*m)
jik=float(-jik+90)
hunk=float(6*m)
hunk=float(-hunk+90)
jizax=float(a*math.cos(math.radians(jik)))
jizay=float(a*math.sin(math.radians(jik)))
hunzax=float(b*math.cos(math.radians(hunk)))
hunzay=float(b*math.sin(math.radians(hunk)))
x=numpy.array([jizax,jizay])
y=numpy.array([hunzax,hunzay])
u=y-x
print(numpy.linalg.norm(u))

    

Measured memory_bytes: 27276
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (k <= a) {
        cout << a-k << " " << b << "\n";
    } else if (k <= a + b) {
        cout << 0 << " " << b - (k - a) << "\n";
    } else {
        cout << 0 << " " << 0 << "\n";
    }
    return 0;
}

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

using namespace std;

void qfind(int n,int y)
{
    int i,j;
    for(i=0;i<=n;i++){
        for(j=0;i+j<=n;j++){
            if(i*10000+j*5000+(n-i-j)*1000==y){
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return;
            }
        }

    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
    return;
}
int main()
{
    int n,y;
    cin>>n>>y;
    qfind(n,y);
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>


// 最大公約数を求める
long long int GCD (long long int a, long long int b) {
    long long int tmp, x, r;
    if (a<b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while (r!=0) {
      a = b;
      b = r;
      r = a % b;
    }
    return b;
}

int main() {
  long long int A, B, C, D, LCM;
  long long int result;
  scanf ("%lld %lld %lld %lld", &A, &B, &C, &D);
  
  
  LCM=C*D/GCD(C, D);
  
  result = B-A+1;
  
  result -= B / C;
  result -= B / D;
  result += B / LCM;
  result += (A-1) / C;
  result += (A-1) / D;
  result -= (A-1) / LCM;
  
  printf("%lld", result);
  return 0;
}




Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

#define INF 0xc0c0c0c0
#define NINF 0x3f3f3f3f

#define FOR(i, a, b) for((i)=a; i<b; ++(i))
#define EFOR(i, a, b) for((i)=a; i>b; --(i))

#define MLC(n, type) (type*)malloc(n*sizeof(type))
#define CLC(n, type) (type*)calloc(n, sizeof(type))

#define MAXH 100+2
#define MAXW 8+2
#define MOD(a) ((a)%1000000007)

void calcFibonacci(int *nums, int numsSize, int s, int n1, int n2) {
	int i = 0,tmp;
	int startPoint = s;
	int t1 = n1;
	int t2 = n2;

	nums[startPoint++] = t1;
	nums[startPoint++] = t2;

	FOR(i, startPoint, numsSize) {
		nums[i] = t1+t2;
		tmp = t2;
		t2 = nums[i];
		t1 = tmp;
	}

	// FOR(i, 0, numsSize) {
	// 	printf("%d %d\n", i, nums[i]);
	// }
	// printf("\n");
}

void _solver(long long int *dp, int h, int w, int k) {
	int i,r = 0;
	long long int n1,n2,n3;
	int a[MAXW] = {0};
	calcFibonacci(a, w+1, 0, 1, 1);

	FOR(i, 1, w+1) {
		dp[i] *= a[w-i];
	}

	// FOR(i, 0, w+1) {
	// 	printf("%lld ", dp[i]);
	// }
	// printf("\n");

	FOR(r, 1, h) {
		n1 = dp[1];
		n2 = dp[2];
		n3 = dp[3];

		dp[1] = MOD(dp[1]*a[w-1] + dp[2]*a[w-2]);

		FOR(i, 2, w) {
			dp[i] = MOD(n1*a[w-i]*a[i-2] + n2*a[w-i]*a[i-1] + n3*a[w-i-1]*a[i-1]);
			n1 = n2;
			n2 = n3;
			n3 = dp[i+2];
		}

		dp[i] = MOD(n1*a[i-2] + n2*a[i-1]);

		// FOR(i, 0, w+1) {
		// 	printf("%lld ", dp[i]);
		// }
		// printf("\n");
	}

	printf("%lld\n", dp[k]);
	return;
}

void solver(int h, int w, int k) {
	long long int dp[MAXW] = {0};

	if (k-1 > h) {
		printf("0\n");
		return;
	}
	else if (w == 1) {
		printf("1\n");
		return;
	}

	dp[1] = 1;
	dp[2] = 1;

	_solver(dp, h, w, k);
}

int main() {
	int h,w,k;

	scanf("%d %d %d", &h, &w, &k);
	solver(h, w, k);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int n,k,s;
signed main(){
    cin>>n>>k;
    rep(i,max(n,k)){
        cout<<min(n,k);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
struct wolf{
	vector<pair<int,int> >A;
	vector<pair<int,long long> >B;
	int left;
	int right;
	wolf(){
		left=right=-1;
	}
};
wolf pool[3500000];
int sz=0;
void add(int a,int b,int c,int d,int e,int f){
	if(d<a||b<c)return ;
	if(c<=a&&b<=d){
		pool[e].A.push_back(make_pair(f,1));
		return;
	}
	//printf("%d: %d %d\n",e,a,b);
	int num=min(b,d)-max(a,c)+1;
	pool[e].B.push_back(make_pair(f,num));
	int to;
	if(min((a+b)/2,d)>=max(a,c)){
		to=pool[e].left;
		if(!~to){
			to=pool[e].left=sz++;
		}
		add(a,(a+b)/2,c,d,to,f);
	}
	if(min(b,d)>=max((a+b)/2+1,c)){
		to=pool[e].right;
		if(!~to){
			to=pool[e].right=sz++;
		}
		add((a+b)/2+1,b,c,d,to,f);
	}
}
long long cnt(int a,int b,int c,int d,int e,int f){
//	printf("%d %d %d %d %d %d\n",a,b,c,d,e,f);
	if(d<a||b<c)return 0LL;
	if(c<=a&&b<=d){
		long long ret=(*(lower_bound(pool[e].B.begin(),pool[e].B.end(),make_pair(f+1,0LL))-1)).second;
		int num=b-a+1;
		ret+=(long long)((*(lower_bound(pool[e].A.begin(),pool[e].A.end(),make_pair(f+1,0))-1)).second)*num;
		return ret;
	}
	int num=min(b,d)-max(a,c)+1;
	long long ret=(long long)((*(lower_bound(pool[e].A.begin(),pool[e].A.end(),make_pair(f+1,0))-1)).second)*num;
	int to=pool[e].left;
	if(~to){
		ret+=cnt(a,(a+b)/2,c,d,to,f);
	}
	to=pool[e].right;
	if(~to){
		ret+=cnt((a+b)/2+1,b,c,d,to,f);
	}
	return ret;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	sz++;
	for(int i=0;i<b;i++){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		add(0,(1<<30)-1,p,q,0,r);
	}
	for(int i=0;i<sz;i++){
	//	printf("%d: %d %d\n",i,pool[i].A.size(),pool[i].B.size());
		pool[i].A.push_back(make_pair(0,0));
		pool[i].B.push_back(make_pair(0,0));
		
		std::sort(pool[i].A.begin(),pool[i].A.end());
		long long now=0;
		for(int j=0;j<pool[i].A.size();j++){
		//	if(j)printf("%d: %d %d\n",i,pool[i].A[j].first,pool[i].A[j].second);
			now+=pool[i].A[j].second;
			pool[i].A[j].second=now;
		}
		std::sort(pool[i].B.begin(),pool[i].B.end());
		now=0;
		for(int j=0;j<pool[i].B.size();j++){
	//		if(j)printf("%d: %d %d\n",i,pool[i].B[j].first,pool[i].B[j].second);
			now+=pool[i].B[j].second;
			pool[i].B[j].second=now;
		}
	}
	for(int i=0;i<c;i++){
		int p,q;
		long long r;
		scanf("%d%d%lld",&p,&q,&r);
		p--;q--;
		int left=0;
		int right=1000000007;
		while(left+1<right){
			int M=(left+right)/2;
			long long val=cnt(0,(1<<30)-1,p,q,0,M);
		//	printf("%lld\n",val);
			if(val>=r)right=M;
			else left=M;
		}
		printf("%d\n",right);
	}
}

Measured memory_bytes: 521568
n=int(input())
a=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
    t=0
    for c,s,f in a[i:]:
        k=max(0,(t-s+f-1)//f)
        t=s+f*k+c
    print(t)

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
ll sum[maxn],ans,wdc;
int num[maxn],a[maxn];
int i,j,k,l,t,n,m,x,y;
void change(int l,int r,int v){
    sum[l]+=(ll)v;
    sum[r+1]-=(ll)v;
}
void modify(int l,int r,int v){
    num[l]+=v;
    num[r+1]-=v;
}
int main(){
    scanf("%d%d",&n,&m);
    fo(i,1,n) scanf("%d",&a[i]);
    fo(i,1,n-1){
        x=a[i];y=a[i+1];
        if (x==y) continue;
        if (x<y){
            change(1,x,y-x);
            change(y+1,m,y-x);
            change(x+1,y,y+1);
            modify(x+1,y,-1);
        }
        else{
            change(y+1,x,y+m-x);
            change(x+1,m,y+m+1);
            modify(x+1,m,-1);
            change(1,y,y+1);
            modify(1,y,-1);
        }
    }
    ans=100000000000000;
    fo(i,1,m){
        sum[i]+=sum[i-1];
        num[i]+=num[i-1];
        wdc=sum[i]+(ll)num[i]*i;
        ans=min(ans,wdc);
    }
    printf("%lld\n",ans);
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n; cout << fib(n) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int x,y,r,tmp;

  scanf("%d%d",&x,&y);
  if(x<1 || y<1 || x>1000000000 || y>1000000000)exit(8);
  if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }

  r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }

  printf("%d\n",y);
  return 0;
}



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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define FORR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 1;

int dp[MAX] = {};

signed main() {
	int n; cin >> n;
	vector<int> a( n );
	REP( i, n ) cin >> a[i];

	fill( dp, dp + MAX, INF );
	dp[0] = 0;
	dp[1] = abs( a[1] - a[0] );
	FOR( i, 2, n ) {
		dp[i] = min( abs( a[i] - a[i - 1] ) + dp[i - 1], abs( a[i] - a[i - 2] ) + dp[i - 2] );		
	}
	
	cout << dp[n - 1] << endl;
	
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n: i64;
    let a: i64;
    let b: i64;
    let xs: Vec<i64>;

    input! {
        n: i64,
        a: i64,
        b: i64,
        xs: [i64; n as usize],
    };

    let ans = xs
        .windows(2)
        .into_iter()
        .map(|pair| pair[1] - pair[0])
        .map(|dist| dist * a)
        .map(|dist| if b < dist { b } else { dist })
        .sum::<i64>();

    println!("{}", ans);
}


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

int main()
{
	cin.sync_with_stdio(false);
	char a, b, c;
	int i = 2;
	int flag = 0;
	cin >> a;
	cin >> b;
	if (a == b) {
		cout << 1 << ' ' << 2 << endl;
		return 0;
	}
	while (cin >> c) {
		if (b == c) {
			flag = 1;
			break;
		}
		else if (a == c) {
			flag = 2;
			break;
		}
		a = b;
		b = c;
		i++;
	}
	if (flag == 1) {
		cout << i << ' ' << (i + 1) << endl;
	}
	else if (flag == 2) {
		cout << (i - 1) << ' ' << (i + 1) << endl;
	}
	else {
		cout << -1 << ' ' << -1 << endl;
	}
	return 0;
}


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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int mx = max({ a, b, c });
	int mn = min({ a, b, c });
	int rr = mx;
	int sum = 0, temp = 0;

	while (k--) {
		temp = mx * 2;
		mx = 2 * mx;
	}	
	sum = a + b + c - rr + temp;
	cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		for(;;){
			int h = scan.nextInt();
			int w = scan.nextInt();

			if(h == 0 && w == 0)
				break;

			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++)
					System.out.print((i+j) % 2 ==  0 ? '#' : '.');
				System.out.println();
			}
			System.out.println();
		}
	}
}



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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int ans = 0;
	vector<int> H;
	
	cin>>N>>K;
	
	H.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>H[i];
	}
	
	sort(H.begin(), H.end(), greater<int>());
	
	for(int i = K; i < N; i++){
		ans += H[i];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, X;
int m[110];

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

    std::cin >> N >> X;

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

    int total = std::accumulate(m, m + N, 0),
        mn = *std::min_element(m, m + N);
    int n = N + (X - total) / mn;

    std::cout << n << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef pair<int, int> pa;
typedef vector<pair<int,int> > vepa;
typedef map<int, int> mp;
const ll N=1e6+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
ll cnt[N]={};
bool f;
int main()
{
    int n,count(0);
    cin>>n;
    rep(i,n&&cin>>arr[i]);
    for(int i=0;i<n;)
    {
        if(arr[i]!=0)
            count++;
        else
        {
            i++;
            continue;
        }
        for(int j=i;j<n;j++)
        {
            if(arr[j]<=0)
                break;
            else
                arr[j]--;
        }
    }
    cout<<count;



go;
}


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

class mint {
  int value;
  static vector<int> _fact;

public:
  static const int MOD = 998244353;
  mint(long long x)
      : value(x % MOD) {}
  mint operator+(mint y) const {
    return mint(value + y.value);
  }
  mint &operator+=(mint a) {
    return *this = *this + a;
  }
  mint operator*(mint y) const {
    return mint(long(value) * y.value);
  }
  mint &operator*=(mint a) {
    return *this = *this * a;
  }
  mint operator-() const {
    return *this * mint(-1);
  }
  mint operator-(mint y) const {
    return *this + (-y);
  }
  mint &operator-=(mint a) {
    return *this = *this - a;
  }
  operator int() const {
    return value;
  }
  static mint pow(mint a, int n) {
    if (n <= 0) {
      return 1;
    }
    else if (n == 1) {
      return a;
    }
    mint half = mint::pow(a, n / 2);
    return n % 2 ? half * half * a : half * half;
  }
  static mint fact(int n) {
    if (size_t(n) < _fact.size()) {
      return _fact[n];
    }
    mint ans = fact(n - 1) * mint(n);
    _fact.push_back(ans);
    return ans;
  }
  mint inv() {
    return pow(value, MOD - 2);
  }
  static mint comb(int n, int k) {
    return fact(n) * fact(k).inv() * fact(n - k).inv();
  }
};
vector<int> mint::_fact = {1};

int main() {
  int N, M, K;
  cin >> N >> M >> K;

  const mint m = M;
  mint ans = 0;
  for (int i = 0; i <= K; i++) {
    ans += m * mint::comb(N - 1, i) * mint::pow(M - 1, N - 1 - i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 10576
open System
let readInt () = stdin.ReadLine() |> int
let readIntArray () = stdin.ReadLine().Split(' ') |> Array.map int

let S = stdin.ReadLine()
let N = S.Length
let dp : bool [] = Array.zeroCreate (N + 1)

let candi = [ "dream"; "dreamer"; "erase"; "eraser" ]

dp.[0] <- true
for i in [0..N-1] do
    if dp.[i] then
       candi |> List.iter (fun str -> if (i + str.Length <= N && S.Substring(i, str.Length) = str ) then (dp.[i + str. Length] <- true))

if dp.[N] then "YES" else "NO"
|> printfn "%s"


Measured memory_bytes: 21848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int now_x = 0, now_y = 0, now_t = 0;
    bool ok = true;
    rep(i,n) {
        int t, x, y; cin >> t >> x >> y;
        int dis = abs(now_x-x) + abs(now_y-y);
        int dif_t = t - now_t;
        if (dis > dif_t) ok = false;
        else if (abs(dis-dif_t) % 2 != 0) ok = false;
        swap(now_x,x); swap(now_y,y); swap(now_t,t);
    }
    printf(ok?"Yes\n":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int A[10][2] = {0};
int main()
{
  cin>>n;
  for(int i=0 ; i<n ; i++)
  {
    cin>>A[i][0]>>A[i][1];
  }
  double sum = 0;
  for(int i=0 ; i<n ; i++)
  {
    for(int j=0 ; j<n ; j++)
    {
      sum = sum + double(sqrt((A[i][0] - A[j][0])*(A[i][0] - A[j][0]) + (A[i][1] - A[j][1])*(A[i][1] - A[j][1])));
    }
  }
  int f = 1;
  int m = n-1;
  while(n)
  {
    f = f*n;
    n--;
  }
  int g = 1;
  while(m)
  {
    g = g*m;
    m--;
  }
  sum = double(g*sum);
  sum = double(sum / f);
  cout<<fixed<<setprecision(10)<<sum;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
	unsigned short *A, *B;
	
	int C[VMAX+1];
	int n, i, j;
	scanf("%d",&n);
	
	A = malloc(sizeof(short)*n+1);
	B = malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++) C[i] = 0;
	
	for(i=0;i<n;i++) {
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
	
	for(j=1;j<=n;j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n;i++) {
		if(i>1) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 9644
#include <bits/stdc++.h>
    using namespace std;
    int main () {
      int n;
      cin >> n;
      string  s;
      cin >> s;
      if (n % 2 == 1 ) {
        cout << "No";}
      else {
        string a = "";
        for (int i = 0; i < n / 2; i++) {
          a += s[i];} 
        string b = "";
        for (int i = n /2 ; i < n; i++) {
          b += s[i]; }
          if (a == b ) {
            cout << "Yes";
        }
        else {
          cout << "No" ; } } }

Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/26.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    ll n;cin>>n;
    vector<ll>x(n);
    vector<ll>y(n);
    for(int i=0;i<n;i++)
    {cin>>x[i];
        y[i]=x[i];}
    sort(all(x));
    for(int i=0;i<n;i++){
        if(y[i]<=x[n/2-1])
         cout<<x[n/2]<<endl;
        else
            cout<<x[n/2-1]<<endl;
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 5376
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int MAX = 1e5 + 10;
int n, m, mx, dis[MAX];
bool mark[MAX];
vector <int> adj[MAX];

int dfs (int v){
	mark[v] = true;
	for (auto u : adj[v]){
		if (!mark[u]){
			dfs(u);
		}
		dis[v] = max (dis[v], dis[u] + 1);
	}
	mx = max (dis[v], mx);
}

main (){
	cin >> n >> m;
	for (int i = 0 ; i < m ; i++){
		int u, v;
		cin >> u >> v;
		adj[--u].pb(--v);
	}
	for (int i = 0 ; i < n ; i++)
		if (!mark[i])
			dfs(i);
	cout << mx;
}

Measured memory_bytes: 8576
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define _v1 CONCAT(qyw1, __LINE__) // unique name in same line (otherwise use __COUNTER__)
#define _v2 CONCAT(qyw2, __LINE__)
#define forbits(i, m) for (int _v1 = m, i = __builtin_ctz(_v1); _v1 != 0; _v1 ^= _v1 & -_v1, i = __builtin_ctz(_v1))
#define forsubm(s, m) for (int s = m; s >= 0; s = !s ? -1 : m & (s - 1))
int __nextXZW(int v){int t=v|(v-1);int w=(t+1)|(((~t&-~t)-1)>>(__builtin_ctz(v)+1));return w;}
#define ksets(i, n, k) for (int i = (1u << k) - 1, max = i << (n - k); i <= max; i = __nextXZW(i))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9+7;
const ll N = 5e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <atcoder/mincostflow> 
using namespace atcoder;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, k; cin >> n >> k;
  vector<vector<int>> a(n, vector<int>(n));
  rep (i, n) rep(j, n) cin >> a[i][j];
  mcf_graph<int, ll> mcf_G(2*n+2);
  
  rep (i, n) {
    mcf_G.add_edge(2*n, i, k, 0);
    mcf_G.add_edge(i+n, 2*n+1, k, 0);
  }
  mcf_G.add_edge(2*n, 2*n+1, n*k, 1000000000);

  rep (i, n) {
    rep (j, n) {
      mcf_G.add_edge(i, j+n, 1, 1000000000-a[i][j]);
    }
  }
  auto [flow, cost] = mcf_G.flow(2*n, 2*n+1, n*k);
  cout << -(cost - 1000000000LL*flow) << '\n';

  vector<string> ans(n, string(n, '.'));
  for (auto edge : mcf_G.edges()) {
    if (edge.from == 2*n || edge.to == 2*n+1) continue;
    if (edge.flow == 0) continue;
    ans[edge.from][edge.to-n] = 'X';
  }

  rep (i, n) cout << ans[i] << '\n';

  return 0;
}

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

int a[100050];

int main()
{
    int n;
    cin >> n;
    int c = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if(a[i] % 4 == 0) c++;
    }
    
    if(c >= n / 2)
    {
        cout << "Yes" << endl;
        return 0;
    }
    int ca = n / 2 - c;
    c = 0;
    for(int i = 0; i < n; ++i)
    {
        if(a[i] % 4 != 0)
        {
            if(a[i] % 2 == 0)
                c++;
        }
    }
    if(c / 2 >= ca)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}





Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void){
  int N,T,A,H[1000],i,cite;
  double min = 1000;
  scanf("%d %d %d",&N,&T,&A);
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
    if(min > fabs((double)T - H[i]*0.006 - (double)A)){
      min = fabs((double)T - H[i]*0.006 - (double)A);
      cite = i + 1;
    }
  }
  printf("%d",cite);
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,d,b[N],depth[N],deg[N],fa[N];
ll ans;
vector<int> e[N];
void chkmax(int &x,int y){if (x<y) x=y;}
void work(int x,int fath){
	fa[x]=fath;deg[x]=0;
	for (auto y : e[x])
	if (y!=fath){
		deg[x]++;depth[y]=depth[x]+1;
		work(y,x);
	}
}
void calc(int x,int y){
	depth[x]=depth[y]=0;
	work(x,y);work(y,x);
	for (int i=0;i<=d;i++) b[i]=0;
	for (int i=1;i<=n;i++) chkmax(b[depth[i]],deg[i]);
	ll t=(x==y) ? 1 : 2;
	for (int i=0;i<d;i++) t*=b[i];
	ans=min(ans,t);
}
int main(){
	n=read();
	ans=0x7fffffffffffffffll;
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int x=1;depth[x]=0;
	work(x,0);
	for (int i=1;i<=n;i++) if (depth[i]>depth[x]) x=i;
	depth[x]=0;
	work(x,0);
	for (int i=1;i<=n;i++) if (depth[i]>depth[x]) x=i;
	d=depth[x]/2;
	for (int i=1;i<=d;i++) x=fa[x];
	if (depth[x]!=d) calc(x,fa[x]);
	else{
		calc(x,x);
		for (auto y : e[x]) calc(x,y);
	}
	printf("%d %lld\n",d+1,ans);
	return 0;
}

Measured memory_bytes: 6400
#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 n;
    cin >> n;
    deque<ll> b;
    REP(i,1,n+1) {
        ll a;
        cin >> a;
        if(i%2==1) b.push_front(a);
        else b.push_back(a);
    }
    if(n%2==0) {
        REP(i,0,n) {
            cout << b.back() << " ";
            b.pop_back();
        }
    }
    else {
        REP(i,0,n) {
            cout << b.front() << " ";
            b.pop_front();
        }
    }



    return 0;
}

/*



*/

Measured memory_bytes: 5232