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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

// x^y%p
long long modpow(long long x, long long y, long long p=1) {
    long long res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0) {
        if (y & 1) res = res * x % p;
        y = y>>1;
        x = x * x % p;
    }
    return res;
}

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

  int N;
  cin >> N;

  int res = N;
  for(int i = 0; i <= N; i++) {
    int cc = 0;
    int t = i;
    while (t > 0) {
      cc += t % 6;
      t /= 6;
    }
    t = N - i;
    while (t > 0) {
      cc += t % 9;
      t /= 9;
    }
    if(res > cc) {
      res = cc;
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>

typedef struct {
  char mark;
  int number;
}card;

void BubbleSort(card C[], int N);
void SelectionSort(card C[], int N);

int main(){
  int N,i;
  card C[36];
  card D[36];

  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf(" %c",&C[i].mark);
    scanf("%d",&C[i].number);
    D[i] = C[i];
  }

  BubbleSort(C,N);
  SelectionSort(D,N);

    for(i=0;i<N-1;i++){
      printf("%c%d ",C[i].mark,C[i].number);
    }
    printf("%c%d\n",C[N-1].mark,C[N-1].number);
    printf("Stable\n");

    for(i=0;i<N-1;i++){
      printf("%c%d ",D[i].mark,D[i].number);
    }
    printf("%c%d\n",D[N-1].mark,D[N-1].number);

    for(i=0;i<N;i++){
      if(i == N-1){
        printf("Stable\n");
      }
      if((C[i].number != D[i].number) || (C[i].mark != D[i].mark)){
          printf("Not stable\n");
          break;
        }
    }
    return 0;
}


void BubbleSort(card C[], int N){
  int i,j;
  card tmp;

  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(C[j].number < C[j-1].number){
        tmp = C[j];
        C[j] = C[j-1];
        C[j-1] = tmp;
      }
    }
  }
}

void SelectionSort(card C[],int N){
  card tmp;
  int minj,i,j;

  for(i=0;i<N;i++){
    minj = i;
    for(j=i;j<N;j++){
      if(C[j].number < C[minj].number){
        minj = j;
      }
    }
    tmp = C[i];
    C[i] = C[minj];
    C[minj] = tmp;
  }

  return;
}




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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<ll, char> pc; 

const ll Mod = 1e9 + 7;
const ll Delta = 10889;
const int Maxn = 42;
const int Maxm = (1 << 18) + 10;
const int Md = (1 << 18);
const ll Inf = 1e16;

ll dp[Maxn][Maxm];

ll p2(int i){
	return (1 << i);
}
bool sub(int a, int b){
	return (a | b) <= a;
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	ll n, x, y, z;
	cin >> n >> x >> y >> z;
	ll pat = 1;
	pat <<= x;
	pat ++;
	pat <<= y;
	pat ++;
	pat <<= z;
	pat ++;
	ll F = Md - 1;
	
	dp[0][1] = 1;
	
	int nx;
	for(int i = 0; i < n; i++){
		for(int mk = 0; mk < Md; mk ++){
			if(dp[i][mk] == 0) continue;
			dp[i][mk] %= Mod;
			for(int d = 1; d <= 10; d++){
				nx = mk << d;
				nx |= 1;
				nx &= F;
				if(!sub(nx, pat)) dp[i + 1][nx] += dp[i][mk];
			}
		}
	}
	ll ans = 0;
	for(int mk = 0; mk < Md; mk ++) ans = (ans + dp[n][mk]) % Mod;
	ll all = 1;
	for(int i = 1; i <= n; i++) all = (all * 10) % Mod;
	cout << (all - ans + Mod) % Mod;
	return 0;
}



Measured memory_bytes: 84224
n = int(input())
if n == 1:
    print('Yes')
    print(2)
    print(1,1)
    print(1,1)
    exit()


for i in range(2,10**3):
    if i*(i+1) == n*2:
        k,l = i+1, i
        break
else:
    print('No')
    exit()

print('Yes')

ans = [ [] for _ in range(k)]
top = 0
bottom = 1
for i in range(1,n+1):
    ans[top].append(i)
    ans[bottom].append(i)
    if bottom < k-1:
        bottom += 1
    else:
        top += 1
        bottom = top+1

print(len(ans))
for row in ans:
    print(len(row), *row )

