akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<string>vc;
int n;

int fact(int n){

int facti=1;
while(n>0){

    facti=facti*n;
    n--;

}
return facti;




}
int main()

{


cin>>n;
vector<pair<int,int>>vc;
 int arr[n];
 int x[n],y[n];
 for(int i=0;i<n;i++)arr[i]=i+1;
for(int i=1;i<=n;i++){

        cin>>x[i]>>y[i];
        }

  sort(arr,arr+n);
  int j=0;
  double sum=0;

  do {
        for(int i=0;i+1<n;i++){
                //cout<<arr[i]<<" ";
        sum+=sqrt((x[arr[i]]-x[arr[i+1]])*(x[arr[i]]-x[arr[i+1]]) +  ( y[arr[i]]-y[arr[i+1]]) *( y[arr[i]]-y[arr[i+1]]));
       // cout<<sum;

                }
          //cout<<endl;
  }
  while ( next_permutation(arr,arr+n) );




  cout<<setprecision(10)<<sum/fact(n);






  return 0;
}




Measured memory_bytes: 256
n,m = map(int, input().split())
INF = 1000*n+1
#edges = [[] for _ in  range(m)]
edge = [[INF for _ in range(n)] for _ in range(n)]
d = [[INF for _ in range(n)] for _ in range(n)]

abc = [list(map(int, input().split())) for _ in range(m)]
for a,b,c in abc:
    
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c
    

def dijkstra(i):
    #d = [INF for _ in range(n)] 
    d[i][i] = 0
    used = [False] * n

    while True:
        v = -1
        for j in range(n):
            if used[j] == False and (v == -1 or d[i][j] < d[i][v]):
                v = j
        if v == -1:
            break
        used[v] = True
        for k in range(n):

            d[i][k] = min(d[i][k], d[i][v] + edge[v][k])
            d[k][i] = d[i][k]


for i in range(n):
    dijkstra(i)
#print(edge)
#print(d)
ans = 0
for a, b, c in abc:
    if d[a-1][b-1] < c:
        ans += 1

