akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

unsigned short calculate_num_monitor (unsigned short num_tree_all, unsigned short num_range)
{
	// variable for this function
	register unsigned short num_tree_monitored;
	register unsigned short num_monitor;

	num_tree_monitored = (unsigned short)(2) * num_range + (unsigned short)(1);
	num_monitor        = num_tree_all / num_tree_monitored;

	if ( num_tree_all % num_tree_monitored != (unsigned short)(0) ) { num_monitor += (unsigned short)(1); }

	return num_monitor;
}

int main (void)
{
	// variables for main process
	register unsigned short N;
	register unsigned short D;

	// STEP.01
	// read out the given data
	std::cin >> N >> D;

	// STEP.02
	// output the answer of this task
	std::cout << calculate_num_monitor (N, D) << std::endl;

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

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

    static class D
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = 1;
            while (T-- > 0)
            {
                solveOne(in, out);
            }
        }

        private void solveOne(Scanner in, PrintWriter out)
        {
            int N = in.nextInt();
            int K = in.nextInt();
            int P[] = CPUtils.readIntArray(N, in);
            int nums[] = CPUtils.readIntArray(N, in);
            long ans = Long.MIN_VALUE;
            for (int idx = 0; idx < N; idx++)
            {
                boolean visited[] = new boolean[N];
                List<Long> seq = new ArrayList<>();
                fillSeq(P[idx] - 1, 0, P, nums, seq, visited);
                //System.out.println(seq);

                if (K <= seq.size() || seq.get(seq.size() - 1) < 0)
                {
                    for (int i = 0; i < Math.min(K, seq.size()); i++)
                    {
                        ans = Math.max(ans, seq.get(i));
                    }
                } else
                { // K >= seq.length && seq is positive
                    long localAns;
                    long times = (K / seq.size() - 1);
                    localAns = times * seq.get(seq.size() - 1);
                    ans = Math.max(ans, localAns);

                    int j = P[idx] - 1;
                    for (long k = (times * seq.size()) + 1; k <= K; k++)
                    {
                        localAns += nums[j];
                        ans = Math.max(ans, localAns);
                        j = P[j] - 1;
                    }
                    //System.out.println(localAns);
                }
            }
            out.println(ans);
        }

        private void fillSeq(int idx, long sum, int[] P, int[] nums, List<Long> seq, boolean[] visited)
        {
            if (visited[idx]) return;
            visited[idx] = true;
            sum += nums[idx];
            seq.add(sum);
            fillSeq(P[idx] - 1, sum, P, nums, seq, visited);
        }

    }

    static class CPUtils
    {
        public static int[] readIntArray(int size, Scanner in)
        {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
            {
                array[i] = in.nextInt();
            }
            return array;
        }

    }
}



Measured memory_bytes: 49056
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	ll a;
	string s;
	cin >> a >> s;

	if (a >= 3200) { cout << s; }
	else { cout << "red"; }

	system("PAUSE");
}

Measured memory_bytes: 504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;


public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br   = new BufferedReader(isr);
        PrintWriter out     = new PrintWriter(System.out);
        String line;
        String[] numList = new String[2];
        int n = Integer.parseInt(br.readLine());
        for(int i=0; i<n; i++) {
            line = br.readLine();
            numList = line.split(" ");
            double num0 = Math.pow(Double.parseDouble(numList[0]), 2);
            double num1 = Math.pow(Double.parseDouble(numList[1]), 2);
            double num2 = Math.pow(Double.parseDouble(numList[2]), 2);
            if ((num2 == num0 + num1) || (num0 == num1 + num2) || (num1 == num0 + num2)) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }
}

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

vector<int> g[100001];
int color[100001];//-1:パス, 0:無色, 1:有色
int N;

bool check_path(int prev,int v){
    if(v==N)return true;
    bool isPath=false;
    for(int to:g[v])if(to!=prev){
        isPath |= check_path(v,to);
    }
    if(isPath)color[v]=-1;
    return isPath;
}

bool paint(deque<int> &qu){
    if(qu.empty()) return false;
    while(color[qu.front()]>0){
        qu.pop_front();
        if(qu.empty()) return false;
    }
    int v = qu.front();
    qu.pop_front();
    color[v] = 1;
    for(int to:g[v]){
        if(color[to]==-1)qu.push_front(to);
        if(color[to]==0)qu.push_back(to);
    }
    return true;
}

