akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

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



void inorder(Node u) {

  if( u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

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


using namespace std;


int main()
{

   long long int H ; long long int N ; long long int sum = 0;

   cin >> H >> N;

   while (N--)
   {
       long long int A ;
        cin >> A;
        sum += A;

   }

   if (sum >= H)
   {
       cout << "Yes" << endl;
   }
   else
   {

       cout  << "No" << endl;
   }


}

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a.at(i);
    ll x = 1000;
    for (int i = 1; i < n; i++) {
        int b = a.at(i-1);
        int s = a.at(i);
        if(b < s) x = x/b * s + x%b;
    }
    cout << x << endl;
    return 0;
}

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

#define pb push_back

using namespace std;

int main(void)
{
	int m,a,b;
	int p,q;
	int i1,i2;
	int max;
	int mul;
	double divi;

	vector<int> prime;
	for(i1=2;i1<=100000;i1++){
		for(i2=2;i2*i2<=i1;i2++){
			if(i1%i2==0) break;
		}
		if(i2*i2>i1) prime.pb(i1);
	}

	while(1){
		cin>>m>>a>>b;
		if(m+a+b==0) break;

		max=0;
		for(i1=0;(prime[i1]*prime[i1])<=m;i1++){
			for(i2=i1;(prime[i2]*prime[i1])<=m;i2++){

				mul=prime[i1]*prime[i2];
				divi=(double)prime[i1]/(double)prime[i2];
				
				if(mul<=m && divi<=1.0 && divi>=((double)a/(double)b)){
					if(max<mul) {
						max=mul;
						p=prime[i1];
						q=prime[i2];
					}
				}
			}
		}

		cout<<p<<" "<<q<<endl;
	}
	return 0;
}

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

ll a, b, n;

ll f(ll x) { // f(x)はbで周期するため、0 <= x < bで考えれば良く、この時、floor(x / b) = 0であるため、f(x) = floor(a * x / b) は、短調増加
    return a * x / b - a * (x / b);
}

int main() {
    cin >> a >> b >> n;
    cout << f(min(b-1, n)) << endl;
}

Measured memory_bytes: 3632
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

result_score = 10000
result_num = 0

for num, h in enumerate(H, 1):
    temp = T - h * 0.006
    score = abs(A-temp)

    if result_score >= score:
        result_score = score
        result_num = num

print(result_num)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	LL ans=0;
	for(int i=0;i<k;i++){
		LL c=n/k+(n%k>=(i+k-1)%k+1?1:0);
		if(i==0||i*2==k){
			ans+=c*c*c;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
-- ABC 137 A
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  [a, b] <- getIntList
  print . maximum $ [a + b, a - b, a * b]

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 380
import static java.lang.Math.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt(), W = in.nextInt();
			List<Integer> v = new ArrayList<>();
			List<Integer> w = new ArrayList<>();
			for (int i = 0; i < N; i++) {
				int vi = in.nextInt();
				int wi = in.nextInt();
				v.add(vi); w.add(wi);
				int m = in.nextInt();

				int p = 2;
				int tmpv = vi, tmpw = wi;
				while (2*p <= m) {
					p *= 2;
					tmpv *= 2;
					tmpw *= 2;
					v.add(tmpv); w.add(tmpw);
				}
				v.add(vi*(m-p+1));
				w.add(wi*(m-p+1));
			}

			int newN = v.size();

			long[][] dp = new long[newN+1][W+1];

			for (int i = 0; i < newN; i++) {
				for (int j = 0; j <= W; j++) {
					if (j-w.get(i) >= 0) {
						dp[i+1][j] = max(dp[i][j], dp[i][j-w.get(i)] + v.get(i));
					} else {
						dp[i+1][j] = dp[i][j];
					}
				}
			}

			out.println(dp[newN][W]);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}



Measured memory_bytes: 143380
#include <bits/stdc++.h>
using namespace std;
#define fio                         \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);                    \
cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, r, x, y, s, b, d;
    ll sx, sy, tx, ty;
cin>>sx>>sy>>tx>>ty;
    for (i=0;i<tx-sx;i++)
        cout<<'R';

    for (i=0;i<ty-sy;i++)
        cout<<'U';
    for (i=0;i<tx-sx;i++)
        cout<<'L';

    for (i=0;i<ty-sy;i++)
        cout<<'D';
    cout<<'D';
    for (i=0;i<tx-sx+1;i++)
        cout<<'R';

    for (i=0;i<ty-sy+1;i++)
        cout<<'U';
    cout<<'L';
    cout<<'U';
    for (i=0;i<tx-sx+1;i++)
        cout<<'L';

    for (i=0;i<ty-sy+1;i++)
        cout<<'D';

    cout<<'R';

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

bool string_order(std::pair<ll, ll> first_entry,
                  std::pair<ll, ll> second_entry)
{
    return (first_entry.second > second_entry.second);
}

int main(void)
{
    ifstream inputFile("data/input.txt");
    if (getenv("SSH_CONNECTION") != nullptr) {
        cin.rdbuf(inputFile.rdbuf());
    }

    int A, P;
    cin >> A >> P;
    A *= 3;
    P += A;
    cout << (P/2) << endl;
    return 0;
}


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

#define N 1000
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define sortcmp(n, cmpfunc) sort(all(n), cmpfunc)
#define fastio ios::sync_with_stdio(false); cin.tie(0)

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
ll powm(ll a, ll b);
ll divm(ll a, ll b);
ll multm(ll a, ll b);
ll subm(ll a, ll b);
ll addm(ll a, ll b);

int main(){
	fastio;
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.in", "r", stdin);
 //    	freopen("output.out", "w", stdout);
	// #endif
	int n, v[20], c, ans = 0;
	cin >> n;
	for(int i = 0 ; i < n ; i++) cin >> v[i];

	for(int i = 0 ; i < n ; i++){
		cin >> c;
		if(c < v[i]) ans += (v[i] - c);
	}
	cout << ans << endl;
	return 0;
}

// template function
ll gcd(ll a, ll b) { 
	if (b == 0) return a; 
	return gcd(b, a % b);  
} 

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

ll powm(ll a, ll b){
	ll x=1, y=a; 
    while (b > 0) {
        if (b%2) x = (x*y) % mod;
        y = (y*y) % mod;
        b /= 2;
    }
    return x % mod;
}

ll multm(ll a, ll b){
	return ((a%mod) * (b%mod)) % mod;
}

ll divm(ll a, ll b){
	return (a * powm(b, mod - 2)); 
}

ll subm(ll a, ll b){
	a -= b;
  	if (a < 0) a += mod;
	return a;
}

ll addm(ll a, ll b){
	a += b;
  	if (a >= mod) a -= mod;
  	return a;
}

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

using namespace std;

#define int long long

struct UF {
  vector<int> data;
  UF(int n):data(n, -1){}
  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }
  int size(int x) {
    return -data[find(x)];
  }
  bool same(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(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
};

struct edge {
  int u, v, w;
  edge(){}
  edge(int u, int v, int w):u(u), v(v), w(w){}
  bool operator < (const edge& e) const {
    return w < e.w;
  }
};

signed main() {
  int n;
  cin >> n;
  vector<edge> es;
  for(int i = 0; i < n-1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    es.emplace_back(a, b, c);
  }
  sort(es.begin(), es.end());
  UF uf(n);
  int ans = 0;
  for(edge& e : es) {
    int x = uf.find(e.u), y = uf.find(e.v);
    if(x == y) continue;
    ans += e.w*uf.size(x)*uf.size(y);
    uf.unite(x, y);
  }
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 9104
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        int upper = N;
        int lower = 1;

        for (int i = 1; i <= M; i++)
        {
            int L = cin.nextInt();
            int R = cin.nextInt();
            if (R < upper)
            {
                upper = R;
            }
            if (L > lower)
            {
                lower = L;
            }
        }

        if (upper - lower < 0)
        {
            Console.WriteLine(0);
            return;
        }

        Console.WriteLine(upper - lower + 1);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 15184
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,m;
    cin>>n>>m;
    ll suma=0,sumb=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        suma+=a;
    }
    for(int i=0;i<m;i++){
        ll a;
        cin>>a;
        sumb+=a;
    }
    cout<<suma*sumb<<endl;
    
    
    
    return 0;
}



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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    double p = 0.08;
    double q = 0.1;
    FOR(i, 1, 10000) {
        int a = i*p;
        int b = i*q;
        if(a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
result = 0
K = int(input())
for i in range(K):
  for j in range(K):
    for k in range(K):
      a = i+1
      b = j+1
      c = k+1
      num = gcd(a,b)
      num2 = gcd(num,c)
      result += num2
print(result)

Measured memory_bytes: 68816
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < 6; i++)
    if(s[i] == '1') ans++;
  cout << ans << endl;  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a,b,c;

int main(){
	cin>>n;
	a=vi(n);
	map<int,int> mp;
	int id=0;
	for(auto &i:a) cin>>i;
	sort(a.rbegin(),a.rend());
	for(int i=0;i<n;i++) if(!i||a[i]!=a[i-1]){
		mp[a[i]]=id++;
		c.push_back(a[i]);
	}
	b=vi(id);
	for(int i=0;i<n;i++) b[mp[a[i]]]++;
	int res=0;
	for(int i=0;i<id;i++) while(b[i]){
		b[i]--;
		int t=1;
		while(t<=c[i]) t*=2;
		int x=t-c[i];
		if(mp.find(x)!=mp.end()&&b[mp[x]]>0) b[mp[x]]--,res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 12020
#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>;
 
struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};
 
int deg[100005];
vector<int> to[100005];
 
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]) {
      if (uf.same(i,u)) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 6784
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()
	a, b, c := 0, 0, 0
	for _, v := range s {
		switch v {
		case 'a':
			a++
		case 'b':
			b++
		case 'c':
			c++
		}
	}

	m := max(a, max(b, c)) - 1

	// out(m, a, b, c)
	if a >= m && b >= m && c >= m {
		out("YES")
	} else {
		out("NO")
	}

}


Measured memory_bytes: 896
def examC(inf):
    N = I()
    A = []
    A.append(1)
    for i in range(1, 7):
        A.append(6 ** i)
    for i in range(1, 6):
        A.append(9 ** i)
    A.sort()
    dp = [10 * 5 + 10] * (N + 1)
    dp[0] = 0
    for i in range(1, N + 1):
        for s in range(len(A)):
            if i - A[s] >= 0:
                dp[i] = min(dp[i - A[s]] + 1, dp[i])
    ans = dp[N]
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC(inf)


Measured memory_bytes: 40304
# 素因数分解されたリストを返す
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

def count_make_fact(n):
    count = 1
    while n - count >= 0:
        n -= count
        count += 1
    return count-1

n = int(input())

if n == 1:
    print(0)
else:
    factor_list = factorization(n)
    print(sum(map(count_make_fact,(map(lambda list: list[1],factor_list)))))


Measured memory_bytes: 9272
n = int(input())
ls = list(map(int, input().split()))

for i in range(n):
    if ls[i] % 2 == 1:
        if i == n - 1:
            print("APPROVED")
    elif ls[i] % 2 == 0:
        if ls[i] % 3 == 0 or ls[i] % 5 == 0:
            if i == n - 1:
                print("APPROVED")
        else:
            print("DENIED")
            break

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int n,i,j;
  cin >> n;
  for(i=1;i<=9;i++){
    for(j=1;j<=9;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
} 

Measured memory_bytes: 3532
#input
N = int(input())

#output
from collections import Counter

M1 = []
M2 = []
for i in range(1, N+1):
    m = str(i)
    m1 = m[0] + m[-1]
    m1 = int(m1)
    m2 = m[-1] + m[0]
    m2 = int(m2)
    M1.append(m1)
    M2.append(m2)

M1 = Counter(M1)
M2 = Counter(M2)
M3 = M1 & M2
answer = 0
for m in M3.keys():
    answer += M1[m]*M2[m]

print(answer)

Measured memory_bytes: 6596
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int a, b, p1 = 0, p2 = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b;
			if (a == b) p1 += a, p2 += b;
			else if (a > b) p1 += a + b;
			else p2 += a + b;
		}
		cout << p1 << " " << p2 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	vector<int> A;
	int a;
	rep(i, 0, 2)
	{
		cin >> a;
		if (i == 0 && 0 < a)
		{
			a--;
		}
		A.push_back(a);
	}

	int ans = 0;
	int b = 1;
	rep(i, 0, 42)
	{
		int res = 0;
		rep(j, 0, SZ(A))
		{
			if ((i == 0 && ((A[j] + 1) / 2) % 2 == 1) || (0 < i && A[j] % (b*2) >= b && A[j] % 2 == 0))
			{
				res ^= 1;
			}
		}
		ans += b*res;
		b *= 2LL;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
import sys

K, A, B = sys.stdin.readline().split(" ")
k = long(K)
a = long(A)
b = long(B)

if (b-a) >= 2:
	hitsteps = a - 1
	leftoversteps = k - hitsteps
	rem = (leftoversteps)%2
	swaps = (leftoversteps-rem)/2
	multbiscuits = swaps * (b-a)
	print(int(multbiscuits+rem+a))
else:
	print(int(k+1))

Measured memory_bytes: 2696
#include <stdio.h>
#include <string.h>

int main(){
    char S[15], T[15], U[15];
    int a, b;
    
    scanf("%s %s", S, T);
    scanf("%d %d", &a, &b);
    scanf("%s", U);
    
    (strcmp(U, S) == 0) ? a-- : b--;
    printf("%d %d", a, b);
    
    return 0;

}

Measured memory_bytes: 1712
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
V = l_inpl()
C = l_inpl()

l = []
for i in range(N):
    l.append(V[i]-C[i])

ans = 0
print(sum([ li for li in l if li > 0]))

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W,H,x,y,r;
    cin >> W>>H>>x>>y>>r;
    if(x>=r&&y>=r&&x+r<=W&&y+r<=H)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }


Measured memory_bytes: 3204
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,a[N];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;
		for(ll i=1;i<=n;i++)cin>>a[i];
		ll max1 = a[1];ll ans = 0;
		for(ll i=1;i<=n;i++)
		{
			max1 = max(max1,a[i]);
			if(a[i]>=max1)continue;
			else ans += max1-a[i];
		}
		cout<<ans;
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int x, y = 0;
	cin >> x >> y;

	int grp[] ={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

	string ans = grp[x] == grp[y] ? "Yes" : "No";
	COUT(ans);

	return 0;
}

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

s = input()
l = ['Sunny', 'Cloudy','Rainy']
i = l.index(s)
if(i == 2):
    print('Sunny')
else:
    print(l[i + 1])

Measured memory_bytes: 74756
n=int(input())
a=list(map(int,input().split()))

from collections import deque    
q = deque([])

for i in range(n):
    if i%2==0:
        q.append(a[i])
    else:
        q.appendleft(a[i])
        
if n%2==0:
    for i in range(n):
        print(q[i],end=" ")
    print()
else:
    for i in range(n-1,-1,-1):
        print(q[i],end=" ")
    print()
    


Measured memory_bytes: 26016
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;

vector<vector<int> >edge;
int n,m;
int co[100011];

bool dfs(int now,int fa,int c)
{
    int i;
    co[now]=c;
    for(i=0;i<edge[now].size();i++)
    {
        int nxt=edge[now][i];
        if(nxt!=fa)
        {
            if(co[nxt]==-1)
            {
                bool bi=dfs(nxt,now,1-c);
                if(!bi)return bi;
            }
            else
            {
                if(co[nxt]==co[now])
                {
                    return false;
                }
            }
        }
    }
    
    return true;
}

long long ans;
int main()
{
    int i,j,k;
    int xx,yy;
    scanf("%d %d ",&n,&m);
    edge.resize(n+1);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d",&xx,&yy);
        edge[xx].push_back(yy);
        edge[yy].push_back(xx);
    }
    
    
    memset(co,-1,sizeof(co));
    bool bi=dfs(1,-1,0);
    
    if(bi==false)
    {
        ans=(long long)n*(n-1)/2-m;
    }
    else
    {
        long long t=0;
        for(i=1;i<=n;i++)
        {
            t+=co[i];
        }
        ans=t*(n-t)-m;
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 6656
import numpy as np
N, M = list(map(int, input().split()))
A = np.array(sorted(list(map(int, input().split())), reverse=True))
sumA = np.sum(A)
cnt = np.sum(np.where(A >= sumA / (4 * M) , 1, 0))
if cnt >= M :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21516
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<locale>
#include<cctype>

using namespace std;

int main() {
  cin.tie(0);
  char b;
  cin>>b;
  if(b=='A')cout<<'T';
  if(b=='T')cout<<'A';
  if(b=='G')cout<<'C';
  if(b=='C')cout<<'G';
  cout<<endl;
  

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)


func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	var max,min int
	min = 1e9
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i] > max {
			max = a[i]
		}
		if a[i] < min {
			min = a[i]
		}
	}
	kotae := max - min
	fmt.Println(kotae)
}


