akhauriyash/Code-Regression huggingface dataset:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N =  int(sys.stdin.readline())
D, X=  map(int, sys.stdin.readline().split())

L =  [int(sys.stdin.readline()) for _ in range(N)]

ans = X

for a in L:
    for i in range(D):
        t = a * i + 1
        if t <= D:
            ans += 1

print(ans)

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

int main(){
  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(),d.end());
  cout << d[n/2] - d[n/2-1] << endl;
}


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

int main(){
	int N;
	cin>>N;
	
	int A[N];
	for(int i=0;i<N;i++)
		cin>>A[i];
	
	int B[N];
	for(int i=0;i<N;i++)
		B[i]=A[i];
		
	sort(B,B+N,greater<int>());
	
	for(int i=0;i<N;i++){
		if(A[i]==B[0]){
			cout<<B[1]<<endl;
		}
		else
			cout<<B[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct BIT{
private:
   int sz;
   vector<ll> node;
public:
   BIT(int n):sz(n),node(n+1){};
   void add(int k,ll x){
       k++;
       while(k<=sz){
           node[k]+=x;
           k+=k&-k;
       }
   }
   ll sum(int k){
       k++;
       ll ret=0;
       while(k>0){
           ret+=node[k];
           k-=k&-k;
       }
       return ret;
   }
   ll sum(int l,int r){
       return sum(r-1)-sum(l-1);
   }
   ll get(int k){
       return sum(k,k+1);
   }
};

int main(){
    cout<<fixed<<setprecision(10);
    int n;
    cin>>n;
    double a[n],b[n],c[n];
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    int ord[n];
    rep(i,n)ord[i]=i;
    sort(ord,ord+n,[&](int x,int y){return -a[y]/b[y]>-a[x]/b[x];});
    int inv[n];
    rep(i,n)inv[ord[i]]=i;
    int ord2[n];
    rep(i,n)ord2[i]=i;
    double d[n];
    rep(j,2){
    double left=-3e8,right=3e8,mid=0;
    rep(k,70){
        mid=(left+right)/2;
        BIT bit(n);
        rep(i,n)d[i]=(-a[i]*mid-c[i])/b[i];
        sort(ord2,ord2+n,[&](int x,int y){return d[x]<d[y];});
        int cnt=0;
        rep(i,n){
            int idx=inv[ord2[i]];
            cnt+=bit.sum(idx);
            bit.add(idx,1);
        }
        if(cnt<=n*(n-1)/4)left=mid;
        else right=mid;
    }
    cout<<-mid<<" ";
    rep(i,n)swap(a[i],b[i]);
    sort(ord,ord+n,[&](int x,int y){return -a[y]/b[y]>-a[x]/b[x];});
    rep(i,n)inv[ord[i]]=i;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2304
#include <stdio.h>

#define min(a, b) (a < b ? a : b)

int main( void ) {
	long long n, s;
	scanf("%lld %lld", &n, &s);
	
	const long long inf = 1LL << 60;
	
	long long ans = inf;
	for( int d = 2; (long long) d * d <= n; d++ ) {
		long long k = n;
		
		long long sum = 0;
		while( k > 0 ) {
			sum += k % d;
			k /= d;
		}
		
		if( sum == s ) {
			ans = min(ans, d);
		}
	}
	
	for( long long d = 1; d * d <= n; d++ ) {
		long long r = s - d;
		if( r >= 0 ) {
			if( (n - r) % d == 0 ) {
				long long b = (n - r) / d;
				if( d < b && r < b ) {
					ans = min(ans, b);
				}
			}
		}
	}
	
	if( n == s ) {
		ans = n + 1;
	}
	
	if( ans < inf ) {
		printf("%lld\n", ans);
	} else {
		printf("-1\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;


Int n;
vector<Int> edge[220000];
Int c[220000];
Int ans[220000];
int last_c[220000];
Int tree_size[220000];
Int parent[220000];
Int no_parent_cnt[220000];
vector<int> children[220000];

Int cnt(Int a){
    return a * (a-1) / 2 + a;
}

void dfs(int x, int last = -1){    
    parent[x] = last_c[c[x]];
    last_c[c[x]] = x;
    if(parent[x] != -1){
        children[parent[x]].push_back(x);
    }
    tree_size[x] = 1;
    for(auto to:edge[x]){
        if(to == last)continue;
        dfs(to, x);
        tree_size[x] += tree_size[to];
        Int tmp = tree_size[to];
        for(auto child: children[x]){
            tmp -= tree_size[child];
        }
        children[x].clear();
        ans[c[x]] -= cnt(tmp);
    }
    if(parent[x] == -1){
        no_parent_cnt[c[x]] -= tree_size[x];
    }
    last_c[c[x]] = parent[x];
}

int main(){
    cin >> n;
    fill(last_c, last_c + 220000, -1);
    fill(no_parent_cnt, no_parent_cnt + 220000, n);
    fill(ans, ans + n, cnt(n));
    for(int i = 0;i < n;i++){
        cin >> c[i];
        c[i]--;
    }
    for(int i = 0;i < n-1;i++){
        int u, v;
        cin >> u >> v;u--,v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0);
    for(int i = 0;i < n;i++){
        ans[i] -= cnt(no_parent_cnt[i]);
        cout << ans[i] << endl;
    }
    return 0;
}

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

typedef long long int ll;
using Graph = vector<vector<int>>;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll MOD = 1000000007;

int main(){
  ll N;
  cin >> N;
  vector<ll> div(1010);
  for(int i = 1;i < N+1;i++){
    int t = i;
    for(int j = 2;j < i+1;j++){
      while(t % j == 0 && t != 0){
        div[j]++;
        t = t / j;
      }
    }
  }
  ll ans = 1;
  for(int i = 1;i < N+1;i++){
    ans *= (div[i]+1);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B&&A!=C)
    cout<<"Yes"<<endl;
  else if(A==C&&A!=B)
    cout<<"Yes"<<endl;
  else if(B==C&&A!=B)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class HeavyLightDecomposition:
    def __init__(self, g, root=0):
        self.g = g
        self.vid, self.head, self.heavy, self.parent = [0] * len(g), [-1] * len(g), [-1] * len(g), [-1] * len(g)
        self.dfs(root)
        self.bfs(root)

    def dfs(self, root):
        stack = [(root, -1, False)]
        sub, max_sub = [1] * len(self.g), [(0, -1)] * len(self.g)
        while stack:
            v, par, flag = stack.pop()
            if not flag:
                self.parent[v] = par
                stack.append((v, par, True))
                stack.extend((c, v, False) for c in self.g[v] if c != par)
            else:
                if par != -1:
                    sub[par] += sub[v]
                    max_sub[par] = max(max_sub[par], (sub[v], v))
                self.heavy[v] = max_sub[v][1]

    def bfs(self, root=0):
        from collections import deque
        k, que = 0, deque([root])
        while que:
            r = v = que.popleft()
            while v != -1:
                self.vid[v], self.head[v] = k, r
                for c in self.g[v]:
                    if c != self.parent[v] and c != self.heavy[v]:
                        que.append(c)
                k += 1
                v = self.heavy[v]

    def lca(self, u, v):
        while self.head[u] != self.head[v]:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
            v = self.parent[self.head[v]]
        else:
            if self.vid[u] > self.vid[v]:
                u, v = v, u
        return u

N = int(input())
g = [[] for _ in range(N)]
for i in range(N):
    for c in map(int, input().split()[1:]):
        g[i].append(c)
        g[c].append(i)
hld = HeavyLightDecomposition(g)
Q = int(input())
for _ in range(Q):
    u, v = map(int, input().split())
    print(hld.lca(u, v))

Measured memory_bytes: 38968
import math

A, B = map(int, input().split())

A_row = math.ceil((A-1)/50)
A_row_full = (A-1)//50
B_row = math.ceil((B-1)/50)
B_row_full = (B-1)//50

if A_row == 0:
    A_row = 1
if B_row == 0:
    B_row = 1

A_mod = (A-1)%50
B_mod = (B-1)%50

if A_row == A_row_full:
    A_mod = 50
    A_row_full -= 1
if B_row == B_row_full:
    B_mod = 50
    B_row_full -= 1

print("100 ", (A_row+B_row)*2)

for i in range(50):
    print('.#'*A_row_full + ('.#' if i < A_mod else '##') + '.#'*B_row_full + ('.#' if i < B_mod else '..'))
    print('##'*A_row + '..'*B_row)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int count;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {
			count = 0;
			int n = Integer.parseInt(line.split(" ")[0]);
			int s = Integer.parseInt(line.split(" ")[1]);
			solve(0, n, s);
			System.out.println(count);
		}
	}

	// p: 算入する数字
	// n: 算入する数字の数
	// s: 目標の合計値
	static void solve(int p, int n, int s) {
		if (p > 9 || n == 0) {
			return;
		}
		if (n == 1 && p == s) {
			count++;
		}
		solve(p + 1, n - 1, s - p);
		solve(p + 1, n, s);
	}
}

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

typedef long long ll;
using namespace std;
int main()
{
  ll n;
  ll l[120];
  cin>>n;
  rep(i,n)cin>>l[i];


  ll count=0;


  sort(l,l+n);


  rep(i,n-2){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k]&&l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
          count++;
        }
      }
    }
  }


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


Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var s string
	var ret int8
	fmt.Scanf("%s",&s)
	if s == "SUN"{
		ret=7
	} else if s == "MON"{
		ret=6
	} else if s == "TUE"{
		ret=5
	} else if s == "WED"{
		ret=4
	} else if s == "THU"{
		ret=3
	}else if s=="FRI"{
		ret=2
	}else if s=="SAT"{
		ret=1
	}
	fmt.Println(ret)
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main( String[] args ) {
		int[] intAry = new int[2];
		Scanner sc = new Scanner( System.in ) ;
		String s = sc.nextLine() ;
		scanInt( s, intAry ) ;
		while( intAry[0] != 0 || intAry[1] != 0 ) {
			if ( intAry[0] > intAry[1] ) {
				System.out.println( intAry[1] + " " + intAry[0] ) ;
			} else {
				System.out.println( intAry[0] + " " + intAry[1] ) ;
			}
			s = sc.nextLine();
			scanInt( s, intAry ) ;
		}
	}
	public static void scanInt( String str, int[] intAry ) {
		Pattern ptn = Pattern.compile( "([0-9]+)\\s+([0-9]+)");
		Matcher mch = ptn.matcher( str ) ;
		if ( mch.find() == true ) {
			intAry[0] = Integer.parseInt( mch.group(1) ) ;
			intAry[1] = Integer.parseInt( mch.group(2) ) ;
		}
	}
}

Measured memory_bytes: 34772
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int H, W, D; cin >> H >> W >> D;
    vector<pair<int, int>> coordinate(H * W);
    REP(i, 0, H) {
        REP(j, 0, W) {
            int a; cin >> a;
            coordinate[--a] = {i, j};
        }
    }

    vector<vector<int>> dist(D);
    REP(i, 0, D) {
        dist[i].push_back(0);
        for (int j = i + D; j < H * W; j += D) {
            dist[i].push_back(abs(coordinate[j - D].first - coordinate[j].first) + abs(coordinate[j - D].second - coordinate[j].second) + dist[i].back());
        }
    }

    int q; cin >> q;
    while (q--) {
        int l, r; cin >> l >> r; l--; r--;
        cout << dist[l % D][r / D] - dist[l % D][l / D] << endl;
    }
    return 0;
}

Measured memory_bytes: 8724
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<vector>
using namespace std;
vector<int> g[100001];
int res[100001][2];
queue<int> q;
void bfs(int sx,int l){
  q.push(sx);
  res[sx][l]=1;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    for(int i=0;i<g[x].size();i++)
      if(!res[g[x][i]][l]){
        res[g[x][i]][l]=res[x][l]+1;
        q.push(g[x][i]);
      }
  }
}
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  bfs(1,0);
  bfs(n,1);
  int cnt=0;
  for(int i=1;i<=n;i++){
    if(res[i][0]<=res[i][1])
      cnt++;
    else
      cnt--;
  }
  puts((cnt>0)?"Fennec":"Snuke");
  return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    vi a(3);
    cin>>a[0]>>a[1]>>a[2];
    Sort(a);
    cout<<a[0]*a[1]/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
std::map<int,std::vector<int>> link;
int hight[100001];
int main() {
    int n,m,left,right;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",hight+i);
    }
    for(int i=0;i<m;i++){
        scanf("%d %d",&left,&right);
        link[left].push_back(right);
        link[right].push_back(left);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        bool test=true;
        for(int j=0;j<link[i].size();j++){
            if(hight[link[i][j]]>=hight[i])
                test=false;
        }
        if(test) ans++;
    }
    printf("%d",ans);
}