int main(void){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    check_path(-1,1);
    color[1] = 0;
    
    deque<int> fennec,snuke;    
    fennec.push_front(1);
    snuke.push_front(N);
    while(true){
        if(!paint(fennec)){
            cout<<"Snuke"<<endl;
            break;
        }
        if(!paint(snuke)){
            cout<<"Fennec"<<endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC
 
#define fi first
#define se second
#define ll long long int
#define dl double long
 
using namespace std;
 
const int N = 1e5 + 7;
const ll mod = 1e9 + 7;

vector<int> dp(N);

void solve1()
{
	int n;
	cin >> n;
	int ar[n];
	for(int i = 0; i < n; i++)
		cin >> ar[i];
	dp[1] = 0;
	dp[2] = abs(ar[1] - ar[0]);
	for(int i = 3; i <= n; i++){
		dp[i] = min(abs(ar[i - 1] - ar[i - 2]) + dp[i - 1], abs(ar[i - 1] - ar[i - 3]) + dp[i - 2]);
	}
	cout << dp[n];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );
	//freopen( "blist.in" , "r" , stdin );
    //freopen( "blist.out" , "w" , stdout );
    
    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 4004
a=int(input())
lis=list(map(int,input().split()))
suu=0
ans=0
x=0
while len(lis)>x:
  if lis[x]==suu+1:
    suu+=1
  else:
    ans+=1
  x+=1
if ans==a:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 26268
n = int(input())
a = list(map(int,input().split()))
mina = a[0]
maxa = a[0]
for i in range(n):
         if a[i] > maxa:
                  maxa = a[i]
         elif a[i] < mina:
                  mina = a[i]
print(maxa - mina)


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

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

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

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){ 
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++){ 
        dp[i] = INF;
    }

    dp[0] = 0;
    for(int i = 0; i < N; i++){ 
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;
 
int main()
{
    int n;
    vi a;
 
    cin >> n;
    a.resize(n);
    rep(i,n) cin >> a[i];
 
    sort(all(a), greater<int>());
 
    ll e[3];
    int m = 0;
    rrep(i,n-1){
        if(i == 0) continue;
        if(a[i] == a[i-1]){
            e[++m] = a[i];
            i++;
        }
        if(m == 2) break;
    }
    ll ans = e[1] * e[2];
    if(m < 2) puts("0");
    else cout << ans << endl;
}


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

M = []
for i in range(n):
    r, c = map(int, input().split())
    if i == 0: M.append(r)
    M.append(c)

dp = [[float("inf")] * (n+1) for _ in range(n+1)]

for i in range(1,n+1):
    dp[i][i] = 0

for l in range(2, n+1):
    for i in range(1,n-l+2):
        j = i + l -1
        for k in range(i, j):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + M[i-1]*M[k]*M[j])

print(dp[1][n])



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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(3e3) + 17;

int n;
int a[MAXN];
bool used[MAXN][MAXN];
pair<ll, ll> dp[MAXN][MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void dfs(int l, int r, int t) {
    if (used[l][r])
        return ;

    used[l][r] = true;

    if (l == r) {
        if (t == 0)
            dp[l][r] = mp(a[l], 0);
        else
            dp[l][r] = mp(0, a[l]);

        return ;
    }

    dfs(l + 1, r, t ^ 1);
    dfs(l, r - 1, t ^ 1);

    if (t == 0) {
        if (a[l] + dp[l + 1][r].f - dp[l + 1][r].s > a[r] + dp[l][r - 1].f - dp[l][r - 1].s)
            dp[l][r] = mp(a[l] + dp[l + 1][r].f, dp[l + 1][r].s);
        else
            dp[l][r] = mp(a[r] + dp[l][r - 1].f, dp[l][r - 1].s);
    } else {
        if (dp[l + 1][r].f - dp[l + 1][r].s - a[l] < dp[l][r - 1].f - dp[l][r - 1].s - a[r])
            dp[l][r] = mp(dp[l + 1][r].f, a[l] + dp[l + 1][r].s);
        else
            dp[l][r] = mp(dp[l][r - 1].f, a[r] + dp[l][r - 1].s);
    }
}

void solve() {
    dfs(0, n - 1, 0);
    cout << dp[0][n - 1].f - dp[0][n - 1].s << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

const int N = 410;
const int mod = 998244353;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}    

int dp[2][N][N][N], A[N], B[N], C[N][N];

int main() {
    int n, s = 0; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &A[i], &B[i]), s = (s + A[i]) % mod;
    for (int i = 0; i <= 400; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
    }
    for (int i = 1, t = 0, t1 = 0; i <= n; t += B[i] - 1, t1 += A[i], i++) 
        for (int j = 0; j <= t; j++) 
            for (int k = 0; k <= t1; k++) {
                dp[0][i][j][k] = (dp[0][i][j][k] + dp[0][i - 1][j][k]) % mod;
                dp[1][i][j][k] = (dp[1][i][j][k] + dp[1][i - 1][j][k]) % mod;
                int p = (LL)k * Pow(k + A[i], mod - 2) % mod, p1 = Pow(p, j);
                for (int l = 0; l < B[i]; l++) {
                    int w = (LL)C[j + l][j] * p1 % mod * Pow(1 + mod - p, l) % mod;
                    dp[0][i][j + l][k + A[i]] = (dp[0][i][j + l][k + A[i]] + (LL)dp[1][i - 1][j][k] * w) % mod;
                    dp[1][i][j + l][k + A[i]] = (dp[1][i][j + l][k + A[i]] + (LL)dp[0][i - 1][j][k] * w) % mod;
                    if (k == 0 && j == 0) dp[1][i][l][A[i]] = (dp[1][i][j + l][A[i]] + w) % mod;
                }
            }
    int ans = 0;
    for (int t = 0; t <= 1; t++) 
        for (int j = 0; j <= 400; j++)
            for (int k = 0; k <= 400; k++) {
            	int w = (LL)dp[t][n][j][k] * s % mod * Pow(k, mod - 2) % mod;
            	if (t & 1) ans = (ans + w) % mod;
				else ans = (ans - w + mod) % mod; 
			}
    printf("%d\n", ans);
    return 0;    
}


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

int f[11];

int main()
{
    for(int i = 0; i < 3; i++)
    {
        int x;
        cin >> x;
        f[x]++;
    }
    cout << ((f[5] == 2 && f[7] == 1) ? "YES" : "NO") << endl;
    return 0;
}


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

void PrimeFactorization(long long n, vector<pair<long long, int>>& f) {
	if (n < 2) {
		pair<long long, int> t;
		t.first = -1;
		f.push_back(t);
		return;
	}
	if (n % 2 == 0) {
		pair<long long, int> t;
		t.first = 2;
		t.second = 0;
		while (n % 2 == 0)
		{
			t.second++;
			n /= 2;
		}
		f.push_back(t);
	}
	for (long long p = 3; p * p <= n; p += 2) {
		if (n % p == 0) {
			pair<long long, int> t;
			t.first = p;
			t.second = 0;
			while (n % p == 0)
			{
				t.second++;
				n /= p;
			}
			f.push_back(t);
		}
	}
	if (n != 1) {
		pair<long long, int> t;
		t.first = n;
		t.second = 1;
		f.push_back(t);
	}
}

int main()
{
	long long n;
	cin >> n;
	vector<pair<long long, int>> x;
	PrimeFactorization(n, x);

	long long sum = 0;
	for (int i = 0; i < x.size(); i++) {
		for (int j = 1; j <= x[i].second;j++) {
			x[i].second -= j;
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void)
{
	int a,b,c[101]={0},d,e=0,f=0,g,h,i;
	for (a=0;a<4;a++)
	{
		cin>>b;
		c[b]=1;
	}
	for (a=100;a>0;a--)
	{
		if (c[a]==1&&e!=3)
		{
			f=f+a;
			e++;
		}
	}
	cin>>d>>e;
	if (d>=e)
	{
		g=d+f;
	}
	else if (d<=e)
	{
		g=e+f;
	}
	cout<<g<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>

#define PI 3.141592
typedef struct {
  double x;
  double y;
} xy_t;

void koch(int n, xy_t* p1_p, xy_t* p2_p){
  xy_t s={0} ,t={0} ,u={0};
  double rad;
if( n == 0 ){
  return;
}

// internally dividing point
  s.x = ( 2*(p1_p->x) + 1*(p2_p->x) )/(1+2);
  s.y = ( 2*(p1_p->y) + 1*(p2_p->y) )/(1+2);
  t.x = ( 1*(p1_p->x) + 2*(p2_p->x) )/(2+1);
  t.y = ( 1*(p1_p->y) + 2*(p2_p->y) )/(2+1);
// http://imagingsolution.blog107.fc2.com/blog-entry-111.html
  rad = 60 * PI / 180;
  u.x = t.x*cos(rad) - t.y*sin(rad) + s.x - s.x*cos(rad) + s.y*sin(rad); 
  u.y = t.x*sin(rad) + t.y*cos(rad) + s.y - s.x*sin(rad) - s.y*cos(rad);

  koch(n-1 ,p1_p ,&s);
  printf("%f %f\n" ,s.x ,s.y );
  koch(n-1 ,&s ,&u);
  printf("%f %f\n" ,u.x ,u.y );
  koch(n-1 ,&u ,&t);
  printf("%f %f\n" ,t.x ,t.y );
  koch(n-1 ,&t ,p2_p);

}

int main(){ 
  int i,j;
  int n;
  xy_t p1, p2;
  p1.x = 0;   p1.y = 0;
  p2.x = 100;  p2.y = 0;

  scanf("%d", &n);

  printf("%f %f\n" ,p1.x ,p1.y );
  koch( n, &p1, &p2);
  printf("%f %f\n" ,p2.x ,p2.y );
  
  return 0; // Don't forget return 0
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
using namespace std;
bool p[1000000];
int prime[80000];
int top;
int F(int p,int m){
	int left,right,midl,midr;
	left=0,right=top;
	while(true){
		if(left>=right-1)break;
		midl=(left+right)/2;
		if(prime[midl]<p-m)left=midl;
		else right=midl;
	}
	if(prime[midl]>=p-m)midl--;
	if(p-m<=2)midl=-1;
	left=0,right=top;
	while(true){
		if(left>=right-1)break;
		midr=(left+right)/2;
		if(prime[midr]==p+m)break;
		if(prime[midr]<p+m)left=midr;
		else right=midr;
	}
	if(prime[midr]>p+m)midr--;
	//cout<<"%"<<prime[midl]<<" "<<prime[midr]<<endl;
	return midr-midl;
}
int main(){
	for(int i=0;i<1000000;i++)p[i]=true;
	for(int i=2;i<1000;i++)if(p[i])for(int j=i*i;j<1000000;j+=i)p[j]=false;
	top=0;
	for(int i=2;i<1000000;i++)if(p[i]){prime[top]=i;top++;}
	int n,p,m,ans;
	while(true){
	cin>>n;
	if(n==0)break;
	ans=0;
	for(int u=0;u<n;u++){
		cin>>p>>m;
		ans+=F(p,m)-1;
		//cout<<"#"<<F(p,m)<<endl;
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

struct Error {
  template<class T1, class T2> Error& operator << (pair<T1,T2> p) {
    return *this << "(" << p.first << ", " << p.second << ")";
  }
  template<class T1> typename enable_if<is_scalar<T1>::value || is_same<T1,string>::value, Error&>::type operator << (T1 a) {
    cerr << boolalpha << a; 
    return *this;
  }
  template<class T1> typename enable_if<!is_scalar<T1>::value && !is_same<T1,string>::value, Error&>::type operator << (T1 a) {
    *this << "{";
    for (auto it = a.begin(); it != a.end(); it++) {
      if (it != a.begin()) 
        *this << ", ";
      *this << *it;
    }
    return *this << "}";
  }
  template<class T1, class T2, class T3> Error& operator << (tuple<T1,T2,T3> t) {
    return *this << "(" << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ")";
  }
  template<class T1, class T2, class T3, class T4> Error& operator << (tuple<T1,T2,T3,T4> t) {
    return *this << "(" << get<0>(t) << ", " << get<1>(t) << ", " << get<2>(t) << ", " << get<3>(t) << ")";
  }
  template<class T1> Error& operator << (queue<T1> q) {
    vector<T1> v;
    while (!q.empty()) {
      v.push_back(q.front());
      q.pop();
    }
    return *this << v;
  }
  template<class T1> Error& operator << (stack<T1> s) {
    vector<T1> v;
    while (!s.empty()) {
      v.push_back(s.top());
      s.pop();
    }
    return *this << v;
  }
};

#define err Error()
#define aty(x) #x << " : " << x 

template<class T1> void dout(string name, T1 a) {
  err << name << " : " << a << "\n";
}

template<class T1, class... T2> void dout(string names, T1 a, T2... args) {
  err << names.substr(0, names.find(",")) << " : " << a << " | ";
  dout(names.substr(names.find(",") + 2), args...);
}

#ifdef LOCAL
#define debug(...) dout(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> minDiv(n + 1, -1);
  for (int i = 2; i <= n; ++i) {
    if (minDiv[i] == -1) {
      for (int j = i; j <= n; j += i) {
        minDiv[j] = i;
      }
    }
  }
  // debug(minDiv);
  // return 0;
  ll ans = 1;
  for (int i = 2; i - 1 < n; ++i) {
    int total = 1;
    int x = i;
    while (x != 1) {
      int cnt = 0;
      int y = minDiv[x];
      while (x % y == 0 && x != 1) {
        x /= y;
        cnt++;
      }
      // debug(cnt, i);
      total = total * 1ll * (cnt + 1);
    }
    ans += total * 1ll * i;
    // debug(ans, total, i);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 42256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<bool> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<ll> a(10000001,1);
    for(int i=2;i<=10000000;i++){
        ll x = i;
        while(x<=10000000){
            a.at(x)++;
            x+=i;
        }
    }
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans += i * a.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81332
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

const llong mod = (llong)1e9 + 7;
llong n;
llong a[100005];
llong b[100005];
llong maxv = 0;
llong cnt = 0;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        maxv = max(maxv, a[i]);
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        maxv = max(maxv, b[i]);
    }

    for (int i = 1; i <= n; i++) {
        if (a[i] == b[i] && a[i] == maxv) cnt++;
    }

    llong ans = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] > a[i - 1] || b[i] > b[i + 1]) continue;
        ans *= min(a[i], b[i]);
        ans %= mod;
    }

    if (cnt) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}


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

int main()
{
    char a[105];
    int n;
    
    scanf("%d",&n);

    scanf(" %s",a);

    int x = 0,maxn = 0;

    for (int i = 0;i < n;i++)
    {
        if (a[i] == 'I')
            x++;
        else
            x--;

        if (x > maxn)
            maxn = x;
    }

    printf("%d\n",maxn);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;
signed main(){
    int n,k;cin>>n>>k;
    int res=0;
    rep1(i,n){
        if(i<=k)continue;
        res+=(n/i)*(i-k)+max((int)0,(n%i)-k+1);
    }
    if(k==0)res=n*n;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
let n, m, ans = Scanf.scanf "%d %d" @@ fun a b -> a, b, ref 0
let f g n = let rec f i = if i * i <= n then (if n mod i = 0 then (g i; if i <> n / i then g (n / i)); f (i + 1)) in f 1
let g d = if m / d >= n then ans := max !ans d
let _ = f g m; Printf.printf "%d\n" !ans

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

int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22)
    {
        cout << "bust" << endl;
        return 0;
    }
    cout << "win" << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
#include <algorithm>
	#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
#include <map>
#include <cmath>

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


int main() {
	//string k;
	//cin >> k;
	//int i = (int)k.length();
	char s[99];
	cin >> s;
	int n = strlen(s);
	int num = 0;
	
	for (int i = 0; i < (n-1)/2; i++) {
		if (s[i] != s[n - 1 - i]) {
			num = 1;
		}
	}

	if (n != 3) {
		for (int i = 0; i < (n - 1) / 4; i++) {
			if (s[i] != s[(n-3)/2-i]) {
				num = 1;
			}
			if (s[n - 1 - i] != s[(n + 1) / 2 + i]) {
				num = 1;
			}
		}
	}


	if (num == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;

}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
const int inf = 1e9;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int h,w;
	cin>>h>>w;
	string s[h];
	rep(i,h){
		cin>>s[i];
	}	
	int a[h+1][w+1];
	rep(i,h+1){
		rep(j,w+1)a[i][j] = inf;
	}
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '.')a[i+1][j+1] = 0;
			else a[i+1][j+1] = 1;
		}
	}
	int dp[h+1][w+1];
	int change[h+1][w+1];
	rep(i,h+1){
		rep(j,w+1){
			dp[i][j] = inf;
			change[i][j] = 0;
		}
	}
	dp[0][1] = 0;
	dp[1][0] = 0;
	repa(i,1,h+1){
		repa(j,1,w+1){
			if(a[i][j] == 0){
				dp[i][j] =  min(dp[i-1][j],dp[i][j-1]);
			}
			else{
				if(a[i-1][j] == 1){
					dp[i][j] = min(dp[i][j],dp[i-1][j]);
				}
				else{
					dp[i][j] = min(dp[i][j],dp[i-1][j]+1);
				}
				if(a[i][j-1] == 1){
					dp[i][j] = min(dp[i][j],dp[i][j-1]);
				}
				else{
					dp[i][j] = min(dp[i][j],dp[i][j-1]+1);
				}			
			}
		}
	}
	cout<<dp[h][w];
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n;
    cin>>n;
    string x;
    cin>>x;
    for(int i = 0 ; i < x.size() ; i++){
        if(i >= n){
            cout<<"...";
            break;
        }else cout<<x[i];
    }

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

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

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

		for (int i = 1; i < s; i++) {
			for (int j = i; j < s; j++) {
				int a = i * (100 + x) / 100;
				int b = j * (100 + x) / 100;
				if (a + b == s) {
					a = i*(100 + y) / 100;
					b = j*(100 + y) / 100;
					ans = max(ans, a + b);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

//関数
//main関数
int main() {
    
    
    
    //入力
    char x;
    cin>>x;
    
    
    
    //計算
    
    //出力
    if(x=='A') cout<<'T'<<endl;
    
    if(x=='T') cout<<'A'<<endl;
    
    if(x=='C') cout<<'G'<<endl;
    
    if(x=='G') cout<<'C'<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

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;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};


int main(){
  double n;cin>>n;
  vector<double> a(n);
  double sum=0;
  REP(i,n){
    cin>>a[i];
    a[i]=1/a[i];
    sum+=a[i];
  }
  cout<<setprecision(15)<<1/sum<<endl;
}


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

int main(){
    int D, G; cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; i++) cin >> p[i] >> c[i];
    int res = 1e9;

    for(int i = 0; i < 1 << D; i++){
        int score = 0, num = 0;
        int Mrest = 0;
        for(int j = 0; j < D; j++){
            if(i >> j & 1){
                num += p[j];
                score += p[j] * (j + 1) * 100 + c[j];
            }else{
                Mrest = j;
            }
        }
        //cout << "i " << i << " score " << score << " num " << num << endl; 
        if(score < G){
            double score1 = 100 * (Mrest + 1);
            int need = ceil((G - score)/ score1);
            if(need >= p[Mrest]) continue;
            num += need;
        }
        res = min(num,res);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
arr_a = []
arr_b = []
for _ in range(n):
    a, b = map(int, input().split())
    arr_a.append(a)
    arr_b.append(b)

max_a = max(arr_a)
arr_b.sort(reverse=True)

ans = 0
for b in filter(lambda x: x > max_a, arr_b):
    ans += 1
    h -= b
    if h <= 0:
        break
else:
    ans += 0 - -h//max_a

print(ans)


Measured memory_bytes: 17052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    private static final long BASE = 1_000_000_000;

    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long s = scanner.nextLong();
        if (s <= BASE) {
            final long diff = BASE - s;
            System.out.println(format(0, 0, BASE, 1, diff, 1));
            return;
        } else if (s == BASE * BASE) {
            System.out.println(format(0, 0, BASE, 0, 0, BASE));
            return;
        }

        final long y3 = s / BASE + 1;
        final long diff = y3 * BASE - s;
        System.out.println(format(0, 0, BASE, 1, diff, y3));
    }

    private static String format(final long x1, final long y1, final long x2, final long y2, final long x3, final long y3) {
        return Stream.of(x1, y1, x2, y2, x3, y3)
                .map(l -> Long.toString(l))
                .collect(Collectors.joining(" "));

    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
    

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

using namespace std;

int n;
bool ans=1;

int main() {
	scanf("%d",&n);
	for(int i=1,v; i<=n; ++i) {
		scanf("%d",&v);
		if(!(v&1) && v%3 && v%5) ans=0;
	}
	puts(ans ? "APPROVED":"DENIED");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s;
    cin >> s;
    int len = s.size();
    int minn = 100005;
    for(int i = 0; i <= len - 3; ++i){
    	int a = s[i] - '0';
    	int b = s[i + 1] - '0';
    	int c = s[i + 2] - '0';
    	int sum = a * 100 + b * 10 + c;
    	if(abs(sum - 753) < minn){
    		//cout << a << " " << b << " " << c << endl;
    		//cout << sum << endl;
    		minn = abs(sum - 753);
    	}
    }
    cout << minn << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 2 * 100000 + 233;
int n;
int pa[maxN], mk[maxN];
vector< pair<int, pii> > ve;

int findset(int x) { return pa[x] == x ? x : pa[x] = findset(pa[x]); }

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#endif
	cin >> n;
	int h, w; cin >> h >> w;
	for(int i = 1; i <= h + w; ++i) pa[i] = i, mk[i] = 0;
	for(int i = 1; i <= n; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		ve.emplace_back(a, pii(x + w, y));
	}
	sort(ve.begin(), ve.end());
	reverse(ve.begin(), ve.end());
	LL ans = 0;
	for(auto e : ve) {
		int x = e.second.first, y = e.second.second;
		x = findset(x); y = findset(y);
		if(x == y) {
			if(!mk[x]) mk[x] = 1, ans += e.first;
		} else if(mk[x] + mk[y] <= 1) {
			pa[x] = y;
			mk[y] |= mk[x];
			ans += e.first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

struct Data{
    int cost,p,tk;
    Data(){}
    Data(int _cost,int _p,int _tk){
        cost=_cost; p=_p; tk=_tk;
    }
    bool operator<(const Data &a)const{
        return cost>a.cost;
    }
};

struct Way{
    int to,cost;
    Way(){}
    Way(int _to,int _cost){
        to=_to; cost=_cost;
    }
};

int main(){
    int C,N,M,S,D,A,B,F;
    while(cin>>C>>N>>M>>S>>D,C||N||M||S||D){
        vector<Way> way[501];
        for(int i=0;i<M;i++){
            cin>>A>>B>>F;
            way[A].push_back(Way(B,F));
            way[B].push_back(Way(A,F));
        }

        priority_queue<Data> q;
        q.push(Data(0,S,0));
        Data q_c;
        bool memo[101][11]={};
        while(!q.empty()){
            q_c = q.top(); q.pop();
            if(q_c.p==D){
                printf("%d\n",q_c.cost);
                break;
            }
            if(memo[q_c.p][q_c.tk]) continue;
            memo[q_c.p][q_c.tk]=true;
            for(int i=0;i<way[q_c.p].size();i++){
                if(q_c.tk<C)
                    q.push(Data(q_c.cost+(way[q_c.p][i].cost)/2,way[q_c.p][i].to,q_c.tk+1));
                q.push(Data(q_c.cost+way[q_c.p][i].cost,way[q_c.p][i].to,q_c.tk));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1296
n = int(input())
res = {}
for i in range(0, n):
  s, p = [elem for elem in input().split()]
  if not s in res:
    res[s] = [(int(p), i + 1)]
  else:
    res[s].append((int(p), i + 1))

for key in sorted(res.keys()):
  for score, idx in sorted(res[key], reverse=-1):
    print(idx)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1LL<<62
#define pb push_back
#define mp make_pair

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

struct edge {
	int from,to;
	int cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

vector<edge> G[105];
ll d[105];

void dijkstra(int s,int n) {
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+n,INF);

	d[s] = 0;
	que.push(P(0,s));

	while(que.size()) {
		P p = que.top();
		que.pop();

		int v = p.second;
		if(d[v] < p.first) continue;

		rep(i,G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int main() {
	int n, m;
	while(cin >> n >> m) {
		if(n == 0 && m == 0) break;

		rep(i, n) G[i].clear();

		rep(i, m) {
			int q, a, b, c;
			cin >> q;

			if(q == 0) {
				cin >> a >> b;

				a--;
				b--;

				dijkstra(a, n);

				if(d[b] == INF) cout << -1 << endl;
				else cout << d[b] << endl;
			} else {
				cin >> a >> b >> c;
				
				a--;
				b--;

				bool flag = true;
				rep(j, G[a].size()) {
					if(G[a][j].to == b) {
						flag = false;
						G[a][j].cost = min(G[a][j].cost, c);
					}
				}

				rep(j, G[b].size()) {
					if(G[b][j].to == a) {
						flag = false;
						G[b][j].cost = min(G[b][j].cost, c);
					}
				}
				
				if(flag) {
					G[a].push_back(edge(b, c));
					G[b].push_back(edge(a, c));
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1244
#include <algorithm>
#include <climits>
#include <chrono>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#ifndef __MACRO_H__
#define __MACRO_H__

using llong = long long;
using ullong = unsigned long long;

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << msec << " msec" << std::endl;
}

#endif

class ABC102C
{
public:
	ABC102C()
	{
		cin >> n_;

		a_collection_.resize(n_);
		loop (i, n_)
			cin >> a_collection_[i];
	}
	void Run(void)
	{
		long long index = 1;
		for (auto & elm_a : a_collection_)
		{	// 最初にindexだけ減算をしてしまう
			elm_a -= index;
			index++;
		}
		sort(all(a_collection_));

		llong ans1, ans2;
		ans1 = ans2 = 0;
		if (n_ % 2 != 0)
		{	// 奇数のときans2は使わないのでMAXで初期化
			b_ = a_collection_[n_ / 2];
			for (const auto & elm_a : a_collection_)
				ans1 += abs(b_ - elm_a);
			ans2 = LONG_MAX;
		}
		else
		{	// 偶数のとき中央値が小数になってしまうので
			// 念の為 b= n/2 - 1 と b= n/2 の2つを計算しておく
			b_ = a_collection_[n_ / 2 - 1];
			for (const auto & elm_a : a_collection_)
				ans1 += abs(b_ - elm_a);
			b_ = a_collection_[n_ / 2];
			for (const auto & elm_a : a_collection_)
				ans2 += abs(b_ - elm_a);
		}

		cout << min(ans1, ans2);
	}
private:
	llong b_;
	llong n_;
	vector<llong> a_collection_;
};

int main()
{
	ABC102C abc102c;

	TimeStart();
	abc102c.Run();
	TimeEnd();

	return 0;
}

Measured memory_bytes: 1792
a,b=map(int,input().split())
n=100

grid=[["#"]*n for _ in range(n//2)]+[["."]*n for _ in range(n//2)]

k=0
cnt=0
for i in range(a-1):
    grid[k][2*i-cnt]="."
    if (2*i)%100==n-2:
        k+=2
        cnt+=n

k=n//2+1
cnt=0
for i in range(b-1):
    grid[k][2*i-cnt]="#"
    if (2*i)%100==n-2:
        k+=2
        cnt+=n
print(100,100)
for i in grid:
    print("".join(i))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define forlist(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<std::string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
template<class T>inline void dumpv(T &v){
    if(!DEBUG)return;cout<<"{";rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1)?",":"}";}cout<<endl;
}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    cill(m);
    LL ans=0;
    VL h(n+10), ch(n+10);
    rep(i, n){
        cin >> h[i];
        ch[i] = 1;
    }
    rep(i, m){
        cill(a);
        cill(b);
        if (h[a-1] < h[b-1]){
            ch[a - 1] = 0;
        }
        if (h[a-1] > h[b-1]){
            ch[b - 1] = 0;
        }
        if  (h[a-1] == h[b-1]) {
            ch[a - 1] = 0;
            ch[b - 1] = 0;
        }
    }
    rep(i, n){
        ans+= ch[i];
    }
    co(ans);
    return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    ll cnt =0;
    for(int i = 0; i  < s.length(); i++)    {
        if(s[i] != t[i])    {
            cnt++;
        }
    }
    cout  << cnt;
    return 0;
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define N 300050
using namespace std;
int n,h;
struct node{
	int a,b,c,d;
}q[N];
int ld[233],lu[233],rd[233],ru[233],ds;
int ind[N],outd[N],fa[N],pd[N];
int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
int main(){
	cin>>n>>h;
	for(int i=1;i<=n;++i)
		scanf("%d%d%d%d",&q[i].a,&q[i].b,&q[i].c,&q[i].d);
	for(int i=1;i<=h;++i)ld[i]=++ds,fa[ds]=ds;
	for(int i=1;i<=h;++i)lu[i]=++ds,fa[ds]=ds;
	for(int i=1;i<=h;++i)rd[i]=lu[i];
	for(int i=1;i<=h;++i)ru[i]=ld[i];
	for(int i=1;i<=n;++i){
		int pol,por;
		if(q[i].c)pol=ld[q[i].c];
		else pol=lu[q[i].a];
		if(q[i].d)por=rd[q[i].d];
		else por=ru[q[i].b];
		++outd[pol];++ind[por];
		fa[getfa(pol)]=getfa(por);
	}
	int al=0;
	for(int i=lu[1];i<=lu[h];++i){
		al+=outd[i]-ind[i];
		if(outd[i]<ind[i])return puts("NO"),0;
	}
	if(al<=0)return puts("NO"),0;
	for(int i=ru[1];i<=ru[h];++i){
		if(outd[i]>ind[i])return puts("NO"),0;
		al+=outd[i]-ind[i];
	}
	if(al)return puts("NO"),0;
	for(int i=1;i<=ds;++i)if(ind[i]!=outd[i])pd[getfa(i)]=1;
	for(int i=1;i<=ds;++i)if((ind[i]||outd[i])&&!pd[getfa(i)])return puts("NO"),0;
	return puts("YES"),0;
}

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

int main() {
    char a, b; cin >> a >> b;
    if (a == 'H' && b == 'H') cout << 'H' << endl;
    else if (a == 'D' && b == 'D') cout << 'H' << endl;
    else cout << 'D' << endl;

    return 0;
}


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

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long X = long.Parse(str[0]);
            long Y = long.Parse(str[1]);

            long n = Y / X;

            int cnt = 0;
            long s = 1;
            while (s <= n)
            {
                s *= 2;
                cnt++;
            }

            Console.WriteLine(cnt);

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int n,mx,mi,a[55];
template <typename T>
inline void rd(T &x){
	x=0;int f=1; char CH=getchar();
	while(CH<'0'||CH>'9') {if(CH=='-') f=0; CH=getchar();}
	while(CH>='0'&&CH<='9') {x=x*10+(CH-'0'); CH=getchar();}
	if(!f) x=-x;	return;
}
int main()
{
	rd(n);
	printf("%d\n",2*n-1);
	for(int i=0;i<n;i++) {rd(a[i]); if(mx<abs(a[i])) mx=abs(a[i]),mi=i;}
	for(int i=0;i<n;i++) printf("%d %d\n",mi+1,i+1),a[i]+=a[mi];
	if(a[mi]>=0) for(int i=1;i<n;i++) printf("%d %d\n",i,i+1);
	else for(int i=n-2;i>=0;i--) printf("%d %d\n",i+2,i+1);
	return 0;
}

Measured memory_bytes: 256
// 2017/05/01 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int C;		// ???????????°

void bubbleSort(int A[], int N)
{
	bool flag = true;

	while(flag){
		flag = false;

		for(int j=N-1; j>=1; j--){
			if(A[j]<A[j-1]){
				swap(A[j], A[j-1]);
				C++;
				flag = true;
			}
		}
	}
}

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

	int A[100];
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	C = 0;

	bubbleSort(A, N);

	for(int i=0; i<N; i++){
		cout << A[i];

		if(i<N-1){
			cout << ' ';
		}
		else{
			cout << endl;
		}
	}
	cout << C << endl;

	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>

int main(void){
    int i,num,x;
    scanf("%d",&num);
    for(i=1;i<=num;i++){
        x=i;
        if(x%3 == 0)
            printf(" %d",i);
        else{
            for(;x && x%10 != 3;)
                x/=10;
            if(x%10 == 3)
                printf(" %d",i);
        }
    }
    puts("");
    return 0;
}

Measured memory_bytes: 608