akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
using namespace std;

void AddRange(vector<int>& a, int s, int e)
{
	for (int i = s; i <= e; ++i)
		a.push_back(i);
}
inline bool Red(const vector<int>& a)
{
	cout << "?";
	for (int i: a)
		cout << ' ' << i + 1;
	cout << endl;
	string res;
	cin >> res;
	if (res[0] == '-')
		exit(0);
	return (res[0] == 'R');
}
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> cur;
	AddRange(cur, n, 2 * n - 1);
	bool rIsRed = Red(cur);
	int l = -1;
	int s = 0, e = n - 1;
	while (s <= e)
	{
		int mid = (s + e) / 2;
		vector<int> cur;
		AddRange(cur, mid, mid + n - 1);
		if (Red(cur) != rIsRed)
		{
			l = mid;
			s = mid + 1;
		}
		else
			e = mid - 1;
	}
	string ans(2 * n, '?');
	ans[l] = (rIsRed ? 'B' : 'R');
	ans[l + n] = (ans[l] == 'R' ? 'B' : 'R');
	for (int i = 0; i < l; ++i)
	{
		vector<int> cur;
		AddRange(cur, l + 1, l + n - 1);
		cur.push_back(i);
		ans[i] = (Red(cur) ? 'R' : 'B');
	}
	for (int i = 2 * n - 1; i > l + n; --i)
	{
		vector<int> cur;
		AddRange(cur, l + 1, l + n - 1);
		cur.push_back(i);
		ans[i] = (Red(cur) ? 'R' : 'B');
	}
	for (int i = l + 1; i < l + n; ++i)
	{
		vector<int> cur;
		AddRange(cur, 0, l - 1);
		AddRange(cur, l + n + 1, 2 * n - 1);
		cur.push_back(i);
		ans[i] = (Red(cur) ? 'R' : 'B');
	}
	cout << "! " << ans << endl;
}


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

long long f(long long x) {
    if (x == 1) return 1;
    return 2 * f(floor(x / 2)) + 1;
}

