akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	unsigned size_; 
	std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	//unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	unsigned root(unsigned x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
bool check(ll a[], ll size, ll center)
{
	ll count = 0;
	rep(i, size)
	{
		if (a[i] % center == 0)
		{
			count++;
		}
	}
	if (count < size - 1)
	{
		return false;
	}
	else
	{
		return true;
	}
	
}

ll gcd(ll a, ll b)
{
	if (a < b)
	{
		return gcd(b, a);
	}
	
	if (b == 0)
	{
		return a;
	}
	else
	{
		return gcd(b, a%b);
	}
	
}
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	ll N;
	
	cin >> N;

	ll A[N];
	rep(i, N)
	{
		cin >> A[i];
	}

	sort(A, A+N);
	vector<ll> l;
	vector<ll> r;
	l.pb(0);
	r.pb(0);

	for(ll i = 1; i <= N; i++)
	{
		l.pb(gcd(l[i-1], A[i-1]));
	}

	for(ll i = N-1; i >= 0; i--)
	{
		r.pb(gcd(r[N-i-1], A[i]));
	}

	ll ans = 0;
	rep(i, N)
	{
		ans = max(ans, gcd(l[i], r[N-1-i]));
	}

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


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	ll H,N; cin>>H>>N;
    vl A(N); rep(i,N) cin>>A[i];

    ll res = 0;
    rep(i,N) res += A[i];
    if(H > res) No
    else Yes
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int k;
double r,l,p,e,t;

double DFS(int i,double left,double right){
	double mid=(left+right)/2;
	if(i==k){
		if(e>=abs(mid-t)) return 1;
		else return 0;
	}

	if(t-e<=left&&right<=t+e) return 1;
	else if(right<=t-e||t+e<=left) return 0;
	
	if(mid>=t){
		return DFS(i+1,left,mid)*(1-p)+DFS(i+1,mid,right)*p;
	}else{
		return DFS(i+1,mid,right)*(1-p)+DFS(i+1,left,mid)*p;
	}
}

void Solve(){
	cin >> k >> r >> l;
	cin >> p >> e >> t;

	cout << fixed << setprecision(6) << DFS(0,r,l) << endl;
}

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

Measured memory_bytes: 1296
/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.4.0"
+/
import std.stdio, std.range, std.algorithm, std.conv;
import core.bitop;

// import dcomp.scanner;

void main() {
    auto sc = new Scanner(stdin);
    int n;
    sc.read(n);
    int[][] g = new int[][](n);
    foreach(i; 0..n-1) {
        int a, b;
        sc.read(a, b); a--; b--;
        g[a] ~= b; g[b] ~= a;
    }
    long dfs(int p, int b) {
        long one, two;
        foreach (d; g[p]) {
            if (d == b) continue;
            long x = dfs(d, p);
            two |= one & x;
            one |= x;
        }
        int off = two ? two.bsr + 1 : 0;
        one = ((one >> off) + 1) << off;
        return one;
    }
    
    writeln(dfs(0, -1).bsr);
}
/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray; 
    import std.algorithm : map;
    File f;
    this(File f) {
        this.f = f;
    }
    string[] buf;
    private bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = f.readln.split;
        }
        return true;
    }
    private bool readSingle(T)(ref T x) {
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {
                //string or char[10] etc
                x = buf.front;
                buf.popFront;
            } else {
                static if (isStaticArray!T) {
                    //static
                    assert(buf.length == T.length);
                }
                x = buf.map!(to!E).array;
                buf.length = 0;                
            }
        } else {
            x = buf.front.to!T;
            buf.popFront;            
        }
        return true;
    }
    int read(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }
}