Measured memory_bytes: 512
z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
def g(x,y,s=0,t=1):
 q,r=x//y,x%y
 return g(y,r,t,s-q*t) if r else t
for _ in[0]*int(input()):
 s=input()
 a,b=f()
 h=g(26,a)
 print(''.join(z[h*(z.index(c)-b)%26]if c in z else c for c in s))


Measured memory_bytes: 5608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
#include <map>

#include <iomanip>


int main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<std::pair<int, int>>> nodes(n);
	for (auto i = 1; i < n; ++i) {
		int u, v, w;
		std::cin >> u >> v >> w;
		nodes[u - 1].push_back(std::make_pair(v - 1, w % 2));
		nodes[v - 1].push_back(std::make_pair(u - 1, w % 2));
	}
	std::vector<int> color(n, -1);
	color[0] = 0;
	std::queue<int> queue;
	queue.push(0);
	while (!queue.empty()) {
		auto top = queue.front(); queue.pop();
		for (auto next : nodes[top]) {
			if (color[next.first] == -1) {
				color[next.first] = (color[top] + next.second) % 2;
				queue.push(next.first);
			}
		}
	}
	for (const auto c : color) {
		std::cout << c << '\n';
	}
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  for(ll i=0;i<3;i++) {
    if(int(s[i]-'0')==7) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 2001000;
int n,m,Q,mod,fa[N],pw[2][N],u[N],v[N],w[N];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int find(int x){return fa[x]= fa[x]==x?x:find(fa[x]);}
void merge(int x,int y){
	x=find(x);y=find(y);
	fa[x]=y;
}
int id(int u,int q,int p){return (u-1)*6+q*2+p;}
int main(){
	read(n);read(m);read(Q);read(mod);
	int g=0;
	for(int i=1;i<=m;i++){
		read(u[i]);read(v[i]);read(w[i]);
		g=gcd(g,abs(w[i]-w[1]));
	}
	if(!g) g=mod;
	mod=gcd(3*g,mod);
	int z=w[1]%g;
	for(int i=0;i<n*6;i++) fa[i]=i;
	for(int i=1;i<=m;i++){
		int x=u[i],y=v[i],k=abs(w[i]-z)/g%3;
		for(int q:{0,1,2})
			for(int p:{0,1})
				merge(id(x,q,p),id(y,(q*2+k)%3,p^1)),
				merge(id(y,q,p),id(x,(q*2+k)%3,p^1));
	}
	for(int i=0,now=z;i<mod;i++,now=now*2%mod) pw[i&1][now]=1;
	while(Q--){
		int x,y,len;read(x);read(y);read(len);
		int flag=0;
		for(int q:{0,1,2})
			for(int p:{0,1})
				flag|=find(id(y,0,0))==find(id(x,q,p))&&pw[p][((len+z-q*g)%mod+mod)%mod];
		if(flag) puts("YES");
		else puts("NO");
	}
	return 0;
}


Measured memory_bytes: 19072
#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
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

const int MOD = 1e9 + 7;

int n, k;
vector<int> v;

bool test(int id){
	
	if(v[id] >= k) return true;
	
	vector<bool> possible(5010);
	possible[0] = true;
	
	for(int i = 0 ; i < n ; i ++){
		if(i == id) continue;
		for(int j = k - 1 ; j >= 0 ; j --){
			if(possible[j] && j + v[i] < k)
				possible[j + v[i]] = true;
		}
	}
	
	for(int i = k - v[id] ; i < k ; i ++)
		if(possible[i]) return true;
	
	return false;
}

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k;
	v.resize(n);
	
	for(int i = 0 ; i < n ; i ++)
		cin >> v[i];
	
	sort(v.begin(), v.end());
	
	int ans = 0;
	int l = 0, r = n - 1;
	
	while(l <= r){
		int mid = (l + r)/2;
		if(test(mid)){
			r = mid - 1;
		} else {
			ans = mid + 1;
			l = mid + 1;
		}
	}
	
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3680
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

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

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll ans = 0;
    ll x = min(N, M / 2);
    ans += x;
    M -= 2 * x;
    ans += M / 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll W, H;
	double x, y;
	cin >> W >> H >> x >> y;

	cout << fixed << setprecision(9);

	cout << W * H / 2.0 << " ";

	if (abs(x - W / 2.0) < 0.1 && abs(y - H / 2.0) < 0.1) cout << 1 << endl;
	else cout << 0 << endl;


	return 0;
}


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

