akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b,c;

signed main(){
    in(a,b,c);
    int ans=2*min(b,c);
    ans+=b-min(b,c);
    c-=min(b,c);
    ans+=(c<=a+1)?c:a+1;
    out(ans);

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

K = read_a_int()
S = input()
print(S if len(S) <= K else (S[:K] + "..."))


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

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    array<int, 3> a;
    for (int& i : a) cin >> i;
    sort(a.begin(), a.end());
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1164
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  int n, m, x;
  cin >> n >> m >> x;
  int a;
  int l=0, r=0;
  r(i,m){
    cin >> a;
    if(a>x)l++;
    else r++;
  }
  cout << min(l, r) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, h, k;

main(){
	while(scanf("%d%d%d%d", &n, &m, &h, &k), n){
		vi p(n);
		REP(i, n) scanf("%d", &p[i]);
		vector<pii> link;
		REP(i, m){
			int a, b;
			scanf("%d%d", &a, &b);
			link.emplace_back(b-1, a-1);
		}
		sort(ALL(link));
		vi idx(n);
		REP(i, n) idx[i]=i;
		vector<pii> swapped;
		REP(i, m){
			swapped.emplace_back(idx[link[i].second], idx[link[i].second+1]);
			swap(idx[link[i].second], idx[link[i].second+1]);
		}
		vi pts(n);
		ll sum = 0;
		REP(i, n){
			pts[idx[i]] = p[i];
			if(idx[i] < k){
				sum += p[i];
			}
		}
		int dec = 0;
		REP(i, m){
			if((swapped[i].first < k) ^ (swapped[i].second < k)){
				int diff = pts[swapped[i].first] - pts[swapped[i].second];
				if(swapped[i].first < k) dec = max(dec, diff);
				else dec = max(dec, -diff);
			}
		}
		cout << sum - dec << endl;
	}
	return 0;
}

Measured memory_bytes: 3288
/*input
3
100 100
10 10000
1 1000000000
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int i, j, n;
	cin >> n;
	vector<int> a(n), b(n);
	for(i=0; i<n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll ret = 0;
	if(n % 2) {
		ret = b[n/2] - a[n/2] + 1;
	}
	else {
		ret = b[n/2] + b[n/2 - 1] - a[n/2] - a[n/2 - 1] + 1;
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 4752
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> v;

int main(void){
	int n,i,t=1,m;
	ll k,ans=0ll;
	string s;
	cin >> s;
	cin >> k;
	n = s.l_ength();
	for(i=1; i<n; ++i){
		if(s[i-1]==s[i]){
			++t;
		}else{
			v.push_back(t);
			t = 1;
		}
	}
	if(t){
		v.push_back(t);
	}
	m = v.l_ength();
	if(m<2){
		cout << (k*n)/2 << endl;
		return 0;
	}
	if(s[0]==s[n-1]){
		for(i=1; i<m-1; ++i){
			ans += k*(v[i]/2);
		}
		ans += v[0]/2;
		ans += v[m-1]/2;
		ans += (k-1)*((v[0]+v[m-1])/2);
	}else{
		for(i=0; i<m; ++i){
			ans += k*(v[i]/2);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[605];
vector<double> cnt;

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  cnt.resize(n);
  rep(i, m) {
    int s, t; cin >> s >> t;
    s--; t--;
    graph[s].push_back(t);
  }

  for(int i=n-2; i>=0; i--) {
    double sum = 0;
    int c = graph[i].size();
    for(auto& e: graph[i]) {
      sum += cnt[e];
    }
    cnt[i] = sum/c + 1;
  }

  double ans = cnt[0];

  vector<P> vec;
  rep(i, n) {
    double mi = -1;
    int p = -1;
    if (graph[i].size() <= 1) continue;
    for(auto& e: graph[i]) {
      if (cnt[e] > mi) {
        mi = cnt[e];
        p = e;
      }
    }
    vec.emplace_back(i, p);
  }

  for(auto& pair: vec) {
    int p = pair.first;
    int q = pair.second;
    for(int i=n-2; i>=0; i--) {
      double sum = 0;
      int c = graph[i].size();
      for(auto& e: graph[i]) {
        if (i==p && e==q) continue;
        sum += cnt[e];
      }
      if (i==p) c--;
      assert(c>0);
      cnt[i] = sum/c + 1;
    }
    chmin(ans, cnt[0]);
  }

  cout << setprecision(10) << fixed << ans << endl;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    { 
        static void Main(string[] args)
        {
            //string[] s =Console.ReadLine().Split(',');

            //int w = int.Parse(s[0]);
            List<string> stringList = new List<string>();
            int count=1;

            for (int i = 0; ; i++)
            {
                string x = Console.ReadLine();
                if (x == "0")  break;
                stringList.Add(x);
            }

            foreach(string j in stringList){
                Console.WriteLine("Case "+count+": "+j);
                count++;
            }
            //int n =int.Parse(s);
        }
    }
}

Measured memory_bytes: 6516
mo=10^9+7
main=do
 [n,a,b]<-map read.words<$>getLine
 print$flip mod mo$(p 2 n)-1-(f n a)-(f n b)
p a n
 |n==0=1
 |odd n=a*(p a(n-1))`mod`mo
 |even n=p(a*a`mod`mo)(div n 2)
f a b=(foldl(\s t->s*(a-t+1)`mod`mo)1[1..b])*(flip p(mo-2)$foldl1(\s t->s*t`mod`mo)[1..b])`mod`mo

Measured memory_bytes: 43388
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
j = 0
U = []
for i in T:
    if j < K:
        U.append(i)
    else:
        if U[j-K] == "o":
            U.append(i)
        elif T[j-K] == i:
            U.append("o")
        else:
            U.append(i)
    j += 1
print(U.count("r")*P+U.count("s")*R+U.count("p")*S)

Measured memory_bytes: 4792
#include <bits/stdc++.h>
     
    using namespace std;
     
    int main() {
    	int n, a, b;
    	scanf("%d %d %d", &n, &a, &b);
    	if ((b - a) % 2 == 0)
    		puts("Alice");
    	else 
    		puts("Borys");
    	return 0;
    }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int lose = 0;
    for (char c : s) {
        if (c == 'x') {
            if (++lose > 7) {
                cout << "NO" << endl;
                return 0;
            };
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 256
x,y = list(map(int, input().split()))

a = set([2])
b = set([4,6,9,11])
c = set([1,3,5,7,8,10,12])


if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3188
class UnionFind:
    def __init__(self):
        self.data = {}
        self.heights = {}
        self.sizes = {}

    def get_num_trees(self):
        return len(self.heights)

    def get_tree_size(self, a):
        return self.sizes[self.get_root(a)]

    def add_node(self, a):
        self.data[a] = a
        self.heights[a] = 1
        self.sizes[a] = 1

    def get_root(self, a):
        nodes = [a]
        while nodes[-1] not in self.heights:
            nodes.append(self.data[nodes[-1]])
        for x in nodes:
            self.data[x] = nodes[-1]
        return nodes[-1]

    def union(self, a, b):
        root_a = self.get_root(a)
        root_b = self.get_root(b)
        if root_a == root_b:
            return
        if self.heights[root_a] > self.heights[root_b]:
            a, b = b, a
            root_a, root_b = root_b, root_a
        self.data[root_a] = root_b
        self.heights[root_b] = max(self.heights.pop(root_a) + 1, self.heights[root_b])
        self.sizes[root_b] += self.sizes.pop(root_a)

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)


N, M = map(int, input().split())

uf = UnionFind()
for i in range(1, N + 1):
    uf.add_node(i)

for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a, b)

print(uf.get_num_trees() - 1)

Measured memory_bytes: 29704
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

template<typename T>
T gcd(T a, T b){
    if(b > a) swap(a, b);
    T tmp;
    while(b != 0){
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

vector<pair<long long, int>> prime_factorization(long long n){
    vector<pair<long long, int>> ret;
    for(long long i=2; i*i<=n; i++){
        if(n%i == 0) ret.push_back({ i, 0 });
        while(n%i == 0){
            ret.back().second++;
            n /= i;
        }
    }
    if(n != 1) ret.push_back({ n, 1 });
    return ret;
}

int N;
int A[1000000];

bool exist[1000001] ={};

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    random_device seed_gen;
    mt19937 engine(seed_gen());
    shuffle(A, A+N, engine);

    int g = A[0];
    for(int i=1; i<N; i++) g = gcd(g, A[i]);
    if(g != 1){
        cout << "not coprime" << endl;
        return 0;
    }

    rep(i, N){
        auto v = prime_factorization(A[i]);
        rep(j, v.size()){
            if(exist[v[j].first]){
                cout << "setwise coprime" << endl;
                return 0;
            }
            exist[v[j].first] = true;
        }
    }

    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 7560
data class Key(val a: Int, val b: Int, val c: Long) {
    constructor(a: Int, b: Int, c: List<Int>) : this(a, b, c.fold(0L){ acc, i ->  acc or (1L shl (i - 1)) })
}


fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val keys = mutableListOf<Key>()
    for (m in 0 until M) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        val c = readLine()!!.split(" ").map { it.toInt() }
        keys.add(Key(a, b, c))
    }
    val ans = calc(N, M, keys)
    println(ans)
}


fun calc(N: Int, M: Int, keys: List<Key>): Int {
    val maxN = Math.pow(2.0, N.toDouble()).toLong() - 1
    val Ns = mutableMapOf(*(0L..maxN).map { it to Int.MAX_VALUE }.toTypedArray())
    Ns[0L] = 0
    for (n in Ns.keys){
        for (key in keys){
            if (Ns[n] == Int.MAX_VALUE){
                continue
            }
            val nextKey = n or key.c
            Ns[nextKey] = Math.min(Ns[nextKey]!!, Ns[n]!!.plus(key.a))
        }
    }
    return if(Ns[maxN] == Int.MAX_VALUE) -1 else Ns[maxN]!!
}




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

//Euclid's algorithm
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main(){
    string S;
    ll N;
    ll ans=0;
    cin>>N>>S;
    vector <ll> R;
    vector <ll> G;
    vector <ll> B;
    for(ll i=0;i<N;i++){
        if(S[i]=='R') R.push_back(i);
        if(S[i]=='G') G.push_back(i);
        if(S[i]=='B') B.push_back(i);
    }
    sort(B.begin(),B.end());
    if(R.size()==0||G.size()==0||B.size()==0){
        cout<<0;
        return 0;
    }
    for(ll i=0;i<R.size();i++){
        for(ll j=0;j<G.size();j++){
            ll tc=0;
            ll t1=-1,t2=-1,t3=-1;
            if(find(B.begin(),B.end(),(R[i]+G[j])/2)!=B.end()&&((R[i]+G[j])%2==0)){
                t1 = find(B.begin(),B.end(),(R[i]+G[j])/2)-B.begin();    
            }
            if(find(B.begin(),B.end(),(2*G[j]-R[i]))!=B.end()){
                t2 = find(B.begin(),B.end(),(2*G[j]-R[i]))-B.begin();
            }
            if(find(B.begin(),B.end(),(2*R[i]-G[j]))!=B.end()){
                t3 = find(B.begin(),B.end(),(2*R[i]-G[j]))-B.begin();
            }
            if(t1!=-1){
                if(B[t1]<max(R[i],G[j])&&B[t1]>min(R[i],G[j])) tc++;    
            }
            if(t2!=-1){
                if(G[j]<max(R[i],B[t2])&&G[j]>min(R[i],B[t2])) tc++;
            }
            if(t3!=-1){
                if(R[i]<max(B[t3],G[j])&&R[i]>min(B[t3],G[j])) tc++;
            }
            ans+=(B.size()-tc);
        }
    }
    cout<<ans;
}
    

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

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

    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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


int main(){
	int N;cin >> N;
	int odd = 0, even = 0;

	rep(i,N){
		int tmp; cin >> tmp;
		if(tmp%2==0) ++even;
		else ++odd;
	}
	int ans = 0;
	int tmp = 1;
	rep(i,N) tmp *= 3;
	ans += tmp;
	tmp = 1;
	rep(i,even) tmp *= 2;
	ans -= tmp;
	cout << ans << endl;




}





Measured memory_bytes: 3636
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
main(){int n,m,a,b;for(;scanf("%d",&n),n;puts(m>150?"NG":"OK")){
vector<pair<int,int> >v;
for(;n;n--)scanf("%d%d%d",&m,&a,&b),v.push_back(make_pair(a,m)),v.push_back(make_pair(b,-m));
sort(v.begin(),v.end());
for(m=n=0;n<v.size();n++)if((m+=v[n].second)>150)break;
}}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int
gcd_euclid(int a, int b)
{
        int tmp;

        if (a < b) {
                tmp = a;
                a = b;
                b = tmp;
        }

        while (b != 0) {
                tmp = a % b;
                a = b;
                b = tmp;
        }
        return a;
}

int
main(void)
{
        int N;
        int *A;
        int *B;
        int *C;

        scanf("%d\n", &N);
        A = malloc(sizeof(int) * N);
        B = malloc(sizeof(int) * N);
        C = malloc(sizeof(int) * N);

        for (int i = 0; i < N; i++)
                scanf("%d%*c", &A[i]);

        int max = 0;
        B[0] = A[0];
        C[N-1] = A[N-1];
        for (int i = 1; i < N; i++)
                B[i] = gcd_euclid(A[i], B[i-1]);
        for (int i = N-2; i > 0; i--)
                C[i] = gcd_euclid(A[i], C[i+1]);

        for (int i = 0; i < N; i++) {
                int gcd;
                if (i == 0)
                        gcd = C[i+1];
                else if (i == N - 1)
                        gcd = B[i-1];
                else
                        gcd = gcd_euclid(B[i-1], C[i+1]);
                if (max < gcd)
                        max = gcd;
        }

        printf("%d", max);
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,x,maxx=-1,sum=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d",&x),sum+=x,maxx=max(maxx,x);
	printf("%d",sum-maxx/2);
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int n, q;
vector<int> com, x, y;
/**********************************************/

template <typename T>
class UnionFind {
    private:
        vector<int> parent;  // 親
        vector<int> rank;    // 木の深さ

        // 重み付きUnionFindでのみ利用
        vector<T> diffWeight; // 親ノードとの値の差
    public:
        UnionFind(int n);          // n要素で初期化
        int Find(int x);           // 木の根を返す
        void Unite(int x, int y);  // xとyの属する集合を併合
        bool Same(int x, int y);   // xとyが同じ集合に属するか否か
        
        // 重み付きUnionFindでのみ利用
        void Unite(int x, int y, T w);
        T Weight(int x);      // xの重みを返す
        T Diff(int x, int y); // xとyの差を返す
};

template <typename T>
UnionFind<T>::UnionFind(int n) : parent(n), rank(n), diffWeight(n, 0)
{
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}

template <typename T>
int UnionFind<T>::Find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        int r = Find(parent[x]);
        diffWeight[x] += diffWeight[parent[x]];
        return parent[x] = r;
    }
}

