akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 10005
#define se second
#define fi first
#define sortv(v) sort(v.begin(),v.end());
#define w() ll _;cin>>_;while(_--)
#define edge pair<ll,ll>
#define pq priority_queue<ll>
#define M 10000007
#define Endl "\n"
using namespace std;



int main()
{
	fast;
	ll a[5];
	ll i;
	for(i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1<<endl;
			return 0;
		}
	}
	

}

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

const int N = 3e5 + 9;

int a[N];
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int k, n; cin >> k >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    int m = 0;
    for(int i = 0; i < n - 1; i++) m = max(m, abs(a[i] - a[i + 1]));
    m = max(m, a[0] + k - a[n - 1]);
    cout << k - m << '\n';
    return 0;
}


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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n;
int a[N], b[N];
ll res;

int main() {
    cin >> n;
    for (int i = 0; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    for (int i = n - 1; i >= 0; --i) {
        ll c = min(b[i], a[i + 1]);
        b[i] -= c;
        res += c;
        c = min(b[i], a[i]);
        a[i] -= c;
        res += c;
    }
    cout << res << endl;

    return 0;
}


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

#define ll long long int
#define inv(name,Type,size) vector<Type> name(size);for(int index=0;index<n;index++) cin>>name[index];
#define F(a,n,i) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define mod 10000000007
#define modpro 99824435

const int d4i[4]={-1,0,1,0},d4j[4]={0,1,0,-1};
const int d8i[8]={-1,-1,0,1,1,1,0,-1},d8j[8]={0,1,1,1,0,-1,-1,-1};


void solve(){
	int n;
	cin>>n;
	int ans=0;
	inv(a,int,n);
	F(0,n,i){
		if((i+1)%2!=0 && a[i]%2!=0) ans++;
	}
	cout<<ans;
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  //int t;cin>>t;while(t--) solve(),cout<<endl;
  solve();
}



Measured memory_bytes: 3656
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

string out_and_read(int idx) {
    cout << idx << endl;
    string res; cin >> res;
    if(res == "Vacant") exit(0);
    return res;
}

bool judge(int l, int r, string vl, string vr) {
    int diff = r - l;
    if(diff % 2 == 0 && vl != vr) return true;
    if(diff % 2 == 1 && vl == vr) return true;
    return false;
}
 
signed main() {
    int N; cin >> N;

    string INIT('z', 10);
    vector<string> res_log(N, INIT);
    int ub = N-1, lb = 0;
    while(ub - lb > 1) {
        if(res_log[lb] == INIT) res_log[lb] = out_and_read(lb);
        if(res_log[ub] == INIT) res_log[ub] = out_and_read(ub);

        int mid = (ub + lb) / 2;
        if(res_log[mid] == INIT) res_log[mid] = out_and_read(mid);

        bool bl = judge(lb, mid, res_log[lb], res_log[mid]);
        bool br = judge(mid, ub, res_log[ub], res_log[mid]);

        assert(bl || br);
        if(bl) ub = mid;
        if(br) lb = mid;
    }
    return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, L;
    cin >> N >> L;
    int apple[N];
    for(int i = 0; i < N; i++){
        apple[i] = L + i;
    }
    int sum = accumulate(apple, apple + N, 0);
    int ans = 1e9;
    for(int i: apple){
        if(abs(ans) > abs(i)){
            ans = i;
        }
    }
    cout << sum - ans << endl;
}


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

int main(void){
  int x, y, i;

  scanf("%d %d", &x, &y);

  for(i=0; i<=x; i++){
    if((4*i + 2*(x-i))==y){
      printf("Yes\n");
      exit(0);
    }
  }

  printf("No\n");

  return(0);
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    double a,b,x;
    cin >> a >> b >> x;

    if (x >= a*a*b/2) {
        double c = 2 * (b - x / a / a);
        printf("%.6f\n", atan(c/a) * 180 / PI);
    } else {
        double c = (2 * x) / (a * b);
        printf("%.6f\n", 90 - atan(c/b) * 180 / PI);
    }

    return 0;
}


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

int main(){
    int x,a,b;
    cin >> x>> a >> b;

    if(a >= b) puts("delicious");
    else if(x + a >= b) puts("safe");
    else puts("dangerous");
}

Measured memory_bytes: 256
s = input()
n = len(list(s))
p = s[:(n-1)//2]
t = s[(n+1)//2:]
p1 = ""
t1 = ""
for i in reversed(range((n-1)//2)):
    p1 += p[i]
    t1 += t[i]
if t1 == t and p1 == p and s == t1 + s[(n-1)//2]+p1:
    print("Yes")
else:
    print("No")

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

int Findgcd_by_Euclid(int a, int b);

int main()
{
	int monster;
	int d;
	int i;
	int gcd = 0;
	scanf("%d", &d);

	for (i = 0; i < d; i++)
	{
		scanf("%d", &monster);
		gcd = Findgcd_by_Euclid(gcd ,monster);
	}
	printf("%d\n", gcd);
	return 0;
}

int Findgcd_by_Euclid(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}

Measured memory_bytes: 128
n = gets.to_i
points = []
distance = 0.0

n.times { points << gets.split(' ').map(&:to_f) }

(0...n).each do |i|
  p1 = points[i]
  (0...n).each do |j|
    next if i == j
    p2 = points[j]
    distance += (((p1[0] - p2[0]) ** 2) + ((p1[1] - p2[1]) ** 2)) ** 0.5
  end
end

puts distance / n.to_f

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

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

  bool flag = true;
  while(flag){
    flag = false;

    for(int i = 1; i + 3 < s.size(); i++){
      if(s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 'w'){
        flag = true;
        s = s.substr(0, i) + s.substr(i + 3);
      }
    }
  }

  if(s == "mew") cout << "Cat" << endl;
  else cout << "Rabbit" << endl;

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		String x="",y="";
		for(int i=0;i<b;i++) {
			x+=a;
		}
		for(int i=0;i<a;i++) {
			y+=b;
		}
		String[] n= {x,y};
		Arrays.parallelSort(n);
		System.out.print(n[0]);
	}
} 

Measured memory_bytes: 23764
# frozen_string_literal: true

s = gets.chomp.chars.map(&:to_i).reverse
n = s.size
MOD = 2019
c = Array.new(2019) { 0 }
c[0] = 1
cur = 0
d = 1
(0...n).each do |i|
  cur = (cur + d * s[i]) % MOD
  c[cur] += 1
  d = (d * 10) % MOD
end
puts c.map { |e| e * (e - 1) / 2 }.sum


Measured memory_bytes: 27972
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;

vector<long long> fact, fact_inv, inv;

/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}

/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

long long F(int r, int c) {
    long long ret = 0;
    FOR(j, 1, c + 2) {
        ret += nCk(r + j, j);
        ret %= MOD;
    }
    return ret;
}

int main() {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    init_nCk(4000000);
    cout << (((F(r2, c2) + (MOD - F(r2, c1 - 1))) % MOD + (MOD - F(r1 - 1, c2))) % MOD + F(r1 - 1, c1 - 1)) % MOD
         << endl;
    return 0;
}


Measured memory_bytes: 93952
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    m = 0
    i0 = i
    while i != 0:
        m += int(i % 10)
        i = int(i / 10)
    if a <= m <= b:
        ans += i0
print(ans)


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll N,T,A[100010],high[100010],low[100010],max=0,ans=0;
	scanf("%lld%lld",&N,&T);
	rep(i,N)scanf("%lld",&A[i]);
	low[0]=0;
	reg(i,1,N-1){
		if(A[low[i-1]]<A[i]){
			low[i]=low[i-1];
		}else{
			low[i]=i;
		}
	}
	high[N-1]=N-1;
	ireg(i,0,N-2){
		if(A[high[i+1]]>A[i]){
			high[i]=high[i+1];
		}else{
			high[i]=i;
		}
	}
	rep(i,N){
		if(max < A[high[i]]-A[low[i]])max = A[high[i]]-A[low[i]];
	}
	rep(i,N){
		if(max == A[high[i]]-A[low[i]]){
			A[high[i]]-=1;
			ans++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<ll, ll>P;
ll h, w;
char a[55][55];
ll d[55][55];
ll dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
ll haba() {
	queue<P>que;
	rep(i, h) { rep(j, w)d[i][j] = -1; }
	que.push(P(0, 0));
	d[0][0] = 0;
	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == h - 1 && p.second == w - 1)break;
		rep(i, 4) {
			ll nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx >= 0 && nx < h && ny >= 0 && ny < w && d[nx][ny] == -1 && a[nx][ny] != '#') {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h - 1][w - 1];
}
signed main() {
	cin >> h >> w;
	rep(i, h) { rep(j, w)cin >> a[i][j]; }
	ll cnt = 0, ans = haba();
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '#')cnt++;
		}
	}
	if (ans == -1)puts("-1");
	else cout << h * w - ans - cnt - 1 << endl;
	ggr
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
A = list(map(int,input().split()))
allsum = 0
sums_list = deque()
sums = 0
for i in range(N-1, 0, -1):
  sums = (sums + A[i]) % (10**9 + 7)
  sums_list.appendleft(sums)
for i in range(N-1):
  allsum = (allsum + A[i] * sums_list[i]) % (10**9 + 7)
print(allsum)

Measured memory_bytes: 95668
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        
        int N = s.nextInt();
        long[] A = new long[N];
        
        long sum = 0;
        int count = 0;
        
        for (int i = 0; i < N; i++) {
            A[i] = s.nextLong();
            if (A[i] < 0)
                count++;
            A[i] = Math.abs(A[i]);
            sum += A[i];
        }
        if (count % 2 == 1) {
            Arrays.sort(A);
            sum -= 2 * A[0];
        }
        System.out.print(sum);
    }

}