using namespace std;
int n;
set<int> a;
map<int,int> mp;

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		int x;cin >> x;
		a.insert(x);
		if(!mp[x]) mp[x]=1;
		else mp[x]=0;
	}
	
	int ans=0;
	for(set<int>::iterator it=a.begin();it!=a.end();it++)
	{
		if(mp[*it]) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll ggg[210][210];
//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    ll ans=0;
    reps(i,1,205){
        reps(j,1,205){
            ggg[i][j]=gcd(i,j);
        }
    }
    reps(i,1,N+1){
        reps(j,1,N+1){
            reps(k,1,N+1){
                ans+=ggg[ggg[i][j]][k];
            }
        }
    }
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

template <typename T>
using V = std::vector<T>;
template <typename T>
vector<T> make_vec(size_t n, T a) {
  return vector<T>(n, a);
}
template <typename... Ts>
auto make_vec(size_t n, Ts... ts) {
  return vector<decltype(make_vec(ts...))>(n, make_vec(ts...));
}
template <typename Container>
ostream &pprint(const Container &a, string_view sep = " ",
                string_view ends = "\n", ostream *os = nullptr) {
  if (os == nullptr) os = &cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
  return pprint(a, ",", "", &(os << "[")) << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &a) {
  return pprint(a, ",", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<i64> A(N);
  REP(i, N) cin >> A[i];
  i64 ans = 0;
  i64 h = A[0];
  for (int i = 1; i < N; ++i) {
    if (A[i] < h) {
      ans += h - A[i];
    } else {
      h = A[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const double eps = 0.000000001;
const int MOD = 1000000009;
const int N = 100005;
int a[N];
bool b[10];
int main()
{
      int n, cnt = 0;
      cin >> n;
      for (int i = 1; i <= n; i ++)
            cin >> a[i];
      for (int i = 1; i <= n; i ++)
      {
            if (1 <= a[i] && a[i] <= 399) b[1] = true;
            if (400 <= a[i] && a[i] <= 799) b[2] = true;
            if (800 <= a[i] && a[i] <= 1199) b[3] = true;
            if (1200 <= a[i] && a[i] <= 1599) b[4] = true;
            if (1600 <= a[i] && a[i] <= 1999) b[5] = true;
            if (2000 <= a[i] && a[i] <= 2399) b[6] = true;
            if (2400 <= a[i] && a[i] <= 2799) b[7] = true;
            if (2800 <= a[i] && a[i] <= 3199) b[8] = true;
            if (3200 <= a[i])cnt ++;
      }
      int mn = 0, mx = 0;
      for (int i = 1; i <= 8; i ++)
            mn += b[i];
      mx = mn + cnt;
      mn = max(mn, 1);
      cout << mn << " " << mx << endl;
      return 0;
}






















Measured memory_bytes: 256
from collections import deque
s=input()
q=int(input())

flug=0
ans=deque(list(s))

for i in range(q):
    t=list(input().split())

    if t[0]=="1":
        flug+=1
    else:
        if (flug%2==0 and t[1]=="2") or (flug%2==1 and t[1]=="1"):
            ans.append(t[2])
        else:
            ans.appendleft(t[2])

ans="".join(map(str,ans))

if flug%2==1:
    ans=ans[::-1]
print(ans)

Measured memory_bytes: 9444
# union-find
class UnionFind:
    def __init__(self, n):
        self.prsz = [-1] * n # parent & size
    def find(self, v): # root
        if self.prsz[v] < 0: return v
        self.prsz[v] = self.find(self.prsz[v])
        return self.prsz[v]
    def union(self, v, u): # unite
        v = self.find(v); u = self.find(u)
        if v == u: return False
        if self.prsz[v] > self.prsz[u]: v, u = u, v # size(v) < size(u)
        self.prsz[v] += self.prsz[u]
        self.prsz[u] = v
        return True

n, m = map(int, input().split())
uf = UnionFind(n)
ans = n - 1
for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    if uf.find(a) !=uf.find(b):
        uf.union(a, b)
        ans -= 1
print(ans)


Measured memory_bytes: 10800
import itertools

S=input()
L=len(S)
ITER=list(itertools.product([0,1],repeat=(L-1)))
ANS=0

for iter in ITER:
    PLUS=S[0]
    for j in range(L):
        if  j==L-1:
            ANS+=int(PLUS)
        elif iter[j]==0:
            ANS+=int(PLUS)
            PLUS=S[j+1]
        else:
            PLUS+=S[j+1]

print(ANS)

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

int main(void){
    ll N;
    cin >> N;
    ll A,sum=0,m = 10000000000;
    ll cnt = 0;
    rep(i,N){
        cin >> A;
        if(A<0)cnt++;
        sum += max(A,-A);
        m = min(m,max(A,-A));
    }
    if(cnt%2==0)cout << sum << endl;
    else cout << sum - m*2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<limits.h>
#define f(i,x,n) for(int i = x;i<n;i++)
#define pb push_back
#define MAX 1e5+1
using namespace std;

int solve(unordered_map<int,list<int>> &mp,int dp[],int n,int curr){
 if(dp[curr] != -1)return dp[curr];
 if(mp[curr].size()==0)return dp[curr] = 0;

 for(auto nbr:mp[curr]){
         dp[curr] = max(dp[curr],1+solve(mp,dp,n,nbr));
 }
 return dp[curr];
}

int main(){
int n,k;
cin>>n>>k;
unordered_map<int,list<int>> mp;
int dp[n+1];
f(i,0,k){
    int a,b;
    cin>>a>>b;
    mp[b].push_back(a);
}
f(i,0,n+1){
    dp[i] = -1;
}

f(i,1,n+1){
    if(dp[i] == -1){
        int v = solve(mp,dp,n,i);
    }
}
int maxi = INT_MIN;
f(i,1,n+1){
    maxi = max(dp[i],maxi);
}
cout<<maxi<<endl;
return 0;
}


Measured memory_bytes: 18232