Measured memory_bytes: 76276
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e6 + 5;
char s[maxn];
int sum[maxn];
int k[maxn];
int n;
LL slove(int k)
{
    queue<int> q;
    int j = 1, pre = 0;
    LL ans = 0, res = 0;
    for (int i = 1; i <= n; i++) {
        if(s[i] != 'D')
            continue;
       // cout << "i " << i << ' ';
        while(!q.empty()) {
            if(i > q.front()) {
                ans -= sum[q.front()] - sum[pre];
                q.pop();
            }
            else
                break;
        }
        if(pre)
            ans -= LL(sum[i] - sum[pre]) * q.size();
        j = max(j, i);
        for (; j < i + k && j <= n; j++) {
            if (s[j] == 'C')
                q.push(j), ans += sum[j] - sum[i];
        }
        res += ans;
       // cout << "res " << res << '\n';
        pre = i;
    }
    return res;
}
int main()
{
    scanf("%d", &n);
    scanf("%s", s + 1);
    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++)
        scanf("%d", &k[i]);
    for (int i = 1; i <= n; i++) {
        // if (s[i] == 'D')
        //     D.push_back(i);
        // if (s[i] == 'C')
        //     C.push_back(i);
        if (s[i] == 'M')
            sum[i] = sum[i - 1] + 1;
        else
            sum[i] = sum[i - 1];
    }
    for (int i = 1; i <= q; i++) {
        printf("%lld\n", slove(k[i]));
    }
    return 0;
}
// 6
// DMCDMC
// 1
// 6

Measured memory_bytes: 12768
fn main() {
    input! {
        a: char
    }

    solve(&a);
}

fn solve(a: &char) {
    if a.is_uppercase() {
        println!("A");
    } else {
        println!("a");
    }
}

#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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


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

using namespace std;

typedef long long ll;

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

	ll MOD = 1e9+7;

	ll N, M;
	cin >> N >> M;

	vector<ll> S(N);
	rep(i, N) cin >> S[i];

	vector<ll> T(M);
	rep(i, M) cin >> T[i];

	vector<vector<ll>> dp(N+1, vector<ll>(M+1, 0));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			dp[i+1][j+1] += dp[i+1][j];
			dp[i+1][j+1] %= MOD;
			dp[i+1][j+1] += dp[i][j+1] - dp[i][j] + MOD;
			dp[i+1][j+1] %= MOD;
			if(S[i] == T[j]){
				dp[i+1][j+1] += dp[i][j] + 1;
				dp[i+1][j+1] %= MOD;
			}

		}
	}

	cout << dp[N][M] + 1 << endl;
}


Measured memory_bytes: 31616
const main = stdin => {
  const input = stdin.trim().split('\n')
  const R = parseInt(input[0])

  if (R < 1200) {
    console.log('ABC')
  } else if (R < 2800) {
    console.log('ARC')
  } else {
    console.log('AGC')
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29540
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M;

  cin >> N >> M;

  ll ans = 0;

  ans += N * (N - 1) / 2;
  ans += M * (M - 1) / 2;

  cout << ans << endl;

  return 0;
}

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


int main(int argc, const char** argv) {

    long long a,b,c,d;
    cin>>a>>b>>c>>d;

    long long result = a*c;
    if(a*c>result)
        result = a*c;
    if(a*d>result)
        result = a*d;
    if(b*c>result)
        result = b*c;
    if(b*d>result)
        result = b*d; 

    cout<<result;
return 0;
}

Measured memory_bytes: 3520
//
//  main.cpp
//  C - Not so Diverse
//
//  Created by wenhan on 2017/12/10.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int x;
int main() {
    int n,k;
    cin>>n>>k;
    map<int,int>q;
    vector<int >p;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        q[x]++;
    }
    for(int i=1;i<=200000;i++)
        if(q[i]!=0)
            p.push_back(q[i]);
    sort(p.begin(), p.end());
    if(p.size()<=k)
        printf("0\n");
    else{
        int v=0;
        for(int i=0;i<p.size()-k;i++)
            v+=p[i];
        printf("%d\n",v);
    }
    
    
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 10748
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	vll a(n);
	map<ll, ll> f;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		f[a[i]]++;
	}

	map<ll, ll> ff;
	for (auto ent : f)
		ff[ent.second]++;

	for (int i = 0; i < n; i++) {
		ll ans = 0;

		ll fai = f[a[i]];	// freq of number written on a[i]
		for (auto ent : ff) {
			if (ent.first != fai) {
				ans += ent.second * ent.first * (ent.first - 1) / 2;
			} else {
				ans += (ent.second - 1) * ent.first * (ent.first - 1) / 2;
			}
		}
		fai--;
		ans += fai * (fai - 1) / 2;

		cout << ans << endl;
	}
}

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



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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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; }