unittest {
    import std.path : buildPath;
    import std.file : tempDir;
    import std.algorithm : equal;
    import std.stdio : File;
    string fileName = buildPath(tempDir, "kyuridenanmaida.txt");
    auto fout = File(fileName, "w");
    fout.writeln("1 2 3");
    fout.writeln("ab cde");
    fout.writeln("1.0 1.0 2.0");
    fout.close;
    Scanner sc = new Scanner(File(fileName, "r"));
    int a;
    int[2] b;
    char[2] c;
    string d;
    double e;
    double[] f;
    sc.read(a, b, c, d, e, f);
    assert(a == 1);
    assert(equal(b[], [2, 3]));
    assert(equal(c[], "ab"));
    assert(equal(d, "cde"));
    assert(e == 1.0);
    assert(equal(f, [1.0, 2.0]));
}


Measured memory_bytes: 14844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <set>
using namespace std;
typedef pair<int, int> pii;
#define X first
#define Y second

//垂直線分の交差判定のためのセグ木
//区間演算+定点クエリ.
struct segmentTree{
    vector<set<int> > node;
    int n;
    
    segmentTree(int s){
        n = 1;
        while(n < s) n*=2;
        node = vector<set<int> >(2*n -1);
    }
    segmentTree(){}

    //区間[l, r]に高さvalの線分を追加
    void Insert(int val, int l, int r){
        _set(val, l, r+1, 0, 0, n);
    }
    void _set(int val, int l, int r, int k, int cl, int cr){
    	if(cr <= l || r <= cl) return;
    	if(l <= cl && cr <= r){
    		node[k].insert(val);
    		return;
    	}
    	int m = (cl +cr)/2;
    	_set(val, l, r, 2*k +1, cl, m);
    	_set(val, l, r, 2*k +2, m, cr);
    }

    //位置posで高さ[b, e]が交わるかどうか
    bool IsIntersect(int pos, int b, int e){
        int idx = n-1 + pos;
        while(1){
        	if(node[idx].lower_bound(b) != node[idx].upper_bound(e)){
        		return true;
        	}
        	if(idx == 0) break;
        	idx = (idx -1) /2;
        }
        return false;
    }
};

bool range_intersect(int s, int t, int p, int q){
	return (s<=p && p<=t) || (s<=q && q<=t) ||
		(p<=s && s<=q) || (p<=t && t<=q);
}

void compress(vector<pii> &s, vector<pii> &t){
	int n = s.size();
	map<int, int> convx, convy;
	for(int i=0; i<n; i++){
    	convx[s[i].X] = 0;
    	convx[t[i].X] = 0;
    	convy[s[i].Y] = 0;
    	convy[t[i].Y] = 0;
    }
    int countx=0, county=0;
    for(auto &xpair: convx) xpair.second = countx++;
    for(auto &ypair: convy) ypair.second = county++;
    for(int i=0; i<n; i++){
    	s[i].X = convx[s[i].X];
    	s[i].Y = convy[s[i].Y];
    	t[i].X = convx[t[i].X];
    	t[i].Y = convy[t[i].Y];
    }
}