Measured memory_bytes: 14796
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[][] a = in.nextInt2dArray(3, 3);
            for (int i = 1; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (a[i][j] - a[i - 1][j] != a[i][0] - a[i - 1][0]) {
                        out.println("No");
                        return;
                    }
                }
            }
            for (int j = 1; j < 3; j++) {
                for (int i = 0; i < 3; i++) {
                    if (a[i][j] - a[i][j - 1] != a[0][j] - a[0][j - 1]) {
                        out.println("No");
                        return;
                    }
                }
            }
            out.println("Yes");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        public int[][] nextInt2dArray(int n, int m) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

    }
}



Measured memory_bytes: 21716
a=int(input())
P = [input().split() for i in range(a)]
#print(P)
import itertools
L=list(itertools.permutations(range(a)))

N=[0]
for l in L:
  A=0
  #print(l)
  for i in range(a-1):
    n0 = int(l[i])
    n1 = int(l[i+1])
    A += (((int(P[n0][0]) - int(P[n1][0])) ** 2) + ((int(P[n0][1]) - int(P[n1][1])) ** 2)) ** 0.5
  N.append(A)
#print(N)
print(sum(N)/len(L))


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    int ans = 0;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                ++cnt;
            }
            int cur = 1;
            while (cnt >= cur) {
                cnt -= cur;
                ++ans;
                ++cur;
            }
        }
    }
    if (n > 1) ++ans;
    cout << ans << '\n';
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  
  int ans=0;
  
  for(int i=0;i<n;i++){
    while(a[i]){
      int p=0;
      for(int j=i;j<n;j++){
        if(a[j]){
          p++;
          a[j]--;
        }
        else break;
      }
      if(p) ans++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3536
#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; }

ll gcd(ll a, ll b){
	while(b){
		a %= b;
		swap(a, b);
	}
	return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin >> t;
    for(int _ = 0; _ < t; _++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(a < b || b > d){
            cout << "No" << '\n';
            continue;
        }
        if(c >= b - 1){
            cout << "Yes" << '\n';
            continue;
        }
        // b <= a, b <= d, c <= b - 2
        // [c + 1, b - 1]
        a %= b;
        ll diff = d - b;
        if(diff == 0){
            cout << (a <= c ? "Yes" : "No") << '\n';
            continue;
        }
        // if(diff > b)
        if(c < a && a < b){
            cout << "No" << '\n';
            continue;
        }
        ll g = gcd(diff, b);
        ll cc = c + 1 - a, bb = b - 1 - a;
        cout << (cc % g && cc / g == bb / g ? "Yes" : "No") << '\n';
    }
}


Measured memory_bytes: 256
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

# ピラミッドの中心に関するH, Cx, Cyが未知数
# (x, y)の高度h = max(H - |Cx -x| - |Cy - y|, 0)
if __name__ == "__main__":
    N = int(sys.stdin.readline())
    L = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

    # ht < 0の要素を確保しておく
    h_base = 0
    for l in L:
        if l[2] > 0:
            h_base = l[:]
    if h_base == 0:
        print("error")
        exit()

    for Cx in range(0, 101):
        for Cy in range(0, 101):
            all_collect = True
            x, y, h = h_base
            H = h + abs(Cx - x) + abs(Cy - y)
            for l in L:
                x, y, h = l
                if h != max(H - abs(Cx - x) - abs(Cy - y), 0):
                    all_collect = False
                    break
            if all_collect:
                print(Cx, Cy, H)
                exit()


Measured memory_bytes: 5164
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2] && s[0] == 'R') print(3);
    else if(s[0] == 'R' && s[0] == s[1]) print(2);
    else if(s[1] == 'R' && s[1] == s[2]) print(2);
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') print(1);
    else print(0);

    

}


Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#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 repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
const long long MOD = 1000000007;
const long long INF = 1LL << 50;
// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	double cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 != 0)cnt++;
	}
	cout << fixed << setprecision(10) << cnt / (double)n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int a,b,c,x,count=0;
	cin >> a >> b >> c >>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if((500*i+100*j+50*k)==x){
					count++;
				}
			}
		}
	}
	cout << count << endl;

	return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,m;
	cin >> n >> m;
	
	vector<vector<int>> g(n+1);
	vector<int> in(n+1);
	while(m--){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
		in[y]++;
	}
	
	queue<int> q;
	vector<int> dist(n+1);
	for(int i = 1; i <= n; ++i){
		if(in[i] == 0){
			q.push(i);
		}
	}
		
	int resp = 0;
	while(!q.empty()){
		int v = q.front(); q.pop();
		for(auto u : g[v]){
			dist[u] = max(dist[u], dist[v]+1);
			resp = max(resp, dist[u]);
			in[u]--;
			if(in[u] == 0){
				q.push(u);
			}
		}
	}
		
	cout << resp << endl;
		
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int b_nontax_min = 10*b;
    int b_nontax_max = 10*(b+1)-1;
    //double a_bar = ceil((a/8.0)*100.0);
    int a_nontax_min = ceil((a/8.0)*100.0);
    int a_nontax_max = ceil(((a+1)/8.0)*100.0) - 1;
    if(a_nontax_min >= b_nontax_min && a_nontax_min <= b_nontax_max)cout << (a_nontax_min) << endl;
    else if(b_nontax_min >= a_nontax_min && b_nontax_min <= a_nontax_max)cout << (b_nontax_min) << endl;
    else cout << -1 << endl;
    return 0;
}


