akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

ll N;
ll nt, nb;

ll count(ll t, ll b, ll size) {
    ll ret = 0;
    if (t == b) {
        if (t <= N) {
            ret++;
        }
    }
    if (b * 10 + t <= N) {
        ret++;
    }
    ll n_size = 3;
    ll tmp = 10;
    while (n_size < size) {
        ret += tmp;
        tmp *= 10;
        n_size++;
    }
    if (size >= 3) {
        tmp *= 10;
        ll now = t;
        now += b * tmp;
        if (now <= N) {
            if (b < nt) {
                ret += tmp / 10;
            } else if (b == nt) {
                if (t <= nb) {
                    ll mid = (N - nt * tmp) / 10;
                    // cout << mid << endl;
                    ret += mid + 1;
                } else if (t > nb) {
                    ll mid = (N - nt * tmp) / 10;
                    // cout << mid << endl;
                    ret += mid;
                }
            }
        }
    }

    return ret;
}

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

    cin >> N;
    ll size = 1;
    ll tmp = N;
    nb = tmp % 10;
    nt = tmp % 10;
    while (tmp / 10) {
        tmp /= 10;
        size++;
        nt = tmp % 10;
    }

    // cout << "nt:" << nt << " size:" << size << endl;

    ll ans = 0;
    FOR(a, 1, N + 1) {
        ll now = a;
        ll b = now % 10;
        ll t = b;
        while (now / 10) {
            now /= 10;
            t = now % 10;
        }
        if (t != 0 && b != 0) {
            ans += count(t, b, size);
            // cout << "a:" << a << " t:" << t << " b:" << b << " count:" << count(t, b, size) << endl;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: E: Range Minimum Queries
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 2000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N], ds[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);

  for (int i = 0; i < n; i++) scanf("%d", &as[i]), bs[i] = as[i];
  sort(bs, bs + n);

  int mindf = INF;
  for (int xi = 0; xi < n; xi++) {
    int &x = bs[xi];

    int p = 0;
    for (int i = 0; i < n;) {
      while (i < n && as[i] < x) i++;
      if (i >= n) break;

      int j = i, m = 0;
      while (j < n && as[j] >= x) cs[m++] = as[j++];
      if (m >= k) {
	sort(cs, cs + m);
	for (int l = 0; l <= m - k;) ds[p++] = cs[l++];
      }
      i = j;
    }

    if (p >= q) {
      sort(ds, ds + p);
      int df = ds[q - 1] - x;
      if (mindf > df) mindf = df;
    }
    else break;
  }

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


Measured memory_bytes: 256
s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=sum
        break

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    nex=int(it)+int(1)
    print(s[it:nex])

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

int main(){
  int n,s,t;
  std::cin>>n;

  std::vector<int>a;
  int x;
  for(int i=0;i<n;i++){
    std::cin>>x;
    a.push_back(x);
  }

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

    s=a[i];
    t=i-1;
    while(t>=0 && a[t]>s){
      a[t+1]=a[t];
      t--;
    }
    a[t+1]=s;

    for(int j=0;j<n;j++){
      if(j==n-1){
	std::cout<<a[j]<<"\n";
	break;
      }
      std::cout<<a[j]<<" ";
    }

  }

  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main() {
    int n,t[100010],x[100010],y[100010],nx=0,ny=0,hoge=0,nt=0;
    bool ok = true;
    cin >> n;
    for(int i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
    for(int i=0;i<n;i++){
        hoge = abs(nx-x[i]) + abs(ny-y[i]);
        nx = x[i];
        ny = y[i];
        if(abs((t[i]-nt) - hoge)%2 != 0 || (t[i]-nt) < hoge)ok = false;
        nt = t[i];
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
	{
		int m=a+b;
		int n=a-b;
		int t=a*b;
		cout<<max(m,max(n,t))<<endl;
	}
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

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

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VVL dp(3,VL(100001));
	const int MAX = 100000;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j <= MAX; j++) {
			dp[i][j] = j;
		}
	}
	for (int i = 0; i <= MAX; i++) {
		for (int j = 6; j <= int(pow(6,6)); j *= 6) {
			if (i - j < 0) {
				continue;
			}
			dp[1][i] = dp[1][i-j] + 1;
			dp[2][i] = dp[1][i];
		}
	}
	for (int i = 0; i <= MAX; i++) {
		for (int j = 9; j <= int(pow(9,5)); j *= 9) {
			if (i - j < 0) {
				continue;
			}
			dp[2][i] = min(dp[2][i-j] + 1,dp[2][i]);
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}


Measured memory_bytes: 3328
n = int(input())
l = list(map(int, input().split()))
if n <= 2:
    print(1)
    quit()
h = 0
ans = 1
for i in range(n - 1):
    if (l[i + 1] - l[i]) * h < 0:
        ans += 1
        h = 0
        continue
    if l[i + 1] - l[i] < 0:
        h = -1
    elif l[i + 1] - l[i] > 0:
        h = 1
print(ans)

Measured memory_bytes: 14252
package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	A := ReadInts(N)
	for i := K; i < N; i++ {
		if A[i] > A[i-K] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
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()
{
int n;
string s,t;
cin >> n >> s >> t;

rep(i,n) cout << s[i] << t[i] ;



return 0;
}

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

using namespace std;

int main()
{
    int a, b;
    while(1)
    {
    cin >> a >>  b;


    if(a == 0 && b == 0)
    { break; }
    if(a > b)
        cout << b << " " << a << endl;
        else 
        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
n = int(input())
mod = 10 ** 9 + 7
a = list(map(int,input().split()))
b = []
for i in range(1,n):
  b.append(a[i]-a[i-1])
c = [1]
def inv(x):
  y = 1
  while x != 1:
    y *= mod // x + 1
    y %= mod
    x -= mod % x
  return y
#print(inv(5))
#print(inv(2))
for i in range(2,n):
  c.append((c[-1]+inv(i))%mod)
#print(c)
ans = 0
for i in range(n-1):
  ans += c[i] * b[i]
  ans %= mod
fact = 1
for i in range(1,n):
  fact *= i
  fact %= mod
ans *= fact
ans %= mod
print(ans)

Measured memory_bytes: 64664
#include <bits/stdc++.h>
#define PB push_back
#define FT first
#define SD second
#define MP make_pair
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>  P;
const int N = 5e3 + 10,MOD = 7+1e9;
char s[N];
vector<string> V;
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int k;
    cin >> s >> k;
    int len = strlen(s);
    int b = min(len, k);
    for(int i = 0;i < len;i ++)
    {
        string ss = "";
        for(int j = 0;j < b && i + j < len;j ++)
        {
            ss += s[i+j];
            V.PB(ss);
        }
    }
    sort(V.begin(), V.end());
    int sz = V.size(), cnt = 1;
    for(int i = 0;i < sz;)
    {
        if(cnt == k)
        {
            cout << V[i];
            return 0;
        }
        int j = i + 1;
        while(j < sz && V[j].compare(V[i]) == 0) j ++;
        cnt ++, i = j;
    }
    if(cnt == k)
        cout << V[sz-1];
    return 0;
}

Measured memory_bytes: 1660
#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;
  map<int,int> mp;
  rep(i,n) {
    int x;
    cin >> x;
    mp[x]++;
  }
  int ans = 0;
  for(auto p: mp) {
    if(p.second<p.first) ans += p.second;
    else ans += p.second-p.first;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4736
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def check(W, N, k, su, s):
    vs = [0]*(N+2)
    vs[1] = r = 1
    p = q = 0
    for i in range(N):
        while (su[i+1] - su[p]) + (i - p)*s >= W:
            p += 1
        while (su[i+1] - su[q]) + (i - q) > W:
            q += 1
        vs[i+2] = r = r + (vs[p] > vs[q])
        if r == vs[q]:
            return k < i+2 and r - vs[k]
    return vs[N+1] - vs[k]
def solve():
    W, N = map(int, readline().split())
    if W == N == 0:
        return False
    *X, = map(int, readline().split())
    su = [0]*(N+1)
    for i in range(N):
        su[i+1] = su[i] + X[i]
    k = N
    while k > 0 and su[N] - su[k-1] + (N-k+1) <= W:
        k -= 1

    ma = 0
    cu = X[0]; c = 1
    for i in range(1, N):
        if cu + c + X[i] > W:
            ma = max(ma, (W - cu + c-2) // (c-1))
            cu = X[i]
            c = 1
        else:
            cu += X[i]
            c += 1

    left = 0; right = ma+1
    while left+1 < right:
        mid = (left + right) >> 1
        if check(W, N, k, su, mid):
            right = mid
        else:
            left = mid
    write("%d\n" % right)
    return True
while solve():
    ...


Measured memory_bytes: 11956
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    set<int> a;
    int tmp = 0, x;
    for (int i=0; i<3; i++) {
        cin >> tmp;
        a.insert(tmp);
    }
    x = a.size();
    if (x == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	for (int i = 0; i < min(n, k); i++) {
		sum -= a[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1792
(format t"~{~A ~}"(subseq'(11 31 41 61 71 101 131 151 181 191 211 241 251 271 281 311 331 401 421 431 461 491 521 541 571 601 631 641 661 691 701 751 761 811 821 881 911 941 971 991 1021 1031 1051 1061 1091 1151 1171 1181 1201 1231 1291 1301 1321 1361 1381)0(read)))

Measured memory_bytes: 2792
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int A,B,C,D,E,F;

int mx[3100];

int main()
{
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	mx[C]=C;
	mx[D]=D;
	pii res=mp(0,min(A,B)*100);
	for(int i=1;i<3100;i++)if(mx[i]==i)
	{
		if(i+C<3100)mx[i+C]=i+C;
		if(i+D<3100)mx[i+D]=i+D;
	}
	repn(i,1,3100)if(mx[i]!=i)mx[i]=mx[i-1];
	repn(t1,0,31)repn(t2,0,31)
	{
		int w=A*t1+B*t2;w*=100;
		if(w==0)continue;
		if(w>F)continue;
		int st=mx[min(F-w,(A*t1+B*t2)*E)];
		pii r=mp(st,st+w);
		if(res.fi*r.se<res.se*r.fi)res=r;
	}
	printf("%d %d\n",res.se,res.fi);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<vector<ll> >a(n,vector<ll>(n));
    rep(i,n)rep(j,n)cin>>a[i][j];
    vector<vector<ll> >dp(n+1,vector<ll>(1<<(n)));
    dp[0][0]=1;
    rep(i,n){
        rep(j,(1<<n)){
            if(dp[i][j]==0)continue;
            rep(k,n){
                if(a[i][k]&&((1<<k)&j)==0){
                    ll s=j;
                    s+=(1<<(k));
                    dp[i+1][s]+=dp[i][j];
                    dp[i+1][s]%=inf;
                }
            }
        }
    }
    cout<<dp[n][(1<<n)-1]<<endl;
}

Measured memory_bytes: 377216
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

// abどちらが大きくてもいけるよ
int gcd(int a,int b){
    return b ? gcd(b, a % b) : a;
}

// 使う時はgcdも呼び出してあげよう
int lcm(int a,int b){
    return a / gcd(a,b) * b;
}
// 使う時はlcmとgcdも呼び出してあげよう
int nlcm(vector<int> a){
    int res = a.at(0);
    for(int i = 1;i < a.size();i ++){
        res = lcm(res,a.at(i));
    }

    return res;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> t(n);
    for(int i = 0;i < n;i ++) cin >> t.at(i);

    cout << nlcm(t) << endl;
}







Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    from fractions import gcd
    #ma = -1
    n = int(input())
    A = readInts()
    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(n):
        left[i+1] = gcd(left[i],A[i])
    for i in range(n-1,-1,-1):
        right[i] = gcd(right[i+1],A[i])
    # 集計
    res = 0
    for i in range(n):
        l = left[i]
        r = right[i+1]
        res = max(res,gcd(l,r))
    print(res)

if __name__ == '__main__':
  main()


Measured memory_bytes: 16128
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << (A*B>C*D ? A*B : C*D) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int n, m, c, cnt = 0;
	cin >> n >> m >> c;
	vector<int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < n; ++i) {
		int sum = 0, x;
		for (int j = 0; j < m; ++j) {
			cin >> x;
			sum += b[j] * x;
		}
		if (sum + c > 0) {
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 50 + 10;

int a[N],sum[N];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cout << setprecision(10) << fixed ;
   int n;
   cin >> n;
   vector<ld> s(n);
   f(i,0,n){
      cin >> s[i];
   }
   sort(all(s));
   ld sum = s[0]+s[1];
   sum  =sum/2;
   f(i,2,n){
      sum += s[i];
      sum = sum/2;
   }
   cout << sum << '\n';
   return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  int x;
  cin>>x;
  vector<ll> p;
  for(i=2;i<=110000;i++){
    int q=(int)round(sqrt(i));
    bool flg=1;
    for(j=2;j<=q;j++){
      if(i%j==0){
        flg=0;
        break;
      }
    }
    if(flg)p.push_back(i);
  }
  bool isPrime[110000];
  for(i=0;i<=110000;i++)isPrime[i]=0;
  for(i=0;i<p.size();i++){
    isPrime[p[i]]=1;
  }
  for(i=x;;i++){
    if(isPrime[i]){
      cout<<i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int N, C;
vector<vector<int>> D;
vector<vector<int>> c;
vector<int> nCol[3];

int calc(int l, int m, int n) {
	if (l == m || m == n || n == l) return inf;

	int ret = 0;
	for (int i = 0; i < 3; i++) for (int j = 0; j < C; j++) {
		if (i == 0) ret += nCol[i][j] * D[j][l];
		if (i == 1) ret += nCol[i][j] * D[j][m];
		if (i == 2) ret += nCol[i][j] * D[j][n];
	}
	return ret;
}

int main() {
	cin >> N >> C;
	D = vector<vector<int>>(C, vector<int>(C, 0));
	c = vector<vector<int>>(N, vector<int>(N, 0));
	for (int i = 0; i < 3; i++) {
		nCol[i] = vector<int>(C);
		fill(nCol[i].begin(), nCol[i].end(), 0);
	}

	for (int i = 0; i < C; i++) for (int j = 0; j < C; j++) cin >> D[i][j];
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
		cin >> c[i][j];
		c[i][j]--;
		nCol[(i + j) % 3][c[i][j]]++;
	}

	int ans = inf;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				ans = min(ans, calc(i, j, k));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
int main() {
	int a;
	cin >> a;
	cout << 3 * a * a;


}
	


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long long a, long long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long long a, long long b){
	return a / gcd(a,b) * b;
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int n,m;
pair <int , int> c[5];
int num[3];
int f;

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

	REP(i,3) num[i] = -1;

	REP(i,m){
		cin >> c[i].first >> c[i].second;

		if (num[c[i].first-1] == c[i].second || num[c[i].first-1] == -1) num[c[i].first-1] = c[i].second;
		else f = -1;
	}

	if (num[0] == 0){
		if (n == 1) f = 1;
		else f = -1;
	}

	if (num[0] == -1){
		if (n == 1) f = 1;
		else {
			num[0] = 1;
		}
	}

	if (num[1] == -1) num[1] = 0;
	if (num[2] == -1) num[2] = 0;

	if (f == 1) cout << 0 << endl;
	else if (f == -1) cout << -1 << endl;
	else {
		REP(i,n) cout << num[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int main() {
	int n, temp;
	cin >> n;
	vector<pair<int, int>>a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		a[i].first = temp;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++)
	{
		cout << a[i].second << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1536
#if !defined(ONLINE_JUDGE)
    #include "prettyprint.hpp" 
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 1729
    #define cer(x) 13
#endif
const bool testcase=0;
typedef long long int ll;
#define INF LONG_MAX
#define MINF LONG_MIN 
#define MAXR 111111
const ll mod1 = 1000000007;
const ll mod2 = 998244353;



//loop 
#define loop(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define loope(i,L,R) for (int i = L; i <= R; i++)
#define rloop(i,L,R) for (int i = L; i > R; i--)
#define rloope(i,L,R) for (int i = L; i >= R; i--)
#define nl cout<<'\n'



//misc
#define sz(x) ((int)((x).size()))
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL) 
#define checkbit(n,b) ( (n >> b) & 1)
#define test int _T_=1;if(testcase){cin>>_T_;}while(_T_--)



//vector
#define lastEle(vec) vec[vec.size()-1]
#define all(ve) ve.begin(),ve.end()
#define rall(x) x.rbegin(),x.rend()
#define fi first
#define se second



template<typename T>inline T mmod(T a,T b,T mod){return ((a%mod)*(b%mod))%mod;}
template<typename T>inline T smod(T a,T b,T mod){return ((a%mod)+(b%mod))%mod;}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.fi>>a.se;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

ll lcm(ll a,ll b){return (max(a,b)/__gcd(a,b))*min(a,b);} 

// MAIN
void solve();
int main(){
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
    fast;
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
        // for debug in error.txt
        freopen("error.txt", "w", stderr);
    #endif
    test {
        solve();
    }
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cerr << "\nElapsed Time: " << elapsed_time << "ms\n";
    return 0;
}


// SOLVE 

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    loop(i,1,n){
        ans += (n-1)/i;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  long long N,K;
  scanf("%lld %lld",&N,&K);
  long long ans=K;
  for(long long i=1;i<N;i++){
    ans=ans*(K-1);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
c = Counter()
cnt = 0
N,M = map(int,input().split())
for i in range(N):
    src = list(map(int,input().split()))
    for j in src[1:]:
        c[j] += 1

for i in c:
    if c[i] == N:
        cnt += 1
print(cnt)

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        for (int i=0; i<n; ++i) {
            cin >> a[i];
        }
        int x = 32;
        int k = 0;
        while (x) {
            x = max(0, x - (x - 1) % 5);
            cout << x << endl;
            if ( ! x) break;
            x = max(0, x - a[k]);
            cout << x << endl;
            k = (k + 1) % n;
        }
    }
    return 0;
}

Measured memory_bytes: 1192
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long int ll;

const int MAXN = 6000;

int N, K;
int a[MAXN];
bool dp[MAXN][MAXN];

bool check(int p) {
    for (int j = 0; j <= K; ++j) {
        dp[0][j] = false;
    }

    for (int i = 0; i < N; ++i) {
        if (i != p) {
            for (int j = 0; j < K; ++j) {
                if (j == a[i]) {
                    dp[i][j] = true;
                } else if (i) {
                    dp[i][j] = dp[i-1][j];
                    if (j > a[i]) {
                        dp[i][j] = dp[i][j] || dp[i-1][j-a[i]];
                    }
                } else {
                    dp[i][j] = false;
                }

                if (K - a[p] <= j && dp[i][j]) {
                    return true;
                }
            }
        } else if (i) {
            for (int j = 0; j < K; ++j) {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    return false;
}

int main() {
    scanf("%d %d", &N, &K);

    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    sort(a, a + N);

    int lb = 0, rb, md;
    for (rb = 0; rb < N && a[rb] < K; ++rb) {}
    while (lb < rb) {
        md = (lb + rb) / 2;

        if (check(md)) {
            rb = md;
        } else {
            lb = md + 1;
        }
    }

    printf("%d", lb);

    return 0;
}

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

const int N = 30;

int h, w;
string s[N][N];

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(s[i][j] == "snuke") {
        cout << (char)('A' + j) << i + 1 << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int N=sc.nextInt();
				int M=sc.nextInt();
				if(N+M==0)    break;
				int[] ds = new int[11];
				for(int i=0; i<N; i++) {
					int d = sc.nextInt();
					int p = sc.nextInt();
					ds[p] += d;
				}
				int P = 0;
				for(int p= 10; p >=0; p--) {
					if(M >= ds[p]) {
						M -= ds[p];
					}
					else {
						P += (ds[p] - M) * p;
						M = 0;
					}
				}
				System.out.println(P);
			}
		}
	}
}


Measured memory_bytes: 99604
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = long.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            long r = 0;
            long g = 0;
            long b = 0;
            for (var i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case 'R': r++; break;
                    case 'G': g++; break;
                    case 'B': b++; break;
                }
            }

            long count = r * g * b;
            for (var i = 0; i < n; i++)
            {
                for (var j = i + 1; j < n; j++)
                {
                    var k = j + j - i;
                    if (k >= n) continue;
                    if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) count--;
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
  int n, m;
  cin >> n >> m;
  ll p = 1;
  rep(i, 0, m)p *= 2;
  cout << (1900*m+100*(n-m))*p <<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    int ans=0;
    string s,t;
    cin>>s>>t;
    rep(i,s.size()){
        if(s.at(i)!=t.at(i))ans++;
    }
   
    
    cout<<ans<<endl;
}



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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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


int n;
ll a[20][20], dp[1<<17], suma[1<<17];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i =0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin>>a[i][j];
        }
    }
    for(int mask = 1; mask<(1<<n); ++mask){
        for(int i =0; i<n; ++i)
            if(mask&(1<<i))
                for(int j =i+1; j<n; ++j)
                    if(mask&(1<<j))
                        suma[mask]+=a[i][j];
    }
    for(int mask = 1; mask<(1<<n); ++mask){
        dp[mask] = suma[mask];
        for(int s = mask; s; s=(s-1)&mask){
            int xs = mask^s;
            dp[mask] = max(dp[mask],dp[s]+dp[xs]);
        }
    }
    cout<<dp[(1<<n)-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1280
import math

def primelist(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def factorization(n):
    plist = primelist(int(n**0.5))
    factor = []
    for p in plist:
        k = 0
        while n%p==0:
            k+=1
            n//=p
        if k>0:
            factor.append((p,k))
        if n==1:
            break
    if n!=1:
        factor.append((n,1))

    return factor

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def main():
    a,b = tuple(map(int,input().split()))

    g = math.gcd(a,b)
    factors = factorization(g)
    print(len(factors)+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int a[1005];
int main(){
    int n,m,sum=0,num=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=1;i<=n;i++){
        if(a[i]*4*m>=sum) num++;
    }
    if(num>=m){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<vector<int> > dp(500, vector<int>(500, INF));
vector<pii> drug(50);
vector<int> cost(50);
int n, ma, mb;
/* function */
void initDPTable() {dp[0][0] = 0;}
void calcDPTable() {
    for (int i = 0; i < n; i++) {
        for (int j = 400; j >= 0; j--) {
            for (int k = 400; k >= 0; k--) {
                int nj = j + drug[i].first;
                int nk = k + drug[i].second;
                dp[nj][nk] = min(dp[nj][nk], dp[j][k] + cost[i]);
            }
        }
    }
}
void calcAns() {
    int ans = INF;
    for (int j = 1; j <= 400; j++) {
        for (int k = 1; k <= 400; k++) {
            if (ma * k == mb * j) {
                ans = min(ans, dp[j][k]);
            }
        }
    }
    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
}
/* main */
int main() {
    cin >> n >> ma >> mb;
    int a, b, c;
    for (int i = 0; i < n; i++) {
        cin >> a >> b >> c;
        drug[i] = pii(a, b);
        cost[i] = c;
    }
    initDPTable();
    calcDPTable();
    calcAns();
}

Measured memory_bytes: 1280
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string w;
    cin >> w;
    int N = w.size();
    vb check(N, false);
    for (int i = 0; i < N; i++) {
        if (check.at(i)) {
            continue;
        }
        char c = w.at(i);
        int count = 1;
        for (int j = i + 1; j < N; j++) {
            if (w.at(j) == c) {
                count++;
                check.at(j) = true;
            }
        }
        if (count % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

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

const int maxN = 4e2 + 10;
const ll inf = 1e18;

int n;
ll a[maxN];
ll pre[maxN];
ll dp[maxN][maxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    fore(d, 2, n)
    {
        for1(i, n - d + 1)
        {
            int j = i + d - 1;
            dp[i][j] = inf;
            fore(k, i, j - 1)
            {
                uin(dp[i][j], dp[i][k] + dp[k + 1][j]);
            }
            dp[i][j] += pre[j] - pre[i - 1];
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string N;
    cin >> N;
    if(N.size() > 1 && N[N.size()-1] != '9') {
        cout << N[0]-'0'+9*(N.size()-1)-1 << endl;
    }
    else {
        cout << N[0]-'0'+9*(N.size()-1) << endl;
    }
}


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

int main(){

for (;;){



	int i, j, h, w;
	cin >> h >> w;
			if (h == 0 && w == 0)
			break;

		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){

				if ((i + j) % 2 == 0)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

int main(void) {
    int A, B, K; cin >> A >> B;
    if (abs(A + B) % 2 == 0) {
        cout << abs(A + B)/2 << endl; 
    }else {
        cout << "IMPOSSIBLE" << 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(){
    int N,count=0;
    cin >> N;
    vector<long long> L(N);
    rep(i,N){
        cin >> L.at(i);
    }
    sort(L.begin(), L.end());

    //int Li=0,Lj=0,Lk=0;
    if(N>2){
    rep(i,N){
        rep(j,N){
            rep(k,N){
                if(i<j && j<k){
                if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)){
                    if(L.at(i)+L.at(j)>L.at(k) && L.at(j)+L.at(k)>L.at(i) && L.at(k)+L.at(i)>L.at(j)){
                        count++;
                    }
                }
                }
            }
        }

    }
    }
    cout << count << endl;

}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n, h;
    cin >> n >> h;
    vi b(n);
    int ma = INT_MIN;
    REP(i, n) {
        int a;
        cin >> a >> b[i];
        ma = max(ma, a);
    }
    sort(ALL(b), greater<int>());
    int cnt = 0;
    for(cnt = 0; cnt < n && h > 0; cnt++) {
        if(b[cnt] > ma) h -= b[cnt];
        else break;
    }
    cout << cnt + max(0, ((h + ma - 1) / ma)) << "\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int int64_t

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int x; cin >> x; 
    cout << (x^1) << '\n'; 
    return 0;
}


Measured memory_bytes: 3568