akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
from heapq import heapify, heappop, heappush
import sys

input = sys.stdin.readline
N, M = map(int, input().split())
item_list = [int(x) * (-1) for x in input().split()]

heapify(item_list)

for i in range(M):
    price = heappop(item_list)
    price = int(price / 2)
    heappush(item_list, price)

total = -sum(item_list)
print(total)



Measured memory_bytes: 14172
#include<stdio.h>
#include<string.h>
#include<math.h>

void swap(int *a, int *b)
{
	int s;
	s=*a;
	*a=*b;
	*b=s;
}

int main()
{
	int a[4];
	int i, j;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	for(i=0; i<2; i++)
	{
		for(j=0; j<2-i; j++)
		{
			if(a[j]>a[j+1])
			{
				swap(&a[j], &a[j+1]);
			}
		}
	}
	
	printf("%d\n", a[2]-a[0]);
	return 0;
}


Measured memory_bytes: 128
from collections import Counter, defaultdict
# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

# mを法とするときのa^n
def modpow(a,n,m):
    res = 1
    t = a
    while n:
        if n%2:
            res = (res*t)%m
        t = (t*t)%m
        n //= 2
    return res

def lcm_mod(nums, mod):
    p = defaultdict(int)
    for n in nums:
        c = Counter(prime_factors(n))
        for v,cnt in c.items():
            p[v] = max(p[v],cnt)

    res = 1
    for v,cnt in p.items():
        res *= modpow(v,cnt,mod)
        res %= mod
    return res


MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))

s = sum(modinv(a,MOD) for a in A)%MOD

s *= lcm_mod(A, MOD)
print(s%MOD)


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

using namespace std;

struct S{
	int a, v;
};

bool operator<(S a, S b){
	return a.v > b.v || (a.v == b.v&&a.a<b.a);
}

