akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;


struct Player {
    int f;
    int a;
    int x,y;
    int t;
};
int dist(Player p1,Player p2) {
    return ((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
vector<Player> player;
int main() {
    cin>>n;
    rep(i,n) {
        int f,a,t,x,y;
        cin>>f>>a>>t>>x>>y;
        Player p;
        p.f=f;
        p.a=a;
        p.x=x;
        p.y=y;
        p.t=t;
        player.pb(p);

    }
    int ans1[2];
    double ans2[2];
    ans1[0]=ans1[1]=-1;
    ans2[0]=ans2[1]=-1;
    rep(i,player.size()) {
        int j=i+1;
        if(j==player.size()) break;
        if(player[i].a==player[j].a) continue;
        if(player[i].t!=player[j].t) continue;

        int t=player[i].t;
        int d=dist(player[i],player[j]);
        if(ans1[t]<d) {
            ans1[t]=d;
            ans2[t]=abs(player[i].f-player[j].f);
        }
        if(ans1[t]==d) {
            ans2[t]=min(ans2[t],1.0*abs(player[i].f-player[j].f));

        }
    }
    rep(t,2) {
        double tmp=ans1[t];
        if(tmp!=-1) tmp=sqrt(1.0*tmp);
        if(ans2[t]!=-1) ans2[t]/=60;
        printf("%.8f %.8f\n",tmp,ans2[t]);
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, A, B;
  std::cin >> n >> A >> B;
  std::vector< lint > X(n); std::cin >> X;
  std::adjacent_difference(all(X), X.begin());
  lint ans = 0;
  rep(i,1,n) {
    ans += std::min(A*X.at(i), B);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
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,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> h >> n;
  int sum = 0;
  REP(i, n) {
    int a;
    cin >> a;
    sum += a;
  }

  cout << (sum >= h ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <map>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	cout << 3 * n * n;





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int X, A, B;
    cin >> X >> A >> B;

    X -= A;
    while(true){
        if(X >= B){
            X -= B;
        }else{
            break;
        }
    }

    cout << X;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
// ABC 116 C

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  vector<int> arr;
  for (int i = 1; i <= 100; ++i) {
    if (a % i == 0 && b % i == 0) {
      arr.push_back(i);
    }
  }
  cout << *(arr.end() - k) << endl;
  return 0;
}


Measured memory_bytes: 256
// Code for C - A x B + C
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

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

  ll total = 0;
  int rootN = sqrt(N);
  for (int A = 1; A <= rootN; A++) {
    int maxB = ( (N-1) / A ) - A;

    total += maxB * 2 + 1;
  }

  if ( rootN * rootN == N ) {
    total += 1;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3700
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		double arr[]=new double[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextDouble();
		}
		double dp[][]=new double[n+1][n+1];
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			dp[i][0]=dp[i-1][0]*(1-arr[i-1]);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=i;j++){
				dp[i][j]=dp[i-1][j]*(1-arr[i-1])+dp[i-1][j-1]*arr[i-1];
			}
		}
		double ans=0;
		for(int i=n;i>n/2;i--){
			ans+=dp[n][i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 116576
nums = [int(e) for e in input().split()]
n = nums[0]
a = nums[1]
b = nums[2]

sum1 = a + b
iter1 = n // sum1
amari = n % sum1
if amari >= a:
	print(iter1 * a + (a))
else:
  print(iter1 * a + (amari))

Measured memory_bytes: 3060
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

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

  bool sorted = true;
  int cnt = 0;

  while (sorted) {
    sorted = false;
    for (int i = n - 1; i >= 1; --i) {
      if (a[i] < a[i - 1]) {
        swap(a[i], a[i - 1]);
        ++cnt;
        sorted = true;
      }
    }
  }
  
  for (int i = 0; i < n; ++i) {
    cout << a[i];
    if (i != n - 1) cout << " ";
    else cout << '\n';
  }
  cout << cnt << '\n';

  return 0;
}



Measured memory_bytes: 3164
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main() {
  int n;
  vector<int> vec;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    vec.push_back(x);
  }

  sort(vec.begin(), vec.end());
  double result = (double)vec.front();
  vec.erase(vec.begin());

  for (int i : vec) {
    result = (result + (double)i) / 2.0;
  }
  printf("%lf\n", result);
  return 0;
}


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

using namespace std;

constexpr auto MOD=1000000007LL;

// a^n mod m を計算する(繰り返し二乗法,二分累乗法:O(logn)) (再帰版)
long long modpow(long long a,long long n){return n?modpow(a*a%MOD,n/2)*(n%2?a:1)%MOD:1;}

// // MOD考慮power関数
// inline long long modpow(long long a,long long n)
// {
// 	long long ret=1;
// 	for(long long i=0;i<n;i++){
// 		ret*=a;
// 		ret%=MOD;
// 	}
// 	return ret;
// }

// gcd関数
// inline long long gcd(long long a, long long b)
// {
// 	if(a<b) swap(a,b);
// 	if(a%b==0) return b;
// 	else return gcd(b,a%b);
// }

int main(){
	int n;
	cin>>n;
	long long zero = 0;
	map<pair<long long, long long>,vector<int>> bad;
	while(n--){
		long long x,y;
		cin >> x >> y;

		// 両方0ならカウントしてcontinue
		if(x==0 && y==0){
			zero++;
			continue;
		}
		
		// 既約分数計算
		long long g = gcd(x, y);
		x /= g;
		y /= g;
		
		// 符号情報を統一
		if(y < 0) x = -x, y = -y;
		if(y==0 && x<0) x = -x, y = -y;
		
		int rotate90 = (x <= 0);
		if(rotate90){ 
			swap(x, y);
			y = -y;
		}

		if(bad.count({x, y}) == 0) bad[{x,y}] = {0, 0};
		bad[{x, y}][rotate90]++;
	}

	// 組み合わせ計算
	long long ans = 1;
	for(auto x:bad){
		vector<int> c = x.second;
		ans *= (modpow(2, c[0]) - 1) + (modpow(2, c[1]) - 1) + 1;
		ans %= MOD;
	}

	ans += zero - 1;
	ans = (ans + MOD) % MOD;
	cout<< ans <<endl;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
signed main(){
	int n;
	cin>>n;
	int a[100010];
	rep(i,n+1)cin>>a[i];
	int c[100010];
	rep(i,1,n+1)c[i]=-1;
	int memo=0;
	rep(i,n+1){
		if(c[a[i]]>=0){
			memo=n+1-2-(i-c[a[i]]-1);
		}
		c[a[i]]=i;
	}
	rep(i,1,n+2){
		cout<<(COM(n+1,i)-COM(memo,i-1)+MOD)%MOD<<endl;
	}
	return 0;
}


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

int N;
long long A[200010],ans;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%lld",A + i);

    if(A[0] != 0)
    {
        printf("-1\n");
        return 0;
    }
    for(int i = 1; i < N; i++)
    {
        if(A[i] - A[i - 1] > 1)
        {
            printf("-1\n");
            return 0;
        }
        if(A[i] - A[i - 1] == 1)ans++;
        else ans += A[i];
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split(" "))


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2,k+K)
    
    L.append(H[k]-H[k+K-1])

print(min(L))


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

int main(){
    string s; cin >> s;
    bool flg = true;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)==s.at(i+1)){
            flg = false;
            break;
        }
    }
    if(flg==true){
        cout << "Good" << endl;
    }
    else{
        cout << "Bad" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a,tmp;
    for (int i=0; i<N; i++) {
        cin >> tmp;
        a ^= tmp;
    }
    if (a == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
arr = ['A', 'C', 'G', 'T']
 
cnt = 0
maxCnt = 0
for s in S:
  if s in arr:
    cnt += 1
  else:
    if maxCnt < cnt:
      maxCnt = cnt
    cnt = 0
if maxCnt < cnt:
  maxCnt = cnt
print(maxCnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int N=1000001;
bool prime[N];
void seive()
{
    memset(prime,1,sizeof(prime));
    prime[0]=prime[1]=0;
    for(int i=2;i*i<=N;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<=N;j+=i)
                prime[j]=0;
        }
    }
}

void solve()
{
    seive();
    int n;cin>>n;
    int ans=0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(prime[i])
        {
            int c=0;
            while(n%i==0)
            {
                n/=i;
                c++;
            }
            ans+=floor((sqrt(1+8*c)-1)/2.0);
        }
    }
    if(n>1)
        ans++;
    cout<<ans<<nl;
}

signed 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: 4652
#include<iostream>

using namespace std;

int main(){
  int t,n;

  while(cin>>t,t){
    int total=0;
    cin>>n;

    for(int i=0;i<n;++i){
      int a,b;
      cin>>a>>b;
      total+=b-a;
    }

    if(total>=t)
      cout<<"OK"<<endl;
    else
      cout<<t-total<<endl;
  }
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] road = new int[h][w];
		int[][] dp = new int[h][w];
		for(int i=0;i<h;i++) {
			String str = sc.next();
			for(int j=0;j<w;j++) {
				char c = str.charAt(j);
				road[i][j] = c - '0';
			}
		}
		
		dp[0][0] = 0;
		for(int j=1;j<w;j++) {
			dp[0][j] = dp[0][j-1] + road[0][j];
		}
		for(int i=1;i<h;i++) {
			dp[i][0] = dp[i-1][0] + road[i][0];
		}
		for(int i=1;i<h;i++) {
			for(int j=1;j<w;j++) {
				dp[i][j] = Math.min(dp[i-1][j], dp[i][j-1]) + road[i][j];
			}
		}
		System.out.println(dp[h-1][w-1]);
	}
}








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

bitset<10000001> pr;
vector<int> primes;
int count=0;
void sieve()
{
    //cout<<pr[0];
    for(int i=2;i*i<10000001;i++)
    {
        if(pr[i])continue;
        for(int j=i*2;j<1000001;j+=i)
        {
            pr[j]=i;
        }
    }
    for(int i=2;i<=1000001;i++)
    {
        if(!pr[i])primes.push_back(i);
    }
}
vector<int> tl;
void primeFctorization(int n)
{
    set<int> th;
    vector<int> ans;
    int N=n;
    n=abs(n);
    for(int i=0;i<primes.size()&&primes[i]*primes[i]<=n;i++)
    {
        while(n%primes[i]==0)
        {
            th.insert(primes[i]);
            n/=primes[i];
            ans.push_back(primes[i]);
            //cout<<primes[i]<< " ";
        }
    }
    if(n>1){
        th.insert(n);
        //cout<<n;;
        ans.push_back(n);
    }
    if(th.size()>=3)
    {
        tl.push_back(N);
        ::count++;
        //cout<<N<<endl;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    cin>>str;
    int count=0;
    for(int i=0;i<str.length()-1;i++)
    {
        if(str[i]==str[i+1])
        {
            if(str[i]=='1')str[i+1]='0';
            else str[i+1]='1';
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1001001001;
const int MX = 200005;


int dp(int n, int k, vector<int> h){
	int cost[MX];
	h.push_back(INF);
	h.push_back(INF);
	h.push_back(INF);
	rep(i,n) cost[i] = INF;
	cost[0]=0;
	for(int i=0; i<n; i++){
		for(int j=1;j<k+1;j++){
			if(i+j >= n) continue;
			cost[i+j]=min(cost[i]+abs(h[i+j]-h[i]),cost[i+j]);
		}
	}
	return cost[n-1];
}



int main(){
	int n,k;
	cin >>n >> k;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	int ans;
	ans = dp(n,k,h);
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 1408
import collections as col
N = int(input())
l = [0]*N
for i in range(N):
    l[i] = input()
ans = []

counter = col.Counter(l)
common = counter.most_common()
ans = []
ans.append(common[0][0])

for i in range(len(common)-1):
    if common[i][1] == common[i+1][1]:
        ans.append(common[i+1][0])
        i += 1
    else:
        break

ans.sort()
for i in range(len(ans)):
    print(ans[i])



Measured memory_bytes: 117320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 36

int main() {

	int i, j, n,flag = 0;
	int minj;
	char C[N][3],S[N][3],tmp[3];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", C[i]);
		strcpy(S[i], C[i]);
	}

	//BubleSort//

  for(i=0;i<n-1;i++){
   for(j=n-1;j>0;j--){
	 if(atoi(&C[j][1]) < atoi(&C[j-1][1])){
		 strcpy(tmp, C[j]);
	     strcpy(C[j],C[j-1]);
		 strcpy(C[j - 1], tmp);
	 }
   }
 }
 
  for (i = 0; i < n; i++) {
	  printf("%s", C[i]);
	  if (i != n - 1) printf(" "); 
	 }
	printf("\n");
	printf("Stable\n");

//SelectionSort

	for (i = 0; i < n - 1; i++) {
		minj = i;
		for (j = i; j < n ; j++) {
			if (atoi(&S[j][1]) < atoi(&S[minj][1])) {
				minj = j;
			}
		}
		strcpy(tmp, S[i]);
		strcpy(S[i], S[minj]);
		strcpy(S[minj], tmp);	
	}

	for (i = 0; i < n; i++) {
		printf("%s", S[i]);
		if (strcmp(S[i],C[i]) != 0) flag = 1;
		if (i != n - 1) printf(" ");
	}
	printf("\n");

	if (flag == 1) printf("Not stable\n");
	else printf("Stable\n");
}






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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToList();

            var c = new List<KeyValuePair<int, int>>();

            foreach (var item in a)
            {
                if (c.Count() != 0 && c.Last().Key == item)
                {
                    c[c.Count() - 1] = new KeyValuePair<int, int>(item, c.Last().Value + 1);
                }
                else
                {
                    c.Add(new KeyValuePair<int, int>(item, 1));
                }
            }

            double ans = 0;

            foreach (var item in c)
            {
                if (item.Key != item.Value)
                {
                    if (item.Key > item.Value)
                    {
                        ans += item.Value;
                    }
                    else
                    {
                        ans += item.Value - item.Key;
                    }
                }
            }


            Console.WriteLine(ans);

        }
    }
}


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

int main()
{
    int A,B,C,X,Y;
    cin >> A>>B>>C>>X>>Y;

    int mincost = INT_MAX;
    REP(z, max(X,Y)+1){
        int xnum = max(0, X-z);
        int ynum = max(0, Y-z);
        int cost = z*2*C+xnum*A+ynum*B;
        mincost = min(mincost, cost);
    }    

    cout << mincost << endl;


   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
      Scanner S = new Scanner(System.in);
      int time= S.nextInt();
      int h = time/ 3600;
      int m = (time - h*3600)/60;
      int s =  time % 60;
      System.out.printf("%d:%d:%d\n", h,m,s);
      }
 }


Measured memory_bytes: 26372
import itertools,collections
a=int(input())
l1=[str(input()) for n in range(0,a)]
c = collections.Counter(l1)
aa=int(c.most_common()[0][1])
#print(c.most_common(0))
#print(aa)
a2 =[w for w,r in c.most_common() if r==aa]
a2=list(sorted(a2))
a3=[print(w1) for w1 in a2]

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/


int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A-B >= C) cout << 0 << endl;
  else cout << C - (A-B) << endl;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, k, h;
	int count=0;
	
	cin >> n;
	cin >> k;
	
	for(int i=0; i<n; i++)
	{
		cin >> h;
		if(h>=k)
		{
			count++;
		}
	}
	
	cout << count << endl;
	