Measured memory_bytes: 51652
#pragma comment(linker, "/STACK:128777216")
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
using namespace std;

#define forx(_name,_from, to, value) for (int name = from; name < to; name += value)
#define rforx(_name, from, to, value) for (int name = from; name > to; name -= _value)
#define all(_STL_NAME) _STL_NAME.begin(), _STL_NAME.end()
#define rall(_STL_NAME) _STL_NAME.rbegin(), _STL_NAME.rend()
#define mp(_FIRST,_SECOND) make_pair(_FIRST,_SECOND)

typedef long long ll;
typedef unsigned long long llu;
typedef long double ld;
const ld eps = 1e-12;
mt19937 rndm;

void start() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout.precision(20); cout.setf(ios::fixed);
	string FILENAME = "navalny";
	rndm.seed(time(0));
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	//freopen((FILENAME + ".in").c_str(), "rt", stdin);
	//freopen((FILENAME + ".out").c_str(), "wt", stdout);
#endif
}

int main() {
	start();
	set<ll> sq;
	for (int i = 0; i <= 1000; ++i)
		sq.insert(i*i);
	vector<vector<int>> q;
	int n, d;
	cin >> n >> d;
	for (int i = 0; i < n; ++i) {
		vector<int> v;
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			v.emplace_back(a);
		}
		q.emplace_back(v);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ll dist = 0;
			for (int k = 0; k < d; ++k) {
				dist += (q[i][k] - q[j][k]) * (q[i][k] - q[j][k]);
			}
			ans += sq.find(dist) != sq.end();
		}
	}
	cout << ans;
