akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

  
int main() {
    map<string, int> dict; // 文字列と出現回数の辞書作成

    int n; cin >> n; // 下for文のループ回数
    for (string x; n--; dict[x]++) { // 辞書内の文字列xに対応する出現回数を+1する
        cin >> x; // 文字列 x 入力
    }
 //sort(ALL(dict));
  
  int max_num=0;
  for(auto itr = dict.begin(); itr != dict.end(); ++itr) {
       if (itr->second>max_num)  max_num= itr->second;
    }
  for(auto itr = dict.begin(); itr != dict.end(); ++itr) {
       if (itr->second==max_num) cout<<itr->first<<endl;
    }
  
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
bool isPrime(int n)
{
	if (n < 2)return false;
	for (int i = 2; i < n; i++)
	{
		if (n % i == 0)return false;
	}
}
int gcd(int a, int b)
{
	for (int i = min(a, b); i >= 2; i--)
	{
		if (a % i == 0 && b % i == 0) return i;
	}
	return 1;
}
int main()
{
	int X;
	cin >> X;
	int ans = 1;
	for (int b = X; b > 1; b--)
	{
		for (int p = 2; p <= X; p++)
		{
			int t = pow(b, p);
			if (t <= X)
			{
				ans = max(t, ans);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)

using namespace std;

long long H, A;

int main(){
	cin >> H >> A;
	if(H%A == 0) {
		cout << H/A  << endl;
	} else {
		cout << H/A + 1 << endl;
	}
	

}

Measured memory_bytes: 3604
while True:
    n,x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    ans+=1
    print(ans)


Measured memory_bytes: 5596
usr1 = input()
usr2 = input()

lst1 = usr1.split()
lst2 = usr2.split()
numlst1=[]
numlst2=[]

for element in lst1:
    numlst1.append(int(element))

for element in lst2:
    numlst2.append(int(element))

print((numlst1[0] - numlst2[0])*(numlst1[1]-numlst2[1]))


Measured memory_bytes: 3060
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 111; i <= 999; i += 111) {
    if (n <= i) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

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

    vector<int> V(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        cin >> V[i];
    }

    vector<int> l(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        l[i] = l[i - 1] + V[i];
    }

    vector<int> r(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        r[i] = r[i - 1] + V[N - i + 1];
    }

    int ans = -10000000;
    for (int i = 0; i <= K && i <= N; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            int ret = l[j] + r[i - j];
            vector<int> neg;
            for (int k = 1; k <= j; k++)
            {
                if (V[k] < 0)
                {
                    neg.push_back(V[k]);
                }
            }
            for (int k = 1; k <= i - j; k++)
            {
                if (V[N - k + 1] < 0)
                {
                    neg.push_back(V[N - k + 1]);
                }
            }
            sort(neg.begin(), neg.end());
            for (int k = 0; k < min((int)neg.size(), K - i); k++)
            {
                ret -= neg[k];
            }
            ans = max(ans, ret);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define MAXN (1 << 20)
#define INF (1 << 30)

int n;
ll a[MAXN];

ll f(ll x) {
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		ret += llabs(x - a[i]);
	}
	return ret;
}

ll ff(ll x) {
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		ret += llabs(x + i + 1 - a[i]);
	}
	return ret;
}


int main() {
	cout << fixed << setprecision(12);	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
//		a[i] -= i + 1;
	}
/*	sort(a, a + n);
	int lm = n / 2;
	int rm = n + 1 / 2;
	if (n == 1) {
		rm = lm;
	}
	cout << min(f(a[lm]), f(a[rm])) << endl;*/
	ll l = -INF, r = INF;
	while (r - l > 2) {
		ll m1 = (2 * l + r) / 3;
		ll m2 = (2 * r + l) / 3;
		if (ff(m1) > ff(m2)) {
			l = m1;
		} else {
			r = m2;
		}
	}
	//cout << l << endl;
	cout << min(min(ff(l), ff(l + 1)), ff(l + 2)) << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 5080
N=gets.to_i
a=gets.split.map &:to_i
p 2*N-2
A=a.map(&:abs).each.with_index.max[1]
N.times{|i|puts "#{A+1} #{i+1}" if i!=A}
puts (N-1).times.map{|i|[i+1,i+2]*" "} if 0<=a[A]
puts (N-1).times.map{|i|[i+2,i+1]*" "}.reverse if a[A]<0

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main() {
	int N, T;
	cin >> N >> T;

	int ans = 1001;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t > T)
			continue;
		if (ans > c)
			ans = c;
	}
	if (ans == 1001)
		cout << "TLE" << endl;
	else
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
S = input()

match = True
for i in range(A+B+1):
    if i == A:
        if S[i] != "-":
            print("No")
            match = False
            break
    else:
        if S[i] not in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]:
            print("No")
            match = False
            break
            
if match:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

vec Start;

ll N;
vec A,B;
ll d[200010][2];

int main(){
    cin>>N;
    rep(i,N){
        cin>>d[i][0]>>d[i][1];
        A.pb(d[i][0]);
        B.pb(d[i][1]);
    }
    ll Ka=(N-1)/2, Kb=N/2;
    sort(ALL(A)); sort(ALL(B));
    if(N%2) cout<<B[Kb]-A[Ka]+1<<endl;
    else cout<<(B[Kb]+B[Ka])-(A[Kb]+A[Ka])+1<<endl;

}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W,H,N;
    cin >> W >> H >> N;
    int xy[W][H]={};
    vector<int> x(N),y(N),a(N);
    REP(i,N)cin >> x.at(i) >> y.at(i) >> a.at(i);
    REP(i,N){
        if(a.at(i)==1){
            REP(j,x.at(i)){
                REP(k,H){
                    xy[j][k]=1;
                }
            }
        }else if(a.at(i)==2){
            REP(j,W-x.at(i)){
                REP(k,H){
                    xy[W-1-j][k]=1;
                }
            }
        }else if(a.at(i)==3){
            REP(j,W){
                REP(k,y.at(i)){
                    xy[j][k]=1;
                }
            }
        }else if(a.at(i)==4){
            REP(j,W){
                REP(k,H-y.at(i)){
                    xy[j][H-1-k]=1;
                }
            }
        }
    }
    int ans = 0;
    REP(i,W)REP(j,H)if(xy[i][j]==0){
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
from itertools import permutations
S = [0] * 5
B = [False, False, True, True, True]
N = int(input())
for _ in range(N):
    s = input()
    if s[0] == 'M':
        S[0] += 1
    elif s[0] == 'A':
        S[1] += 1
    elif s[0] == 'R':
        S[2] += 1
    elif s[0] == 'C':
        S[3] += 1
    elif s[0] == 'H':
        S[4] += 1
res = 0
for p in set(permutations(B)):
    t = 1
    for i in range(5):
        if p[i]:
            t *= S[i]
    res += t
print(res)


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

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

    int a = x / 500;
    x -= 500 * a;

    int b = x / 5;
    int ans = a * 1000 + b * 5;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

// bellman-ford法
struct edge { int to, cost; };

void bellman_ford(int s, int n, const vector<vector<edge>> &G, vector<ll> &d) {
    const int V = G.size();
    d = vector<ll>(V, LLINF);
    d[s] = 0;
    bool update = true;
    int i = 0;
    while (update)
    {
        update = false;
        for (int j = 0; j < V; j++)
        {
            for (edge e : G[j])
            {
                if (d[j] != -LLINF && d[j] != LLINF && d[j] + e.cost < d[e.to]) {
                    d[e.to] = d[j] + e.cost;
                    if (i == V - 1) {
                        d[e.to] = -LLINF;
                    }
                    update = true;
                }
                else if (d[j] == -LLINF && d[e.to] != -LLINF) {
                    d[e.to] = -LLINF;
                    update = true;
                }
            }
        }
        if (i < V - 1) i++;
    }
}

int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<vector<edge>> G(n);
    vector<ll> dist(n);
    REP(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--; c -= p;
        c *= -1;
        G[a].push_back({b,c});
    }
    bellman_ford(0, n - 1, G, dist);
    if (dist[n - 1] == -LLINF) cout << -1 << endl;
    else cout << max(0LL, -dist[n - 1]) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;

ll binpow(ll a, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) {
			(res *= a) %= mod;
		}
		p >>= 1;
		(a *= a) %= mod;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (auto& i : a) {
		cin >> i;
	}
	sort(a.begin(), a.end());
	ll res = a[0];
	ll inf = 1e18;
	for (int i = 1; i < n; i++) {
		if (inf / a[i] < res) {
			cout << -1 << endl;
			return 0;
		}
		res *= a[i];
		if (res > inf) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll x, y;
	cin >> x >> y;

	for (ll i = 0; i < 100; i++) {
		for (ll j = 0; j < 100; j++) {
			if (i + j == x && 2 * i + 4 * j == y) {
				Yes();
				return 0;
			}
		}
	}
	No();
}

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

int main()
{
    int n, m;
    int l = 0;
    int r = 1e9;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        l = max(l, a);
        r = min(r, b);
    }

    int ans = r - l + 1;
    if (l <= r) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 505
int a[N][N],K,n;
int main()
{
	scanf("%d",&K);
	if(K<=500)
	{
		printf("%d\n",K);
		for(int i=1;i<=K;i++,puts(""))
			for(int j=1;j<=K;j++)
				printf("%d ",i);
		return 0;
	}else if(!(K&3))
	{
		n=K>>1;
		printf("%d\n",n);
		for(int i=1;i<=n;i++,puts(""))
			for(int j=1;j<=n;j++)
				printf("%d ",(j&1)?(i):(i+n));
		return 0;
	}else
	{
		n=((K+3)>>2)<<1;
		printf("%d\n",n);
		for(int i=1;i<=n;i++,puts(""))
			for(int j=1;j<=n;j++)
			{
				int x=(i+j)%n+((i&1)?0:n);
				printf("%d ",(x>=K?x-n:x)+1);
			}
	}
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int64_t u;
  int64_t sum = 0;
  int A[200010];
  cin >> N;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  if (N == 1){
    cout<<sum<<endl;
  }
  else{
  for(int i=0 ; i < N-1 ; i++){
    int s =i+1;
    //cout<<A[i]<<A[s]<<endl;
  if(A[i] > A[s]){
    u = A[i] - A[s];
    A[s] = A[i] ;
    sum += u;
    //cout << u <<endl;
   }
                 }
  cout << sum << endl;
  }
}


Measured memory_bytes: 4396
#include<iostream>
#include<vector>

int main(void){
  int N;
  std::vector<int> B;
  int sum=0;
  std::cin>>N;
  for(size_t i=0; i<N-1; i++){
    int tmp;
    std::cin >> tmp;
    B.push_back(tmp);
  }
  sum+=B[0];
  for(size_t i=1; i<N-1; i++){
    sum += (B[i]>B[i-1]) ? B[i-1] : B[i]; 
  }
  sum += B[N-2];
  std::cout<<sum;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc137/tasks/abc137_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 [X-K+1,X+K-1]の範囲
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll K,X;cin >> K >> X;
    res = vector<ll>(2*K-1);
    iota(res.begin(),res.end(),X-K+1);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
if n==1:
    print(0)
    quit()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
tmp=factorization(n)
# print(tmp)
lst=list(accumulate(range(1,1000)))
# print(lst)
ans=0
for i in range(len(tmp)):
    so,num=tmp[i]
    ans+=bisect.bisect_right(lst,num)
    # print(so,num)
print(ans)

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

class Student {
public:
    int id;
    int score;
    Student() {}
    Student(int id, int score) :id(id), score(score) {}
    bool operator<(const Student& rhs) const {return score != rhs.score ? score < rhs.score : id < rhs.id;}
};

class Range {
public:
    int left, right;
    Range(int left, int right) :left(left), right(right) {}
};

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

    vector<int> score(N);
    for(auto& s: score) cin >> s;

    vector<Student> student(N);
    for(int i = 0; i < N; ++i) {
        student[i].id = i;
        student[i].score = score[i];
    }
    sort(student.begin(), student.end());

    vector<int> rank(N);
    for(int i = 0; i < N; ++i) rank[student[i].id] = i;

    vector<Student> leader;
    for(int i = 0; i < Q; ++i) {
        string process;
        int x;
        cin >> process >> x;
        if(process == "ADD") {
            Student s(x - 1, score[x - 1]);
            leader.insert(upper_bound(leader.begin(), leader.end(), s), s);
        } else if(process == "REMOVE") {
            leader.erase(lower_bound(leader.begin(), leader.end(), Student(x - 1, score[x - 1])));
        } else {
            if(N - leader.size() <= x) cout << 0 << endl;
            else if(leader.empty()) cout << "NA" << endl;
            else if(N - 1 - (upper_bound(student.begin(), student.end(), Student(1000000, leader.back().score)) - student.begin() - 1) > x) cout << "NA" << endl;
            else {
                int low = -1;
                int high = 1000000000;
                while(high - low > 1) {
                    int r = (low + high) / 2;
                    vector<Range> cover;
                    for(int i = 0; i < leader.size(); ++i) {
                        Student s(-1, leader[i].score - r);
                        int left = lower_bound(student.begin(), student.end(), s) - student.begin();
                        s = Student(1000000, leader[i].score);
                        int right = lower_bound(student.begin(), student.end(), s) - student.begin() - 1;
                        cover.push_back(Range(left, right));
                    }
                    int out = cover.front().left - 0;
                    for(int i = 0; i < cover.size() - 1; ++i) {
                        if(cover[i + 1].left - cover[i].right - 1 < 0) continue;
                        out += cover[i + 1].left - cover[i].right - 1;
                    }
                    out += N - 1 - cover.back().right;
                    if(out <= x) high = r;
                    else low = r;
                }
                cout << high << endl;
            }
        }
    }
}

Measured memory_bytes: 16828
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=25005,maxm=3000005,inf=1000000;
struct edge{
  int to,next,w;
}lst[maxm];int len=0,first[maxn],_first[maxn];
void addedge(int a,int b,int w){
  lst[len].to=b;lst[len].next=first[a];lst[len].w=w;first[a]=len++;
  lst[len].to=a;lst[len].next=first[b];lst[len].w=0;first[b]=len++;
}
int q[maxn],head,tail,s,t,dis[maxn],vis[maxn],T;
bool bfs(){
  head=tail=0;vis[s]=++T;dis[s]=1;q[tail++]=s;
  while(head!=tail){
    int x=q[head++];
    for(int pt=first[x];pt!=-1;pt=lst[pt].next){
      if(lst[pt].w&&vis[lst[pt].to]!=T){
	vis[lst[pt].to]=T;dis[lst[pt].to]=dis[x]+1;q[tail++]=lst[pt].to;
      }
    }
  }
  if(vis[t]==T)memcpy(_first,first,sizeof(first));
  return vis[t]==T;
}
int dfs(int x,int lim){
  if(x==t)return lim;
  int flow=0,a;
  for(int pt=_first[x];pt!=-1;pt=lst[pt].next){
    _first[x]=pt;
    if(lst[pt].w&&dis[lst[pt].to]==dis[x]+1&&(a=dfs(lst[pt].to,min(lst[pt].w,lim-flow)))){
      lst[pt].w-=a;lst[pt^1].w+=a;flow+=a;
      if(flow==lim)return flow;
    }
  }
  return flow;
}
int dinic(){
  int ans=0,x;
  while(bfs())while(x=dfs(s,inf))ans+=x;
  return ans;
}
int n,m;
char pond[105][105];
int main(){
  memset(first,-1,sizeof(first));
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;++i)scanf("%s",pond[i]+1);
  int sx,sy,tx,ty;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=m;++j){
      if(pond[i][j]=='S')sx=i,sy=j;
      if(pond[i][j]=='T')tx=i,ty=j;
      if(pond[i][j]!='.'){
	addedge((i-1)*m+j,n*m+(i-1)*m+j,1);
	addedge((i-1)*m+j+n*m,2*n*m+i,inf);
	addedge(2*n*m+i,(i-1)*m+j,inf);
	addedge((i-1)*m+j+n*m,2*n*m+n+j,inf);
	addedge(2*n*m+n+j,(i-1)*m+j,inf);
      }
    }
  }
  if(sx==tx||sy==ty)printf("-1\n");
  else{
    s=(sx-1)*m+sy+n*m;t=(tx-1)*m+ty;
    printf("%d\n",dinic());
  }
  return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DZabuton {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<P> vec(n);
      rep(i, n) {
        cin >> vec[i].first >> vec[i].second;
      }
      sort(all(vec), [](P a, P b){ return a.first+a.second < b.first+b.second; });
      vector<vector<ll>> dp(n+1, vector<ll>(n+1, LLONG_MAX/2));
      dp[0][0] = 0;
      rep(i, n) {
        for(int j=0; j<=n; j++) {
          chmin(dp[i+1][j], dp[i][j]);
          if (j+1 <= n && vec[i].first >= dp[i][j]) {
            chmin(dp[i+1][j+1], dp[i][j] + vec[i].second);
          }
        }
      }

      int ret = 0;
      for(int i=1; i<=n; i++) {
        if (dp[n][i] != LLONG_MAX/2) {
          ret = i;
        }
      }
      cout << ret << endl;


    }
};