return 0;
}

Measured memory_bytes: 3616
#include<vector>
#include<cstdio>
#include<queue>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define MOD 998244353LL
#define N 4096
ll q[2][N] = {{1}};

int main(){
	int n, s; scanf("%d%d", &n, &s);
	REP(i, n){
		int a; scanf("%d", &a);
		fill(q[1], q[1]+N, 0);
		REP(j, s+1){
			// p[i+1][j] = (p[i+1][j] + p[i][j]) % MOD;
			q[1][j] = (q[1][j] + q[0][j] * 2) % MOD;
			if(j + a <= s){
				// p[i+1][j+a] = (p[i+1][j+a] + p[i][j]) % MOD;
				q[1][j+a] = (q[1][j+a] + q[0][j]) % MOD;
			}
		}
		REP(j, s+1) DEBUG("%lld ", q[0][j]);
		DEBUG("\n");
		swap(q[0], q[1]);
	}
		REP(j, s) DEBUG("%lld ", q[0][j]);
	printf("%lld\n", q[0][s]);
}


Measured memory_bytes: 1796
import java.util.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();
        int m = sc.nextInt();

        List<Integer> a = new ArrayList<>();
        for (int i=0; i < n; i++)
            a.add(sc.nextInt());

        List<Map.Entry<Integer, Integer>> bc = new ArrayList<>();
        for (int i=0; i < m; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            bc.add(new AbstractMap.SimpleEntry<>(b, c));
        }
        bc.sort((o1, o2) -> o2.getValue() - o1.getValue());
        Collections.sort(a);

        int index = 0;
        for (Map.Entry<Integer, Integer> e : bc) {
            for (int i=0; i < e.getKey(); i++) {
                if (index >= a.size())
                    break;
                
                if (a.get(index) < e.getValue()) {
                    a.set(index, e.getValue());
                } else {
                    break;
                }

                index++;
            }
        }

        long ans = 0;
        for (int i : a)
            ans += i;
        System.out.println(ans);

    }
}


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