int main() {
    ll n, x;
    cin >> n;
    x = sqrt(n);
    vector<bool> p(x, true);
    for (int i = 2; i <= x; ++i) {
        if (!p[i])continue;

        for (int j = i * 2; j <= x; j += i) {
            p[j] = false;
        }
    }

    map<ll, int> m;
    for (int i = 2; i < x; ++i) {
        if (!p[i])continue;
        int cnt = 0;
        while (n % i == 0)n /= i, cnt++;

        if (cnt > 0) {
            m[i] = cnt;
        }
    }
    if (n > 1)m[n]++;
    int ans = 0;
    for (auto y:m) {
        int c = 1;
        int v = y.second;
        while (v >= c)v -= c, c++, ans++;
    }
    cout << ans << endl;


    return 0;
}


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

using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, M, C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    for (int j=0; j<M; ++j)
    {
        cin >> B[j];
    }
    
    int sum, A;
    int cnt = 0;
    for (int i=0; i<N; ++i)
    {
        sum = C;
        
        for (int j=0; j<M; ++j)
        {
            cin >> A;
            sum += A*B[j];
        }
        if (sum > 0)
        {
            ++cnt;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a;
    double b;
    cin>>a>>b;
    cout<<fixed<<setprecision(0)<<(ll)((a*(ll)(round)(b*100))/100)<<endl;
    return 0;
}


Measured memory_bytes: 3740
#list(map(int,input().split()))
#a,b=map(int,input().split()

n,k=map(int,input().split())
l=list(map(int,input().split()))

#ソートする
l.sort()
#逆にする（降順)
l.reverse()
#合計
sum=0;

for i in range(0,k):
    sum=sum+l[i]

print(sum)


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]
#i-1番目までの魔法で、j以上のだめを得与えるのに最低限必要な魔力
infi=10**12
dp=[[infi]*(h+1) for i in range(n+1)]
#shoki化
for i in range(n+1):
    dp[i][0]=0