template <typename T>
void UnionFind<T>::Unite(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

template <typename T>
bool UnionFind<T>::Same(int x, int y) { return Find(x) == Find(y); }

template <typename T>
void UnionFind<T>::Unite(int x, int y, T w){
    w += Weight(x); w -= Weight(y);
    x = Find(x); y = Find(y);
    if(x == y) return;

    if(rank[x] < rank[y]) swap(x, y), w = -w;

    if(rank[x] == rank[y]) rank[x]++;
    parent[y] = x;

    diffWeight[y] = w;
}

template <typename T>
T UnionFind<T>::Weight(int x){
    Find(x);
    return diffWeight[x];
}

template <typename T>
T UnionFind<T>::Diff(int x, int y){
    return Weight(y) - Weight(x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> q;
    com.assign(q, 0);
    x.assign(q, 0);
    y.assign(q, 0);
    
    REP(i, q) cin >> com[i] >> x[i] >> y[i];

    UnionFind<int> uf(n);
    REP(i, q){
        if(com[i] == 0) uf.Unite(x[i], y[i]);
        else cout << (uf.Same(x[i], y[i]) ? 1 : 0) << endl;
    }

}



Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin p(n);
    rep(i,n)cin>>p[i];
    int sum=0;
    for(int i=1;i<n-1;i++){
        if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))sum++;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
// ABC129_A

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int P,Q,R;


    std::cin>>P;
    std::cin>>Q;
    std::cin>>R;
    std::vector <int> times(6);

    times[0] = P+Q;
    times[1] = Q+R;
    times[2]= P+R;
    times[3] = Q+R;
    times[4] = R+P;
    times[5] = Q+P;

    cout<<*std::min_element(times.begin(),times.end());


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;


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

#define PI              acos(-1.0)
#define en '\n'
#define Infi 0x3f3f3f3f
#define LInfi 0x3f3f3f3f3f3f3f3f



#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int  ll;
typedef unsigned long long int llu;

vector<int> weight;
vector<int> cost;

llu dp[102][100005];

llu knap(int id,int w){

    if(w==0)return 0;
    if(id==cost.size()){
       return 0;
    }

    if(dp[id][w]!=LInfi)return dp[id][w];

    llu p1;

    bool bol = false;

    if(w-weight[id]>=0){
    p1 = cost[id] + knap(id+1,w-weight[id]);
    bol = true;

    }

    llu p2 = knap(id+1,w);

    if(bol)
    return dp[id][w] = max(p1,p2);
    else
        return dp[id][w] = p2;
}


int main(void){

    int N,W;

    cin >> N >> W;

    for(int i=0;i<N;i++){
        int w,c;
        cin >> w >> c;

        weight.push_back(w);
        cost.push_back(c);
    }
    memset(dp,LInfi,sizeof(dp));

   cout << knap(0,W) << endl;


    return 0;
}


Measured memory_bytes: 80000
// AOJ 1346 "Miscalculation" (ICPCアジア地区予選 2014 東京大会 Problem B)
import java.util.Scanner;

public class Main {
    static int pos = 0; // 四則演算の構文解析における現在位置
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int ansOfBob = sc.nextInt();
        
        int ansMulFirst = evalMulFirst(s);
        int ansLeftToRight = evalLeftToRight(s);
        
        if (ansOfBob == ansMulFirst && ansOfBob == ansLeftToRight) {
            System.out.println("U");
        } else if (ansOfBob == ansMulFirst) {
            System.out.println("M");
        } else if (ansOfBob == ansLeftToRight) {
            System.out.println("L");
        } else {
            System.out.println("I");
        }
    }
    
    public static int evalMulFirst(String s) {
        int ans = evalMul(s);
        while (pos < s.length()) {
            pos++;
            ans += evalMul(s);
        }
        return ans;
    }
    
    private static int evalMul(String s) {
        int ans = evalFactor(s);
        while (pos < s.length() && s.charAt(pos) == '*') {
            pos++;
            int b = evalFactor(s);
            ans *= b;
        }
        
        return ans;
    }
    
    private static int evalFactor(String s) {
        int num = s.charAt(pos) - '0';
        pos++;
        return num;
    }
    
    public static int evalLeftToRight(String s) {
        int ans = s.charAt(0) - '0'; // 最初の文字を足す
        for (int i = 1; i < s.length(); i += 2) {
            char c = s.charAt(i);
            if (c == '+') {
                ans += s.charAt(i + 1) - '0';
            } else {
                ans *= s.charAt(i + 1) - '0';
            }
        }
        
        return ans;
    }
}