int main(void) {
    long long h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    int N, H; cin >> N >> H;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        cin >> b[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    
    int bi = 0;
    while(b[bi] > a[0] && bi <= N) {
        H -= b[bi];
        if (H <= 0) {
            H = 0;
            break;
        }
        bi++;
    }
    
    if (H % a[0] == 0 && H != 0) {
        cout << H / a[0] + bi << endl;
    } else {
        cout << H / a[0] + bi + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
s = input()
m = (len(s) - 1) // 2
l = s[:m]
r = s[(len(s) + 3) // 2 - 1:]


def check(s):
    mid = len(s) // 2
    if len(s) % 2 != 0:
        left = s[:mid]
        right = s[mid+1:]
    else:
        left = s[:mid]
        right = s[mid:]
    if left == right[::-1]:
        return True
    else:
        return False

if check(s) and check(r) and check(l):
    print("Yes")
else:
    print("No")


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

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

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

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 500001; //check the limits, dummy

struct Res {
    ll g, x, y;
};

ll fact[MX];

Res modinv(ll a, ll b) {
    if(b == 0) return {a, 1, 0};
    Res res = modinv(b, a % b);
    return {res.g, res.y, res.x - (a / b) * res.y };
}

ll ncr(ll n, ll r) {
    return (((fact[n] * modinv(fact[r], MOD).x) % MOD) * modinv(fact[n - r], MOD).x) % MOD;
}

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


    ll n, k; cin >> n >> k;
    fact[0] = 1;
    for(ll i = 1; i <= n; i++)
        fact[i] = (fact[i - 1] * i) % MOD;

    ll ans = 0;
    for(ll i = 1; i < min(n, k + 1); i++) {
        int x = ncr(n, i);
        int y = ncr(n - 1, i);
        ans = (ans + (ncr(n, i) * ncr(n - 1, i)) % MOD) % MOD;
    }

    cout << (ans + 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static int32_t N;
static vector<int32_t> l(N), len(3), usage;

static int32_t dfs(int32_t _index)
{
	int32_t res;

	if (_index >= N) {
		vector<int32_t> total(3, 0), pole_cnt(3, 0);
		for (int32_t i = 0; i < N; i++) {
			if (usage[i] > 2)
				continue;
			total[usage[i]] += l[i];
			pole_cnt[usage[i]]++;
		}

		res = 0;
		for (int32_t i = 0; i < 3; i++) {
			if (pole_cnt[i] == 0)
				return numeric_limits<int32_t>::max();
			res += (pole_cnt[i] - 1) * 10;
			res += abs(len[i] - total[i]);
		}

		return res;
	}

	res = numeric_limits<int32_t>::max();
	for (int32_t i = 0; i < 4; i++) {
		usage[_index] = i;
		res = min(res, dfs(_index + 1));
	}
	return res;
}

int main()
{
	cin >> N;

	for (int32_t i = 0; i < 3; i++) {
		cin >> len[i];
	}

	l.resize(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> l[i];
	}

	// 0: A
	// 1: B
	// 2: C
	// 3: None
	usage.resize(N);

	cout << dfs(0) << endl;

	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

vector<ll> A(202020);
vector<ll> pos[202020];

ll N, K;

pll next(ll val, ll now){
	ll next_pos, rot;
	auto itr = upper_bound(pos[val].begin(), pos[val].end(), now);
	if(itr == pos[val].end()){
		auto itr2 = upper_bound(pos[val].begin(), pos[val].end(), -1);
		int plc = itr2 - pos[val].begin();
		next_pos = pos[val][plc];
		rot = 1;
	}else{
		int plc = itr - pos[val].begin();
		next_pos = pos[val][plc];
		rot = 0;
	}

	pll res = {next_pos, rot};
	return res;
}

ll get_period(){
	ll P = 0;
	ll now = 0;
	while(1){
		ll val = A[now];
		pll tmp = next(val, now);
		ll next_pos = tmp.first;
		ll rot = tmp.second;

		P += rot;

		if(next_pos == N-1) break;
		now = next_pos+1;
	}
	P++;
	return P;
}

void solve(){
	ll R = 0;
	ll now = 0;

	while(R<K-1){
		ll val = A[now];
		pll tmp = next(val, now);
		ll next_pos = tmp.first;
		ll rot = tmp.second;

		R += rot;
		now = next_pos+1;
	}

	vector<ll> res;
	while(1){
		ll val = A[now];
		pll tmp = next(val, now);
		ll next_pos = tmp.first;
		ll rot = tmp.second;

		if(rot==0){
			now = next_pos+1;
		}else{
			res.push_back(A[now]);
			now = now+1;
		}
		if(now==N) break;
	}

	REP(i, res.size()) cout << res[i]+1 << " ";
	cout << endl;
}

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

    cin >> N >> K;

    REP(i, N) cin >> A[i];
    REP(i, N) A[i]--;
    REP(i, N) pos[A[i]].push_back(i);

    ll P = get_period();
    K %= P;

    solve();
    return 0;
}

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

int main() {
    int n, m;
    double p;
    cin >> n >> m >> p;
    p /= 100;
    vector<int> cnt(1 << n);
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        for(int S = 0; S < (1 << n); ++S) {
            if((S & (1 << a)) && (S & (1 << b))) {
                cnt[S]++;
            }
        }
    }
    vector<double> dp(1 << n, 1);
    for(int S = 1; S < (1 << n); ++S) {
        if(!(S & 1)) continue;
        for(int T = S & (S - 1); T > 0; T = (T - 1) & S) {
            if(!(T & 1)) continue;
            dp[S] -= dp[T] * pow(p, cnt[S] - cnt[T] - cnt[(~T) & S]);
        }
    }
    cout << fixed << setprecision(10) << dp.back() << endl;
}



Measured memory_bytes: 3572
n, m = map(int, input().split())
a = [[int(x) for x in input().split()] for _ in range(n)]
a = sorted(a)
i = 0
ans = 0
while m>0:
    if a[i][1] >= m:
        ans += a[i][0] * m
        break
    else:
        ans += a[i][0] * a[i][1]
        m -= a[i][1]
        i += 1
print(ans)    

Measured memory_bytes: 22376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    long long N,P; cin>>N>>P;
    if(N==1) cout << P << endl;
    else{
        long long ans=1;
        long long p = sqrt(P);
        for(long long i=2;i<=p;i++){
            long long count =0;
            while(P%i==0){
                P/=i; count++;
            }
            ans*=pow(i,count/N);
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void){
	int w, a, b; cin >> w >> a >> b;
	if(a > b) swap(a, b);
	if(a + w < b) printf("%d\n", b - (a + w));
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int stoi (string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}


// 配列の総和
// greater



int main(){
	/*
	ll A;
    cin >> A;
	cout << "hello" << endl;
	cout << stoi("14") << endl;
	*/
	ll N, K;
	cin >> N >> K;
	pair<ll, ll> TD[N];
	rep(i, N) {
		ll a, b;
		cin >> a >> b;
		TD[i] = pair<ll, ll>(b, a);
	}
	sort(TD, TD+N, greater<pair<ll, ll>>());
	ll types=0, ans=0, answer=0, t, d;
	set<ll> s, f;
	rep(i, K){
		d = TD[i].first;
		t = TD[i].second;
		if(s.count(t)==0){f.insert(i);
		ans += s.size() * 2 + 1;
		s.insert(t);
		}
		ans += d;
		
		//show(s.size());
	}
	answer = ans;
	//show(ans);
	ll l=K-1;
	for(int i=K; i<N; i++){
		while(f.count(l))l--;
		if(l<0)break;
		d = TD[i].first;
		t = TD[i].second;
		if(s.count(t))continue;
		s.insert(t);
		ans += d;
		ans -= TD[l].first;
		ans += s.size() * 2 - 1;
		l--;
		//show(i);
		//show(ans);
		chmax(answer, ans);
	}
	cout << answer << endl;

}








Measured memory_bytes: 7680
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, e, t = map(int, input().split())
    if b < t:
        a = a[:b] + a[t:t+e-b] + a[e:t] + a[b:e] + a[t+e-b:]
    else:
        a = a[:t] + a[b:e] + a[t+e-b:b] + a[t:t+e-b] + a[e:]
print(*a)


Measured memory_bytes: 5804
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace
 
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
 
int MOD = 1000 * 1000 * 1000 + 7;
const int N = 100000;

std::vector<int> adj[N+1];
ll cnt[N+1] = {0};
ll dp[N+1];
bool visited[N+1] = {false};

void dfs(int node){
    visited[node] = true;
    cnt[node] =1;

    for(auto child : adj[node]){
        if(!visited[child]){
            dfs(child);
            cnt[node] *= cnt[child]+1;
            cnt[node] %= MOD;
        }
    }
}

void cal_ways(int node, int parent){
    dp[node] = 1;
    for( int child : adj[node]) dp[node] = (dp[node]*(cnt[child]+1))%MOD;

    int n = adj[node].size();
    vector<ll> pre(n), suf(n);

    for (int i = 0; i < n; ++i){
        pre[i] = cnt[adj[node][i]] +1 ;
        suf[i] = cnt[adj[node][i]] +1 ;        
    }

    for (int i = 1; i < n; ++i) pre[i] = (pre[i] * pre[i-1])%MOD;
    
    for (int i = n-2; i >= 0; --i) suf[i] = (suf[i] * suf[i+1])%MOD;

    for (int i = 0; i < n; ++i){
        if(adj[node][i]!=parent){
            cnt[node] = 1;
            if(i)cnt[node] *= pre[i-1];
            if(i+1<n) cnt[node] *=suf[i+1];
            cnt[node] %= MOD;
            cal_ways(adj[node][i],node);
        }
    }
}


int main()
{

    int n;cin>>n>>MOD;
    for (int i = 1; i < n; ++i)
    {
        int x,y;cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    dfs(1);


    cal_ways(1,0);

    for (int i = 1; i <= n; ++i)
    {

        cout<<dp[i]<<endl;
    }

    return 0;
} 



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    ll d = abs(A-B);
    if(d==0) cout << "YES" << endl;
    else if(V<=W) cout << "NO" << endl;
    else{
        ll mt = (V-W) * T;
        if(d<=mt) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    vll xs(3);
    for (ll& x:xs) cin>>x;
    sort(all(xs));
    for (ll x:xs) if (x%2==0) return cout << "0\n", 0;
    cout << (xs[0]*xs[1]) << '\n';
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  
}




Measured memory_bytes: 256
import itertools
a = list()
for i in range(5):
    a.append(int(input()))

time_list = list()
comb = itertools.permutations(a)
for tmp in comb:
    time_sum = 0
    # print(tmp)
    for i in range(5):
        if time_sum % 10 != 0:
            time_sum += 10 - time_sum % 10
        time_sum += tmp[i]
        # print(time_sum)
    time_list.append(time_sum)

result = min(time_list)
print(result)




Measured memory_bytes: 3060
# 初期入力
A,B,K = map(int, input().split())

for i in range(2):
    if K <= A: # K<Aの時はAが残って終了
        A -= K
        K =0
        break
    elif 0 < A : # ０＜A<Kの時、Aがなくなる
        K -= A
        A =0
    elif K < B: # A終了後でもK<BならBが残って終了
        B -= K
        K = 0
        break

    elif B <= K:# B　<　Kの時、Bがなくなる
        K -= B
        B =0
        break
    elif K <B:
        B -=K
        break

print(A,B)

Measured memory_bytes: 3060
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
P = inpl()

ave = []
for p in P:
    ave.append((p+1)/2)
    
pre = sum(ave[:k])
ans = pre
for i in range(1,n-k+1):
    now = pre - ave[i - 1] + ave[i + k - 1]
    pre = now
    ans = max(ans,now)

print(ans)

Measured memory_bytes: 111396
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		boolean ans = true;
		if (n % k != 0) {
			ans = false;
		}
		System.out.println(ans ? 0 : 1);
	}

}


Measured memory_bytes: 35672
#include<stdio.h>
int main(void)
{
	int m,f,b,a;
	scanf("%d",&m);
	scanf("%d",&f);
	scanf("%d",&b);
    if(m+f<b){
		printf("NA\n");
	}
	else{
	if(m>=b){
		a=0;
		printf("%d\n",a);
	}
	if(m<b){
		a=b-m;
		printf("%d\n",a);
	}
	}
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  string s,t; cin>>s>>t;
  
  ll g=gcd(n,m);
  ll res=n/g*m;
  n/=g, m/=g;
  
  bool ok=true;
  rep(i,g){
    if(s[i*n]!=t[i*m]) ok=false;
  }
  if(ok) cout<<res<<endl;
  else cout<<-1<<endl;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N = 1e9+7;
ll maxProductSubarrayOfSizeK(ll A[], ll n, ll k)
{
    sort(A, A + n);


    ll product = 1;


    if (A[n - 1] == 0 && (k & 1))
        return 0;


    if (A[n - 1] <= 0 && (k & 1))
    {
        for (ll i = n - 1; i >= n - k; i--)
        {
            product = (product*A[i])%N;
            product = (product+N)%N;
        }
        return product;
    }
    ll i = 0;

    ll j = n - 1;


    if (k & 1)
    {
        product = (product*A[j])%N;
        product = (product+N)%N;
        j--;
        k--;
    }

    k >>= 1;
    for (ll itr = 0; itr < k; itr++)
    {
        //cout<<i<<" "<<product<<endl;
        ll left_product = A[i] * A[i + 1];

        ll right_product = A[j] * A[j - 1];

        if (left_product > right_product)
        {
            product = (product*A[i])%N;
            product = (product*A[i+1])%N;
            product = (product+N)%N;
            i += 2;
        }
        else
        {
            product = (product*A[j])%N;
            product = (product*A[j-1])%N;
            product = (product+N)%N;
            j -= 2;
        }
    }


    return product;
}

int main()
{
    ll a[200009];
    ll i,j,k,n,m,x;
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    cout << maxProductSubarrayOfSizeK(a, n, k);

    return 0;
}



Measured memory_bytes: 5128
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] b = Console.ReadLine().Split();
            int A = int.Parse(b[0]); int B = int.Parse(b[1]);
            int an;
            an = A + B / 2;
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        long ANS=0L;
        for(int i=0;i<N;i++){
            ANS+=sc.nextLong()-1L;
        }
        System.out.println(ANS);
    }
}


Measured memory_bytes: 25716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int alp[27];

int main()
{
	string S; cin >> S;
	long long cnt = 0;
	for (int i = 1; i <= S.size(); i++)cnt += i;

	for (int i = 0; i < S.size(); i++)alp[S[i]-'a']++;

	long long cnt2 = 0;
	for (int i = 0; i < 27; i++) {
		for (int j = 1; j <= alp[i]; j++)cnt2 += j;
	}

	cout << cnt-cnt2+1 << endl;

    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

ll rec(int n, ll x) {
    if (n == 0) return 1;
    ll len = (1LL<<(n+1)) - 3;
    ll num = (1LL<<n) - 1;
    if (x == 1) return 0;
    else if (x <= len + 1) return rec(n - 1, x - 1);
    else if (x == len + 2) return num + 1;
    else if (x <= (len + 1) * 2) return num + 1 + rec(n - 1, x - len - 2);
    else return num * 2 + 1;
}

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

    cout << rec(n, x) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <functional>
#include <limits>

using namespace std;


template<typename T>
class segment_tree{
	int n;
	T fval;
	function<T(T,T)> operation;
	vector<T> dat;
	
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l){
			return fval;
		}
		
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = _query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
			return operation(vl, vr);
		}
	}
	
public:
	
	segment_tree(){
		
	}
	
	segment_tree(int n_, T val, function<T(T,T)> fun){
		init(n_, val, fun);
	}
	
	void init(int n_, T val, function<T(T,T)> fun){
		fval = val;
		
		operation = fun;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}

	void update(int k, T a){
		k += n - 1;
		dat[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			dat[k] = operation(dat[k*2 + 1],dat[k*2 + 2]);
		}
	}
	
	T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}
	
};