int main(){
	int n;
	cin >> n;
	vector<pii> s(n),t(n);
	for(int i=0; i<n; i++){
    	cin >> s[i].X >> s[i].Y >> t[i].X >> t[i].Y;
    }
    compress(s, t);

    segmentTree tree[2];
    vector<set<pii> > rvec[2]; //pair(ub, lb)
    for(int d=0; d<2; d++){
    	tree[d] = segmentTree(2*n);
		rvec[d] = vector<set<pii> >(2*n);
	}
	for(int i=0; i<n; i++){
		//xxx[d]:自分と平行の線分 の気持ち
    	int d = (s[i].X == t[i].X)? 0 : 1;
    	bool ok = true;
    	int pos, rmax, rmin;
    	if(d == 0){
    		pos = s[i].X;
    		rmax = max(s[i].Y, t[i].Y);
    		rmin = min(s[i].Y, t[i].Y);
    	}else{
    		pos = s[i].Y;
    		rmax = max(s[i].X, t[i].X);
    		rmin = min(s[i].X, t[i].X);
    	}
    	//垂直線分との交差判定
    	if(tree[1-d].IsIntersect(pos, rmin, rmax)){
    		ok = false;
    	}
    	//水平線分との交差判定
    	auto itr = rvec[d][pos].lower_bound(pii(rmin, 0));
    	if(itr != rvec[d][pos].end() &&
    		range_intersect(rmin, rmax, itr->second, itr->first)){
    		ok = false;
    	}
    	if(ok){
    		tree[d].Insert(pos, rmin, rmax);
    		rvec[d][pos].insert(pii(rmax, rmin));
    		cout << 1 << endl;
    	}else{
    		cout << 0 << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 91496
x1, y1, x2, y2 = map(int, input().split())
y3 = y2 + ( x2 - x1 )
y4 = y1 + ( x2 - x1 )
x3 = x2 - ( y2 - y1 )
x4 = x1 - ( y2 - y1 )
print(x3, y3, x4, y4)


Measured memory_bytes: 61696
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

int main() {

  int N;
  cin >> N;

  int n = N;
  int sumDigit = 0;
  while (n != 0) {
    sumDigit += n % 10;
    n /= 10;
  }
  //cout << sumDigit << endl;

  if (N % sumDigit == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>

using namespace std;

int main(){
	long long x, y;
	cin >>x >>y;
	long long ans = 1e18, dist = 0;
	
	if(abs(x) == abs(y)){
		cout <<"1\n";
		return 0;
	}

	//BA
	if(-x < y){
		dist = y + x + 1;
		ans = min(ans, dist);
	}
	//AB
	if(x < -y){
		dist = -y - x + 1;
		ans = min(ans, dist);
	}
	//BA...AB
	if(-x < -y){
		dist = -y + x + 2;
		ans = min(ans, dist);
	}	
	//AAA..A
	if(x < y){
		dist = y - x;
		ans = min(ans, dist);
	}

	cout <<ans <<'\n';
	return 0;
}


Measured memory_bytes: 3540
// AGC15-A.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
using namespace std;

int main()
{
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b || (n == 1 && a != b)) cout << 0 << endl;
	else if (n == 1) cout << 1 << endl;
	else cout << (b - a) * (n - 2) + 1 << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin >> h[i];
    int ans=0;
    int count=0;
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
            count++;
        }
        else{
            if(count>ans){
                ans=count;
                count=0;
            }
            else{
                count=0;
            }
        }
        if(i==n-2){
            if(count>ans){
                ans=count;
                count=0;
            }
            else{
                count=0;
            }
        }
    }
     cout << ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,x,sum=0,ans=0;
  int a[100];
  cin>>n>>x;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  ans+=n;
  x-=sum;
  ans+=x/a[0];
  cout<<ans<<endl;
    

  return 0;
}






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


using namespace std;

long long mod = (long long)1e9 + 7;

int main(){
	long long n,m;
	cin>>n>>m;
	if (abs(n-m)>1){
		cout<<0<<endl;
		return 0;
	}
	long long ans = 1;
	for(int i =1; i <=n; i++){
		ans *= i;
		ans %= mod;
	}
	for(int i =1; i <=m; i++){
		ans *= i;
		ans %= mod;
	}
	if (n==m) ans *=2;
	ans %= mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    string s1 , s2 , s3 ;
    cin >> s1 >> s2 >> s3 ;
    string foo = "" ;
    foo =foo + s1[0] + s2[0] + s3[0] ;
    cout << foo << el;
    ro ;
}
































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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define all(x) (x).begin() , (x).end()

ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

void solve()
{
	int n;
	cin >> n;
	map<pair<int, int> , int> cnt;

	for (int i = 0 ; i < n ; i++) {
		double x ;
		cin >> x;
		ll j = llround(x * 1e9);
		int two = 0 , five = 0;

		while (j % 2 == 0) {
			two++;
			j /= 2;
		}

		while (j % 5 == 0) {
			five++;
			j /= 5;
		}

		++cnt[ {two , five}];
	}

	ll ans = 0;

	for (auto p1 : cnt) {
		for (auto p2 : cnt) {
			if (p1.ff.ff + p2.ff.ff >= 18 and p1.ff.ss + p2.ff.ss >= 18) {
				if (p1 < p2)
				{
					ans += (ll)p1.ss * p2.ss;
				}
				else if (p1 == p2)
					ans += (ll)p1.ss * (p1.ss - 1) / 2;

			}
		}
	}

	cout << ans << "\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--)
		solve();

	return 0;
}





Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//
		Scanner sc = new Scanner(System.in);

		//
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if(a > c) {
			if((a - c) <= d) {
				System.out.println("Yes");
			}
			else if(a > b){
				if((a - b) <= d && (b - c) <= d) {
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}
			}else {
				if((b - a) <= d && (b - c) <= d) {
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}
			}
		}else {
			if((c - a) <= d) {
				System.out.println("Yes");
			}
			else if(c > b){
				if((c - b) <= d && (b - a) <= d) {
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}
			}else {
				if((b - c) <= d && (b - a) <= d) {
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}
			}
		}
	}
}

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