int main(){

	int n, q, a, v;
	vector<S> fish;
	vector<S> sort_fish;
	S av;
	int max = 0, max_i = 1;

	cin >> n >> q;

	for (int i = 0; i < n; i++){
		av.a = i + 1, av.v = 0;
		fish.push_back(av);
	}

	while (q--> 0){
		cin >> a >> v;
		fish[a - 1].v += v;
		if (v < 0){
			if (max_i == a){
				sort_fish = fish;
				sort(sort_fish.begin(), sort_fish.end());
				cout << sort_fish[0].a << " " << sort_fish[0].v << endl;
				max = sort_fish[0].v, max_i = sort_fish[0].a;
			}
			else{
				cout << max_i <<" "<< max << endl;
			}
		}
		else{
			if (max < fish[a - 1].v || (max == fish[a - 1].v&&max_i >= a)) max = fish[a - 1].v, max_i = a;
			cout << max_i << " " << max << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 10196
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL INF=1e18;
const int MAXN=2e5+100;
const double eps=1e-10;

int main()
{
    LL k,n=50;
    while(scanf("%lld",&k)!=EOF)
    {
        printf("50\n");
        LL cnt=k/50,res=k%50;
        for(int i=0;i<50;i++)
        {
            if(i<res) printf("%lld",i+cnt+n-res+1);
            else printf("%lld",i+cnt-res);
            if(i!=49) printf(" ");
        }
        printf("\n");
    }
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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


vector<int> vs[18];
int bc(int a)
{
	int r=0;
	for(int i=0;i<18;i++)
	{
		if(a&(1<<i))
		{
			r++;
		}
	}
	return r;
}


int g(int v,int i,int N)
{
	int r=0;
	for(int j=0;j<i;j++)
	{
		r|=v&(1<<j);
	}
	for(int j=i;j+1<N;j++)
	{
		r|=(v&(1<<(j+1)))>>1;
	}
	return r;
}
int h(int v,int i,int N)
{
	int r=0;
	for(int j=0;j<i;j++)
	{
		r|=v&(1<<j);
	}
	for(int j=i+1;j<N;j++)
	{
		r|=(v&(1<<(j-1)))<<1;
	}
	return r;
}
vector<int> f(int N,int A,int B){
	if(N==1)
	{
		return {A,B};
	}
	for(int i=0;i<N;i++)
	{
		if((A&(1<<i))!=(B&(1<<i)))
		{
			int a=g(A,i,N);
			int b=g(B,i,N);
			vector<int> ret;
			for(auto v:f(N-1,a,a^1))
			{
				ret.push_back(h(v,i,N)|(A&(1<<i)));
			}
			for(auto v:f(N-1,a^1,b))
			{
				ret.push_back(h(v,i,N)|(B&(1<<i)));
			}
			return ret;
		}
	}
	return {};
}

int main()
{
	int N,A,B;
#if 1
	cin >> N>>A >> B;
	if(bc(A)%2==bc(B)%2)
	{
		cout << "NO" << endl;
		return 0;
	}
	auto v=f(N,A,B);
	cout << "YES" << endl;
	auto sp="";
	for(auto v:f(N,A,B))
	{
		cout << sp << v;
		sp=" ";
	}
	cout << endl;
#else
  std::mt19937 rand_src(12345);
	for(int i=0;i<20;i++)
	{
  std::uniform_int_distribution<int> rand_dist(1, 5);
  N=rand_dist(rand_src);
  uniform_int_distribution<int> rd2(0,(1<<N)-1);
  A=rd2(rand_src);
  B=rd2(rand_src);
  cerr << N << ", " << A << ", " << B << endl;
  f(N,A,B);
	}
#endif
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    ll ans = 0;
    for(int i=1;i<n;i++){
        if(a.at(i-1)>a.at(i)){
            ans+= a.at(i-1)-a.at(i);
            a.at(i)=a.at(i-1);
        }
    }
    cout<<ans<<endl;
}
    



Measured memory_bytes: 4776
object Main extends App {

  import scala.io.StdIn._

  val n = readInt
  val heights = readLine.trim.split(' ').map(_.toInt).toList
  println(minCount(heights))
  def minCount(heights: List[Int], stack: List[Int] = List(0)): Int = {
    (heights, stack) match {
      case (h::t, s::_) if h > s ⇒ minCount(t, h::stack)
      case (h::t, s::_) if h == s ⇒ minCount(t, stack)
      case (h::_, f::s::r) if s > h ⇒ f - s + minCount(heights, s::r)
      case (h::t, f::r) ⇒ f - h + minCount(t, h::r)
      case (Nil, f::s::t) ⇒ f - s + minCount(Nil, s::t)
      case (Nil, s::Nil) ⇒ 0
      case (Nil, Nil) ⇒ ???
    }
  }

  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}

Measured memory_bytes: 27456
S_prime = list(map(str, input()))
T = list(map(str, input()))

len_S = len(S_prime)
len_T = len(T)

un = 1

for i in reversed(range(0, len_S - len_T + 1)):
	match = 1
	for j in range(i, i + len_T):
		# print(S_prime[j], T[j - i])
		if S_prime[j] == "?": continue
		if not S_prime[j] == T[j - i]:
			match = 0
			break
	if match:
		un = 0
		# print(i)
		init = i
		break
		
if un:
	print("UNRESTORABLE")
else:
	for i in range(init, init + len_T):
		S_prime[i] = T[i - init]
	
	for i in range(len_S):
		if S_prime[i] == "?":
			print("a", end = "")
		else:
			print(S_prime[i], end = "")

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n,k;
	cin>>n>>k;
	vector<long long> h(n,0ll);
	for(int i=0;i<n;i++)
		cin>>h[i];
	sort(rfull(h));
	long long ans=0;
	for(int i=k;i<n;i++){
		ans+=h[i];
	}
	cout<<ans<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val ans = IntArray(N + 1) { -1 }
    var ng = false
    repeat(M) {
        val (s, c) = readLine()!!.split(" ").map(String::toInt)
        if (ans[s] != -1 && ans[s] != c) ng = true
        ans[s] = c
    }

    if (ans[1] == -1) ans[1] = if (N == 1) 0 else 1
    if (ng || (N > 1 && ans[1] == 0)) println(-1) else println(ans.drop(1).map { it.coerceAtLeast(0) }.joinToString(""))
}

Measured memory_bytes: 37872
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int X, Y, a, b, c; cin >> X >> Y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());
  vector<int> d;
  rep(i, X) d.push_back(p[i]);
  rep(i, Y) d.push_back(q[i]);
  rep(i, c) d.push_back(r[i]);
  sort(d.rbegin(), d.rend());
  ll ans = 0;
  rep(i, X+Y) ans += d[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n;
	cin >> n;
	string a,b;
	cin >> a>>b;

	int ans = 0;
	bool flag = 0;

	rep(i,n){
		flag = 0;
		int k = i;
		FOR(j,i,n){
			if(a[k]!=b[j-i]){
				flag = 1;
				break;
			}
			k++;
		}
		if(!flag){	//途中でいい感じのが見つかったよ!
		ans = i+n;
		break;
		}
	}
	if(ans == 0&&flag){
		ans = n*2;
	}

	cout << ans << endl;
	return 0;
}


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

int dp[101][10001];

int main() {
  int n,W; cin >> n >> W;
  int v[101],w[101];

  for ( int i = 0; i < n; i++ ) cin >> v[i] >> w[i];
  
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 1; j <= W; j++ ) {
      if ( w[i] > j ) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
  }
  
  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 5068
/**
  Given a network G consisting of n vertices and m edges. For each edge (generally speaking, 
  oriented edges, but see below), the capacity (a non-negative integer) and the cost per 
  unit of flow along this edge (some integer) are given. Also the source s and the sink t are marked.

  For a given value K, we have to find a flow of this quantity, and among all flows of this quantity 
  we have to choose the flow with the lowest cost. This task is called minimum-cost flow problem.

  Sometimes the task is given a little differently: you want to find the maximum flow, and among 
  all maximal flows we want to find the one with the least cost. This is called the minimum-cost maximum-flow problem.

  Time : O ( n * n * n * m) using Desopo-Pape intermediate algo as single source shortest distance from 

**/

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

struct Edge {
  int from, to, capacity, cost;
};

vector<vector<int>> adj, cost, capacity;
const int INF = 1e9;

void shortest_paths(int n, int v0, vector<int>& d, vector<int>& p) {
  d.assign(n, INF);
  d[v0] = 0;
  vector<int> m(n, 2);
  deque<int> q;
  q.push_back(v0);
  p.assign(n, -1);

  while (!q.empty()) {
    int u = q.front();
    q.pop_front();
    m[u] = 0;
    for (int v : adj[u]) {
      if (capacity[u][v] > 0 && d[v] > d[u] + cost[u][v]) {
        d[v] = d[u] + cost[u][v];
        p[v] = u;
        if (m[v] == 2) {
          m[v] = 1;
          q.push_back(v);
        } else if (m[v] == 0) {
          m[v] = 1;
          q.push_front(v);
        }
      }
    }
  }
}

int min_cost_flow(int N, vector<Edge> edges, int K, int s, int t) {
  adj.assign(N, vector<int>());
  cost.assign(N, vector<int>(N, 0));
  capacity.assign(N, vector<int>(N, 0));
  for (Edge e : edges) {
    adj[e.from].push_back(e.to);
    adj[e.to].push_back(e.from);
    cost[e.from][e.to] = e.cost;
    cost[e.to][e.from] = -e.cost;
    capacity[e.from][e.to] = e.capacity;
  }

  int flow = 0;
  int cost = 0;
  vector<int> d, p;
  while (flow < K) {
    shortest_paths(N, s, d, p);
    if (d[t] == INF) {
      break;
    }

    // find max flow on that path
    int f = K - flow;
    int cur = t;
    while (cur != s) {
      f = min(f, capacity[p[cur]][cur]);
      cur = p[cur];
    }

    // apply flow
    flow += f;
    cost += f * d[t];
    cur = t;
    while (cur != s) {
      capacity[p[cur]][cur] -= f;
      capacity[cur][p[cur]] += f;
      cur = p[cur];
    }
  }

  if (flow < K) {
    return -1;
  }
  else {
    return cost;
  }
}

int main() {
  int n, m, amount;
  vector <Edge> edges;

  int src, dst, cap, cost;
  cin >> n >> m >> amount;
  for (int i = 0; i < m; i++) {
    cin >> src >> dst >> cap >> cost;
    Edge e = {src, dst, cap, cost};
    edges.push_back(e);
  }
  int s = 0; 
  int t = n - 1;
  int mincost = min_cost_flow(n, edges, amount, s, t);
  if (mincost == -1) {
    cout << -1 << '\n';
  } else { 
    cout << mincost << '\n';
  }
  return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int n, x;
    cin >> n >> x;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long int res = 0;
    for (int i = 1; i < n; i++) {
        if (v[i - 1] >= x) {
            res += v[i];
            res += v[i - 1] - x;
            v[i] = 0;
        } else if (v[i] + v[i - 1] > x) {
            res += v[i] + v[i - 1] - x;
            v[i] -= v[i] + v[i - 1] - x;
        } 
    }
    cout << res << endl;
}




Measured memory_bytes: 3780
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let m = get();
    let mut x: Vec<i64> = vec![0; n];
    let mut y: Vec<i64> = vec![0; n];
    let mut z: Vec<i64> = vec![0; n];
    for i in 0 .. n {
        x[i] = get();
        y[i] = get();
        z[i] = get();
    }
    let mut ma = 0;
    for a in [-1, 1].iter() {
        for b in [-1, 1].iter() {
            for c in [-1, 1].iter() {
                let mut iroha = vec![0; n];
                for i in 0 .. n {
                    iroha[i] = a * x[i] + b * y[i] + c * z[i];
                }
                iroha.sort();
                iroha.reverse();
                let tot = iroha[0 .. m].iter().sum();
                ma = max(ma, tot);
            }
        }
    }
    println!("{}", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

import static java.lang.Integer.parseInt;

/**
 * A Traveler
 * JOI 9th, Fin.1
 */
public class Main {

	static final int MOD = 100000;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n, m;
			n = parseInt(line.substring(0, line.indexOf(' ')));
			m = parseInt(line.substring(line.indexOf(' ') + 1));

			int[] d = new int[n];

			for (int i = 1; i <= n - 1; i++) {
				d[i] = d[i - 1] + Integer.parseInt(br.readLine());
			}

			long sum = 0;
			int inn = 0;

			for (int i = 0; i < m; i++) {
				int _inn = parseInt(br.readLine());
				sum += Math.abs(d[inn + _inn] - d[inn]);
				sum %= MOD;
				inn += _inn;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, K, C;
string S;
int l[200010];
int r[200010];


signed main(){
    cin >> N >> K >> C;
    cin >> S;

    int k = 0, pre = -C-1;
    rep(i, 0, N) if(S[i] == 'o' and pre+C < i) l[++k] = i, pre = i;
    int c = k;
    pre = N+C;
    repr(i, N, 0) if(S[i] == 'o' and i < pre-C) r[k--] = i, pre = i;

    if(c == K) repe(i, 1, K) if(l[i] == r[i]) cout << l[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 4996
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        long ans = 0;
        for(int n=1; n<=N; n++){
            long num = N/n;
            /*n, 2n, 3n, ..., num*n == (1+num) * num / 2*/
            ans += n * (1+num) * num / 2;
        } 
        System.out.println(ans);
        
    }
}


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

int main(){
  int S;cin>>S;
  if (S/100>=13||S/100==0){ 
    if(S-(S/100)*100>=13||S-(S/100)*100==0){cout << "NA"<< endl;}
    else{cout <<"YYMM" << endl;} }
  else if(S-(S/100)*100>=13||S-(S/100)*100==0){cout << "MMYY"<< endl;}
  else{cout << "AMBIGUOUS" << endl;}
  return 0;
}

Measured memory_bytes: 256
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define pii pair<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    while(T --> 0)
    {
        cin>>a;
        double pi=3.14159265358;
        cout<<fixed<<setprecision(12);
        cout<<2*pi*a;
    }
    return 0;
}

Measured memory_bytes: 3784
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s = read_as_string();
    let mut counters: Vec<usize> = vec![0;3];

    for c in s.chars(){
        counters[(c as u8 - 'a' as u8) as usize] += 1;
    }

    counters.sort();
    let (a, b, c) = (counters[0], counters[1], counters[2]);
    // if a + b < c{
    //     println!("NO");
    //     return;
    // }

    if (a == c-1 || a == c) && (b == c-1 || b == c){
        println!("YES");
    }else{
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e1 + 10;
LL dp[N][N*N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	dp[0][0] = 1;
	int n, a;
	cin >> n >> a;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		sum += x;
		for (int k = i; k > 0; k--)
		{
			for (int j = x; j <= sum; j++)
			{
				dp[k][j] += dp[k - 1][j - x];
			}
		}
	}
	LL ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += dp[i][i*a];
	}
	cout << ans << endl;
	return 0;
}

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

string s,t;
int dp[3002][3002];

int main() {
    cin>>s>>t;
    int l1=s.size(),l2=t.size();
    for(int i=1;i<=l1;++i)
        for(int j=1;j<=l2;++j)
            if(s[i-1]==t[j-1])  dp[i][j] = 1 + dp[i-1][j-1];
            else    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

    int len = dp[l1][l2];
    char *ans = new char [len+1];
    ans[len--] = '\0';

    for(int i=l1,j=l2;i>0 && j>0;)
        if(s[i-1]==t[j-1]) {
            ans[len--] = s[i-1];
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])  i--;
        else j--;

    printf("%s",ans);
    return 0;
}


Measured memory_bytes: 35456
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;

int main(){
    int n;
    cin>>n;
    int r=1;
    int count=0;
    while(r*2<=n){
        r*=2;
        count++;
    }
cout<<r;
return 0;
}

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


int main(){
    ll a, b, c, d; cin >> a >> b >> c >> d;
    if(a+b < c+d) cout << "Right" << endl;
    else if(a+b == c+d) cout << "Balanced" << endl;
    else cout << "Left" << endl;
}


Measured memory_bytes: 3592
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;
using mint = static_modint<MOD>;

/*
  == AC Library Cheat sheet
  documentation: file:///Users/nobu/Downloads/ac-library/document_ja/index.html

  mint
    mint m.pow(int p)  //! return m^p
    mint m.inv() //! returns i that gives (m * i).val() == 1 
    int m.val() 

  fenwick_tree (BIT)
    fenwick_tree<T> fw(int n) //! init a[0] .. a[n-1] with all 0
    void fw.add(int idx, T x); //! a[idx] += x
    T fw.sum(int l, int r); //! return a[l] + .. + a[r-1]

  dsu (UnionFind)
    dsu d(int n)  //! prepare dsu with n nodes
    void d.merge(int x, int y)  //! connect node x and y
    bool d.same(int x, int y)  //! return true if node x and y are connected
    int d.leader(int x)  //! return the leader node of the connected group
    int d.size(int x) //! return the size of the group that node x belongs to
    vector<vector<int>> d.groups() //! return a vector of vectors that contain the nodes in each group

  scc_graph
    scc_graph　g(int n)  //! create a directed graph with n nodes
    g.add_edge(int from, int to)  //! create a directed edge from node from to node to
    vector<vector<int>> g.scc()  //! return the vector of strongly connected components that are topologically sorted

  floor_sum(ll n, ll m, ll a, ll b)   
*/

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

    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    vector<vector<int>> scc = g.scc();
    cout << scc.size() << endl;
    for (auto s: scc) {
        cout << s.size() << ' ';
        for (int c: s) {
            cout << c << ' ';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 40584
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
bool check(vector< int > &A, int m, bool f) {
	int a = m;
	rep(i, K) {
		a = a / A[i] * A[i];
	}
	return f ? (a >= 2) : (a <= 2);
}
signed main() {
	cin >> K;
	vector< int > A(K);
	rep(i, K) cin >> A[i];
	int l = 0, r = LINF;
	int min, max;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(A, m, true)) {
			r = m;
		} else {
			l = m;
		}
	}
	min = r;
	l = 0, r = LINF;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(A, m, false)) {
			l = m;
		} else {
			r = m;
		}
	}
	max = l;
	if (max < min) {
		cout << -1 << endl;
	} else {
		cout << min << " " << max << endl;
	}
	return 0;
}

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