for i in range(n):
    if AB[i][0]+1<h+1:
        for j in range(AB[i][0]+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
        for j in range(AB[i][0]+1, h+1):
            dp[i+1][j]=min(dp[i][j], dp[i+1][j-AB[i][0]]+AB[i][1])
    else:
        for j in range(h+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
print(dp[n][h])

Measured memory_bytes: 119612
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = new uint[][](n, 10);
  foreach (i; 0..n) {
    auto t = readln.chomp.map!(a=>a-'a').array;
    sort(t);
    s[i] = t;
  }
  sort(s);

  long res, lsum;
  uint i;
  while (i < n - 1) {
    foreach (j; i+1..n) {
      if (s[i] == s[j]) {
        lsum++;
        i++;
      } else {
        i = j;
        foreach (long t; 1..lsum+1) {
          res += t;
        }
        lsum = 0;
        break;
      }
    }
    foreach (long t; 1..lsum+1) {
      res += t;
    }
  }
  res.writeln;
}


Measured memory_bytes: 22268
# -*- coding:utf-8 -*-
N  = int(input())
a = list(map(int, input().split()))
b = [ 0 for _ in range((10**5)+1) ]
ans = float('-inf')
for tmp in a:
    if tmp != 0:
        b[tmp-1] += 1
    b[tmp] += 1
    b[tmp+1] += 1
for tmp in b:
    ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define For1(i, n) for(int i = 1; i <= (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    Cin(int, k);
    
    for(char &c : s){
        int n = ('z'- c + 1) % 26;
        if(k < n) continue;
        c = 'a', k -= n;
    }
    if(k > 0) s.back() = (s.back() - 'a' + k % 26) % 26 + 'a';
    Cout(s);
}


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

ll dp[8000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,t;
    cin>>n>>t;
    t--;
    array<ll,2> a[n];
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a[i] = {x,y};
    }
    sort(a,a+n);
    ll ans = 0;
    for(int i=0;i<n;i++){
        for(int j=t+a[i][0];j>=a[i][0];j--){
            dp[j] = max(dp[j],dp[j-a[i][0]]+a[i][1]);
            ans = max(ans,dp[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#define MOD_TYPE 2

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

#pragma endregion

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

  ll n, a, b;
  cin >> n >> a >> b;
  if (n == 1)
  {
    cout << (a == b) << endl;
    return 0;
  }
  if (a > b)
  {
    cout << 0 << endl;
    return 0;
  }
  ll L = a * (n - 1) + b;
  ll R = a + b * (n - 1);
  cout << R - L + 1 << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const int N = 123456;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , x;
    cin >> n >> x;

    vector < ll > a;
    vector < ll > p;
    a.push_back(1);
    p.push_back(1);

    for(int i = 1 ; i <= 50 ; i++) {
        a.push_back(a[i - 1] * 2 + 3LL);
        p.push_back(p[i - 1] * 2 + 1LL);
    }

    ll ans = 0;
    while(x > 0) {
        while(x < a[n] && x > 0) {
            x--;
            n--;
        }
        if(x == 0) break;
        x -= a[n];
        ans += p[n];
        if(x > 0) {
            x--;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    if k == 0:
        print(n ** 2)
        exit()
        
    res = 0
    for b in range(1, n + 1):
        q, r = divmod(n, b)
        res += max(0, (b - 1 - (k - 1))) * q + max(0, r - (k - 1))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9136
#include<cstdio>
#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
stack<char>s;
string a;
int main(){
    cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++){
        s.push(a[i]);
    }
    bool ju=1;
    for(int i=0;i<n;i++){
        char top=s.top();
        if(top=='b') top='d';
        else if(top=='d') top='b';
        else if(top=='p') top='q';
        else if(top=='q') top='p';
        if(top==a[i]) {
            ju=1;
            s.pop();
        }
        else {
            ju=0;
            break;
        }
    }
    if(ju==0) printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt(),m=in.nextInt(),a=in.nextInt();
			if((n|m|a)==0)
				return;
			int A[][]=new int[1001][n+1];
			int sh=1;
			int sw=a;
			for(int i=0;i<m;i++)
			{
				int h=in.nextInt();
				int p=in.nextInt();
				int q=in.nextInt();
				sh=Math.max(sh,h);
				A[h][p]=q;
				A[h][q]=p;
			}
			for(;;)
			{
				if(A[sh][sw]!=0)
					sw=A[sh][sw];
				sh--;
				if(sh==0)
					break;
			}
			System.out.println(sw);
		}
	}
}

Measured memory_bytes: 71072
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 1010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

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

    int n, k; cin>>n>>k;
    calc(1005);

    cout << comb(k, n) << endl;

    return 0;
}


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

int main() {
  int n, k;
  long long ans=0;
  cin >> n >> k;
  vector<int> h(n);
  for (int i=0; i<n; i++){
    cin >> h.at(i);
  }
  if (k >= n)
    cout << 0 << endl;
  else{
    sort(h.begin(), h.end());
    for (int i=0; i<n-k; i++)
      ans += h.at(i);
    cout << ans << endl;
  }  
}



Measured memory_bytes: 1024
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"reflect"
	"sort"
)

func main() {
	defer writer.Flush() // Use printf, scanf

	// CODE
	var N int
	scanf("%d\n", &N)
	a := make([]int, N)
	for i := 0; i < N-1; i++ {
		scanf("%d ", &a[i])
	}
	scanf("%d\n", &a[N-1])
	var ans int
	for i := 1; i < N; i++ {
		if a[i-1] == a[i] {
			ans++
			a[i] = -1
		}
	}
	printf("%d\n", ans)

}

// I/O {{{
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

// }}}
// Math {{{
func maxInt(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

// }}}
// {{{ dummy
func dummy() {
	fmt.Printf("Hello, World\n")
	fmt.Printf("%v", reflect.TypeOf(0))

	arr := []int{10, 9, 8, 7, 1}
	sort.Ints(arr)
	fmt.Println(arr)
}

// }}}
// PriorityQueue {{{
// Usage:
// type Person struct {
// 	name string
// 	age  int
// }
//
// func (p1 Person) Less(p2 interface{}) bool {
// 	return p1.age < p2.(Person).age
// }
//
// func main() {
// 	sc.Split(bufio.ScanWords)
// 	defer out.Flush() // Use printf
//
// 	// CODE
// 	q := NewPriorityQueue()
// 	q.Push(Person{name: "B", age: 11})
// 	q.Push(Person{name: "A", age: 10})
// 	q.Push(Person{name: "C", age: 12})
//
// 	for q.Len() > 0 {
// 		p := q.Pop().(Person)
// 		printf("%s %d\n", p.name, p.age)
// 	}
// }
func NewPriorityQueue() *PriorityQueue {
	q := &PriorityQueue{s: new(sorter)}
	heap.Init(q.s)
	return q
}

func (q *PriorityQueue) Pop() Comparable {
	return heap.Pop(q.s).(Comparable)
}

func (q *PriorityQueue) Top() Comparable {
	if len(*q.s) > 0 {
		return (*q.s)[0].(Comparable)
	}
	return nil
}

func (q *PriorityQueue) Fix(x Comparable, i int) {
	(*q.s)[i] = x
	heap.Fix(q.s, i)
}

func (q *PriorityQueue) Remove(i int) Comparable {
	return heap.Remove(q.s, i).(Comparable)
}

func (q *PriorityQueue) Len() int {
	return q.s.Len()
}

type Comparable interface {
	Less(other interface{}) bool
}

type sorter []Comparable

func (s *sorter) Push(x interface{}) {
	*s = append(*s, x.(Comparable))
}

func (s *sorter) Pop() interface{} {
	n := len(*s)
	if n > 0 {
		x := (*s)[n-1]
		*s = (*s)[0 : n-1]
		return x
	}
	return nil
}

func (s *sorter) Len() int {
	return len(*s)
}

func (s *sorter) Less(i, j int) bool {
	return (*s)[i].Less((*s)[j])
}

func (s *sorter) Swap(i, j int) {
	(*s)[i], (*s)[j] = (*s)[j], (*s)[i]
}

// Define priority queue struct
type PriorityQueue struct {
	s *sorter
}

func (q *PriorityQueue) Push(x Comparable) {
	heap.Push(q.s, x)
}

// }}}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a,b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3580
n, k = map(int, input().split())

nums = []
for _ in range(n):
  ab = list(map(int, input().split()))
  nums.append(ab)
sn = sorted(nums)

i = 0
while k > 0:
  if sn[i][1] < k:
    k -= sn[i][1]
  else:
    print(sn[i][0])
    break
  i += 1
  


Measured memory_bytes: 28640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
using namespace std;

struct Node {
  int key;
  Node *r, *l, *parent;
};

Node *root, *NIL;

Node *treeMin(Node *x){
  while(x->l != NIL)x = x->l;
  return x;
}

Node *find(Node *u, int k){
  while(u!=NIL && k!=u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }

  return u;
}

Node *treeSuccessor(Node *x){
  if(x->r != NIL)return treeMin(x->r);
  Node *y = x->parent;
  while(y!=NIL && x == y->r){
    x = y;
    y = y->parent;
  }

  return y;
}

void Delete(Node *z){
  Node *y; // delete
  Node *x; //y's child
  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->l != NIL)x = y->l;
  else x = y->r;

  if(x != NIL)x->parent = y->parent;

  if(y->parent == NIL)root = x;
  else {
    if(y == y->parent->l) y->parent->l = x;
    else y->parent->r = x;
  }

  if(y != z) z->key = y->key;

  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)x = x->l;
    else x = x->r;
  }

  z->parent = y;
  if(y == NIL)root = z;
  else {
    if(z->key < y->key)y->l = z;
    else y->r = z;
  }
    
}

void inorder(Node *u){
  if(u == NIL)return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL)return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL)printf("yes\n");
      else printf("no\n");
    }

    else if(com == "insert"){ // Cの場合strcmp,strcpy..を使用
      scanf("%d", &x);
      insert(x);
    }

    else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

    else if(com == "delete"){
      scanf("%d", &x);
      Delete(find(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 21908
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define MOD 1000000007

typedef long long ll;

const ll MAX = 1e10 + 5;

int n, c[26];
string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	F(i,65,91,1){
		c[i-65] = i; 
	}
	cin>>n>>s;
	REP(i,s.size()){
		cout<<char(c[(int(s[i]) - 65 + n) % 26]);
	}
	return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,t,temp,x,y;
string str;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>x;
	ll dis;
	vll v(n);
	for(int i=0;i<n;i++)
	{
	    cin>>temp;
	    v[i]=abs(temp-x);
	}
	ll g=v[0];
	for(int i=1;i<n;i++)
	{
	    g=__gcd(g,v[i]);
	}
	cout<<g;
	
	
	
	
	
}

Measured memory_bytes: 1024
#!/usr/bin/python3

import array
import math
import os
import sys


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


INF = 2 ** 31 - 1


def solve(N, M, A, B, C):
    D = []
    for c in C:
        b = 0
        for v in c:
            b |= 1 << (v - 1)
        D.append(b)

    bits = 1 << N
    dp = array.array('i', [INF] * bits)

    dp[0] = 0
    for a, d in zip(A, D):
        for b in range(bits):
            if dp[b] == INF:
                continue
            nb = b | d
            dp[nb] = min(dp[nb], dp[b] + a)

    if dp[bits - 1] == INF:
        return -1
    return dp[bits - 1]


def main():
    N, M = [int(e) for e in inp().split()]
    A = []
    B = []
    C = []
    for _ in range(M):
        a, b = [int(e) for e in inp().split()]
        c = [int(e) for e in inp().split()]
        A.append(a)
        B.append(b)
        C.append(c)
    print(solve(N, M, A, B, C))


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void){
    int n, l;
    cin >> n >> l;
    int diff = 1000000, sum = 0, point;
    for(int i = 1; i < n+1; i++){
        if(abs(l+i-1) < diff){
            diff = abs(l+i-1);
            point = i;
        }
        sum += l+i-1;
    }
    diff = l+point-1;
    cout << (sum)-(diff) << endl;
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin>>s;
  int n;
  n = s.size()-1;
  if(s.at(n)=='s') cout<<s<<"es"<<endl;
  else cout<<s<<"s"<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> l(n), r(n);
    for (int i = 1; i <= n-1; i++) {
      l[i] = __gcd(l[i-1], a[i-1]);
    }
    for (int i = n-2; i >= 0; i--) {
      r[i] = __gcd(r[i+1], a[i+1]);
    }
    int ans = 0;
    rep(i,n) {
      ans = max(ans, __gcd(l[i],r[i]));
    }
    cout << ans << endl;
    return 0;
}

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

const int MN = 500010;
int L;

char S[MN];
int N[MN], M[MN], R[MN];

void mult(int k, int *n) {
    int ca = 0;
    int i;
    for(i = 0; n[i] != -1; i++) {
        int v = n[i] * k + ca;
        n[i] = v % 10;
        ca = v / 10;
    }
    if(ca) n[i] = ca;
}

void sum() {
    int i, ca = 0;
    memset(R, -1, MN * sizeof(int));
    for(i = 0; N[i] != -1 && M[i] != -1; i++) {
        int v = N[i] + M[i] + ca;
        R[i] = v % 10;
        ca = v / 10;
    }
    for(; N[i] != -1; i++) {
        int v = N[i] + ca;
        R[i] = v % 10;
        ca = v / 10;
    }
    for(; M[i] != -1; i++) {
        int v = M[i] + ca;
        R[i] = v % 10;
        ca = v / 10;
    }
    if(ca) R[i] = ca;
}

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

    memset(N, -1, MN * sizeof(int));
    memset(M, -1, MN * sizeof(int));

    L = 0;
    for(int i = 0; S[i]; i++) L++;
    for(int i = 0; S[i]; i++) N[L - 1 - i] = S[i] - '0';
    mult(9, N);

    int s = 1, e = 1000000;
    int ans;
    while(s <= e) {
        int m = (s + e)>>1;

        memset(M, -1, MN * sizeof(int));

        int tmp = m;
        int d = 0;
        while(tmp) {
            M[d] = tmp % 10;
            tmp /= 10;
            d++;
        }
        mult(9, M);
        sum();

        int dsum = 0;
        for(int i = 0; R[i] != -1; i++) {
            dsum += R[i];
        }
        if(dsum <= 9*m) {
            ans = m;
            e = m - 1;
        }
        else s = m + 1;
    }
    printf("%d", ans);
}