int main() {
  int ans = 0;
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0) {
      ans = i + 1;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define ll long long int
#define ld long double

using namespace std;

int main(){

    ll n,i,j;
    cin >> n;
    ll a[n+1];

    a[0]=-1;
    ll count = 0;

    for(i=1;i<=n;i++){
        cin >> a[i];
    }

    ll min = a[1];

    for(i=1;i<=n;i++){
        if(min>=a[i]){
            count++;
            min = a[i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> hs(n);
    for (int i = 0; i < n; ++i) {
        cin >> hs[i];
    }
    vector<int> dp(n, numeric_limits<int>::max());
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i + j >= n) {
                break;
            }
            dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i + j] - hs[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

bool SWAP = true;
bool judge(){
    ll ss = S.size();
    vec alpha(26,-1);
    rep(i,ss){
        ll id = S[i] - 'a';
        if(alpha[id] != -1){
            if(T[i] != T[alpha[id]]) return false;
        }
        alpha[id] = i;
    }
    rep(i,26) SWAP = SWAP & (alpha[i] != -1);
    return true;
}
int main() {
    cin>>S>>T;
    bool yes = judge();
    if(yes) {
        swap(S,T);
        yes = judge();
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, Z, W;
  cin >> N >> Z >> W;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<vector<ll>> dp(N, vector<ll>(2));
  for (ll i = N - 1; i >= 0; i--)
  {
    dp.at(i).at(0) = -INF;
    ll Y = ((i > 0) ? A.at(i - 1) : W);
    chmax(dp.at(i).at(0), abs(Y - A.back()));
    for (ll j = i + 1; j < N; j++)
    {
      chmax(dp.at(i).at(0), dp.at(j).at(1));
    }

    dp.at(i).at(1) = INF;
    ll X = ((i > 0) ? A.at(i - 1) : Z);
    chmin(dp.at(i).at(1), abs(X - A.back()));
    for (ll j = i + 1; j < N; j++)
    {
      chmin(dp.at(i).at(1), dp.at(j).at(1));
    }
  }

  ll ans = dp.at(0).at(0);
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long H,N,A,sum=0;
  cin >> H >> N;
  for(int i = 0;i<N;i++){
  	cin >> A;
    sum += A;
  }
  if(H <= sum){
  	cout << "Yes" << endl;
  }else if(H > sum){
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
x,k,d=map(int,input().split())
if(x<0):
    x=x*-1
if(x>=k*d):
    print(x-(k*d))
else:
    r=x%d
    g=x//d
    k=k-g;
    if(k%2==0):
        print(r)
    else:
        ans=min(r+d,abs(r-d))
        print(ans)

Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int A, B, M;
vector<int> a, b;

int main()
{
    cin >> A >> B >> M;
    int mina = 1e6;
    int minb = 1e6;
    int aa, bb, cc;
    for(int i = 0;i < A;i++)
    {
        cin >> aa;
        mina = min(mina, aa);
        a.push_back(aa);
    }
    for(int i = 0;i < B;i++)
    {
        cin >> bb;
        minb = min(minb, bb);
        b.push_back(bb);
    }
    int ans = mina + minb;
    for(int i = 0;i < M;i++)
    {
        cin >> aa >> bb >> cc;
        aa--;
        bb--;
        ans = min(ans, a[aa]+b[bb]-cc);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll N, string S, ll K){
    char target = S[K-1];
    rep(i, N) {
        if (target != S[i]) {
            S[i] = '*';
        }
    }
    cout << S << endl;
}

int main() {
  ll N;
    scanf("%lld",&N);
    string S;
    cin >> S;
    ll K;
    scanf("%lld",&K);
  solve(N, S, K);
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
typedef long long ll;
using namespace std;

const int mod = 1e9+7;

ll powi(ll x, ll y, ll p) {
    assert (y >= 0);
    x = (x % p + p) % p;
    ll z = 1;
    for (ll i = 1; i <= y; i <<= 1) {
        if (y & i) z = z * x % p;
        x = x * x % p;
    }
    return z;
}
ll inv(ll x, ll p) {
    assert ((x % p + p) % p != 0);
    return powi(x, p-2, p);
}
ll choose(ll n, ll r) { // O(n) at first time, otherwise O(1)
    static vector<ll> fact(1,1);
    static vector<ll> ifact(1,1);
    if (fact.size() <= n) {
        int l = fact.size();
        fact.resize( n + 1);
        ifact.resize(n + 1);
        repeat_from (i,l,n+1) {
            fact[i]  = fact[i-1] * i % mod;
            ifact[i] = inv(fact[i], mod);
        }
    }
    r = min(r, n - r);
    return fact[n] * ifact[n-r] % mod * ifact[r] % mod;
}

int main() {
    int h, w, a, b; scanf("%d%d%d%d", &h, &w, &a, &b);
    ll ans = 0;
    a = h - a - 1;
    for (; a >= 0 and b < w; -- a, ++ b) {
        int c = h - a - 1;
        int d = w - b - 1;
        ans += choose(a + b, a) * choose(c + d, d) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3016
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let k = read::<usize>();

    let mut que = VecDeque::new();
    for i in 1..10 {
        que.push_back(i as i64);
    }
    let mut count = 0;
    while let Some(i) = que.pop_front() {
        count += 1;
        if count == k {
            println!("{}", i);
            return;
        }
        let c = i % 10;
        if i % 10 == 0 {
            que.push_back(10 * i);
            que.push_back(10 * i + 1);
        } else if i % 10 == 9 {
            que.push_back(10 * i + 8);
            que.push_back(10 * i + 9);
        } else {
            que.push_back(10 * i + c - 1);
            que.push_back(10 * i + c);
            que.push_back(10 * i + c + 1);
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6396
#include<cstdio>
int a[200002];
int main()
{
	int n,i,j,c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&c),a[c]=i;
	for(i=1,c=0;i<=n;j-i>c&&(c=j-i),i=j)
		for(j=i+1;a[j]>a[j-1];j++);
	printf("%d\n",n-c);
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b || b == c || c == a){
        if(a+b+c != a*3) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else cout << "No" << endl;
        
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,p[5005],c[5005],s[5005][5005],d[5005][5005];
long long ans=-1e18;
int main()
{
	memset(d,0x3f,sizeof(d));
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	 cin>>p[i];
	for(int i=1;i<=n;++i)
	 cin>>c[i];
	for(int i=1;i<=n;++i)
	{
		int j=p[i],stp=1;
		while(j!=i)
		{
			s[i][i]+=c[j];
			s[i][j]=s[i][i];
			d[i][j]=stp;
			j=p[j];++stp;
		}
		s[i][i]+=c[i];
		d[i][i]=stp;
	}
	for(int i=1;i<=n;++i)
	 for(int j=1;j<=n;++j)
	  if(d[i][j]<=k)
	  {
	 	long long z=(k-d[i][j])/d[i][i],tot=s[i][j];
	 	if(s[i][i]>0) tot=z*s[i][i]+s[i][j];
	 	if(tot>ans) ans=tot;
	  }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 394912
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    
    int H, W, M; std::cin >> H >> W >> M;
    std::vector<int> X(H, 0), Y(W, 0);
    std::vector<std::pair<int, int>> A(M); 
    for(int i = 0; i < M; ++i){
        std::cin >> A[i].first >> A[i].second;
        ++X[--A[i].first]; ++Y[--A[i].second];
    }
    std::sort(A.begin(), A.end());
    const int mx = *std::max_element(X.cbegin(), X.cend());
    std::vector<int> XX; XX.reserve(H); for(int i = 0; i < H; ++i) if(X[i] == mx) XX.push_back(i);
    const int my = *std::max_element(Y.cbegin(), Y.cend());
    std::vector<int> YY; YY.reserve(W); for(int i = 0; i < W; ++i) if(Y[i] == my) YY.push_back(i);
    for(const int x : XX){
        const auto l_itr = std::lower_bound(A.cbegin(), A.cend(), std::pair<int, int>(x, 0) );
        const auto r_itr = std::lower_bound(l_itr, A.cend(), std::pair<int, int>(x + 1, 0));
        for(const int y : YY){
            const std::pair<int, int> V(x, y);
            const auto itr = std::lower_bound(l_itr, r_itr, V);
            if(itr == r_itr or V != *itr){
                std::cout << mx + my << '\n';
                return 0;
            }
        }
    }
    std::cout << mx + my - 1 << '\n';
    return 0;
}

Measured memory_bytes: 10296
#include <stdio.h>
 
int main() {
  int height, width;

  while(1){
    scanf("%d %d",&height,&width);
    if(height == 0 && width == 0) break;

    for(int i=1; i<=height; i++) {
      for(int j=1; j<=width; j++) {
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2100
package main

import (
	"fmt"
	"sort"
)


func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int,n)
	s := make([]int,n)
	for i:=0;i<n;i++{
		fmt.Scan(&d[i])
	}
	copy(s,d)
	sort.Ints(s)
	harf := len(d) /2
	L := s[harf-1]
	R := s[harf]

	ans:=R-L
	fmt.Println(ans)
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool doubleCheck(vector<string> words, string w) {
    bool ans = true;
    int cnt = 0;
    for (string s : words) {
        if (w == s) {
            cnt++;
        }
    }
    if (cnt != 1) {
        ans = false;
    }
    return ans;
}

bool checkWordStart(string beforeW, string w) {
    bool ans = true;

    if (*w.begin() != *--beforeW.end()) {
        ans = false;
    }

    return ans;
}
bool checkRule(vector<string> words, string w, int i) {
    bool ans = true;

    if (doubleCheck(words, w) != true || checkWordStart(words[i - 1], w) != true) {
        ans = false;
    }

    return ans;
}

int main()
{
    int n; cin >> n;
    vector<string> words;
    bool ans = true;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        words.push_back(s);
    }

    for (int i = 1; i < n; i++) {
        if (checkRule(words, words[i], i) != true) {
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

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

typedef long long ll;
using namespace std;
constexpr ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<ll> dp(1 << n);
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        vector<int> a(n);
        for (int j = 0; j < n; j++) cin >> a[j];

        vector<ll> after(1 << n);
        for (int bit = 0; bit < 1 << n; bit++) {
            if (dp[bit] > 0) {
                for (int j = 0; j < n; j++) {
                    if (a[j] == 1) {
                        if (bit & (1 << j))continue;
                        after[bit | (1 << j)] += dp[bit], after[bit | (1 << j)] %= MOD;
                    }
                }
            }
        }
        dp = after;
    }

    cout << dp[(1 << n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long
 
int main() {
    int n;
    cin >> n;
 
    vector<LL> vt;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
        if (mp[a] == 2) { 
            vt.push_back(a);
            mp[a] = 0;
        }
    }
 
    sort(vt.begin(), vt.end(), greater<>());
    LL ans = 0;
    if (vt.size() >= 2) {
        ans = vt[0] * vt[1];
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] ary = new int[n][2];
        for (int i = 0; i < n; i++) {
            ary[i][0] = Integer.parseInt(sc.next());
            ary[i][1] = Integer.parseInt(sc.next());
        }
        double sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                sum += Math.sqrt(Math.pow(ary[i][0] - ary[j][0], 2) + Math.pow(ary[i][1] - ary[j][1], 2));
            }
        }
        System.out.println(sum / n);
    }
}

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

#ifdef LOCAL
#include "debug.h"
#define input \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#else
#define debug(...) 4
#define input 4
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int32_t main() {
    input;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int cnt = 1;
    vector<pair<int, char>> v;
    for(int i = 1; i < s.size(); i++) {
        if(s[i] == s[i - 1]) {
            cnt++;
        }
        else {
            v.push_back({cnt, s[i - 1]});
            cnt = 1;
        }
    }    
    int ans = 0;
    v.push_back({cnt, s.back()});
    for(auto it : v) {
        if(it.second == 'R') {
            ans = max(ans, it.first);
        }
    }
    cout << ans;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(char C){
    printf("%c\n", C + 1);
}

int main(){
    // cout << fixed << setprecision(5);

    char C;
    std::cin >> C;
    func(C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

ll N;
void dfs(string s)
{
  if (s.size() == N)
  {
    cout << s << endl;
    return;
  }

  string S = s;
  sort(S.begin(), S.end());
  char C = S.back() + 1;
  for (char c = 'a'; c <= C; c++)
  {
    dfs(s + c);
  }
}

int main()
{
  cin >> N;
  dfs("a");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define iiordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define MOD (1000*1000*1000+7)
ll power(ll a,ll b, ll m=MOD)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll inverse(ll a,ll m=MOD)
{
    return power(a,m-2,m);
}
int ceil(int a,int b)
{
    return (a+b-1)/b;
}
#define INFl (1e18+5)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<long long>
#define vvl vector<vl>
#define vll vector<pll>
#define vii vector<ii>
#define vvii vector<vii>
#define tri pair<int,ii>
#define F first
#define S second
#define forl(i,n) for(int i=0;i<n;i++)
#define fore(i,n) for(int i=1;i<=n;i++)
#define rforl(i,n)  for(int i=n-1;i>=0;i--)
#define rfore(i,n)  for(int i=n;i>=1;i--)
#define CASE(t) cout<<"Case #"<<(t)<<": ";
#define INF 1020000000
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<it->F<<' '<<it->S<<endl;  
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int h,w,k;
int res=INF;
vector<string> a;
void solve(int mask)
{
	int ans=0;
	int tmp=mask;
	vi cnt(15),mm(15);
	forl(i,h)
	{
		mm[i]=ans;
		if(tmp%2)	ans++;
		tmp/=2;
	}
	forl(i,w)
	{
		bool cut=false;
		forl(j,h)
		{
			cnt[mm[j]]+=a[j][i]-'0';
			if(cnt[mm[j]]>k)
				cut=true;
		}
		if(!cut)	continue;
		i--;
		ans++;
		if(ans>h+w)	return;
		cnt.assign(15,0);
	}
	res=min(res,ans);
}
int main()
{
	cin>>h>>w>>k;
	a.resize(h);
	forl(i,h)	cin>>a[i];
	// cout<<"HEY"<<endl;
	for(int i=0;i<(1<<(h-1));i++)
	{
		solve(i);
	}
	cout<<res<<endl;
}

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


int main() {
    int n,ans=0;
    cin>>n;
    int keta=(int)(log10(n)+1);
    rep(i,keta)if(i%2==0)ans+=9*pow(10,i);
    if(keta%2)ans+=n-pow(10,keta)+1;
    cout << ans <<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0 ; i < (n); ++i)
#define rrep(i,n) for(i  1; i <= (n); ++i)
#define drep(i,n) for(i  (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int n,i,max=0,sum=0,ans=0;
cin >> n;
int p[n];
rep(i,n){
    cin >> p[i];
}
rep(i,n){
    if(p[i]>max){
        max = p[i];
    }
    sum += p[i]; 
}
ans = sum-max/2;
cout << ans << endl;






//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
abc = "abcdefghijklmnopqrstuvwxyz"
n = int(input())

ans = []


def f(s="", x=1):
    global ans
    if len(s) == n:
        ans.append(s)
        return 0
    for i in range(x):
        f(s + abc[i], max(x, i+2))


f()
ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 58404
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr>void dump(Itr begin, Itr end) {
  for(;begin != end; ++begin) clog << ' ' << *begin;
  clog << LF;
}

signed main()
{
  string s = "1974";
  char c;
  string t;

  for (int i = 0; i < 4; ++i) {
    cin >> c;
    t += c;
  }


  sort(ALL(s));
  sort(ALL(t));

  if (s == t) {
    puts("YES");
  } else {
    puts("NO");
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

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

    int res = 0;
    for(int i=0;i<s.size();i++){
        res += stoi(s.substr(i,1));
    }
    Yes(stoi(s)%(res)==0)
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n, l, i, j, taste_bef = 0, taste_aft[201] = {},ans,max=10000;
    scanf("%d %d", &n, &l);
    for(i=1;i<n+1;i++){
        taste_bef += l + i - 1;
        for(j=1;j<n+1;j++){
            if(i!=j){
                taste_aft[i] += l + j - 1;
            }
        }
    }
    for(i=1;i<n+1;i++){
        if(abs(taste_bef-taste_aft[i]) < max){
            ans = taste_aft[i];
            max = abs(taste_bef-taste_aft[i]);
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>


int main(void){
	int n,t[128],m,p,x,i,s = 0;
	scanf("%d",&n);
	for(i = 1;i <= n;i++){scanf("%d",&t[i]);s+=t[i];}
	scanf("%d",&m);
	for(i = 1;i <= m;i++){
		scanf("%d%d",&p,&x);
		printf("%d\n",s+x-t[p]);
	}
	return 0;
}

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

#define ff first
#define ss second
#define pb push_back


void solve() {
	string str; cin>>str;
	ll ans = 0;
	for(int i=0;i<str.size();i++) {
		ans += (str[i] - '0');
	}
	if(ans%9 == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

    int t = 1, no = 0;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3720
// abc172-b
object Main extends App {
    val s = io.StdIn.readLine
    val t = io.StdIn.readLine

    def rec(count: Int, list1: List[Char], list2: List[Char]): Int = (list1, list2) match {
        case (Nil, Nil) => count
        case (head1::tail1, head2::tail2) => {
            if (head1 != head2) rec(count+1, tail1, tail2)
            else rec(count, tail1, tail2)
        }
    }

    val result = rec(0, s.toList, t.toList)
    println(result)
}

Measured memory_bytes: 66132
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=0;
	int C=0;
	int V=0;
	string S;
	while(cin>>S){
		int c,v;
		sscanf(S.c_str(),"%d,%d",&c,&v);
		N++;
		C+=c*v;
		V+=v;
	}
	out(C);
	out((int)round(V/(double)N));

	return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	H, Count := readInt(), readInt()
	loop(0, Count, func(i int) {
		H -= readInt()

		if H <= 0 {
			fmt.Println("Yes")
			os.Exit(0)
		}
	})
	fmt.Println("No")
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readInt() int {
	var v int
	fmt.Scan(&v)
	return v
}


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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pii = pair<int,int>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;

#define pi acos(-1)
#define pb push_back
#define mp make_pair
#define test int TEST;cin>>TEST;while(TEST--)
#define all(x) x.begin(),x.end()
#define vrevsort(x) sort(x.rbegin(),x.rend())
#define opy cout<<"YES"
#define opn cout<<"NO\n"
#define flush fflush(stdout)
#define NL cout<<'\n'
#define SP cout<<' '

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

void solve(){
int n,k,t;
cin>>n>>k>>t;
int ans=n/k;
if(n%k) ans++;
cout<<ans*t;
		
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
   // test{solve();cout<<'\n';}
	solve();
    
}


Measured memory_bytes: 3556