/*
税抜きX
税込みY = X*(108/100)
税   Y - X = 0.08*X
X  = (100/8 )*(Y-X )
X' = (100/10)*(Y-X')

1:10%の時の最大最小を出す
2:8%の値が入ってるか見る
*/

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
mina = 10**9
minus = 0
sumA = 0
for a in A:
    if a < 0:
        minus += 1
        a = -a
    sumA += a
    mina = min(a, mina)
if minus % 2 == 1:
    sumA -= 2 * mina
print(sumA)

Measured memory_bytes: 14332
N = int(input())
As = [0] + [int(a) for a in input().split()] + [0]

total = 0
for i in range(N+1):
    total += abs(As[i+1]-As[i])

for i in range(1,N+1):
    if As[i-1] == As[i] or As[i] == As[i+1] or \
            (As[i-1] < As[i]) == (As[i] < As[i+1]):
        print(total)
    else:
        da = abs(As[i-1]-As[i])
        db = abs(As[i]-As[i+1])
        print(total-2*min(da,db))

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;

int V, E;
long long d[110][110];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> V >> E;
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            d[i][j] = INF;
        }
        d[i][i] = 0;
    }
    for(int i = 0; i < E; i++){
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
    }
    for(int k = 0; k < V; k++){
        for(int i = 0; i < V; i++){
            for(int j = 0; j < V; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            if(d[i][i] != 0){
                cout << "NEGATIVE CYCLE" << endl;
                return 0;
            }
        }
    }
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            if(j) cout << " ";
            if(d[i][j] > 1e11) cout << "INF";
            else cout << d[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3240
# coding: utf-8
from math import floor, ceil
N = int(input())
tmp = floor(N / 1.08)
tmp2 = ceil(N / 1.08)
flag = False
if floor(tmp * 1.08) == N:
    print(tmp)
elif floor(tmp2 * 1.08) == N:
    print(tmp2)
else:
    print(":(")

Measured memory_bytes: 3060
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        mut h: [usize; n]
    }
    let mut ans = 0;
    loop {
        if h.clone().into_iter().max().unwrap() == 0 {
            break;
        }
        let mut i = 0;
        while i < n {
            if h[i] == 0 {
                i += 1;
            } else {
                ans += 1;
                while i < n && h[i] > 0 {
                    h[i] -= 1;
                    i += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2180
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vi v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K; cin>>K;
    cout<<v.at(K-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <long long> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
 
#define all(v) v.begin(),v.end()
#define nl endl
#define bs(v,n) binary_search(v.begin(),v.end(),n)
#define sz() size()
#define pb push_back
 
ll mod=10000;

int main() {
	int R,G,B,N;
	cin>>R>>G>>B>>N;
	ll c=0;
	ll i,j;
	for(i=0;i<=N;i++){
		if(R*i>N) break;
		for(j=0;j<=N;j++){
			if(G*j>N) break;
			if((N-i*R-j*G)%B==0){
				ll k=(N-i*R-j*G)/B;
				if(0<=k and k<=N and (R*i+G*j+B*k)==N) c++;
			}
		}
	}
	cout<<c<<nl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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

long long int a[3][100001];

int main() {
	int n = 0;
	int x = 0;
	cin >> n >>  x;
	vector<int> a(10000);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	int d = 0;
	int cnt = 1;
	for (int i = 0; i < n; i++) {
		d += a.at(i);
		if (d <= x) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define fore(i,a) for(auto &i:a)
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

//---------------------------------------------------------------------------------------------------


//---------------------------------------------------------------------------------------------------

int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   int n,sum = 0,ans = 0,ans2 = 0;
   cin >> n;
   int a[n];
   rep(i,0,n){
      cin >> a[i];
      sum += a[i];
   }

   int b = sum / n;

   if(sum % n != 0){
      b++;
      rep(i,0,n){
         ans += (a[i] - b) * (a[i] - b);
      }
      b--;
      rep(i,0,n){
         ans2 += (a[i] - b) * (a[i] - b);
      }
      cout << min(ans,ans2) << endl;
   }else{
      rep(i,0,n){
         ans += (a[i] - b) * (a[i] - b);
      }
      cout << ans << endl;
   }
   return 0;
}

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

class D
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(long.Parse).ToArray();
		Console.WriteLine(Factorize(Gcd(h[0], h[1])).Distinct().Count() + 1);
	}

	static long Gcd(long x, long y) { for (long r; (r = x % y) > 0; x = y, y = r) ; return y; }

	static long[] Factorize(long n)
	{
		var r = new List<long>();
		for (long x = 2; x * x <= n && n > 1; ++x)
			while (n % x == 0) { r.Add(x); n /= x; }
		if (n > 1) r.Add(n);
		return r.ToArray();
	}
}


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

int main(){
	int a, b, c, x = 0;
	 cin >> a >> b >> c;
	 
	 for(int y = a; y <= b ; y++ ){
	 	if( c%y == 0) x++;
		else ;
	 }
	 
	 cout << x <<endl;
	 
	 return 0;
}


Measured memory_bytes: 3096
P,L="+<"
p=print
r=range
p(6484,P,0,1,3,L,2,3,3)
for x in 0,1:
	p(P,x,3,x)
	for t in r(30):exec('p(P,v:=x+4,v,v,P,v,3,6,'+'P,6,6,6,'*(29-t)+'L,6,x,T:=x*60+9+t,P,v,T,v)')
for t in r(60):p(P,2,2,2);[p(P,8+t-s,69+s,5,L,3,5,6,P,2,6,2)for s in r(t)]

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

int main(void){
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for(int i = 0; i < n; i++){
	std::cin >> a[i];
    }

    int all = 0;
    for(int i = 0; i < n; i++){
	all ^= a[i];
    }

    for(int i = 0; i < n; i++){
	int ans = all ^ a[i];
	std::cout << ans << std::endl;
    }

    return 0;
}



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

using namespace std;

#define N_CONTEST   (26)
#define N_DAY       (365)

static void get_input (int &D, vector<int> &c, vector<vector<int>> &s) {
    cin >> D;
    assert(D == N_DAY);
    for ( int i = 1; i <= N_CONTEST; i++ ) {
        cin >> c.at(i);
    }
    for ( int i = 1; i <= N_DAY; i++ ) {
        for ( int j = 1; j <= N_CONTEST; j++ ) {
            cin >> s.at(i).at(j);
        }
    }
}

static long long calc_score (vector<int> &c, vector<vector<int>> &s, vector<int> &t) {
    vector<int> last(N_CONTEST+1, 0);

    long long score = 0;

    for ( int d = 1; d <= N_DAY; d++ ) {
        score += s.at(d).at(t.at(d));
        last.at(t.at(d)) = d;
        for ( int con = 1; con <= N_CONTEST; con++ ) {
            score -= c.at(con) * (d - last.at(con));
        }
        cout << score << endl;
    }

    return score;
}

int main (void) {
    int D;
    vector<int> c(N_CONTEST+1);
    vector<vector<int>> s(N_DAY+1, vector<int>(N_CONTEST+1, 0));

    get_input(D, c, s);

    for ( int d = 1; d <= N_DAY; d++ ) {
        int max_con = 0;
        int max_score = 0;
        for ( int con = 1; con <= N_CONTEST; con++ ) {
            if ( max_score < s.at(d).at(con) ) {
                max_score = s.at(d).at(con);
                max_con = con;
            }
        }
        cout << max_con << endl;
    }

//    vector<int> t(N_DAY+1, 0);
//    for ( int i = 1; i <= N_DAY; i++ ) {
//        cin >> t.at(i);
//    }
//
//    calc_score(c, s, t);

    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int N, M;
	std::vector<int> L, R;

	std::cin >> N >> M;
	L.resize(M);
	R.resize(M);
	for (int i = 0; i < M; ++i) {
		int l, r;
		std::cin >> l >> r;
		L[i] = l;
		R[i] = r+1;
	}
	
	std::sort(L.rbegin(), L.rend());
	std::sort(R.begin(), R.end());
	std::cout << std::max(0, (R.front() - L.front())) << "\n";
}


Measured memory_bytes: 1024
import numpy as np
import copy

N = int(raw_input().replace("\n", ""))

a_array = np.asarray(sorted([int(raw_input().replace("\n", "")) for i in xrange(N)]))

len_array = len(a_array)

coffs = np.ones(len(a_array), dtype=bool) * 2

if len_array % 2 == 0:
    coffs = [-2] * ((len_array - 1) / 2) + [-1] + [1] + [2] * ((len_array -1) / 2)
    out = np.dot(a_array, coffs)
else:
    coffs1 = [-2] * ((len_array-3) / 2) + [-1] * 2 + [2] * ((len_array-1) / 2)
    coffs2 = [-2] * ((len_array-1) / 2) + [1] * 2 + [2] * ((len_array-3) / 2)
    out1 = np.dot(a_array, coffs1)
    out2 = np.dot(a_array, coffs2)
    out = max(out1, out2)

print out


Measured memory_bytes: 23632
n, l = map(int, input().split())
azi = [l+i-1 for i in range(1, n+1)]
diff = [0]*n
for i in range(n):
    diff[i] = abs(azi[i])

if sum(azi) < 0:
    print(sum(azi) + abs(min(diff)))
else:  
    print(sum(azi) - min(diff))



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

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

  int H, W, N;
  cin >> H >> W >> N;

  vector<long long> ans(10);
  map<pair<int, int>, int> grid;

  for (int qi = 0; qi < N; qi++) {
    int r, c;
    cin >> r >> c;
    for (int i = r - 1; i <= r + 1; i++) {
      for (int j = c - 1; j <= c + 1; j++) {
        if (1 < i && i < H && 1 < j && j < W) {
          grid[{i, j}]++;
        }
      }
    }
  }
  int sum_all = 0;
  for (auto &i : grid) {
    ans[i.second]++;
    sum_all++;
  }

  ans[0] = 1ll * (H - 2) * (W - 2) - sum_all;

  for (int i = 0; i < 10; i++) {
    cout << ans[i] << "\n";
  }

  // for (int i = 1; i <= H; i++) {
  //   for (int j = 1; j <= W; j++) {
  //     cout << grid[{i, j}] << " \n"[j == W];
  //   }
  // }

}

Measured memory_bytes: 56576
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    vector<pair<pi,int>> r;
    REP(i,1,150){
        REP(j,i+1,150){
            r.pb({{i,j},i*i+j*j});
        }
    }
    sort(all(r),[](pair<pi,int> &x,pair<pi,int> &y){if(x.se==y.se)return x.fi.fi<y.fi.fi;return x.se<y.se;});
    while(true){
    int h,w;
    cin>>h>>w;
    if(!h)break;
    rep(i,r.size()){
        if(r[i].fi==mp(h,w)){
            cout<<r[i+1].fi.fi<<sp<<r[i+1].fi.se<<endl;
            break;
        }
    }
    }
}


Measured memory_bytes: 3280
n, m = map(int, input().split())
hList = list(map(int, input().split()))
hAns = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if hList[a - 1] > hList[b - 1]:
        hAns[b - 1] = 0
        continue
    if hList[a - 1] < hList[b - 1]:
        hAns[a - 1] = 0
        continue
    hAns[a - 1] = 0
    hAns[b - 1] = 0
print(sum(hAns))

Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=3e2+10;
#define fi first
#define se second
#define pb push_back
LL dis[N][N];
int n,m,l,vis[N];
struct uzi{
    int a;
    LL b;
    LL c;
    bool operator <(const uzi & t)const{
        if(c==t.c)return b<t.b;
        return c>t.c;
    }
};
vector<pair<int,int> >v[N];

LL tmp[N][N];
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>m>>l;
    for(int i=1;i<=m;i++){
        int s,t,w;
        cin>>s>>t>>w;
        v[s].pb({t,w});
        v[t].pb({s,w});
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i!=j)dis[i][j]=LLONG_MAX,tmp[i][j]=0;
            else dis[i][j]=0;
        }
    }
    for(int i=1;i<=n;i++){
        priority_queue<uzi>q;
        memset(vis,0,sizeof vis);
        q.push({i,l,0});
        tmp[i][i]=l;
        while(!q.empty()){
            auto now=q.top();
            q.pop();
            vis[now.a]=0;
            for(auto k:v[now.a]){
                int cost=k.se;
                int tmpa=tmp[i][now.a];
                if(tmpa>=cost){
                    if(dis[i][k.fi]<dis[i][now.a])continue;
                    if(dis[i][k.fi]==dis[i][now.a]){
                        if(tmp[i][k.fi]>=tmpa-cost)continue;
                    }
                    dis[i][k.fi]=dis[i][now.a];
                    tmp[i][k.fi]=tmpa-cost;
                    if(!vis[k.fi])q.push({k.fi,tmpa-cost,dis[i][now.a]}),vis[k.fi]=1;
                }else if(l>=cost){
                    int need=1;
                    cost=need*l-cost;
                    if(dis[i][k.fi]<dis[i][now.a]+need)continue;
                    if(dis[i][k.fi]==dis[i][now.a]+need){
                        if(tmp[i][k.fi]>=cost)continue;
                    }
                    tmp[i][k.fi]=cost;
                    dis[i][k.fi]=dis[i][now.a]+need;
                    if(!vis[k.fi])q.push({k.fi,cost,need+dis[i][now.a] }),vis[k.fi]=1;
                }else {
                    continue;
                }
            }
        }
    }
    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int s,t;
        cin>>s>>t;
        if(dis[s][t]==LLONG_MAX)cout<<-1<<endl;
        else cout<<dis[s][t]<<endl;
    }
    return 0;
}



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

typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> X(M);
	for(int i=0; i<M; i++) cin >> X[i];
	sort(X.begin(), X.end());

	vector<int> d(M-1);
	for (int i = 0; i < M-1; i++) {
		d[i] = X[i+1]-X[i];
	}
	sort(d.begin(), d.end());

	int ans=0;
	if (N >= M) {
		cout << ans << endl;
	}
	else {
		for (int i = 0; i < M-N; i++) {
			ans += d[i];
		}
		cout << ans << endl;
	}
	
}


Measured memory_bytes: 1024