Measured memory_bytes: 6656
n = int(input())

nn = n
nnn = n 

e = []
while n % 2 == 0:
    e.append(2)
    n = n // 2
p = 3
while p * p <= n:
    if n % p == 0:
        e.append(p)
        n = n // p
    else:
        p = p + 2
if n != 1:
    e.append(n)

ue = set(e)
cnt = 0
for f in ue:
    tmpf = f
    while nn % f == 0:
        cnt = cnt + 1
        nn = nn // f
        f = f*tmpf

if nnn == 1:
    print(0)
else:
    print(cnt)




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


int main(){

    int n,m;
    cin >> n >> m;
    int case_1 = m;//1900ms
    int case_2 = n-m;//100ms

    int t_case2 = 100*case_2;
    long long int ans = (1900*m+100*(n-m));
    for(int i = 0;i < m;i++){
        ans*=2;
    }
    cout << ans << endl;
    
    




    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    S.append(s)
P = list(map(int, input().split()))

bit = []
ans = 0


def dfs(cnt):
    if cnt == n:
        for j in range(m):
            if P[j] != sum(bit[idx] for idx in S[j]) % 2:
                break
        else:
            global ans
            ans += 1
    else:
        bit.append(0)
        dfs(cnt+1)
        bit.pop()

        bit.append(1)
        dfs(cnt+1)
        bit.pop()


dfs(0)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a[100001];
	int m,n;
	cin>>n;
	int d=0;
	for(int i=0;i<100001;i++){
		a[i]=0;
	}
	for(int i=0;i<n;i++){
		cin>>m;
		if(m>100000)d++;
		else a[m]++;
	}
	for(int i=0;i<100001;i++){
		if(a[i]<i)d+=a[i];
		else d+=a[i]-i;
	}
	cout<<d<<endl;
}