signed main() {
  DZabuton solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main(){
  int n,ans=0,w,m=1e10;
  cin >> n;
  rep(i,n) {
    cin >> w;
    m=min(w,m);
    if(m>=w)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
#define pu(n) cout << n;
#define mod 1000000007
int i,j,k,l;
static const int MAX_N=10e5;

int main(void){
	int a,b;cin >> a >> b;
	int ans=0,take=1;
	while(1){
		if(take>=b)break;
		take--;
		ans++;
		take+=a;
	}puts(ans);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int m = sc.nextInt();
                int k = sc.nextInt();
                boolean ebishu = true;
                for(int i = 0 ; i <= n && ebishu ; i++){
                        for(int j = 0 ; j <= m && ebishu ; j++){
                                if(i * j + (n - i) * (m - j) == k){
                                        ebishu = false;
                                }
                        }
                }
                if(ebishu){
                        System.out.println("No");
                }else{
                        System.out.println("Yes");
                }
        }
}
//変に考えずに全探索でよかった

Measured memory_bytes: 35656
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = copy.deepcopy(a)
b.sort()
firint = b[-1]
secint = b[-2]

for i in a:
    if i == firint:
        print(secint)
    else:
        print(firint)


Measured memory_bytes: 97112
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=100010;
const int c=2147483647;
int a[maxn],b[maxn],n,k;
ll ans=0;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	ans=0;
	for(int i=1;i<=n;i++)
		if((a[i]|k)<=k) ans+=b[i];
	for(int t=31;t>=1;t--)
		if((k>>t)&1)
		{
			ll cnt=0;
			for(int i=1;i<=n;i++)
			{
				//cout<<"%%%:"<<a[i]<<' '<<(a[i]&(c-(1<<t)+1)|k)<<endl;
				if((((a[i]>>t)&1)==0)&&((a[i]&(c-(1<<t)+1)|k)<=k)) cnt+=b[i];
			}
			//cout<<"!:"<<t<<' '<<cnt<<endl;	
			ans=max(cnt,ans);			
		}
	printf("%lld",ans);	
	return 0;
}

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

int main() {
    vector<vector<int>> vec(3, vector<int>(3));
    int n;
    rep(i,3) rep(j,3) cin >> vec.at(i).at(j);
    cin >> n;
    rep(i,n) {
        int b;
        cin >> b;
        rep(j,3) rep(k,3) {
            if(vec.at(j).at(k) == b) vec.at(j).at(k) = 0;
        }
    }
    bool ans = false;
    rep(i,3) {
        if(vec.at(i).at(0) == 0 && vec.at(i).at(1) == 0 && vec.at(i).at(2) == 0) {
            ans = true;            
        }
    }
    rep(j,3) {
        if(vec.at(0).at(j) == 0&&vec.at(1).at(j)==0&&vec.at(2).at(j)==0) {
            ans = true;
        }
    }
    if(vec.at(0).at(0)==0 && vec.at(1).at(1)==0 && vec.at(2).at(2) == 0) {
        ans = true;
    }
    if(vec.at(0).at(2)==0 && vec.at(1).at(1) == 0 && vec.at(2).at(0) == 0) {
        ans = true;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
! AtCoder Beginner Contest 119 A
! [URL]      https://atcoder.jp/contests/abc119/tasks/abc119_a
! [compiler] fortran (gfortran v4.8.4)
! 
module ABC119

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public :: ABC119_A


	! constants for this <module>
	character(len=10, kind=1), parameter, private :: word_border = '2019/04/30'
	character(len= 6, kind=1), parameter, private :: word_before = 'Heisei'
	character(len= 3, kind=1), parameter, private :: word_after  = 'TBD'


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC119_A

		! variables for this <subroutine>
		character( len=10, kind=1 ) :: buffer

		! STEP.01
		! read out the the date
		read( unit=INPUT_UNIT, fmt='(A)' ) buffer

		! STEP.02
		! output the result
		if( lle(string_a=buffer, string_b=word_border) ) then
			write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) word_before
		else
			write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) word_after
		end if

		! STEP.END
		return

	end subroutine ABC119_A

end module ABC119


program main

	! <module>s to import
	use, non_intrinsic :: ABC119

	! require all variables to be explicitly declared
	implicit none

	call ABC119_A

end program main


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;

int main() {
    ll h, w;
    cin >> h >> w;
    vector<vector<bool>> m(h, vector<bool>(w, false)); // true -> white , black -> false
    for (ll i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (ll j = 0; j < w; ++j) {
            if (s[j] == '.') {
                m[i][j] = true;
            }
        }
    }
    vector<vector<ll>> dp(h, vector<ll>(w, -10));
    dp[0][0] = 0;
    if (m[0][0] == false) dp[0][0] = 1;
    ll cur = dp[0][0];
    while(dp[h-1][w-1] < 0) {

/*         for (ll i = 0; i < h; ++i) {
            for (ll j = 0; j < w; ++j) {
                cerr << dp[i][j];
            }
            cerr << endl;
        }
 */
        for (ll i = 0; i < h; ++i) {
            for (ll j = 0; j < w; ++ j) {
                if (dp[i][j] > 0) continue;
                if (i > 0 && m[i-1][j] == m[i][j] && dp[i-1][j] == cur) {
                    dp[i][j] = cur;
                }
                if (j > 0 && m[i][j-1] == m[i][j] && dp[i][j-1] == cur) {
                    dp[i][j] = cur;
                }
                if (i > 0 && m[i-1][j] != m[i][j] && dp[i-1][j] == cur-1) {
                    dp[i][j] = cur;
                }
                if (j > 0 && m[i][j-1] != m[i][j] && dp[i][j-1] == cur-1) {
                    dp[i][j] = cur;
                }
            }
        }
        ++cur;
    }

/*         for (ll i = 0; i < h; ++i) {
            for (ll j = 0; j < w; ++j) {
                cerr << dp[i][j];
            }
            cerr << endl;
        }
 */
    auto res = dp[h-1][w-1];
    res = (res / 2) + (res % 2);
    cout << res << endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <vector>

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

    int count = 0;
    std::vector<long long> b(n);
    long long sum = 0;
    for(int i = 0; i < n; ++i){
        long long val;
        std::cin >> val;
        b.at(i) = std::abs(val);
        if(val < 0){
            ++count;
        }
    }

    long long ans = std::accumulate(b.begin(), b.end(), 0ll);
    if(0 != count % 2){
        ans -= 2 * *std::min_element(b.begin(), b.end());
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
  int i, j, a, b, q;
  string str, command, tmpstr, repstr;
  cin >> str >> q;
  for (i = 0; i < q; i++){
    cin >> command >> a >> b;
    if (command == "print") {
      cout << str.substr(a, b - a + 1) << endl;
    }
    else if (command == "reverse") {
      string tmpstr(b - a + 1, 0);
      for (j = 0; j < b - a + 1; j++) {
        tmpstr[j] = str[b - j];
      }
      str.replace(a, b - a + 1, tmpstr);
    }
    else if (command == "replace") {
      cin >> repstr;
      str.replace(a, b - a + 1, repstr);
    }
  }
}

Measured memory_bytes: 1224
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()

	frontnum := 1
	breaknum := 0
	for i := 0; i < n; i++ {
		tmp := nextInt()
		if tmp == frontnum {
			frontnum++
		} else {
			breaknum++
			if breaknum == n {
				fmt.Println("-1")
				return
			}
		}
	}

	fmt.Println(breaknum)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

const long long INF = 3LL << 60;

long long memo[100005][3];

long long A[100005];
char op[100005];

int N;

long long dp(int i, int j){
    if(i == N){
        return 0;
    }else if(memo[i][j] != -INF){
        return memo[i][j];
    }else if(op[i] == '+'){
        if(j == 0){
            return memo[i][j] = A[i] + dp(i+1, 0);
        }else if(j == 1){
            return memo[i][j] = -A[i] + max(dp(i+1, 1), dp(i+1, 0));
        }else if(j == 2){
            return memo[i][j] = A[i] + max(dp(i+1, 2), dp(i+1, 1));
        }
    }else if(op[i] == '-'){
        if(j == 0){
            return memo[i][j] = max(-A[i] + dp(i+1, 1), -A[i]+dp(i+1, 0));
        }else if(j == 1){
            return memo[i][j] = max(max(A[i] + dp(i+1, 1), A[i]+dp(i+1, 2)), A[i]+dp(i+1, 0));
        }else if(j == 2){
            return memo[i][j] = max(-A[i] + dp(i+1, 1), -A[i]+dp(i+1, 2));
        }
    }
}

int main(){
    scanf("%d", &N);

    scanf("%d", &A[0]);
    op[0] = '+';
    for(int i = 1; i < N; i ++){
        scanf(" %c %d", &op[i], &A[i]);
    }

    for(int i = 0; i <= N; i ++){
        for(int j = 0; j < 3; j ++){
            memo[i][j] = -INF;
        }
    }

    /*for(int i = 0; i <= N; i ++){
        for(int j = 0; j < 3; j ++){
            printf("memo[%d][%d] = %lld\n", i, j, dp(i, j));
        }
    }*/

    printf("%lld", dp(0, 0));
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long n, m, a = 1, b = 1, e = 0;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << '0' << endl;
	}
	else {
		for (int h = 1; h <= n; h++) {
			a = a * h % 1000000007;
		}
		for (int h = 1; h <= m; h++) {
			b = b * h % 1000000007;
		}
		if (abs(n - m) == 1) {
			cout << a * b % 1000000007 << endl;
		}
		else {
			cout << a * b * 2 % 1000000007 << endl;
		}
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define v(x) vector<x>
#define pb push_back 
#define mp make_pair
#define maxint 1e18
#define mint -1e18
/*
(͡ ° ͜ʖ ͡ °): Hi, be careful of overflow.
*/
int S;
const int mod = 1e9+7;
ll dp[2005];
int solve(int sum){
	if(sum > S)return 0;
	if(sum == S)return 1;
	if(dp[sum]!=-1)return dp[sum];
	ll res = 0;
	for(int i=3;sum+i<=S;i++){
		res += solve(sum+i)%mod;
		res%=mod;
	}
	return dp[sum] = res%mod;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>S;
	cout<< solve(0)%mod<<'\n';
	return 0;
}

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

int arr[100];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int i = 0; i < n; i++)
    {
        int key = arr[i];
        int j = i - 1;
        while (arr[j] > key && j >= 0)
        {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = key;
        for (int k = 0; k < n - 1; k++)
            cout << arr[k] << ' ';
        cout << arr[n-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    ll vt = 1;
    ll va = 1;
    for (int i = 0; i < N; i++) {
        int t, a;
        cin >> t >> a;
        ll ma = va % a == 0 ? va / a : va / a + 1;
        ll mt = vt % t == 0 ? vt / t : vt / t + 1;
        ll m = max(mt, ma);
        vt = m * t;
        va = m * a;
    }
    cout << vt + va << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

string s;

int main() {

 // freopen("input.in","r",stdin);
//  freopen("output.out","w",stdout);

  cin>>s;
  rep(i,s.size()) {
    if(s[i] == '?') s[i]='D';
  }
  cout<<s;
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){

	int N;
	cin>>N;
	
	vector<double> A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	
	sort(A.begin(),A.end());
	
	double ans = (A[0]+A[1])/2.0;
	
	for(int i=2;i<N;i++){
		ans = (ans + A[i])/2.0;
	}
	
	cout<<fixed<<setprecision(20)<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

    void solve(){

	Scanner sc = new Scanner( System.in );
	int n = sc.nextInt();
	double x = sc.nextDouble();

	double max_slope = 0.0;
	for ( int i=0; i<n; ++i ) {

	    double xi = sc.nextDouble();
	    double hi = sc.nextDouble();
	    double slope = hi/xi;
	    
	    if ( slope > max_slope ) max_slope = slope;
	}

	//	System.out.println( x*max_slope );
	System.out.printf( "%f", x*max_slope );
    }

    public static void main( String[] a ) {new Main().solve(); }
}



Measured memory_bytes: 40892
N,K=map(int,input().split())
h=list(map(int,input().split()))

dp=[[float("inf") for j in range(N+1)] for k in range(N)]

for j in range(N):
    dp[j][1]=h[j]
    dp[j][0]=0

for i in range(1,N):
    for j in range(2,N+1):
        dp[i][j]=min(dp[k][j-1]+(h[i]-h[k])*(h[i]>=h[k]) for k in range(i))

test1=min(dp[i][N-K] for i in range(N))
print(test1)


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

int main(){
  int i,a,j,k,b,m,c,d=0,e;
  cin>>a>>b>>c;
  for(i=1;i<=a;i++){
    e=i;
    m=0;
    while(e){
      m+=e%10;
       e/=10;
    }
    if(m<=c&&m>=b){
      d+=i;
    }
  }
  cout<<d<<endl;
}

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

int main(){
	int A, B, X;
	cin >> A >> B >> X;
	if (A <= X && X <= A + B) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int mod=1e9+7;

int dp[101][4][4][4];

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

    dp[0][3][3][3] = 1;

    for(int len = 0; len < n; len++)
    {
        for(int c1 = 0; c1 < 4; c1++)
        {
            for(int c2 = 0; c2 < 4; c2++)
            {
                for(int c3 = 0; c3 < 4; c3++)
                {
                    if(dp[len][c1][c2][c3] == 0) continue;

                    for(int a = 0; a < 4; a++)
                    {
                        if(a==2 && c1==1 && c2==0) continue;
                        if(a==2 && c1==0 && c2==1) continue;
                        if(a==1 && c1==2 && c2==0) continue;
                        if(a==2 && c1==1 && c3==0) continue;
                        if(a==2 && c2==1 && c3==0) continue;

                        dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len+1][a][c1][c2] %= mod;
                    }
                     
                }
            }
        }
    }
    
    int ans =0;

    for(int c1 = 0; c1 < 4; c1++)
    {
        for(int c2 = 0; c2 < 4; c2++)
        {
            for(int c3 = 0; c3 < 4; c3++)
            {
                ans += dp[n][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;

}

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

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.bigin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    int Max = 1, Min = n;
    Srep(m){
        int l,r;
        cin >> l >> r;
        Max = max(l,Max);
        Min = min(r,Min);
    }
  	if(Min - Max < 0) ans = 0;
  	else ans = Min - Max + 1;
    cout << ans << endl;
}


Measured memory_bytes: 3548
#include <iostream>
#include <cstring>
using namespace std;
int mp[2][20010];
int n;

int solve(int goal){
  int x=0,f=1,cost=0,y=0;
  while(x!=goal+1) {
    if(f&&mp[0][x])f=0,cost++,y=mp[0][x]=0;
    else if(f&&mp[1][x])cost++,f=y=0;
    else if(mp[1][x]) cost++,y=1,mp[1][x]=0;
    else if(mp[0][x]) cost++,y=mp[0][x]=0;
    else cost++,x++;
  }
  if(y==1)cost++;
  return cost-1;
}

int main(){
  int q;
  cin>> q;
  while(q--){
    cin>>n;
    memset(mp,0,sizeof(mp));
    int pos,cnt;
    for(int i=0;i<2;i++){
      pos=0,cnt=1;
      char a;
      for(int j=0;j<2*n;j++){
	cin>> a;
	if(a=='Y') a=1;
	else a=0;
	mp[i][pos] |= a;
	cnt++;
	if(cnt==2)pos++,cnt=0;
      }
    }
    //     for(int i=0;i<2;i++){for(int j=0;j<=pos;j++) cout << mp[i][j]<<" ";cout <<endl;}
    cout<<solve(pos)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

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

    ll ret = 1;
    ll fin_count = 0;
    ll calc_count = 0;
    for (int i = 2 * n - 1; i >= 0; i--) {
        if ((i % 2 == 0) == (s[i] == 'W'))fin_count++;
        else {
            ret *= fin_count;
            ret %= mod;
            fin_count--;
            calc_count++;
        }
    }

    for (ll i = 1; i <= n; i++) {
        ret *= i;
        ret %= mod;
    }
    cout << (calc_count == n ? ret : 0) << endl;
    return 0;
}

Measured memory_bytes: 640
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
MO = 10**9+7
SA = [0]*N
SA[N-1] = A[N-1]
for i in reversed(range(1, N)):
    SA[i-1] = SA[i]+A[i-1]

for i in range(N-1):
    ans += A[i]*SA[i+1]%MO

print(ans%MO)


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

string S, T;

int main()
{
    cin >> T;

    for(int i = 0; i < T.size(); i++)
    {
        if(i != T.size() && T[i] == 'B' && T[i + 1] =='C')
        {
            S.push_back('D');
            i++;
        }
        else S.push_back(T[i]);
    }

    long long ans = 0, cnt = 0, num = 0, pre = 0;
    for(int i = 0; i <= S.size(); i++)
    {
        if(i == (int)(S.size()) || S[i] == 'B' || S[i] == 'C')
        {
            ans += num;
            pre = i + 1;
            cnt = 0;
            num = 0;
        }
        else
        {
            if(S[i] == 'D')
            {
                num += i - pre - cnt;
                cnt++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,k,ans=0;
void Main(){
    cin>>n;
    if(n%2){
        cout<<0<<endl;
        return;
    }
    else{
        n/=2;
        while(n){
            ans+=n/5;
            n/=5;
        }
        cout<<ans<<endl;
    }
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256