using namespace std;

mt19937 rnd(228);

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    vector <int> ans(n);
    for (int i = 0; i < k; ++i)
        ans[i] = s;
    for (int i = k; i < n; ++i)
        ans[i] = rnd() % (1'000'000'000);
    for (int i : ans)
        cout << i << " ";
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
//#include<stdio.h>
typedef long long LL;
using ld = long double;
using namespace std;
#define MAXN 1000105
const double eps = (1e-12);
const int logn = 21;
const double Pi = acos(-1.0);
LL pp = 1000000007;
int lowbit(int x) { return x & (-x); }
#define MP(i,j) make_pair(i,j)
#define M(x) ((((x)%pp)+pp)%pp)
//#define int LL
#define P pair<double,double>
const int INF = 1e9;

signed main() {
	int x; scanf("%d", &x);
	for (int i = 1; i <= 360; i++) {
		if (i * x % 360 == 0) {
			printf("%d", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3824
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}

ll gcd(ll a, ll b) {    //最小公倍数
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {    //最大公約数
  return a * b / gcd(a, b);
}
 

int main(void){

    int n;
    cin>>n;

    vector<pair<int, int>> a(n);

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

        a[i] = make_pair(x, i+1);
    }

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

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

    cout<<endl;
    return 0;


}

Measured memory_bytes: 1664
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	aa := makeGrid(h, w)
	bb := makeGrid(h, w)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			aa[i][j] = getNextInt(scanner)
		}
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			bb[i][j] = getNextInt(scanner)
		}
	}
	center := 6400
	mx := center << 1
	var dp [81][81][12805]bool
	dp[0][0][center+aa[0][0]-bb[0][0]] = true
	dp[0][0][center+bb[0][0]-aa[0][0]] = true
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			for k := 0; k < mx; k++ {
				dif := abs(aa[i][j] - bb[i][j])
				if i-1 >= 0 {
					if k+dif < mx {
						dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k+dif]
					}
					if k-dif >= 0 {
						dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k-dif]
					}
				}
				if j-1 >= 0 {
					if k+dif < mx {
						dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k+dif]
					}
					if k-dif >= 0 {
						dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k-dif]
					}
				}
			}
		}
	}
	for i := 0; i < center; i++ {
		if dp[h-1][w-1][center+i] || dp[h-1][w-1][center-i] {
			fmt.Fprintln(writer, i)
			return
		}
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func makeGrid(h, w int) [][]int {
	index := make([][]int, h, h)
	data := make([]int, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


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

int main() {
  int N,cnt=0;
  cin>>N;
  vector<int> p(N),q(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    q.at(i)=p.at(i);
  }
  sort(p.begin(),p.end());
  
  for(int i=0;i<N;i++){
  	if(p.at(i)!=q.at(i)) cnt++;
    if(cnt==3){
   		cout<<"NO"<<endl;
      	break;
    }
    if(i==N-1&&(cnt==0||cnt==2)) cout<<"YES"<<endl;
  }
  
  
}

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

using namespace std;

ll MOD=1e9+7;

int main() {
	
	ll n;
	cin >> n;
	vector<vector<ll> > v(n, vector<ll>(n));
	for(ll i=0; i<n; i++)
		for(ll j=0; j<n; j++)
			cin >> v[i][j];
	
	ll dp[1<<n];
	
	memset(dp, 0, sizeof(dp));
	
	dp[0]=1;
	for(ll i=0; i<(1<<n)-1; i++){
		ll j=__builtin_popcount(i);
		for(ll k=0; k<n; k++){
			if(!v[j][k])
				continue;
			if(!((1<<k)&i))
				dp[(i^(1<<k))]+=dp[i];
				if(dp[(i^(1<<k))]>=MOD)
					dp[(i^(1<<k))]-=MOD;
		}
	}
	
	cout << dp[(1<<n)-1] << endl;
	
	return 0;
}

Measured memory_bytes: 16640
N, T = [int(num) for num in input().split()]
costs = []
times = []
for i in range(N):
  c, t = [int(num) for num in input().split()]
  if t <= T:
    costs.append(c)
    times.append(t)
if times == []:
  print("TLE")
else:
  print(min(costs))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
static bool visited[100000];
static int color[100000];
vector<pair<ll,int>> vec[100000];

void dfs(int num,int col){
  if(visited[num]) return;
  //cout << num+1 << endl;
  color[num] = col;
  visited[num] = true;
  for(auto u : vec[num]){
    if(u.second == 1){
      dfs(u.first,!col);
    }else{
      dfs(u.first,col);
    }
  }
}

int main(){
  ll n,u,v,w;
  cin >> n;
  for(int i=0;i<n-1;i++){
    cin >> u >> v >> w;
    // vec[u-1] = make_pair(v-1,w%2);
    // vec[v-1] = make_pair(u-1,w%2);
    vec[u-1].push_back(make_pair(v-1,w%2));
    vec[v-1].push_back(make_pair(u-1,w%2));
  }
  dfs(0,0);
  //cout << endl;
  for(int i=0;i<n;i++){
    cout << color[i] << endl;
  }
}


Measured memory_bytes: 9088
def getlist():
	return list(map(int, input().split()))

con = 1000000007

#処理内容
def main():
	#前処理
	S = list(input())
	N = len(S)
	for i in range(N):
		if S[i] != "?":
			S[i] = int(S[i])
	S.reverse()
	
	#あまり前計算
	amari = [[0] * 6 for i in range(10)]
	for i in range(10):
		for j in range(6):
			amari[i][j] = (i * (10 ** j)) % 13

	#DP
	DP = [[0] * 13 for i in range(N + 1)]
	if S[0] == "?":
		for i in range(10):
			DP[0][i] = 1
	else:
		DP[0][S[0]] = 1
	for i in range(1, N):
		if S[i] != "?":
			A = amari[S[i]][i % 6]
			for j in range(13):
				DP[i][(A + j) % 13] += DP[i - 1][j]
				DP[i][(A + j) % 13] %= con
		else:
			for k in range(10):
				A = amari[k][i % 6]
				for j in range(13):
					DP[i][(A + j) % 13] += DP[i - 1][j]
					DP[i][(A + j) % 13] %= con

	#答え
	print(DP[N - 1][5])

if __name__ == '__main__':
	main()

Measured memory_bytes: 70264
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin >> n;
  vector<long int> a(n);
  vector<long int> b(n);
  vector<long long int> gap(n);
  long long int asum = 0;
  long long int bsum = 0;
  long long int downsum = 0;
  long int count = 0;
  for(long int i = 0;i < n;i++){
    cin >> a.at(i);
    asum += a.at(i);
  }
  for(long int i = 0;i < n;i++){
    cin >> b.at(i);
    long long int gaps = a.at(i)-b.at(i);
    if(gaps < 0){
      downsum += gaps;
      count++;
    }else gap.at(i) = gaps;
    bsum += b.at(i);
  }
  sort(gap.begin(),gap.end());
  reverse(gap.begin(),gap.end());
  //正の値を大きい順に
  //cout << count << endl;
  if(bsum > asum) cout << -1 << endl;
  else if(downsum == 0) cout << 0 << endl;
  else{
    for(long int i = 0;;i++){
      downsum += gap.at(i);
      count++;
      if(0 <= downsum) break;
    }
    cout << count << endl;
  }
}
    
    
  
  

Measured memory_bytes: 2560
program hihi;
var
	n, i : longint;
    sum : int64;
begin
	readln(n);
    sum:=0;
    for i:=1 to n do
    	if not ((i mod 3 =0) or (i mod 5 = 0)) 
        then sum := sum + i;
    writeln(sum);
end.

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

#define int long long
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; }

signed main(){
	int x, n;
	cin >> x >> n;
	
	bool used[200] = {};
	for(int i = 0;i < n;i++){
		int p;
		cin >> p;
		used[p] = true;
	}

	int ans = -1;
	int ans_num = INT_MAX;
	for(int i = 0;i < 200;i++){
		if(!used[i]){
			if(ans_num > abs(i-x)){
				ans_num = abs(i-x);
				ans = i; 
			}
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            long N = cin.ReadLong;
            long[] B = cin.ReadLongArray(N-1);
            long ans = B[0];
            for(long i = 1; i < N - 1; i++)
            {
                ans += Min(B[i - 1], B[i]);
            }
            ans += B[N - 2];
            Console.WriteLine(ans);
        }
            

                
    }  
            


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}


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

#define ll long long

const ll MAX = 1e5 + 10, inf = 1e17+1;

ll n, e, t, dp[MAX], x[MAX], p[MAX];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    fill (dp, dp+MAX, inf);
    fill (p, p+MAX, inf);
    cin >> n >> e >> t;
    for (int i = 0; i < n; i++)
        cin >> x[i + 1];
    dp[0] = 0;
    p[0] = -2 * x[1];
    for (int i = 1; i <= n; i++)
    {
        int j = lower_bound(x + 1, x + n + 1, x[i] - t / 2) - x;
        j--;
        if (j > 0)
            dp[i] = p[j-1] + 2 * x[i];
        dp[i] = min(dp[i], dp[j] + t);
        p[i] = min(p[i-1], dp[i] - 2 * x[i+1]);
        //cout << i << " " << j << " " << dp[i] << " " << p[i] << "\n";
    }
    cout << dp[n] + e  << endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        boolean eol = false;

        int count = sc.nextInt(); // 材料の種類数
        int gram = sc.nextInt(); // 材料の総量

        List<Integer> costs = new ArrayList<>();

        for (int i=0; i < count; i++) {
            costs.add(sc.nextInt());
        }

        System.out.println(calcMax(count, gram, costs));
    }

    public static int calcMax(int count, int gram, List<Integer> costs) {

        // 最小の必要材料量を取得
        Optional<Integer> minObj = costs.stream().min(Comparator.naturalOrder());
        int min = minObj.get();

        // 全てのドーナツを一つずつ作る場合の必要材料量
        int sum = costs.stream().mapToInt(Integer::intValue).sum();

        // 作ることのできるドーナツの量
        int total = 0;

        // まず１つずつドーナツを作る
        total = count;
        gram = gram - sum;

        // 残った材料で、最も少ない材料で作ることができるドーナツを作る
        while(gram >= min) {
            gram = gram - min;
            total = total + 1;
        }

        return total;
    }


}


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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(q);
    vector<int> r(q);
    for (int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i];
    }
    
    vector<int> hoge(n);
    hoge[0] = 0;
    for (int i = 1; i < n; i++)
    {
        
        if (s[i - 1] == 'A' && s[i] == 'C')
        {
            hoge[i] = hoge[i - 1] + 1;
        }
        else
        {
            hoge[i] = hoge[i - 1];
        }
    }

    for (int i = 0; i < q; i++)
    {
        int ans = hoge[r[i] - 1] - hoge[l[i] - 1];
        cout << ans << endl;
    }
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  998244353
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()


signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int ans=0;
   int k;cin>>k;
   for(int i=1;i<=k;i++)
   {
       for(int j=1;j<=k;j++)
       {
           for(int l=1;l<=k;l++)
           {
               int g=__gcd(i,j);
               g=__gcd(g,l);
               ans+=g;
           }
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3656