Measured memory_bytes: 17360
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	x, y := nextInt(), nextInt()

	c := 0
	for i := x; i <= y; i *= 2 {
		c++
	}

	fmt.Println(c)
}


Measured memory_bytes: 640
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 200001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a[N],ans;
map<int,int> f,u;
int main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=n;++i)++f[a[i]];
	for(int i=1;i<=n;++i)
		if(u[a[i]])--u[a[i]];
		else
		{
			--f[a[i]];
			for(int j=30;j;--j)
				if(a[i]<(1<<j) && f[(1<<j)-a[i]])
				{
					++ans;
					--f[(1<<j)-a[i]];
					++u[(1<<j)-a[i]];
					break;
				}
		}
	printf("%d\n",ans);
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

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

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

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

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

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(si, h) rep(sj, w)
    {
        if (s[si][sj] == '#')
            continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<pii> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF)
                return;
            dist[i][j] = x;
            q.push(pii(i, j));
        };
        update(si, sj, 0);
        while (!q.empty())
        {
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(dir, 4)
            {
                int ni = i + di[dir], nj = j + dj[dir];
                if (ni < 0 || ni >= h || nj < 0 || nj >= w)
                    continue;
                if (s[ni][nj] == '#')
                    continue;
                update(ni, nj, dist[i][j] + 1);
            }
        }
        rep(i, h) rep(j, w)
        {
            if (dist[i][j] == INF)
                continue;

            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long ll;
using namespace std;
const int mod=1e9+7;

const int maxn = 1e6+5;
int k[maxn];
int main()
{
   int n; cin >> n;
   for(int i = 1; i <= n; i++) cin >> k[i];
   sort(k+1, k+n+1);
   for(int i = 1; i <= n-1; i++) {
    if(k[i] == k[i+1]) {
        cout << "NO" << endl;
     return 0;
    }
   }
   cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
bool Tmax[100005];
bool Amax[100005];
int H,W,g1=0,g2=0,g4=0;
string board[105];
int charcnt[26];
bool g1check,g2check,g4check;
int main(void)
{
  cin >> H >> W;
  for(int i=0;i<H;i++)
    {
      cin >> board[i];
    }
  for(int i=0;i<H;i++)
    {
      for(int j=0;j<W;j++)
	{
	  int cnt;
	  cnt=int(board[i][j]-'a');
	  charcnt[cnt]++;
	}
    }
  if(H%2==1 && W%2==1) g1=1;
  g2=(H%2)*(W/2)+(H/2)*(W%2);
  g4=(H/2)*(W/2);
  for(int j=0;j<26;j++)
    {
      while(g4 && charcnt[j]>=4)
	{
	  g4--;
	  charcnt[j]-=4;
	}
    }
  for(int j=0;j<26;j++)
    {
      while(g2 && charcnt[j]>=2)
	{
	  g2--;
	  charcnt[j]-=2;
	}
    }
  for(int j=0;j<26;j++)
    {
      while(g1 && charcnt[j]>=1)
	{
	  g1--;
	  charcnt[j]-=1;
	}
    }
  if(g1 || g2 || g4) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

int main(){
  long long N, K;
  cin >> N >> K;
  
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  vector<long long> s(N + 1);
  s[0] = 0;
  for(int i = 1; i <= N; i++) s[i] = (s[i - 1] + A[i - 1]) % K;
  for(int i = 0; i <= N; i++) s[i] = (s[i] + N * K - i) % K;
  
  unordered_map<long long, long long> m;
  for(int j = 0; j <= min(K - 1, N); j++) m[s[j]]++;
  
  long long cnt = 0;
  for(int i = 0; i < N; i++){
    m[s[i]]--;
    cnt += m[s[i]];
    if(i + K <= N) m[s[i + K]]++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 11592
#include <iostream>

using namespace std;



int main () {
	string s;
	cin >> s;
	int b = 0, e = s.length()-1;
	while (s[b] != 'A') b ++;
	while (s[e] != 'Z') e --;
	cout << e - b + 1 << endl;
	
	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    map<int, int> mp[2];
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int checker = i % 2;
        int in;
        cin >> in;
        mp[checker][in]++;
    }
    int maxi1[2] = {0, 0};
    int maxi2[2] = {0, 0};
    int maxi3[2] = {-1, -1};
    for(int i = 1; i <= 100000; i++){
        for(int k = 0; k < 2; k++){
            int checker = mp[k][i];
            if(maxi1[k] < checker){
                maxi2[k] = maxi1[k];
                maxi1[k] = checker;
                maxi3[k] = i;
                continue;
            }
            maxi2[k] = max(maxi2[k], checker);
        }
    }
    if((maxi1[0] == maxi2[0]) || (maxi1[1] == maxi2[1])){
        cout << n - maxi1[0] - maxi1[1] << endl;
        return 0;
    }
    if(maxi3[1] != maxi3[0]){
        cout << n - maxi1[0] - maxi1[1] << endl;
        return 0;
    }
    int number = max(maxi1[0] + maxi2[1], maxi1[1] + maxi2[0]);
    cout << n - number << endl;
    return 0;
}

Measured memory_bytes: 9600
#include<cstdio>
#include<cstring>
//#include<string>
#include<algorithm>
#include<iostream>

using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i) {
  int l, r, largest;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i) {
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}

int extract() {
  int maxv;
  if(H < 1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key) {
  if(key < A[i]) return;
  A[i] = key;
  while(i > 1 && A[i / 2] < A[i]) {
    swap(A[i], A[i / 2]);
    i = i/2;
  }
}

void insert(int key) {
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

int main() {
  int key;
  string com;
  while(1) {
    cin >> com;
    if(com == "insert") {
      scanf("%d", &key);
      insert(key);
    } else if(com == "extract") {
      printf("%d\n", extract());
    } else {
      break;
    }
  }

  return 0;
}



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

using namespace std;
using ll = long long;

#define MOD 1000000007
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
   mint fac(int n) {
       if(n < 0)return 0;
       return fact[n];
   }
};
MComb comb(200000);
 
mint ncr(int n, int r) {
   mint res = 1;
   for (int i = n - r + 1; i <= n; i++) res *= i;
   for (int i = 1; i <= r; i++) res /= i;
   return res;
}


int main()
{
    int n, b;
    cin >> n >> b;
    int r = n - b;

    for(int i = 1; i <= b; i++) {
        mint res = comb.ncr(r + 1, i);
        res *= comb.ncr(b - 1, i - 1);
        cout << res << endl;
    }
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
inline int readInt() {int x; cin >> x; return x;}
inline char readChar() {char c; cin >> c; return c;}
inline string readString() {string s; cin >> s; return s;}

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	IOS;
	
	int n = readInt();
	vector<char> a(n);
	for(auto &x: a) x = readChar();

	int i = 0, j = n-1;
	int ans = 0;

	while(i <= j) {
		if(a[i] == 'R' && a[j] == 'W') {
			++i; --j;
		}
		else if(a[i] == 'W' && a[j] == 'W') {
			--j;
		}
		else if(a[i] == 'R' && a[j] == 'R') {
			++i;
		}
		else if(a[i] == 'W' && a[j] == 'R') {
			swap(a[i], a[j]);
			++i; --j; ++ans;
		}
		else {
			break;
		}
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

const int inf = 1e9;

int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  vector<int> a(n, inf);
  vector<bool> vis(n, false);
  queue<int> q;
  for (int i = 1; i <= 9; i++) {
    if (!vis[i % n]) {
      vis[i % n] = true;
      a[i % n] = i;
      q.push(i % n);
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = false;
    for (int i = 0; i < 10; i++) {
      int v = (u * 10 + i) % n;
      if (a[u] + i < a[v]) {
        a[v] = a[u] + i;
        if (!vis[v]) {
          vis[v] = true;
          q.push(v);
        }
      }
    }
  }
  cout << a[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <array>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

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

ll getrnd(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

struct node {
    int cnt[26];
    node* to[26];
    
    node () {
        for (int i = 0; i < 26; ++i)
            cnt[i] = 0, to[i] = nullptr;
    }
};

ll ans = 0;
vector<int> cur(26);
void add(node*& root, string& x, int pos = 0) {
    if (!root)
        root = new node();
    
    if (pos < x.size()) {
        for (int i = 0; i < 26; ++i)
            cur[i] += root->cnt[i];
        
        ans += cur[x[pos]];
        cur[x[pos]] = 0;
        
        if (pos == x.size() - 1)
            ++root->cnt[x[pos]];
        add(root->to[x[pos]], x, pos + 1);
    }
}

void solve() {
    int n;
    cin >> n;
    
    node* root = nullptr;
    vector<string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
        
        reverse(s[i].begin(), s[i].end());
        for (char& c : s[i]) c -= 'a';
    }
    sort(s.begin(), s.end(), [](const string& a, const string& b) {
        return a.size() < b.size();
    });
    
    for (int i = 0; i < n; ++i) {
        cur.assign(26, 0);
        add(root, s[i]);
    }
    
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 316684
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

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

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;


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

	vector<int> perm, p(n), q(n);
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];
	for(int i = 1; i <= n; i++) perm.push_back(i);
	

	int cnt = 0, a = 0, b = 0;
	do {
		//debug(perm);
	  cnt++;
		bool pok = true, qok = true;
	  rep(i,n) if (perm[i] != p[i]) pok = false;
		rep(i,n) if (perm[i] != q[i]) qok = false;
   // cout << pok << " " << qok << endl;
		if(pok) a = cnt;
		if(qok) b = cnt;
	}while(next_permutation(perm.begin(),perm.end()));

	cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
alpha = str(input())

small = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
#large = [Q,W,E,R,T,Y,U,I,O,P,L,K,J,H,G,F,D,S,A,Z,X,C,V,B,N,M]

if alpha in small:
    print('a')
else:
    print('A')

Measured memory_bytes: 9116
#include<stdio.h>


int main(void)
{
	int i;
	int b=100000;
	int a;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		b*=1.05;
		if(b%1000!=0){
		b=b/1000;
		b=b+1;
		b=b*1000;
		}
	}
	printf("%d\n",b);
	
	
	return 0;
}

Measured memory_bytes: 592