int main() {
    int N;
    cin >> N;
    ll A[N];
    bool zero = false;
    for (int i = 0; i < N; i++)
    {
        A[i] = 0;
        cin >> A[i];
        if (A[i] == 0)
        {
            zero = true;
        }
        
    }
    
    if (zero)
    {
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    for (int i = 0; i < N; i++)
    {
        if (A[i] > (long double)1e18 / ans)
        {
            ans = -1;
            break;
        }
        ans *= A[i];
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int a,b,c,p,x,u,v,d;
   cin>>a>>b>>c;
   d=c-a-b;
 if(d>=0&&d*d>4*a*b)
   {
       cout<<"Yes"<<endl;
   }
   else

   {
       cout<<"No"<<endl;
   }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        for(int i = 0; i < a; i++) {
        	l[i] = sc.nextInt();
        }

        for(int j = a-1; j >= 0; j--) {
        	if(j == 0) {
            	System.out.println(l[j]);
        	} else {
            	System.out.print(l[j] + " ");
        	}

        }
	}
}



Measured memory_bytes: 26280
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N; cin >> N;
	cout << 0 << endl;
	string first; cin >> first;

	int l = 0, r = N;
	if(first!="Vacant")while (1) {
		int m = (l + r) / 2;
		cout << m << endl;

		string s; cin >> s;
		if (s == "Vacant")break;
		
		if (m % 2 && s != first || m % 2 == 0 && s == first)l = m + 1;
		else r = m;
	}

    return 0;
}