print(ans)


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N,K;cin >> N >> K;
    vector<ll> A(N),F(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> F[i];
    sort ALL(A);reverse ALL(A);
    sort ALL(F);
    ll L = -1,R = 1e12 + 1,cost = 0,mid = INF,ans = INF;
    while(R - L > 1){
        cost = 0;
        mid = L + (R - L)/2;
        REP(i,N){
            if(A[i] * F[i] > mid) cost += A[i] - (mid) / F[i];
        }
        if(cost <= K){
            ans = mid;
            R = mid;
        }
        else if(cost > K){
            L = mid;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N=200200;
const ll oo=1000000000000000000ll;
int i,j,k,n,m,ch,ff,En,a,v;
ll l,r,mid;
int h[N];
struct cc { ll a,b;} t;
vector<cc> Tmp;
struct edge { int s,n,v;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y,int v) {
	E[++En].s=y;E[En].v=v;
	E[En].n=h[x];h[x]=En;
}
void Add(vector<cc> &A,const cc &t) {
	if (A.empty() || A[A.size()-1].b>t.b) A.push_back(t);
}
vector <cc> dfs(int x,ll V) {
	if (!h[x]) return Tmp;
	vector<cc> A[2],B[2],Ans;
	int i,j,k,l,nm=0;
	for (k=h[x];k;k=E[k].n) {		
		A[nm]=dfs(E[k].s,V);
		for (i=0;i<A[nm].size();i++) A[nm][i].a+=E[k].v,A[nm][i].b+=E[k].v;
		if (A[nm].empty()) return A[nm];
		nm++;
	}
	k=0;
	if (A[0].size()>A[1].size()) k=1;
	j=-1;l=k^1;
	for (i=0;i<A[k].size();i++) {
		int fg=0;
		while (j+1<A[l].size() && A[k][i].b+A[l][j+1].a<=V) j++,fg=1;
		if (fg) {
			t.a=A[k][i].a;
			t.b=A[l][j].b;
			B[k].push_back(t);
		}
	}
	j=A[l].size();
	for (i=A[k].size()-1;i>=0;i--) {
		int fg=0;
		while (j-1>=0 && A[k][i].a+A[l][j-1].b<=V) j--,fg=1;
		if (fg) {
			t.a=A[l][j].a;
			t.b=A[k][i].b;
			B[l].push_back(t);
		}
	}
	for (i=0;i+i+1<B[l].size();i++) {
		t=B[l][i];B[l][i]=B[l][B[l].size()-i-1];B[l][B[l].size()-i-1]=t;
	}
	int p[2];
	p[0]=0;
	p[1]=0;
	while (p[0]<B[0].size() && p[1]<B[1].size()) {
		if (B[0][p[0]].a==B[1][p[1]].a) {
			t.a=B[0][p[0]].a;
			t.b=min(B[0][p[0]].b,B[1][p[1]].b);
			Add(Ans,t);
			p[0]++;p[1]++;
		}
		else {
			if (B[0][p[0]].a<B[1][p[1]].a) k=0;
			else k=1;
			Add(Ans,B[k][p[k]]);
			p[k]++;
		}
	}
	for (k=0;k<2;k++) {
		while (p[k]<B[k].size()) Add(Ans,B[k][p[k]]),p[k]++;
	}
	return Ans;
}
int main() {
	Tmp.push_back(t);
	R(n);
	for (i=2;i<=n;i++) {
		R(a);R(v);
		E_add(a,i,v);
	}
	l=0;r=oo;
	while (l<r) {
		mid=(l+r-1)>>1;
		if (dfs(1,mid).empty()) l=mid+1;
		else r=mid;
	}
	printf("%lld\n",l);
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n; cin >> n;
	long long ans = n - 1;
	for(long long i = 1; i * i <= n; i++){
		if(n % i == 0){
			long long a = i, b = n / i;
			ans = min(ans, a - 1 + b - 1);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def div_pairs(n):
    for i in range(1, n + 1):
        if i * i > n:
            break
        d, m = divmod(n, i)
        if m == 0:
            yield (i, d)


def f(a, b):
    return max(len(str(a)), len(str(b)))


def solve(n):
    return min(f(a, b) for a, b in div_pairs(n))


def main():
    print(solve(int(input())))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 3.141592653589793

int main(){
    int a,b,C;
    double S,L,h,rad;
    
    cin >> a >> b >> C;
    rad = C*PI/180.0;
    S = (a*b*sin(rad))/2;
    L = a+b+(sqrt(a*a+b*b-2*a*b*cos(rad)));
    h = 2*S/a;
    
    printf("%f\n%f\n%f\n" ,S ,L ,h);

    return 0;
}

Measured memory_bytes: 1188
from itertools import groupby

S = input()

l = [0]*(S[0]=="<") + [len(list(g)) for k, g in groupby(S)] + [0]*(S[-1]==">")

s = 0
m = [0]*(len(l)//2)
for i in range(0, len(l)//2):
    a, b = l[i*2], l[i*2+1]
    m[i] = b
    if i >= 1:
        m[i-1] = min(m[i-1], a)
    s += int((a+1)*(a/2) + (b+1)*(b/2))

print(s-sum(m[:-1]))

Measured memory_bytes: 8328
// #define pragma

#ifdef pragma
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // pragma

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define all(x) begin(x), end(x)
#define pb push_back
#define x first
#define y second
#define int long long
#define zero(two) memset(two, 0, sizeof(two))

using namespace std;
using namespace __gnu_pbds;


typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<vi> matrix;
template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = atan2(0, -1);

void seriy() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    cout << fixed << setprecision(10);
    #if _offline
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

const int MAXN = 5e3 + 10;
const int INF = 1e18 + 7;
const int MAXLOG = 31;
const int MOD = 1e9 + 7;
const int BASE = 47;

signed main() {
    seriy();
    vi a(5);
    for(int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;
    sort(all(a));
    if(a[4] - a[0] > k) {
        cout << ":(";
    }
    else {
        cout << "Yay!";
    }
    return 0;
}


Measured memory_bytes: 256
n,l=map(int,input().split())
apples = [l+i for i in range(n)]
sumap = sum(apples)
minap=10**9
diff=10**9
for ap in apples:
	if abs((sumap-ap)-sumap)<=diff:
		diff = abs((sumap-ap)-sumap)
		minap = ap
print(sumap-minap)

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = (int) 2e5 + 7;
int n, col[N], sub[N], pr[N];
vector<int> g[N];
ll su[N], sol[N];

void build(int a) {
  sub[a] = 1;
  vector<int> kids;
  for (auto &b : g[a]) {
    if (sub[b] == 0) {
      pr[b] = a;
      kids.push_back(b);
      build(b);
      sub[a] += sub[b];
    }
  }
  g[a] = kids;
}

ll f(ll len) {
  return len * (len + 1) / 2;
}

void dfs(int a) {
  int ini1 = su[col[a]];
  int ini2 = su[col[pr[a]]];
  for (auto &b : g[a]) {
    dfs(b);
  }
  su[col[a]] = ini1 + sub[a];
  int tot = su[col[pr[a]]] - ini2;
  tot = sub[a] - tot;
  sol[col[pr[a]]] += f(tot);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> col[i];
  }
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  build(1);
  dfs(1);
  for (int i = 1; i <= n; i++) {
    sol[i] += f(sub[1] - su[i]);
    sol[i] = f(n) - sol[i];
    cout << sol[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 44900
N = int(input())
L_s = str(input()).split(" ")
L = []
for l in L_s:
    L.append(int(l))

max_v = int(max(L))
L.pop(L.index(max(L)))

sum = 0
for i in L:
    sum += int(i)

if max_v < sum:
    print("Yes")
else:
    print("No")


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

int main(){
  
  int n;cin>>n;
  int a[n];
  map<int,int> mp;
  
  for(int i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]=0;
  }
  int sum=0;
  
  for(pair<int,int> x:mp){
    sum++;
  }
 
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] dice = Console.ReadLine().Split(' ');
            int q = int.Parse(Console.ReadLine());

            while(q-->0)
            {
                string str = Console.ReadLine();
                
                if(str.Equals(dice[0]+" "+dice[1])|| str.Equals(dice[1] + " " + dice[5])|| str.Equals(dice[5] + " " + dice[4])|| str.Equals(dice[4] + " " + dice[0]))
                        Console.WriteLine(dice[3-1]);
                if (str.Equals(dice[1] + " " + dice[0]) || str.Equals(dice[0] + " " + dice[4]) || str.Equals(dice[4] + " " + dice[5]) || str.Equals(dice[5] + " " + dice[1]))
                        Console.WriteLine(dice[4-1]);
                if (str.Equals(dice[2] + " " + dice[1]) || str.Equals(dice[1] + " " + dice[3]) || str.Equals(dice[3] + " " + dice[4]) || str.Equals(dice[4] + " " + dice[2]))
                        Console.WriteLine(dice[6-1]);
                if (str.Equals(dice[1] + " " + dice[2]) || str.Equals(dice[2] + " " + dice[4]) || str.Equals(dice[4] + " " + dice[3]) || str.Equals(dice[3] + " " + dice[1]))
                        Console.WriteLine(dice[1-1]);
                if (str.Equals(dice[0] + " " + dice[2]) || str.Equals(dice[2] + " " + dice[5]) || str.Equals(dice[5] + " " + dice[3]) || str.Equals(dice[3] + " " + dice[0]))
                        Console.WriteLine(dice[5-1]);
                if (str.Equals(dice[0] + " " + dice[3]) || str.Equals(dice[3] + " " + dice[5]) || str.Equals(dice[5] + " " + dice[2]) || str.Equals(dice[2] + " " + dice[0]))
                        Console.WriteLine(dice[2-1]);
            }
        }
    }
}

Measured memory_bytes: 8864
package main

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	n, _ := strconv.Atoi(ReadString())
	return n
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	h, w, k := readInt(), readInt(), readInt()
	var cs []string
	for i := 0; i < h; i++ {
		cs = append(cs, ReadString())
	}
	var res [][]int
	whiteRow := strings.Repeat(".", w)
	for hbit := 0; hbit < 1<<uint64(h); hbit++ {
		for wbit := 0; wbit < 1<<uint64(w); wbit++ {
			tmp := make([]string, len(cs))
			copy(tmp, cs)
			for i := 0; i < h; i++ {
				for j := 0; j < w; j++ {
					if (hbit>>uint64(i))&1 == 1 {
						tmp[i] = whiteRow
					}
					if (wbit>>uint64(j))&1 == 1 {
						for k := 0; k < h; k++ {
							out := []byte(tmp[k])
							out[j] = '.'
							tmp[k] = string(out)
						}
					}
				}
			}
			if calcScore(tmp) == k {
				res = append(res, []int{hbit, wbit})
			}
		}
	}
	fmt.Println(len(res))
}

func calcScore(cs []string) int {
	var counter int
	for _, strs := range cs {
		for _, c := range strs {
			if c == '#' {
				counter++
			}
		}
	}
	return counter
}


Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
int n;
vi p;
pii dp[101][55555];

pii solve(int shop, int coin)
{
	if (shop == n) return pii(0, 0);
	if (dp[shop][coin].first >= 0) return dp[shop][coin];
	pii res(0, 0);
	chmax(res, solve(shop + 1, coin));
	pii tmp;
	if (p[shop] % 1000 == 0)
	{
		if (coin >= 500)
		{
			tmp = solve(shop + 1, coin - 500);
			chmax(res, pii(tmp.first + 1, tmp.second - p[shop]));
		}
	}
	else if (p[shop] % 1000 > 500)
	{
		tmp = solve(shop + 1, coin + 1000 - p[shop] % 1000);
		chmax(res, pii(tmp.first, tmp.second - p[shop]));
		if (p[shop] % 1000 - 500 <= coin)
		{
			tmp = solve(shop + 1, coin - (p[shop] % 1000 - 500));
			chmax(res, pii(tmp.first + 1, tmp.second - p[shop]));
		}
	}
	else
	{
		tmp = solve(shop + 1, coin + 500 - p[shop] % 1000);
		chmax(res, pii(tmp.first + 1, tmp.second - p[shop]));
	}
	return dp[shop][coin] = res;
}

int main()
{
	cin.sync_with_stdio(false);
	while (cin >> n, n)
	{
		p.resize(n);
		REP(i, n) cin >> p[i];
		REP(i, 101)REP(j, 55555) dp[i][j] = pii(-1, -1);
		pii ans = solve(0, 0);
		cout << ans.first << " " << -ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 47032
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;

int V,E;
 
class UnionFind {
private:
  int n;
  vector<int> a;
public:
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) {return a[x] < 0 ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    --n;
  }
  int size() {return n;}
  int size(int x) {return -a[find(x)];}
//   void reset(){a.assign(n, -1);}
};
 
int main(){
    
    cin >> V >> E;
    int a[E], b[E];
    
    for(int i=0; i<E; i++) cin >> a[i] >> b[i];
    for(int i=0; i<E; i++){--a[i]; --b[i];}
    
    int ans = 0;
    for(int i=0; i<E; i++){
        UnionFind uf(V);
        for(int j=0; j<E; j++){
            if(i!=j) uf.unite(a[j],b[j]);
        }
        if(not uf.equal(a[i],b[i])) ans++;
    }
    
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  int N;

  cin >> N ;

  vector<pair<int, int>> student(N);

  for(int i = 0; i < N ; i++){
    int tmp;
    cin >> tmp;
    student[i] = make_pair(tmp, i+1);
  }

  sort(student.begin(), student.end());

  for(int i = 0; i < N ; i++){
    
    cout << student[i].second << " ";  
    
  }


  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
int main() {
	int k, n;
	char s[11];
	scanf("%d%s%d", &n, s, &k);
	for (int i = 0; i < n; i++) {
		if (s[k - 1] != s[i]) {
			printf("*");
		} else {
			printf("%c", s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())

a = [0] * (n+1)
b = [0] * (n+1)

c = 0

for i in [0]*(m):

    s = input().split()

    if a[int(s[0])] == 0:
        if s[1] == "AC":
            a[int(s[0])] = 1
            c += b[int(s[0])]
        else:
            b[int(s[0])] += 1

print(sum(a), c)


Measured memory_bytes: 5364
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX 1000000001
using ll=long long;

int main(){
    int n,m;cin>>n>>m;
    vector<vector<int> > lights(m);
    vector<int> p(m);
    rep(i,m){
        int k;cin>>k;
        lights[i].resize(k);
        rep(j,k){
            cin>>lights[i][j];
            lights[i][j]--;
        }
    }
    rep(i,m) cin>>p[i];
    
    int ans=0;
    for(int sState=0;sState<(1<<n);sState++){
        bool all=true;
        for(int light=0;light<m;light++){
            int count=0;
            for(int s:lights[light]){
                if((sState>>s)&1) count++;
            }
            if(count%2!=p[light]){
                all=false; break;
            }
        }
        if(all) ans++;
    }

    cout<<ans<<endl;
}

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

int main(void){
	ll N;
	cin >> N;

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		int j = 1;
		while (i*j <= N){
			ans += i*j;
			j++;
		}
	}

	cout << ans << endl;

return 0;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        ll a, b;
        cin >> a >> b;
        ll c = a * b - 1;
        ll c2 = sqrt((long double)c);
        ll ans;
        // if(a < 10 && b < 10){
        //     int ans = 0;
        //     for(int i = 1; i <= 100; i++){
        //         for(int j = 1; j <= 100; j++){
        //             ans += i != j && i * j < a * b;
        //             if(i != j && i * j < a * b){
        //                 printd(a, b, ans, i * j, a * b);
        //                 // printd(a, b, ans, i != j && i * j < a * b);
        //             }
        //         }
        //     }
        //     cout << ans << '\n';
        //     continue;
        // }
        // if((a == 1 && b == 3) || (a == 3 && b == 1)){
        //     cout << 1 << '\n';
        //     continue;
        // }else if((a == 1 && b == 5) || (a == 5 && b == 1)){
        //     cout << 3 << '\n';
        //     continue;
        // }
        if(c2 * (c2 + 1) <= c){
            ans = c2 * 2;
            ans -= a <= c2;
            ans -= b <= c2;
            // ans -= a <= c2 || b <= c2;
        }else{
            ans = c2 * 2 - 1;
            printd(ans, c2, a, b);
            ans -= a <= c2;
            printd(ans);
            ans -= b <= c2;
            printd(ans);
            // ans -= a <= c2 || b <= c2;
        }
        // if(min(a, b) == 1 && max(a, b) > 4){
        //     ans++;
        // }
        // ll ans = c2 * 2 - 1;
        // ll ans = c2 * 2;
        // ans -= a < c2;
        // ans -= b < c2;
        // ans -= a <= c2;
        // ans -= b <= c2;
        // ans -= c2 * c2 == c;
        // ans += c2 * (c2 + 1) < c;
        // ans -= c2 * (c2 + 1) > c;
        cout << max(0ll, ans) << '\n';
        // prints(c2 * 2);
        // cout << c2 * 2 + (a == b ? 0 : a + b & 1 ? -2 : -1) << '\n';
        // ll ans = min(a - 1, c - (c >= b));
        // printd(ans, min(b - 1, c - (c >= a)));
        // ans = max(ans, min(b - 1, c - (c >= a)));
        // cout << ans << '\n';
    }
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

a, b = map(int,input().split())
a_list = [x[0] for x in factorization(a)]
b_list = [x[0] for x in factorization(b)]
ans = set(a_list) & set(b_list) | {1}
print(len(ans))


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val b = readLine()!!.split(" ").map { it.toInt() }
    var ans = b[0] + b[n-2]
    for (i in 0 until n-2) {
        ans += if (b[i] > b[i+1]) b[i+1] else b[i]
    }
    println(ans)
}


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define int long long

using namespace std;

typedef long long ll;

const int mod = (int)1e18 + 7;
const int N = (int)2e6 + 7;

int n,mx = 1;

struct node {
        int x,y;
}a[5005];

bool cmp (node a,node b) {
        if (a.x == b.x)
                return a.y < b.y;
        return a.x < b.x;
}
int dp[5001][5001];

 main () {
        cin >> n;

        for (int i = 1; i <= n; i ++) {
                cin >> a[i].x >> a[i].y;
                a[i].x += a[i].y;
        }
        sort (a + 1,a + n + 1,cmp);

        for (int i = 1; i <= n; i ++)
                a[i].x -= a[i].y;

        for (int i = 0; i <= n; i ++)
                for (int j = 0; j <= n; j ++)
                        dp[i][j] = mod;

        dp[1][1] = a[1].y;

        for (int i = 2; i <= n; i ++) {
                for (int j = 1; j <= i; j ++) {
                        if (dp[i - 1][j - 1] <= a[i].x)
                                dp[i][j] = min(dp[i - 1][j],dp[i - 1][j - 1] + a[i].y);
                        else
                                dp[i][j] = dp[i - 1][j];
                }
        }

        for (int i = n; i >= 1; i --) {
                if (dp[n][i] < mod) {
                        cout << i;
                        return 0;
                }
        }
}


Measured memory_bytes: 195712
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
//#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x,m) (((x)%m*(x)%m)%m)%m
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll mod           = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
#define N 1000001
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE  
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main(){
    fastio();
    ll n; 
    cin>>n; 
    ll ans=0,sum=0;
    for(ll i=1;i<=n;i++){
      ll ans=n/i;
      if(n%i==0){
        ans--; 
      }
      sum+=ans; 
    }
    cout<<sum; 
    //printclock;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> d(K);
  vector<bool> ans(N+1,false);
  for (int i = 0; i < K; i++) {
    ll n;
    cin >> n;
    for (int l = 0; l < n; l++) {
      ll x;
      cin >> x;
      ans[x-1] = true;
    }  
  }  
  ll a=0;
  for (int i = 0; i < N; i++) {
    if(!(ans[i]))a++;
  }
  cout << a << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int H,W,i,j,dp[105][105];
char M[105][105];

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d%d\n",&H,&W);
	for(i=0;i<H;i++)gets(M[i]);
	for(i=0;i<H;i++)
		for(j=0;j<W;j++)
		{
			dp[i][j]=M[i][j]=='c'?0:j==0||dp[i][j-1]==-1?-1:dp[i][j-1]+1;
		}
	for(i=0;i<H;i++)
		for(j=0;j<W;j++)
			printf("%d%c",dp[i][j],j==W-1?'\n':' ');
	return 0;
}

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

using namespace std;
#define int long long
#define MAXN 250000
int c[250000];
int lsh[MAXN],cnt,num[MAXN],n,k;

int lowbit(int x){return x&(-x);}

void update(int x){
    for(int i=x;i<=n;i+=lowbit(i))
        c[i]+=1;
}

int getsum(int x){
    int ans = 0;
    for(int i=x;i;i-=lowbit(i))
        ans += c[i];
    return ans;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	lsh[0]=0;
	num[0]=0;
	for(int i=1; i<=n; i++) {
		int temp;
		scanf("%lld",&temp);
		num[i]=num[i-1]+temp-k;	
		lsh[i]=num[i];
	}
	sort(lsh+1 , lsh+n+1);
	cnt = unique(lsh+1 , lsh+n+1) - lsh - 1;
	for(int i=0; i<=n; i++)
		num[i] = lower_bound(lsh+1 , lsh+cnt+1 , num[i]) - lsh;
	int ans=0;
	for(int i=0;i<=n;i++){
		ans+=getsum(num[i]);
		update(num[i]);
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 5376
module Main where

import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Char
import qualified Data.Map.Strict as M
import Control.Arrow
-- import Debug.Trace

main :: IO ()
main = do
  [a, b] <- unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print . succ . length . primeFactor' $ gcd a b

-- http://qiita.com/myuon_myon/items/ad006568bd187223f494#2-4
primes = 2:3:[x|i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x] where
  isPrime n = null [i|i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

-- | returns [(PrimeFactor, Exponent)]
-- >>> primeFactor 9
-- [(2,0),(3,2)]
primeFactor x = go x primes
  where       
    ub = floor . sqrt $ fromIntegral x
    go x (p:ps) 
      | p <= ub = let (x', e) = gogo x p 0 
        in (p, e) : go x' ps
      | x == 1 = []
      | otherwise = [(x, 1)]
      where
        gogo x p e = case quotRem x p of
          (q, 0) -> gogo q p (e + 1)
          (q, _) -> (x, e)

-- | returns [(PrimeFactor, Exponent)]
-- >>> primeFactor' 9
-- [(3,2)]
primeFactor' x = map (head &&& length) . group $ go x divisor
  where
    go 1 [] = []
    go y [] = [y]
    go y ps'@(p : ps) = case quotRem y p of
      (q, 0) -> p : go q ps'
      (q, _) -> go y ps
    ub = floor . sqrt $ fromIntegral x
    divisor = takeWhile (<= ub) primes


Measured memory_bytes: 7932
#!/usr/bin/env python
# coding: utf-8

# In[17]:


N = int(input())
A = [int(input()) for i in range(5)]
"""
10000000007
2
3
5
7
11
"""


# In[19]:


ma = min(A)
if ma == 1:
    print(N//ma+4)
else:
    print(N//ma+5)


# In[11]:


#ppl = [0]*6
#ppl[0] += N


# In[13]:


"""
time = 0
while max(ppl[:5]) > 0:
    tmppl = ppl.copy()
    for i in range(len(A)):
        mina = A[i] if ppl[i]>=A[i] else ppl[i]
        tmppl[i] -= mina
        tmppl[i+1] += mina
    ppl = tmppl
    time += 1
    #print(ppl)
"""


# In[14]:


#print(time)


# In[ ]:






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

int main(){
    string X, Y;
    cin >> X >> Y;

    if(X > Y){
        cout << '>' << endl;
    }
    else if(X == Y){
        cout << '=' << endl;
    }
    else{
        cout << '<' << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1e9+7
using namespace std;
#define  pp push_back
#define  po pop_back
#define  mp make_pair
#define clr(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,-1,sizeof(a))
#define fas(a) memset(a,false,sizeof(a))
#define debug(x) cout<<#x<<": "<<x<<endl
#define debug1(x) cout<<#x<<": "<<x<<" "
#define rev(x) reverse(x.begin(), x.end())
#define int long long 
#define F first
#define S second
//int a[2000];
void printvector(std::vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<""<<endl;}
void printarray(int a[],int n){for (int i = 0; i < n; ++i){cout<<a[i]<<" ";}cout<<""<<endl;}
 
 
int fill(int i,int a[],string& s)
{
   if(a[i]!=-1)return a[i];
   else
   {
      a[i]=0;
      if(i!=0&&s[i-1]=='<')a[i]=max(a[i],fill(i-1,a,s)+1);
      if(i!=s.length()&&s[i]=='>')a[i]=max(a[i],fill(i+1,a,s)+1);
      return a[i];  
   } 
}
 

void  solve()
{
   string s;cin>>s;
   int n=s.length()+1;
   int a[n];neg(a); 
   int ans=0;
   for(int i=0;i<n;i++)
   {
     ans+=fill(i,a,s);
   }
   //printarray(a,n);

   cout<<ans<<endl;


}




 int32_t main() 
{

  // #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
  // #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    
   solve();

return 0;

}

Measured memory_bytes: 28188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    string s; cin >> s;
    string ans = "";
    rep(i, s.size()){
        if(s[i] == 'B'){
            if(ans.size()) ans = ans.substr(0, ans.size()-1);
        }
        else ans += s[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:14:47 2020

@author: liang
"""

N, K = map(int,input().split())
A = list()
for i in range(N):
    a, b = map(int,input().split())
    A.append((a,b))
A.sort(key= lambda x:x[0])

tmp = 0
for i in range(N):
    a, b = A[i]
    tmp += b
    if tmp >= K:
        print(a)
        break


Measured memory_bytes: 24008
#include<bits/stdc++.h>
using namespace std;
#define  ll  long long  //define a macro variable of long long type
# define  loop(x,n)  for(int x = 0; x < n; ++x)  // define a for loop
#define   constloop(x,a,n) for(int x = a; x < n; ++x)  //define a for loop with start a const
#define  revloop(x,a,n)  for(int x = a; x > n; x--) // rev for loop
//#define   vect vector<ll>  // define a vector of longlong type;


int  main() {

//
//#ifndef ONLINE_JUDGE
//
//   freopen("input.txt", "r", stdin);
//
//   freopen("output.txt", "w", stdout);
//   #endif

   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
int a,b,c,d;
cin>>a>>b>>c>>d;
int l=a;
int m=c;
bool s=true;
while(l>0 && m>0)
{
    if(s)
    {
        m -=b;
        s=false;

    }
    else
    {
        l -=d;
        s=true;
    }


}
//cout<<l<<" "<<m;
if(l<=0)
{
    cout<<"No"<<endl;
}
else
    cout<<"Yes"<<endl;

   return 0;

}


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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n), v(1e6 + 1);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 0;
    rep(i, n){
        if(v[a[i]] == 0){
            if(!(i != n - 1 && a[i] == a[i + 1])) cnt++;
            for(int j = a[i]; j < 1e6 + 1; j += a[i]) v[j] = 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

// 前2文字を選んで消す <=> 一番前から何文字か消して、1文字復活させる
// s から t を得る <=> s と t は末尾 len(t) - 1 文字一致、s の冒頭 len(s) - len(t) + 1 文字のどれかが t の冒頭 1 文字と一致

using count_t = int32_t;

struct Node {
    char c;
    unordered_set<char> leaf;
    map<char, Node> child;
    //vector<count_t> num_substr;
    count_t num_child;
};

void construct(Node &node, const string &s, const size_t i){
    if(i == s.size() - 1){
        node.leaf.emplace(s[i]);
    }else{
        if (node.child.count(s[i]) == 0){
            node.child[s[i]] = Node{s[i], {}, {}, 0};
        }
        construct(node.child[s[i]], s, i+1);
    }
}

void print(const Node &node){
    cout << "{" << node.c << "[";
    //for(const auto &n: node.num_substr)cout << n << ",";
    cout << "]\n";
    for(const auto &c: node.leaf)cout << c << "+";
    for(const auto &c: node.child){
        print(c.second);
        cout << "+";
    }
    cout << "}";
}

// 葉ノードが文字cを含むなら、子ノードで文字cを含む部分文字列の数だけペアができる
// 「子ノードで文字cを含む部分文字列」を上に向かって数え上げていく
// void traverse(Node &node){
//     // 長さ3以上の部分列の個数は、子たちの部分列の個数の総和
//     node.num_child = node.leaf.size();
//     for(auto &child_node: node.child){
//         traverse(child_node.second);
//         for(auto i=0; i<26; ++i){
//             node.num_substr[i] += child_node.second.num_substr[i];
//         }
//         node.num_child += child_node.second.num_child;
//     }
//     node.num_substr[node.c - 'a'] = node.num_child;
//     for (const auto &c: node.leaf){
//         if (c != node.c) node.num_substr[c - 'a']++;
//     }
// }

pair<ll, vector<count_t>> traverse_count(Node &node){
    node.num_child = node.leaf.size();
    auto node_count = vector<count_t>(26);
    ll ret = 0;
    for(auto &child_node: node.child){
        const auto child_node_count = traverse_count(child_node.second);
        for(auto i=0; i<26; ++i){
            node_count[i] += child_node_count.second[i];
        }
        node.num_child += child_node.second.num_child;
        ret += child_node_count.first;
        for(const auto &c: node.leaf){
            ret += child_node_count.second[c-'a'];
        }
    }
    node_count[node.c - 'a'] = node.num_child;
    for (const auto &c: node.leaf){
        if (c != node.c) node_count[c - 'a']++;
    }
    return {ret, node_count};
}

// ll count(const Node &node){
//     ll ret=0;
//     for(const auto &child_node: node.child){
//         ret += count(child_node.second);
//     }
//     for(const auto &c: node.leaf){
//         for(const auto &child_node: node.child){
//             ret+=child_node.second.num_substr[c-'a'];
//         }
//     }
//     return ret;
// }

int main()
{
    int n;
    cin >> n;
    auto trie = Node{'a', {}, {}, 0};
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        construct(trie, s, 0);
    }
    //traverse(trie);
    // print(trie);
    // cout << "\n\n";
    cout << traverse_count(trie).first;
    return 0;
}


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

using namespace std;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

int main(){
    init();
    int n;
    cin >> n;
    int counter = 0;
    for(int i = 1;i<=n;i+= 2)
    {
        int subcounter = 0;
        for(int j = 1;j<=i;j++)
        {
            if(i % j == 0) subcounter++;

        }
        if(subcounter == 8) counter++;
    }

    cout << counter;
    return 0;
}




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

int n, m;
int p[100010];
int ans;

class UnionFind{
	public:
		int N;
		vector<int> Parent;
		vector<int> Rank;
		UnionFind(int n){
			N = n + 1;
			for(int i=0; i<N; ++i){
				Parent.push_back(i);
				Rank.push_back(0);
			}
		}

		int find(int x){
			if(Parent[x] == x) return x;
			return Parent[x] = find(Parent[x]);
		}

		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return;
			if(Rank[x] < Rank[y]) Parent[x] = y;
			else{
				Parent[y] = x;
				if(Rank[x] == Rank[y]) ++Rank[x];
			}
		}

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

int main(){
	cin >> n >> m;
	for(int i=0; i<n; ++i) cin >> p[i];
	UnionFind uf(n);
	for(int i=0; i<m; ++i){
		int x, y;
		cin >> x >> y;
		uf.unite(x, y);
	}
	for(int i=0; i<n; ++i)
		if(uf.same(p[i], i+1))
			++ans;
	cout << ans << endl;
}

Measured memory_bytes: 1660
R, G, B = map(int, input().strip().split(" "))
K = int(input())
k = 0
while (k < K):
    if (G <= R):
        G *= 2
    elif (B <= G):
        B *= 2
    k += 1
if (B > G and G > R):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9156
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  string s;
  cin >> N;
  map<int, int> m, m2;
  FOR(i, 0, 26)m[i] = inf;
  FOR(i, 0, N){
    cin >> s;
    FOR(j, 0, 26)m2[j] = 0;
    FOR(j, 0, s.size()){
      m2[s[j] - 'a'] += 1;
    }
    FOR(j, 0, 26)m[j] = min(m[j], m2[j]);
  }
  FOR(i, 0, 26){
    char c = 'a' + i;
    FOR(j, 0, m[i])cout << c;
  }
  cout << endl;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

U = N + 1
inf = 1e18

dp = [[[inf] * U for _ in range(U)] for _ in range(U)]
dp[0][0][0] = 0.0

for c in range(N + 1):
    for b in range(N + 1):
        if c + b > N:
            break
        for a in range(N + 1):
            if a + b + c == 0:
                continue
            if a + b + c > N:
                break
            prob = 0
            E = N
            if a > 0:
                E += a * dp[a - 1][b][c]
                prob += a
            if b > 0 and a < N:
                E += b * dp[a + 1][b - 1][c]
                prob += b
            if c > 0 and b < N:
                E += c * dp[a][b + 1][c - 1]
                prob += c
            dp[a][b][c] = E / prob

x = C[1]
y = C[2]
z = C[3]
print(dp[x][y][z])

Measured memory_bytes: 255624
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

#define ll long long

using namespace std;

const long long mod = 1e9 + 7;

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

    for(int i = x-k+1; i < x+k; i++){
        cout << i << " ";
    }
    cout << endl;
}

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

signed main(){
    int n, m; cin >> n >> m;
    vector<pair<int, char>> vec(m);
    rep(i,m) cin >> vec[i].first >> vec[i].second;
    rep(i,1000){
        if(to_string(i).size() != n) continue;
        bool yes = true;
        rep(j,m){
            int s = vec[j].first;
            char c = vec[j].second;
            string t = to_string(i);
            if (s < 1 || s > n){
                yes = false;
                break;
            }
            if (t[s-1] != c){
                yes = false;
                break;
            }
        }
        if (yes){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int a[3600*24+5];

int n;
string s;
int tr(int i){
  return s[i] - '0';
}

void solve(){
  fill(a,a+3600*24+5,0);
  rep(i,0,n){
    int l,r;
    cin >> s;
    l = (tr(0)*10+tr(1))*3600 + (tr(3)*10+tr(4))*60 + tr(6)*10+tr(7);
    cin >> s;
    r = (tr(0)*10+tr(1))*3600 + (tr(3)*10+tr(4))*60 + tr(6)*10+tr(7);
    a[l]++;
    a[r]--;
    //cout << l << " " << r << endl;
  }
  int u = a[0];
  rep(i,1,3600*24){
    a[i] += a[i-1];
    u = max(u,a[i]);
  }
  cout << u << endl;
}


int main(){
  for(;;){
    cin >> n;
    if(n==0)break;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3464
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int h,w,i,j;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0)
            break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
import sys
import bisect
input = sys.stdin.readline
inf = float("inf")
a, b, q = map(int, input().split())
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]
for i in range(q):
    x = int(input())
    idx_s = bisect.bisect_left(s, x)
    idx_t = bisect.bisect_left(t, x)

    indices_s = []
    indices_t = []

    indices_s.append(idx_s)
    indices_s.append(idx_s-1)

    indices_t.append(idx_t)
    indices_t.append(idx_t-1)

    ans = []
    for i in indices_s:
        for j in indices_t:
            l, r = min(s[i], t[j]), max(s[i], t[j])
            if x < l:
                ans.append(r-x)
            elif l <= x and x < r:
                ans.append(min(r-l+(x-l), r-l+(r-x)))
            else:
                ans.append(x-l)
    print(min(ans))



Measured memory_bytes: 12816
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
const int inf=2e9;
int32_t main()
{
	//bk is max heap storing left side
	//fw is min heap storing right side
	
	int q=in();int bs=0,a,b,as=0,n=0,ch,smaller=0;
	priority_queue<int> bk;
	priority_queue<int,vector<int>, greater<int>> fw;
	fw.push(inf);
	while(q--)
	{
		ch=in();
		if(ch==1)
		{
			a=in();b=in();
			bs+=b;as+=a;n++;
			if(n%2==1)
			{
				//on the left
				bk.push(a);smaller+=a;
			}
			else fw.push(a);
		}
		else
		{
			while(bk.top()>fw.top())
			{
				int tb=bk.top();
				int tf=fw.top();
				bk.pop();fw.pop();
				fw.push(tb);bk.push(tf);
				smaller+=tf-tb;
			}
			int minima=bk.top();
			cout<<minima<<" ";
			
			int ans=((n+1)/2)*minima-smaller;
			ans+=as-smaller-(n/2)*minima;
			ans+=bs;
			cout<<ans<<"\n";
			
			
			
		}
		
	}
	
	
}

Measured memory_bytes: 5068
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;


int main()
{
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else cout<<"Sunny"<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
N, M = map(int,input().split())
bridge = []
for i in range(M):
    A, B = map(int,input().split())
    bridge.append((A - 1, B - 1))
    
uf = UnionFind(N)
ans = [N * (N - 1) // 2]
cnt = 0
for i in range(M - 1):
    A, B = bridge[-i-1]
    if not uf.same(A, B):
        cnt += uf.size(A) * uf.size(B)
        uf.union(A, B)
    ans.append(ans[0] - cnt)
for i in range(M):
    print(ans[-i-1])

Measured memory_bytes: 22532