#ifdef _DEBUG
	cout << "\nTime: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = input()
c = Counter(map(int, raw_input().split()))

ma = max(c)
mi = min(c)

if (ma+1)/2 == mi and c[mi] == (ma%2) + 1:
    if all(c[x] >= 2 for x in xrange(mi+1, ma+1)):
        print "Possible"
        exit(0)
print "Impossible"

Measured memory_bytes: 2812
import sys
bbn=1000000007
	
#+++++

		
def main():
	k, x = map(int, input().split())
	ret='Yes' if 500*k >= x else 'No'
		
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;
int dp[1100000];


int main() {
	int n;
	cin >> n;
	for (int i=0; i<=1000000; i++) dp[i] = 10000000;

	dp[0] = 0;
	rep(i, 1000000) {
		dp[i+1] = min(dp[i]+1, dp[i+1]);

		for (int j=6; i+j<=1000000; j*=6) {
			dp[i+j] = min(dp[i+j], dp[i]+1);
		}
		for (int j=9; i+j<=1000000; j*=9) {
			dp[i+j] = min(dp[i+j], dp[i]+1);
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 7492
n = int(input())
lis=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
li=[]
a=0
b=0
c=0
d=0
e=0
for i in range(15):
    p=n
    q=0
    while(p>0):
        q+=p//lis[i]
        p=p//lis[i]
    if q>=74:
        e+=1
    if q>=24:
        a+=1
    if q>=14:
        b+=1
    if q>=4:
        c+=1
    if q>=2:
        d+=1
ans=a*(d-1)+b*(c-1)+(c*(c-1))//2*(d-2)+e
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int l = sc.nextInt();
		int[] a = new int[n+1];
      	a[0] = 0;
		for(int i=1; i<=n; i++){
			a[i] = l + i -1;
		}
      	int sum = 0;
      	for(int i=1; i<=n; i++){
          sum += a[i];
        }
      	int low = Math.abs(a[1]);
      	int num = 0;
      	int eat = 0;
      	for(int i=1; i<=n; i++){
          num = Math.abs(a[i]);
          if(low>=num){
            low = num;
            eat = a[i];
          }
        }
      	System.out.println(sum-eat);
	}
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;

int fact(int n)
{
    if (n == 0)
        return 1;
    return fact(n - 1);
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a*b/gcd(a,b)<<endl;
}

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

int main(void){
  int n,m; cin >> n >> m;
  
  vector<ll> h(n+1);
  rep(i,n) cin >> h[i+1];

  int a,b;
  vector<ll> ma(n+1);
  rep(i,m){
    cin >> a;
    cin >> b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    if(h[i]>ma[i]) ans++;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
namespace IO
{
    char ibuf[(1<<21)+1],obuf[(1<<21)+1],st[15],*iS,*iT,*oS=obuf,*oT=obuf+(1<<21);
    inline char Get()
    {
        return (iS==iT? (iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT? EOF:*iS++)):*iS++);
    }
    inline void Flush()
    {
        fwrite(obuf,1,oS-obuf,stdout);
        oS=obuf;
    }
    inline void Put(char x)
    {
        *oS++=x;
        if(oS==oT)
            Flush();
    }
   	inline int read()
    {
       	register int x=0;
        register char ch=Get();
    	while(ch>'9'||ch<'0')
    		ch=Get();
    	while(ch>='0'&&ch<='9')
       		x=(x<<3)+(x<<1)+(ch^48),ch=Get();
       	return x;
    }
    inline void write(int x)  
    {  
        register int top=0;
    	while(x) 
            st[++top]=(x%10)+48,x/=10;
   		while(top)
            Put(st[top--]);
    }
}
using namespace IO;
const int N=200001,M=N<<3;
struct Edge
{
    int u,v,w,Next;
    Edge(){}
    Edge(int U,int V,int W,int NEXT)
    {
        u=U,v=V,w=W,Next=NEXT;
    }
    bool operator<(Edge a)const
    {
            return w<a.w;
    }
}edge[M];
int head[N],tot,f[N],d[N];
inline void add(int x,int y,int z)
{
    edge[++tot]=Edge(x,y,z,head[x]),head[x]=tot;
}
int find(int x)
{
    return x==f[x]? x:f[x]=find(f[x]);
}
bool cmp(int x,int y)
{
    int fx=find(x),fy=find(y);
    if(fx==fy)
        return false;
    if(fy>fx)
        f[fy]=fx;
    else
        f[fx]=fy;
    return true;
}
int main()
{
    register int n=read(),q=read();
    memset(d,0x3f,sizeof d);
    for(register int i=1,a,b,c;i<=q;++i)
    {
        a=read(),b=read(),c=read();
        add(a,b,c);
        d[a]=min(d[a],c+1),d[b]=min(d[b],c+2);
    }
    for(register int i=0;i<n;++i)
        d[i]=min(d[i],d[(i-1+n)%n]+2);
    for(register int i=0;i<n;++i)
        d[i]=min(d[i],d[(i-1+n)%n]+2);
    for(register int i=0;i<=n;++i)
        add(i,(i+1)%n,d[i]);
    sort(edge+1,edge+1+tot);
    for(register int i=1;i<n;++i)
        f[i]=i;
    register int lt=n;
    long long ans=0;
    for(register int i=1;i<=tot&&lt>1;++i)
        if(cmp(edge[i].u, edge[i].v))
            ans+=edge[i].w,--lt;
    return printf("%lld",ans),0;
}

Measured memory_bytes: 15360
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


pii operator+(pii obj, pii obj2) {
	return MP(obj.first + obj2.first, obj.second + obj2.second);
}
pii operator-(pii obj, pii obj2) {
	return MP(obj.first - obj2.first, obj.second - obj2.second);
}

int main() {
	string str;
	cin >> str;
	char bef = 'B';
	for (auto itr : str) {
		if (bef == 'A' && itr == 'C') {
			printf("Yes\n");
			return 0;
		}
		bef = itr;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	double n;
	double a=0;
	int i;
	scanf("%lf", &n);
	for (i = 0; i <= n; i++) {
		if (i % 2 == 1) {
			a++;
		}
	}
	printf("%lf", a/n);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cctype>
#include <cmath>
using namespace std;

int main() {
    string str;
    cin >> str;
    const char sunny = 'S';
    int rainStreak = 3;
    int countSunny = 0;
    for (int i = 0; i < 3; i++)
    {
        if (str[i] == sunny) {
            countSunny += 1;
        }
    }
    rainStreak -= countSunny;
    if (countSunny == 1 && str[1] == sunny) {
        rainStreak -= 1;
    }
    cout << rainStreak;
	return 0;
}



Measured memory_bytes: 3628
import java.util.Scanner;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        double di = Math.sqrt(Math.pow((x1-x2),2)+ Math.pow((y1-y2),2));
        System.out.printf("%.4f\n",di);
    }
}


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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int INF = 1e7;
int N, M;
int G[111][111];
int W[111][111];
int visited[111][111];

void print() {
   rep (i, 1, N+1) {
      rep (j, 1, N+1) {
         cout << visited[i][j] << " ";
      }
      cout << endl;
   }
}

int main() {
   cin >> N >> M;
   rep (i, 1, N+1) {
      rep (j, 1, N+1) {
         visited[i][j] = visited[j][i] = 3;
         if (i == j) continue;
         G[i][j] = G[j][i] = INF;
         W[i][j] = W[j][i] = INF;
      }
   }
   rep (i, 0, M) {
      int a, b, c;
      cin >> a >> b >> c;
      G[a][b] = G[b][a] = c;
      W[a][b] = W[b][a] = c;
      visited[a][b] = visited[b][a] = 2;
   }

   rep (k, 1, N+1) {
      rep (i, 1, N+1) {
         rep (j, 1, N+1) {
            W[i][j] = W[j][i] = min(W[i][j], W[i][k] + W[k][j]);
         }
      }
   }

   // i~jまでの距離
   rep (k, 1, N+1) {
      rep (i, 1, N+1) {
         rep (j, 1, N+1) {
            int dist = G[i][k] + G[k][j];
            if (dist == W[i][j]) {
               visited[i][k] = visited[k][j] = 1;
               visited[k][i] = visited[j][k] = 1;
            }
         }
      }
   }

   int cnt = 0;
   rep (i, 1, N+1) {
      rep (j, 1, N+1) {
         if (i==j) continue;
         if (visited[i][j] == 2) {
            visited[i][j] = visited[j][i] = 1;
            cnt++;
         }
      }
   }
   cout << cnt << endl;


   return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for (ll i = 0; i < n - 1; i++){
        if (a[i] == a[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll x;
  cin >> x;
  
  /*
  while (x % 100 != 0){
    if (x % 10 == 0){
      x -= 210;
    }
    else if (x % 10 >= 5){
      x -= 105;
    }
    else if (x % 10 == 1){
      x -= 101;
    }
    else if (x % 10 == 2){
      x -= 102;
    }
    else if (x % 10 == 3){
      x -= 103;
    }
    else if (x % 10 == 4){
      x -= 104;
    }
  }
  */

  if ((x - x % 100)*0.05 - x % 100 >= 0){
    cout << 1 << endl;
  }
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n;
    cin >> n;
    int dp[100001];

    REP(i,100001){
        dp[i] = INF;
    }
    dp[0] = 0;
    for(int i = 1;i <= n;i++){

        dp[i] = dp[i-1]+1;
        for(int j = 6; j <= i; j *= 6){
            dp[i] = min(dp[i],dp[i-j]+1);
        }

        for(int j = 9; j <= i; j *= 9){
            dp[i] = min(dp[i],dp[i-j]+1);
        }
    }
    cout << dp[n] << endl;



    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  string a;
  cin>>a;
  if(a=="ABC")
    cout<<"ARC";
  else
    cout<<"ABC";
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    scanf("%d",&n);
    cin>>s;
    int cnt = 0;
    int len = s.size();
    for(int i = 0; i < len; i++){
        if(s[i] =='A' && s[i+1] == 'B' && s[i+2] == 'C')
            cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3756
n = int(input())
s = input()
target = [str(i) for i in range(10)]
count = 0
for x in target:
    a = s.find(x)
    if a == -1:
        continue
    for y in target:
        b = s.find(y,a+1)
        if b == -1:
            continue
        for z in target:
            c = s.find(z,b+1)
            if c != -1:
                count +=1
print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long xx, yy, i, j, k, n, x, y, a, b;
	cin >> xx >> yy >> n;

	map<pair<long long, long long>, long long> ct;
	for (i = 0; i < n; i++) {
		cin >> x >> y;
		for (a = 0; a < 3; a++) {
			for (b = 0; b < 3; b++) {
				if ((x - a >= 1) && (y - b >= 1) && (x - a <= xx - 2) && (y - b <= yy - 2)) ct[{x - a, y - b}]++;
			}
		}
	}

	vector<long long> ans(10, 0);
	for (auto p : ct) {
		ans[p.second]++;
	}
	ans[0] = (xx - 2) * (yy - 2);
	for (i = 1; i < 10; i++) ans[0] -= ans[i];

	for (auto p : ans)cout << p << "\n";


	return 0;
}



Measured memory_bytes: 56448
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class E
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		var adj = new List<int>[N];
		for(int i = 0; i < N; i++)
			adj[i] = new List<int>();
		for(int i = 0; i < M; i++)
			adj[GetInt() - 1].Add(GetInt() - 1);
		int S = GetInt() - 1;
		int T = GetInt() - 1;

		long[,] d = new long[3, N];
		for(int i = 0; i < 3; i++)
			for(int j = 0; j < N; j++)
				d[i, j] = -1;

		d[0, S] = 0;
		var queue = new Queue<Tuple<int, int>>();
		queue.Enqueue(Tuple.Create(0, S));
		while(queue.Count > 0)
		{
			var e = queue.Dequeue();
			int state = e.Item1;
			int v = e.Item2;
			foreach(int u in adj[v])
			{
				int nextState = (state + 1) % 3;
				if(d[nextState, u] != -1)
					continue;

				d[nextState, u] = d[state, v] + 1;
				queue.Enqueue(Tuple.Create(nextState, u));
			}
		}

		Console.WriteLine((d[0, T] == -1) ? -1: d[0, T] / 3);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 30936
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,t,d;
	cin>>n>>k;
	vector<pll> v(n);
	rep(i,n) cin>>v[i].fs>>v[i].sc;
	sort(all(v),[](const pll &a,const pll &b){
		return a.sc>b.sc;
	});
	ll ans=0,sum=0;
	set<ll> s;
	priority_queue<ll,vector<ll>,greater<ll>> q;
	rep(i,n){
		if(i<k){
			sum+=v[i].sc;
			if(s.find(v[i].fs)!=s.end()){
				q.push(v[i].sc);
			}
			s.insert(v[i].fs);
		}
		else{
			if(q.empty()||s.find(v[i].fs)!=s.end())continue;
			ll waste=q.top();q.pop();
			sum-=waste;sum+=v[i].sc;
			s.insert(v[i].fs);
		}
		chmax(ans,(ll)(s.size()*s.size()+sum));
	}
	cout<<ans<<endl;
	
}



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

#define  pf                  printf
#define  sc                  scanf
#define  PI                  2*acos(0.0)
#define  fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define  mem(a,b)            memset(a, b, sizeof(a) )
#define  gcd(a,b)            __gcd(a,b)
#define  lcm(a,b)            (a*(b/gcd(a,b)))
#define  MAX                 1234567899
#define  mod                 1000000007
#define  all(v)              (v).begin(),(v).end()
#define  vSort(v)            sort(all(v))
#define  maxSort(v)          sort(all(v),greater<int>())
#define  Unique(v)           v.erase(unique(all(v)),v.end())
#define  sqr(x)              ((x)*(x))
#define  qube(x)             ((x)*(x)*(x))
#define  deci(n)             cout<<fixed<<setprecision(n)
#define  sci(n)              sc("%d",&(n))
#define  scii(x,y)           sc("%d %d",&(x),&(y))
#define  scl(x)              sc("%lld",&(x))
#define  scll(x,y)           sc("%lld %lld",&(x),&(y))
#define  vi                  vector<int>
#define  hi                  pf(" HI \n")
#define  pp                  pair<int,int>
#define  pb(x)               push_back(x)
#define  mp(x,y)             make_pair(x,y)
#define  F                   first
#define  S                   second
#define  check(n,pos)        (n & (1<<(pos)))
#define  biton(n,pos)        (n  (1<<(pos)))
#define  bitoff(n,pos)       (n & ~(1<<(pos)))
typedef  long long int       lli;
typedef  unsigned long long int ulli;
int dx4[] = { 0 , 0 , -1 , 1 } ;
int dy4[] = { -1 , 1 , 0 , 0 } ;
bool valid( int r , int c , int x , int y ){
    if( x >= 1 && x <= r && y >= 1 && y <= c ) return 1 ; return 0 ;}

using namespace std;
lli n,k;
lli DP[100005];
lli a[100005];
int cal(int pos)
{
    if(pos==(n))
        return 0;
    if(pos>n)
        return MAX;
    if(DP[pos]!= -1)
        return DP[pos];
    lli val =MAX;
    for(int i=1;i<=k;i++)
    {
        if((pos+i)<=n)
            val = min ( val,abs(a[pos]-a[pos+i])+cal(pos+i));
    }
    DP[pos]=val;
    return DP[pos];
}
int main ()
{
    mem(DP,-1);
    cin >> n >> k;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    lli ans = cal(1);
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 8064
N = input()
A1 = map(int, raw_input().split())
A2 = map(int, raw_input().split())
s = sum(A2) + A1[0]
ans = s
for i in range(N-1):
    s = s + A1[i+1] - A2[i]
    ans = max(s, ans)
print ans

Measured memory_bytes: 2568
import sys
import time
st = time.perf_counter()
# ------------------------------

x, y = map(int, input().split())
ok = False
for i in range(x + 1):
    if i * 4 + (x - i) * 2 == y:
        ok = True
        break
if ok:
    print('Yes')
else:
    print('No')

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9084
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
h = list(map(int, readline().split()))

l = [1]*n
for i in range(m):
    a, b= map(int, readline().split())
    if h[a - 1] < h[b - 1]:
        l[a - 1] = 0
    elif h[a - 1] > h[b - 1]:
        l[b - 1] = 0
    else:
        l[a - 1] = 0
        l[b - 1] = 0
print(sum(l))


Measured memory_bytes: 18288
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());

        String str1 = scan.next();
//        int int3 = Integer.parseInt(scan.next());
//        String str1 = scan.next();

        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";

        StringBuilder sb = new StringBuilder(str1);
        sb.replace(0,4,"2018");
        PrintWriter out = new PrintWriter(System.out);
        out.println(sb);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
s=input()
leng=len(s)
cnt1=cnt2=0
m=["0","1"]
for i in range(leng):
    if s[i]!=m[0]:
        cnt1+=1
    else:
        cnt2+=1
    t=m[0]
    m[0]=m[1]
    m[1]=t
print(min(cnt1,cnt2))    


Measured memory_bytes: 3188
// Created by Sharat Sachin
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin>>n;
    vector<ll>  v(n),sol(n);
    rep(i,n) cin>>v[i];
    rep(i,n){
        if(i==0) sol[0]=0;
        else if(i==1) sol[1]=abs(v[1]-v[0]);
        else sol[i] = min(sol[i-1]+abs(v[i]-v[i-1]),sol[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<sol[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int h1, h2, m1, m2, k; 
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int st=60*h1+m1;
    int ed=60*h2+m2;
    ll res = ed-st-k;
    cout << res << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << (a * b) / 2 << endl;
}

Measured memory_bytes: 3636
#ifndef TestHeader_hpp
    #define TestHeader_hpp
    #include<bits/stdc++.h>
    typedef long long int lli;
    #ifndef UNS
        #define UNS
        using namespace std;
    #endif // UNS
    #ifndef Nstdio
        #define Nstdio
        //#include<stdio.h>
    #endif // Nstdio
    #ifndef Nvector
        #define Nvector
        //#include<vector>
        typedef vector<lli> vl;
        typedef vector<int> vi;
    #endif // Nvector
    #ifndef Nutility
        #define Nutility
        //#include<utility>
        typedef pair<int,int> pii;
        typedef pair<lli,lli> pll;
    #endif // Nutility
    #define DP(H,W) lli[H][W] = {0}
    #define PUB push_back
    #define MsP make_pair
    #define F first
    #define S second
    #define INT 1
    #define LLI 2
    #define DOUBLE 3
    #define FLOAT 4
    #define CHAR 5
    #define STRING 6
    #define READ scanf
    #define PL printf
    #define SPACE PL(" ")
    #define ENTER PL("\n")
    #define REPI(ite) for(int i = 0;i < ite;i++)
    #define REPJ(ite) for(int j = 0;j < ite;j++)
    #define REPK(ite) for(int k = 0;k < ite;k++)
    #define DREPI(ite) for(int i = ite-1;i >= 0;i--)
    #define DREPJ(ite) for(int j = ite-1;j >= 0;j--)
    #define DREPK(ite) for(int k = ite-1;k >= 0;k--)
    #define AREPI(ite) for(int Ai = 0;Ai < ite;Ai++)
    #define AREPJ(ite) for(int Aj = 0;Aj < ite;Aj++)
    #define AREPK(ite) for(int Ak = 0;Ak < ite;Ak++)
    #define INPUT(address,type) if(type == INT){READ("%d",address);}else if(type == LLI){READ("%lld",address);}else if(type == DOUBLE){READ("%lf",address);}else if(type == FLOAT){READ("%f",address);}else if(type == CHAR){READ("%c",address);}else if(type == STRING){READ("%s",address);}
    #define OUTPUT(address,type) if(type == INT){PL("%d",*(address));}else if(type == LLI){PL("%lld",*(address));}else if(type == DOUBLE){PL("%lf",*(address));}else if(type == FLOAT){PL("%f",*(address));}else if(type == CHAR){PL("%c",*(address));}else if(type == STRING){PL("%s",*(address));}
    #define INARRAY(addredd,len,type) AREPI(len){INPUT(address+Ai,type);}
    #define OUTARRAY(address,len,type) AREPI(len){OUTPUT(address+Ai,type);SPACE;}ENTER
    lli GCD(lli a,lli b){
        if(a%b == 0){
            return b;
        }
        else{
            return GCD(b,a%b);
        }
    }
    lli NT(lli x,lli n){
        int XN = 0;
        while(1){
            if(x%n != 0){
                return XN;
            }
            XN++;
            x/=n;
        }
    }
#endif // TestHeader_hpp

int main(){
    int a,b;
    INPUT(&a,INT);
    INPUT(&b,INT);
    char c = (a+b==15 ? '+':(a*b==15 ? '*':'x'));
    OUTPUT(&c,CHAR);ENTER;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int maxi=0,mini=1000,sum=0;
		rep(i,n){
			int a; scanf("%d",&a);
			sum+=a;
			if(maxi<a) maxi=a;
			if(mini>a) mini=a;
		}
		printf("%d\n",(sum-maxi-mini)/(n-2));
	}

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){

  int i,j,N,c;
  scanf("%d",&N);
  char s[11000];
  scanf("%s",&s);
  c=strlen(s);

  for(i=0;i<N;i++){
   for(j=0;j<c;j++){
   
     if(s[j]=='Z')
       s[j]='A';
     else
       s[j]=s[j]+1;
   }
  }
  printf("%s",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double eps = 1e-9;
const double PI = acos(-1);
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
string s;
bool yes[128];
int main(){
	cin>>s;
	for(int i=0; i<s.size(); ++i)
		yes[s[i]]=1;
	if(s.size()<26){
		for(char i='a'; i<='z'; ++i)
			if(!yes[i]){
				cout<<s<<i<<endl;
				break;
			}
		return 0;
	}
	if(s=="zyxwvutsrqponmlkjihgfedcba")
		puts("-1");
	else{
		char x=s.back();
		s.pop_back();
		set<char> st;
		st.insert(x);
		while(st.upper_bound(s.back())==st.end()){
			st.insert(s.back());
			s.pop_back();
		}
		x=s.back();
		s.pop_back();
		cout<<s<<*st.upper_bound(x)<<endl;
	}
	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#define F 7500000
using namespace std;bool t[F];int n,m,i;int main(){while(cin>>m>>n&&m){for(i=0;i<F;i++)t[i]=0;while(1){if(!t[m]){if(!n)break;for(i=m*2;i<F;i+=m)t[i]=1;n--;}m++;}cout<<m<<endl;}return 0;}

Measured memory_bytes: 10360