Measured memory_bytes: 852
q=int(input())
lr=[tuple(map(int,input().split())) for _ in range(q)]

def main():
  n=10**5
  ansl=[]
  sieve=[1]*(n+1)
  sieve[0],sieve[1]=0,0
  for i in range(2,n):
    if sieve[i]:
      sieve[2*i::i]=[0 for _ in range(2*i,n+1,i)]
  ans=[0]*(n+1)
  for i in range(3,n):
    if sieve[i]==1 and sieve[(i+1)//2]==1:
      ans[i]=ans[i-1]+1
    else:
      ans[i]=ans[i-1]

  for e in lr:
    print(ans[e[1]]-ans[e[0]-1])

if __name__=='__main__':
  main()

Measured memory_bytes: 24784
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char rbuf[2800014];
int rbufl;

#define getchar_unlocked() rbuf[rbufl++]

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int edge[200000][2];

int qmem[400000];

int *e[100001];
int el[100001];

int prev[100001];

int s[100000];
int sl, sr;

int main(void){
	read(STDIN_FILENO, rbuf, sizeof(rbuf));
	int n=nextint();
	int m=nextint();
	for(int i=0; i<m; i++){
		int A=nextint();
		int B=nextint();
		edge[i][0]=A;
		edge[i][1]=B;
		el[A]++;
		el[B]++;
	}
	int ne=0;
	for(int i=1; i<=n; i++){
		e[i]=&qmem[ne];
		ne+=el[i];
		el[i]=0;
	}
	for(int i=0; i<m; i++){
		int A=edge[i][0];
		int B=edge[i][1];
		e[A][el[A]++]=B;
		e[B][el[B]++]=A;
	}
	int k=0;
	prev[1]=1;
	s[sr++]=1;
	while(sl<sr){
		k++;
		int from = s[sl++];
		for(int i=0; i<el[from]; i++){
			int to = e[from][i];
			if(prev[to]==0){
				prev[to]=from;
				s[sr++]=to;
			}
		}
	}
	if(k==n){
		puts("Yes");
		for(int i=2; i<=n; i++){
			printf("%d\n", prev[i]);
		}
	}else{
		puts("No");
	}
}


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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector <int> a(n);
    map <int,int> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
        m[a[i]]++;
    }
    vector <int> v;
    for(auto x:m){
        v.push_back(x.second);
    }
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=0;i<((int)v.size()-k);i++){
        ans+=v[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11516
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (a, b, c, d) = Read4Longs();

            var max = long.MinValue;
            max = Math.Max(max, a * c);
            max = Math.Max(max, a * d);
            max = Math.Max(max, b * c);
            max = Math.Max(max, b * d);

            return max;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

using namespace std;

#define FOR(i, a) for(int i = 0; i < (int) a; i++)
#define all(v) v.begin(), v.end()
#define f first
#define s second

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



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

	int n, k; cin >> n >> k;
	vi v(n);
	for(auto& p: v) cin >> p;

	sort(all(v));

	ll sum = 0;
	FOR(i, n-k){
		sum+=v[i];
	}

	cout << sum << '\n';	

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=110,maxl=15;
int n,len[maxn];
char x[maxn][maxl];
void gaoci(){
    printf("No");exit(0);
}
int main(){
    scanf("%d",&n);
    memset(x,'\000',sizeof(x));
    for(register int i=1;i<=n;i++){
        scanf("%s",x[i]);len[i]=strlen(x[i]);
        if(i>1) if(x[i][0]!=x[i-1][len[i-1]-1]) gaoci();
        for(register int j=1;j<i;j++){
            if(len[j]!=len[i]) continue;
            int k;
            for(k=0;k<len[i];k++) if(x[j][k]!=x[i][k]) break;
            if(k>=len[i]) gaoci();
        }
    }
    printf("Yes");
    return 0;
}
/*
9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly
*/

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

signed main(){
  int K,A,B;cin>>K>>A>>B;
  if(B-A<2)cout<<1+K<<endl;
  else{
    if(K<A-1)cout<<1+K<<endl;
    else{
      cout<<A+(K-(A-1))/2*(B-A)+(K-(A-1))%2<<endl;
    }
  }
}


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

using namespace std;

int main(){
    double N,Y;
    cin>>N>>Y;
    bool t=false;
	bool s=false;
	vector <int>a(3,0);
	a[0]=N;
	for(int i=0 ; i<=N ; i++){
		for(int j=0 ; j<=i ; j++){
			//cout<<(a[0]*10000)+(5000*j)+((i-j)*1000)<<endl;
			if(Y==(a[0]*10000)+(5000*j)+((i-j)*1000)){
				a[1]=j;
				a[2]=i-j;
				t=true;
				s=true;
				break;
			}
		}
		if(s)break;
		if(a[0]==N){
			if(a[0]*10000==Y){
				t=true;
				break;
			}
		}
		if(a[0]!=0)a[0]-=1;
		//cout<<a[0];
		//a[0]-=1;
	}
	if(t)cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	else cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(long long i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	string s;
  cin >> s;
  int sl = s.length();
  int sw = 0;
  froop1(0,sl / 2){
    if(s[i] != s[sl - i - 1]){
      cout << "No" << endl;
      return 0;
    }
  }
  string s1 = s.substr(0,(sl - 1) / 2);
  int sl1 = s1.length();
  string s2 = s.substr((sl + 3) / 2 - 1,sl - (sl + 3) / 2 + 1);
    int sl2 = s2.length();
  froop1(0,sl1 / 2){
   if(s1[i] != s1[sl1 - 1 - i]){
cout << "No" << endl;
     return 0;
   }
  }
  
  froop1(0,sl2 - 1){
   if(s2[i] != s2[sl2 - 1 - i]){
cout << "No" << endl;
     return 0;
   }
  }
  cout << "Yes" << endl;
 }

Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MIN(_A, _B) (((_A) < (_B)) ? (_A) : (_B))

//define
int cnt;
int n, m;
int fr[777];
int ne[1111111];
int to[1111111];
bool map[777][777];

//input
void add(int a, int b){
	ne[++cnt] = fr[a], fr[a] = cnt, to[cnt] = b;
	ne[++cnt] = fr[b], fr[b] = cnt, to[cnt] = a;
}

void input(){
	scanf("%d %d", &n, &m);
	for(int i = 1, a, b; i <= m; i++){
		scanf("%d %d", &a, &b);
		map[a][b] = map[b][a] = true;
	}
	for(int i = 1; i <= n; i++)
		for(int j = 1; j < i; j++)
			if(!map[i][j]) add(i, j);
}

//work
bool C[777];
bool vis[777];
int c[777][2];
bool bk = false;

void dfs(int a, bool co){
	C[a] = co;
	c[cnt][co]++;
	vis[a] = true;
	for(int i = fr[a]; i; i = ne[i]){
		if(vis[to[i]]){
			if(C[to[i]] != !co) bk = true;
			continue;
		}
		dfs(to[i], !co);
	}
}

void work(){
	cnt = 0;
	for(int i = 1; i <= n; i++)
		if(!vis[i]) ++cnt, dfs(i, 0);
	if(bk) {puts("-1"); return;}
}

//dp
bool f[777][777];
void dp(){
	int la = 0, now;
	f[0][0] = true;
	for(int i = 1; i <= cnt; i++){
		now = la + c[i][0] + c[i][1];
		for(int j = 0; j <= la; j++)
			if(f[la][j]) f[now][j + c[i][0]] = f[now][j + c[i][1]] = true;
		la = now;
	}
	int ans = 99999999;
	for(int i = 0; i <= n; i++)
		if(f[n][i]) ans = MIN(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	printf("%d\n", ans);
}

int main(){
	input();
	work();
	if(bk) return 0;
	dp();
	return 0;
}

Measured memory_bytes: 7168
n,m = gets.chomp.split.map(&:to_i)
as = n.times.map{gets.chomp}
bs = m.times.map{gets.chomp}
ans_flag = true
(0..n-m).each do|i|
  (0..n-m).each do|j|
    ans_flag = true
    (0..m-1).each do|x|
      (0..m-1).each do|y|
        if as[i+x][j+y] != bs[x][y]
          ans_flag = false
          break
        end
      end
      break if ans_flag == false
    end
    if ans_flag
      puts "Yes"
      exit 0
    end
  end
end

puts "No"

Measured memory_bytes: 1788
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();

		// 出力
		if (A == B) {
			System.out.println(C);
		} else if (A == C) {
			System.out.println(B);
		} else {
			System.out.println(A);
		}

		sc.close();
	}
}


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

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

  int ans = 0;
  for (int i = 1; i <= n; i++)
  {
    string s = to_string(i);
    if(s.size()%2==1) ans++;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    if 2 * b >= a {
        println!("{}", 0);
    } else {
        println!("{}", a - 2 * b);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<string>

int main(){
  std::string str;
  std::string maxlen;
  std::string maxocc;
  std::map<std::string, int> occ;
  //std::cin >> str;
  //std::cout << str << std::endl;

  while(std::cin >> str){
    if(str.size()>maxlen.size()){
      maxlen = str;
    }
    occ[str]++;
    if(occ[str]>occ[maxocc]){
      maxocc = str;
    }
  }
  std::cout << maxocc << ' ' << maxlen << std::endl;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
//-------
const int N = 2e5 + 7;
const int M = 26;
const int INF = 1e9 + 7;
char A[N];
int n, nxt[N][M];
int f[N], g[N];
void solve() {
	for (int i = n; i >= 0; --i) {
		f[i] = INF, g[i] = -1;
		rep(j, 0, M)
			if (~nxt[i + 1][j]) {
				if (f[i] > f[nxt[i + 1][j]] + 1) {
					g[i] = j;
					f[i] = f[nxt[i + 1][j]] + 1;
				}
			} else if (f[i] > 1) {
				g[i] = j, f[i] = 1;
			}
//		dd(i), dd(g[i]), de(f[i]);
	}
	vector<char> ans;
	for (int i = 0; ~i; i = nxt[i + 1][g[i]])
		ans.pb('a' + g[i]);
	rep(i, 0, sz(ans)) putchar(ans[i]);
}
int main() {
	scanf("%s", A + 1);
	n = strlen(A + 1);
	rep(i, 0, 26) nxt[n + 1][i] = -1;
	for (int i = n; i >= 0; --i) {
		rep(j, 0, 26) nxt[i][j] = nxt[i + 1][j];
		if (i)
			nxt[i][A[i] - 'a'] = i;
	}
	solve();
	return 0;
}


Measured memory_bytes: 22272
#include <iostream>

using namespace std;

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

  for (size_t n = 0; n < N; ++n) {
    int A;
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 && A % 5) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll mok;
	scanf("%lld", &mok);
	vector<ll>t;
	for (int i = 0; i < 50; i++)t.push_back(49 + mok / 50);
	for (int i = 0; i < mok % 50; i++)
	{
		for (int j = 0; j < 50; j++)
		{
			if (i != j)t[j]--;
			else t[j] += 50;
		}
	}
	printf("50\n");
	for (int i = 0; i < 50; i++)printf("%lld\n", t[i]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999

#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)

#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)

#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;


bool rs(ll a, ll b){return(a>b);}
int main()
{
    ll n; cin>>n;
    ll d=n%1000;
    if(d!=0)d=1000-d;
    cout<<d<<endl;


return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    string s,t;
    ll a,b,ans=1e17;
    cin >> s >> t;
    a=s.size();
    b=t.size();
    rep(i,0,a-b){
        ll mm=0;
        rep(j,0,b-1){
            if(s[i+j]!=t[j]) mm++;
        }
        chmin(ans,mm);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define forout(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
const int N=1e5+1;
int f[N];
int n,k;
int a[N];
main()
{
    cin>>n>>k;
    forinc(i,1,n) cin>>a[i];
    a[0]=0;
    forinc(i,1,n) f[i]=INT_MAX;
    f[0]=0;
    f[1]=0;
    f[2]=abs(a[2]-a[1]);
    forinc(i,3,n)
    {
        forinc(j,1,k)
        {
            if(i-j>0) f[i]=min(f[i-j]+abs(a[i-j]-a[i]),f[i]);
        }
    }
    cout<<f[n]<<"\n";
}


Measured memory_bytes: 1024
#include <cstdio>
int H, W, h, w;
int main() {
	scanf("%d%d%d%d", &H, &W, &h, &w);
	if(H%h + W%w == 0) return !puts("No");
	puts("Yes");
	for(int i=0; i<H; i++, puts("")) for(int j=0; j<W; j++)
		if(H%h) printf("%d ", i%h ? -1000 : 1000*(h-1)-1);
		else printf("%d ", j%w ? -1000 : 1000*(w-1)-1);
	return 0;
}

Measured memory_bytes: 1664
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b;cin>>a>>b;
  if(a<=b)cout<<a<<endl;
  else cout<<a-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int maxn=1e5+10;
int a[maxn],n;
bool cmp(int a,int b){
    return a>b;
}
int main(){
    std::cin>>n;
    for(int i=1;i<=n;i++){
        std::cin>>a[i];
    }
    std::sort(a+1,a+n+1,cmp);
    int p=1;
    for(int i=1;i<=n;i++,p=i){
        if(a[i]<i) {
            break;
        }
    }
    p--;int f=p;
    bool flag=0;
    for(int i=p;i<=n&&a[i]>=p;i++,f=i);
    if((f-p-1)&1) flag=1;
    if((a[p]-p)&1) flag=1;
    if(flag) std::cout<<"First";
    else std::cout<<"Second";
    return 0;
}


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define repll3(i,n) REPLL(i,0,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

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

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

    if (a > b) {
        swap(a, b);
        swap(x, y);
    }

    ll cost1 = a * x + b * y;
    ll cost2 = 2 * c * max(x, y);
    ll cost3 = (x - y >= 0 ? a * (x - y) + 2 * c * y : LINF);
    ll cost4 = (y - x >= 0 ? b * (y - x) + 2 * c * x : LINF);

    cout << min({cost1, cost2, cost3, cost4}) << endl;

    return 0;
}

Measured memory_bytes: 256