Measured memory_bytes: 1148
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
int a[maxn];
int b[maxn];
int c[maxn];
ll sumb[maxn];
int numb[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)scanf("%d",&c[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
    for(int i=1;i<=n;i++)
    {
        int num=b[i]+1;
        int nn=lower_bound(c+1,c+n+1,num)-(c);
        numb[i]=n-nn+1;
    }
//    for(int i=1;i<=n;i++)cout<<numb[i]<<' ';
//    cout<<endl;
    for(int i=1;i<=n;i++)sumb[i]=sumb[i-1]+1LL*numb[i];
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        int num=a[i]+1;
        int nn=lower_bound(b+1,b+n+1,num)-(b);
        if(nn<=n)sum+=sumb[n]-sumb[nn-1];
       // cout<<num<<' '<<nn<<endl;
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 2560
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    long long int a,b,c,d;
    
    cin >> a >> b >> c >> d;
    
    cout << max({a*c,a*d,b*c,b*d}) << endl;
    
    return 0;
}

Measured memory_bytes: 3616
/**
    A	Darker and Darker    	C++14 (GCC 5.4.1)
    Accept
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>    // std::copy
#include <iterator>     // std::back_inserter
#include <set>
using namespace std;
 
int main(){
    int N,D ;
    cin >> N >> D ;

    if( (N % (2 * D + 1)) == 0) {
        cout << N / (2 * D + 1 ) << endl;
    }
    else {
        cout << N / (2 * D + 1) + 1 << endl;
    }
    // int count = 0;
    // for(int i = 0 ; i < 20 ; i++){
    //     if(N <= 0) break;
    //     N -= 2 * D;
    //     count++;
    // }

    // cout << count << endl;
    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++)
    cin >> l.at(i);
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  for (int i = 0; i < K; i++)
    ans += l.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    ll x = 1;
    REP(i, N)
    {
        x = a[x - 1];
        if (x == 2)
        {
            OUT(i + 1);
            return 0;
        }
    }
    OUT(-1);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
#define hell 1000000007

using namespace std;
void solve()
{
double m,i,j,d=1,b,c=0,sum=0,z=0,x=0,y=0,n;
int k,q,b1;
cin>>n>>k;
for(i=1;i<=n;i++)
{
    y=0; d=1;
    q=0;
    b=double(k)*1.000000000000;
   z=b/i;
   q=int(log2(z));
   if((1<<q)*i < k ) q++;
    rep(j,0,q) d/=2;
    c+=d;
}
c/=n;
cout<<fixed<<setprecision(12)<<c<<endl;
}



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

 int t=1;
//cin>>t;
 while(t--)
  solve();
}


Measured memory_bytes: 256