signed main(){
	
	segment_tree<int> seg;
	
	int n, q;
	int com, x, y;
	
	cin>>n>>q;
	
	seg.init(n+1,numeric_limits<int>::max(), [](int first, int second){ return min(first,second);});
	
	for(int i = 0; i < q; i++){
		cin>>com>>x>>y;
		
		if(com){
			cout<<seg.query(x,y+1)<<endl;
		} else {
			seg.update(x,y);
		}
	}
	return 0;
}


Measured memory_bytes: 3800
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >>N;
  int MAX=0;
  for (int i=0;i<N;i++){
    int H;
    cin >>H;
    if (MAX>=H+2){
      cout <<"No";
      exit(0);
    }
    MAX=max(MAX,H);
  }
  cout <<"Yes";
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int m;
    scanf("%d%d",&n,&m);
    int sum;
    sum=(n*n)-m;
    printf("%d\n",sum);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  // input
  int a, b;
  cin >> a >> b;
  int c = a * b;

  //solve
  if (c % 2 == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
ll cnt = 0;

int main(){
  ll n;    cin >> n;
  for(int i=1;i<=n;i++){
      if(i%5 == 0 || i%3 == 0){
          continue;
      }
      cnt+=i;
  }
  cout << cnt  << endl;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll m, k;
    cin >> m >> k;

    if(m == 1) {
        if(k == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }

    if(k < (1LL<<m)) {
        for(ll i=(1LL<<m)-1; i>=0; --i) {
            if(i == k) continue;
            cout << i << " ";
        }
        cout << k << " ";
        REP(i, 1LL<<m) {
            if(i == k) continue;
            cout << i << " ";
        }
        cout << k << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

struct Edge {
  int from, to;
  Edge(int from = -1, int to = -1) : from(from), to(to) {}
  bool operator<(auto e) const {return from != e.from ? from < e.from : to < e.to;}
  Edge reverse() const {return Edge(to, from);}
};

set<Edge> bfs(auto N, auto E) {
  vector<vector<int>> G(N);
  for(auto e: E) G[e.from].emplace_back(e.to);
  for(auto e: E) G[e.to].emplace_back(e.from);

  vector<int> d(N, -1);
  vector<set<int>> parent(N);
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  while(!q.empty()) {
    auto cost = q.front().first;
    auto cur = q.front().second;
    q.pop();
    for(auto nex: G[cur]) {
      if(d[nex] == cost) parent[nex].emplace(cur);
      if(d[nex] == -1) {
        d[nex] = cost;
        parent[nex] = {cur};
        q.emplace(cost + 1, nex);
      }
    }
  }

  set<Edge> res;
  for(auto to = 0; to < N; ++to) for(auto from: parent[to]) res.emplace(from, to);
  return res;
}

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

  vector<Edge> E(M);
  for(auto& e: E) cin >> e.from >> e.to;
  for(auto& e: E) --e.from;
  for(auto& e: E) --e.to;

  vector<int> R(Q);
  for(auto& q: R) cin >> q;
  for(auto& q: R) --q;

  vector<int> ans;

  auto valid = bfs(N, E);

  vector<vector<int>> G(N);

  vector<bool> dead(M);
  for(auto q: R) dead[q] = true;
  for(auto i = 0; i < M; ++i) {
    if(dead[i]) continue;
    for(auto e: {E[i], E[i].reverse()}) {
      if(!valid.count(e)) continue;
      G[e.from].emplace_back(e.to);
    }
  }

  vector<bool> connected(N);

  auto bfs2 = [&](auto v) {
    auto res = 0;
    vector<bool> visited(N);
    queue<int> q;
    q.emplace(v);
    while(!q.empty()) {
      auto cur = q.front();
      q.pop();
      if(visited[cur]) continue;
      visited[cur] = true;
      if(connected[cur]) continue;
      connected[cur] = true;
      ++res;
      for(auto nex: G[cur]) q.emplace(nex);
    }
    return res;
  };

  auto cnt = N - bfs2(0);
  reverse(begin(R), end(R));
  for(auto q: R) {
    ans.emplace_back(cnt);
    for(auto e: {E[q], E[q].reverse()}) {
      if(!valid.count(e)) continue;
      if(connected[e.from]) cnt -= bfs2(e.to);
      else                  G[e.from].emplace_back(e.to);
    }
  }

  reverse(begin(ans), end(ans));
  for(auto i: ans) cout << i << endl;
}

Measured memory_bytes: 35464
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] f = new Integer[N+1];
		f[0] = 0;
		for (int i = 1; i < N+1; i++) {
			f[i] = sc.nextInt();
		}
		Arrays.sort(f, Collections.reverseOrder());
		List<Integer> point = new ArrayList<>();
		for (int i = 0; i < (f.length)/2+1; i++) {
			if (i == 0) {
				point.add(f[i]);
			} else {
				point.add(f[i]);
				point.add(f[i]);
			}
		}
		long count = 0;
		for (int i = 0; i < N-1; i++) {
			count += point.get(i);
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 63408
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = list(map(int,list(input())))
L = len(S)
ans = INF
for i in range(L-2):
    tmp = S[i]*100 + S[i+1]*10 + S[i+2]*1
    ans = min(ans,abs(753-tmp))
print(ans)


Measured memory_bytes: 4212
#include <stdio.h>

int main(void)
{
    int n;
    int digit;

    while (1){
        scanf("%d", &n);
        if (n == -1){
            break;
        }
        digit = 1;
        while (digit * 4 <= n){
            digit *= 4;
        }
        while (digit > 0){
            printf("%d", n / digit);
            n %= digit;
            digit /= 4;
        }
        printf("\n");
    }

    return (0);
}

Measured memory_bytes: 604
N,K=map(int,input().split())
A=list(map(int,input().split()))

B=[]
for s in range(N):
    t=0
    for e in range(s,N):
        t+=A[e]
        B.append(t)

def check(a):
    count=0
    for b in B:
        if b&a==a:
            count+=1
            if count>=K:
                return True
    return False

ans=0
for i in range(40,-1,-1):
    tmp=ans|(1<<i)
    if check(tmp):
        ans=tmp

print(ans)


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

int main(void){
  string s,ans="Good";
  cin>>s;

  r(i,s.size()-1){
    if(s.at(i)==s.at(i+1)){
      ans="Bad";break;
    }
  }
  cout<<ans<<endl;


  return 0;
}


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

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


int main()
{
    int N, D, A;
    cin >> N >> D >> A;
    vector<pair<long long, long long>> M(N);
    REP(i, N) cin >> M[i].first >> M[i].second;

    // モンスターの位置の昇順にソート
    sort(M.begin(), M.end());

    long long ans = 0, tot = 0;
    queue<pair<long long, long long>> q;
    REP(i, N){
        long long X = M[i].first;
        long long H = M[i].second;
        while(!q.empty() and q.front().first < X){
            tot -= q.front().second;
            q.pop();
        }
        H -= tot;
        if(H > 0){
            long long num = (H+A-1)/A;
            long long damage = A*num;
            ans += num;
            tot += damage;
            q.emplace(X+2*D, damage);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int h, w, k;
        scanf("%d %d %d", &h, &w, &k);
        char fie[h][w+1];
        REP(i, 0, h) scanf("%s", fie[i]);

        int ans = 0;
        REP(I, 0, 1<<h) REP(J, 0, 1<<w){
                int cnt = 0;
                REP(i, 0, h) REP(j, 0, w){
                        if((I>>i)&1 || (J>>j)&1) continue;
                        if(fie[i][j]=='#') cnt++;
                }
                if(cnt==k) ans++;
        }
        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 3812
from collections import defaultdict

while True:
    n = int(input())
    if n == 0:
        break
    ice = defaultdict(int)
    
    for _ in range(n):
        i = int(input())
        ice[i] += 1
    
    for i in range(10):
        if ice[i] == 0:
            print("-")
        else:
            print("*" * ice[i])

        
    


Measured memory_bytes: 5992
a = [int(s) for s in input().split()]
N, K = a[0], a[1]
prob = 0
if N > K - 1: prob += (N - K + 1)/N
prob2 = 0
for i in range(1, min(N, K - 1) + 1):
    a = i
    j = 0
    while(a < K): 
        a = a << 1
        j += 1
    prob2 += 1/(2**j)
print(prob + prob2 * (1/N))


Measured memory_bytes: 9196
#include <stdio.h>
#include <math.h>
int main(void)
{
	int n,t,a,i,ansN;
	double ans;
	scanf("%d",&n);
	scanf("%d %d",&t,&a);

	int h[n];

	for(i=0;i<n;i++)
	{
		scanf("%d",&h[i]);

		if(i == 0)
		{
			ans = fabs((double)(t - h[0] * 0.006) - a);
			ansN = 1;
		}
		else if(ans >= fabs((double)(t - h[i] * 0.006) - a))
		{
			ans = fabs((double)(t - h[i] * 0.006)-a);
			ansN = i + 1;
		}
	}
	printf("%d",ansN);
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
set<string>senten;

void make(int n,int nowc,string s){

    vector<string>p(nowc+1);
    rep(i,nowc+1)p[i]=s;

    if(s.size()==n){
        senten.emplace(s);
        return;
    }
    //char c=s[s.size()-1];
    char start='a';
    //新色
    p[0].append(1,start+nowc);
    make(n,nowc+1,p[0]);
    
    rep2(i,nowc){
    
    p[i].append(1,start+i-1);
    make(n,nowc,p[i]);
    }

    //if(s.size()==n)return s;
}

int main(){

    int n;
    cin>>n;
    
    make(n,1,"a");
    auto iter=senten.begin();
    
    while(iter!=senten.end()){
        cout<<*iter<<endl;
        iter++;
    }
    

    return 0;

}
/*


*/


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

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

    ans = (b-a)*(n-2)+1;
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3560
n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))

nums.sort()
# 奇数は2通り
# w型とm型
if n % 2 == 1:
    w = -2*sum(nums[:n//2])+nums[n//2]+nums[n//2+1]+2*sum(nums[n//2+2:])
    m = -2*sum(nums[:n//2-1])-nums[n//2-1]-nums[n//2]+2*sum(nums[n//2+1:])
    print(max(w,m))
# 偶数は1通り
else:
    print(-2*sum(nums[:n//2-1])-nums[n//2-1]+nums[n//2]+2*sum(nums[n//2+1:]))

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

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

  int ans = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = i + 1; j <= k; j++) {
      if(i % 2 != j % 2) ans++;
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    ll s;
    scanf("%lld", &s);

    ll a = 1000000000;
    ll b = (s-1) / a;
    ll c = (s-1) % a;

    printf("0 0 %lld %lld 1 %lld\n", a, a-c-1, b+1);


    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  int n, m;
  cin >> n >> m;
  vi32 g(n + 1, true);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    g[a] = !g[a];
    g[b] = !g[b];
  }
  rep(i, n + 1) {
    if (!g[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
table = ('a'..'z').to_a

while line = gets
  encoded = line.chomp.split('')
  for i in 0...table.size do
    decoded = ''
    for j in 0...encoded.size do
      index = table.index(encoded[j])
      unless index.nil?
        decoded += table[(index + i) % (table.size)]
      else
        decoded += encoded[j]
      end
    end

    if decoded =~ /\b(the|this|that)\b/
      puts decoded
      break
    end
  end
end

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

#define endl '\n'
#define ll long long
#define LSB __builtin_ctzll
#define sc(a) scanf("%d",&a)
#define MSB 63-__builtin_clzll
#define scl(a) scanf("%lld",&a)
#define BITS __builtin_popcountll
#define mem(a , v)  memset(a , v , sizeof(a))
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9+7;
const int MAX = 1e5+55;
const int INF = 1e9+77;
const ll INFINF = 1e18+1e17;
const double PI = acos(-1.0);
vector<int> months = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll power(ll x,ll y){
         if(y==0)
         return 1;
         ll s=power(x,y/2);
         s*=s;
         if(y&1)
         s*=x;
         return s;
}

string s1;
string s2;
string ans;
int n1;
int n2;


int dp[3001][3001];

int solve(int i,int j){
    if(i==n1){
        return 0;
    }
    if(j==n2){
        return 0;
    }

    int &res=dp[i][j];
    if(res!=-1){
        return res;
    }

    res=0;
    if(s1[i]==s2[j]){
        res+=solve(i+1,j+1)+1;
    }
    else{
        res=max(    solve(i+1,j)  ,   solve(i,j+1)   );
    }

    return res;

}


void build(int i,int j){
    if(i==n1){
        return;
    }
    if(j==n2){
        return;
    }


    if(s1[i]==s2[j]){
        ans+=s1[i];
        build(i+1,j+1);
    }
    else{
        if(solve(i+1,j)>=solve(i,j+1)){
            build(i+1,j);
        }
        else{
            build(i,j+1);
        }
    }

    return;

}



int main(){

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);



     cin>>s1>>s2;
     n1=s1.size();
     n2=s2.size();

     mem(dp,-1);
     int cur=solve(0,0);
     if(!cur){
        return 0;
     }
     ans="";
     build(0,0);
     cout<<ans;








     return 0;

}


Measured memory_bytes: 35712
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<iomanip>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
//#define T_ int
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
//struct bit_2d{T_ a[2005][2005];int lowbit(int x){return x&(-x);}void add(int x,int y,T_ z){int i,j;for (i=x;i<=2000;i+=lowbit(i)){for (j=y;j<=2000;j+=lowbit(j)){a[i][j]+=z;}}}T_ query(int x,int y){int i,j;T_ s=0;for (i=x;i;i-=lowbit(i)){for (j=y;j;j-=lowbit(j)){s+=a[i][j];}}return s;}T_ query(int x,int y,int xx,int yy){return query(xx,yy)-query(x-1,yy)-query(xx,y-1)+query(x-1,y-1);}};
long long n,m,i,j,f[1000005],g[1000005],ans,mod=1e9+7;
int main()
{
	scanf("%lld",&n);
	f[1]=1;
	fz1(i,n)
	{
		(g[i]+=g[i-1])%=mod;
		(f[i]+=g[i])%=mod;
		(g[i+3]+=f[i])%=mod;
		(f[i+1]+=f[i])%=mod;
		(ans+=min(n-1,i)*f[i])%=mod;
		if (i!=n) (ans+=sqr(n-1)%mod*f[i])%=mod;
	}
	(ans+=g[n]+g[n+1]+f[n+1])%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,n=100;
    cin>>a;
    int e[a]={0},b[a];
    for(int i=0;i<a;i++) cin>>b[i];
    for(int i=0;i<a;i++){
        for(int j=0;j<=30;j++){
            if(b[i]%2==0) {
                e[i]++;
                b[i]=b[i]/2;
            }
        }
        if(e[i]<n) n=e[i];
    }
    cout<<n<<endl;
}


Measured memory_bytes: 256