akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define N 100005

int a[N], b[N], c[N];
int dpa[N], dpb[N], dpc[N];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for (int i = 1; i < n; i++)
    {
        dpa[i] = max(dpb[i - 1], dpc[i - 1]) + a[i];
        dpb[i] = max(dpa[i - 1], dpc[i - 1]) + b[i];
        dpc[i] = max(dpa[i - 1], dpb[i - 1]) + c[i];
    }
    cout << max(dpa[n - 1], max(dpb[n - 1], dpc[n - 1])) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct boundary {
    ll a;
    ll b;

    bool operator<(const boundary& other) const {
        if (a < other.a) return true;
        else return false;
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<ll, ll> > AB(N);
    vector<pair<ll, ll>> As(N), Bs(N);
    ll v_min = 1e9, v_max = 0;
    REP(i, N) {
        ll a, b;
        cin >> a >> b;
        As[i].first = a;
        As[i].second = i;
        Bs[i].first = b;
        Bs[i].second = i;
    }
    sort(ALL(As));
    sort(ALL(Bs));
    ll ans = 0;
    if(N%2 == 1) {
        ans = Bs[(N-1)/2].first - As[(N-1)/2].first + 1;
    } else {
        ans = (Bs[(N)/2].first + Bs[(N-2)/2].first - As[(N)/2].first -  As[(N-2)/2].first) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12680
s = input().rstrip()

table = [0] * len(s)

start = 0
pre = 'R'
for i in range(1, len(s)):
    if pre != s[i]:
        if pre == 'R':
            for j in range(start, i):
                if (i - j) % 2 == 0:
                    table[i] += 1
                else:
                    table[i-1] += 1
        else:
            for j in range(start, i):
                if (i - j) % 2 == 0:
                    table[start-1] += 1
                else:
                    table[start] += 1

        pre = s[i]
        start = i

for j in range(start, len(s)):
    if (len(s) - j) % 2 == 0:
        table[start - 1] += 1
    else:
        table[start] += 1

print(*table)

Measured memory_bytes: 49660
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi dp(N + MGN, INF);
    // dp[i] : Number of steps to pay i
    dp[0] = 0; 
    dp[1] = 1;
    // dp[i] = min(dp[i-1]+1, dp[i-6]+1, dp[i-6^2]+1, ... dp[i-9]+1, dp[i-9^2]+1, ...)

    FOR(i,1,N+1) {
        dp[i] = dp[i - 1] + 1;
        int pw = 6;
        while(pw <= i) {
            dp[i] = min(dp[i], dp[i - pw] + 1);
            pw *= 6;
        }
        pw = 9;
        while(pw <= i) {
            dp[i] = min(dp[i], dp[i - pw] + 1);
            pw *= 9;
        }
    }

    int ans = dp[N];
    cout << ans << endl;

    return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}
bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

int main() {
  const int M = 1000000;
  auto ps = PrimeSieve(M);

  loop {
    int n; cin >> n;
    if (!n) break;
    int sum  = 0;
    for (int i = 2; n && i < M; ++i) {
      if (ps[i]) {
        sum += i;
        --n;
      }
    }
    cout << sum << endl;
  }

  return 0;
}

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

 
int main() {
  vector<char> a(3);
  int f=0;
  for(int i=0;i<3;i++){
    cin >> a.at(i);
    if(a.at(i)=='7'){
      f=1;
    }
    //cout << f << endl;
  }
  
  if(f==0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
}


Measured memory_bytes: 3620
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (input) {
    //??\????????????????????????????????????
    var inputArray = input.split(' ');
    //??\?????????????????°????????????
    var num = inputArray.map(function(x){
        return parseInt(x);
    });
    console.log(num.sort()[0],num.sort()[1],num.sort()[2]);
});

Measured memory_bytes: 15640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    reslut = 'No'
    for i in range(N // 4 + 1):
        for j in range(N // 7 + 1):
            if N == i * 4 + j * 7:
                reslut = 'Yes'
    print(reslut)


if __name__ == "__main__":
    main()


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

int main(){

    int n; cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<long long> b(n, 0);
    b[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = b[i - 1] + a[i];
    }

    /*for(int i = 0; i < n; i++){
        cout << a[i] << " " << b[i] << endl;
    }*/
    int ans = 0;
    for(int i = 1; i < n; i++){
        if(2*b[i - 1] < a[i]) ans = i;
    }

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

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;
import static java.awt.geom.Line2D.*;

public class Main {
    public static void main(String args[])throws Exception{
        Scanner cin= new Scanner(System.in);
		
		while(cin.hasNextDouble()){
			double in[] = new double[8];
			for(int i=0;i<8;i++) in[i]= cin.nextDouble();
			int t1,t2,t3;
			t1= relativeCCW(in[0],in[1],in[2],in[3],in[6],in[7]);
			t2= relativeCCW(in[2],in[3],in[4],in[5],in[6],in[7]);
			t3= java.awt.geom.Line2D.relativeCCW(in[4],in[5],in[0],in[1],in[6],in[7]);
			if((t1==1 && t2==1 && t3==1) || (t1==-1 && t2==-1 && t3==-1)) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int dp[222222];
int p[11][11];

int func(int d, int x, int n){
	REP(i, 222222)dp[i] = 0;
	REP(i, 111111){
		REP(j, n){
			dp[i + p[d][j]] = max(dp[i + p[d][j]], dp[i] + p[d+1][j]);
		}
	}

	ll ret = 0;
	REP(i, x + 1)ret = max(ret, dp[i] + (x - i));
	return ret;
}

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

	int n, d, x;cin >> n >> d >> x;
	REP(i, d)REP(j, n)cin >> p[i][j];

	REP(i, d - 1)x = func(i, x, n);

	cout << x << endl;

	return 0;
}



Measured memory_bytes: 4068
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
		return positive ? x : -x;
}
long long ans,n,sum[200005];
int main(){
	n=read(); ans=200000000000000;
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+read();
	for(int i=1;i<n;i++)ans=min(ans,abs(sum[n]-sum[i]-sum[i])); 
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false)

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

int main()
{   
    fast;
    lli n; cin>>n;
    lli x; cin>>x;
    lli t; cin>>t;
    lli g = abs(x-t);
    for(int i=0;i<n-1;i++)
    {
        cin>>t; g = gcd(abs(t-x),g);
    }
    cout<<g<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	string s;
	cin >> s;
	char c, prev_c='E';
	int cnt=0;
	for(char& c  : s){
		if(c != prev_c){
			if(prev_c != 'E') cnt++;
			prev_c = c;
		}
	}
	cout << cnt << '\n';
	
	return 0;
}


Measured memory_bytes: 512
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j;
	int X, Y, Z;

	cin >> X >> Y >> Z;
	int total = Z;
	int count = 0;

	while (total < X) {
		total += Y + Z;
		if (X >= total) {
			++count;
		}

	}

	cout << count << endl;


}

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

int main(){
	string S;
	long long K;
	cin>>S>>K;
	int ans = 0;
	for(char s:S){
		int x = s-'0';
		if(x > 1){
			ans = x;
			break;
		}
		else{
			K--;
			if(K<=0){
				ans = x;
				break;
			}
		}
	}
	cout<< ans <<endl;
}

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

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

    if(a > 0 && b > 0){
        cout << "Positive" << endl;
    }else if(a < 0 && b < 0){
        if((a + b) % 2 == 0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }else if(a < 0 && b > 0){
        cout << "Zero" << endl;
    }
}

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

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> is(26);
    rep(i, n) is[s[i]-'a'].insert(i);
    rep(qi, q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            is[s[i]-'a'].erase(i);
            s[i] = c;
            is[s[i]-'a'].insert(i);
        }else {
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            rep(i, 26) {
                auto it = is[i].lower_bound(l);
                if (it != is[i].end() && *it < r) ans++;
            }
            printf("%d\n", ans);
        }
    }

    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    ll ans=1900*m+100*(n-m);
    ans*=1<<m;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if((b-a)==(c-b)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 55
#define LL long long 
using namespace std;
LL C[maxn][maxn],ans;
int n,P,p,q;
int main(){
	cin>>n>>P;
	int x;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(x%2==0) q++;
		else p++;
	}
	C[1][0] = C[1][1] = 1;
	for (int i = 2; i <=n; i++){
		C[i][0] = 1;
		for (int j = 1; j <=n; j++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]);
	}
	ans=0;
	LL tem=1;
	tem<<=q;
	if(P==0){
		for(int i=0;i<=p;i+=2){
			ans+=C[p][i];
		}
		if(ans==0) ans=1;
		ans*=(tem);
	}
	else{
		for(int i=1;i<=p;i+=2){
			ans+=C[p][i];
		}
		ans*=tem;
	}
	cout<<ans;
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


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

int main() {
    int N; cin >> N;
    vector<pair<int, int> > V;
    rep(i, N){
        int a; cin >> a;
        V.emplace_back(a, i+1);
    }
    sort(V.begin(), V.end());
    rep(i, N){
        cout << V[i].second << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
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(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#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 smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------
const ll MAX_N = 2 * limit;
ll fact[MAX_N];
ll fact_inv[MAX_N];

ll bin_pow_mod(ll x, ll y) { //x^y mod
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % MOD;
        x = (x * x) % MOD;
        y /= 2;
    }
    return prod % MOD;
}

void init_fact() {
    fact[0] = fact_inv[0] = 1;

    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
    }
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    h--, w--;
    init_fact();
    ll ans = 0;

    rep(i, h - a + 1) {
        ll p = fact[b - 1 + i] * fact_inv[b - 1] % MOD * fact_inv[i] % MOD;
        ll q = fact[w + h - b - i] * fact_inv[w - b] % MOD * fact_inv[h - i] % MOD;
        ans += p * q % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
N, A, B = [int(_) for _ in input().split()]
H = [int(input()) for _ in range(N)]


def enough(x):
    return sum([1 + (max(h - B * x, 0) - 1) // (A - B) for h in H]) <= x


ng = 0
ok = 1 + (max(H) - 1) // B

while ok - ng > 1:
    half = (ok + ng) // 2
    if enough(half):
        ok = half
    else:
        ng = half
print(ok)

# https://img.atcoder.jp/arc075/editorial.pdf


Measured memory_bytes: 11060
#include<bits/stdc++.h>
#define int long long int
#define inf 1000000000000
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    set <int> mp;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        mp.insert(x);
    }
    if(mp.size()==n)
        cout<<"YES";
    else
        cout<<"NO";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (i % 2 == 0) {
			if (A % 2 == 1) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  if(A==1)
    A+=13;
  if(B==1)
    B+=13;
  if(A<B)
    cout<<"Bob"<<endl;
  else if(B<A)
    cout<<"Alice"<<endl;
  else
    cout<<"Draw"<<endl;
  
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.io.StdIn

object Main extends App {
  val N = StdIn.readInt()
  val cards = StdIn.readLine().split(" ").map(_.toInt)

  val sortedCards = cards.sorted.reverse

  @tailrec
  def rec(cards: List[Int], index: Int = 0, accum: (Int, Int) = (0, 0)): (Int, Int) = cards match {
    case Nil => accum
    case head::tail if index % 2 == 0 => rec(tail, index + 1, (accum._1 + head, accum._2))
    case head::tail => rec(tail, index + 1, (accum._1, accum._2 + head))
  }

  val points = rec(sortedCards.toList)
  println(points._1 - points._2)
}


Measured memory_bytes: 25408
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
  intll n , k ;
  cin >> n >> k ;
  int ans = 0;
  intll now = 0;
  vector<pair<int,intll>> d;
  rep(i,n){
    int a , b ;
    cin >> a >> b ;
    d.push_back(make_pair(a,b));
  }
  sort(all(d));
  int i =0;
  
  while(now<k){
    ans = d.at(i).first;
    now += d.at(i).second;
    i++;
  }
  
  cout <<ans ;
    
  
}


Measured memory_bytes: 2420
// Starting with the name of Allah

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

int main()
{
	int n,k;
	cin>>n;
	k=n%10;
	if(k==1 || k==6 || k==0 || k==8){
		cout<<"pon";
	}
	else if(k==3){
		cout<<"bon";
	}
	else{
		cout<<"hon";
	}
	return 0;
}


Measured memory_bytes: 3568
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    string s,t;
    cin>>s;
    int n=0;
    for(auto i:s){
        if (i=='-')n--;
        if (i=='+')n++;
    }
    cout<<n;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

struct mission{int l,r,x;};

int main(void){
	ll n,m;cin>>n>>m;
	vector<mission> M;
	rep(i,m){
		int l,r,x;
		cin>>l>>r>>x;
		M.push_back({l,r,x});
	}
	//dp[t][i][j] t個目の要素まで考慮して, 遠い終端がi, 近い終端がj
	vector<vector<vector<ll>>> dp;
	rep(t, 2){
		dp.push_back(vector<vector<ll>>());
		rep(i, n+2){
			dp[t].push_back(vector<ll>());
			rep(j, n+2){
				dp[t][i].push_back(0);
			}
		}
	}

	sort(all(M), [](const mission &a, const mission &b){return a.r < b.r;});
	int mi = 0;
	dp[0][0][0] = 1;

	rep(t,n+1){
		while(mi < M.size()){
			int l,r,x;
			l = M[mi].l;
			r = M[mi].r;
			x = M[mi].x;

			if(r == t){
				rep(i, t+1){
					rep(j, t+1){
						int count = 1;
						count += l <= i;
						count += l <= j;
						if(count != x){
							dp[0][i][j] = 0;
						}
					}
				}
			}else{
				break;
			}
			mi++;	
		}
		if(t==n) break;
		rep(i, t+1){
			rep(j, t+1){
				dp[0][i][j] %= MOD;
				dp[1][i][j] += dp[0][i][j]; dp[1][i][j] %= MOD;
				dp[1][i][t] += dp[0][i][j]; dp[1][i][t] %= MOD;
				dp[1][j][t] += dp[0][i][j]; dp[1][j][t] %= MOD;
			}
		}
		rep(i, n+1){
			rep(j, n+1){
				dp[0][i][j] = dp[1][i][j];
				dp[1][i][j] = 0;
			}
		}
	}


	/*rep(t, n+1){
		rep(i, t+1){
			rep(j, t+1){
				//cerr<<t<<" "<<i<<" "<<j<<" "<<dp[t][i][j]<<endl;
			}
		}
	}*/

	ll ans = 0;
	rep(i, n+1){
		rep(j, n+1){
			ans += dp[0][i][j];
			ans %= MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2816
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;

void ABC333() {
	int A, B;
	cin >> A >> B;
	cout << (((A * B) % 2 == 0) ? "No" : "Yes") << "\n";

}

int main() {
	ABC333();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N, K, X, Y;
            cin >> N >> K >> X >> Y;
                if(N <= K){
                    cout << N*X << endl;
                }else{
                    cout << K*X + (N-K)*Y << endl;
                }
    return 0;}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n, m, l;
	int tmp;
	scanf("%d %d %d", &n, &m, &l);
	if(n>m){
		tmp=n;
		n=m;
		m=tmp;
	}
	if(m>l){
		tmp=m;
		m=l;
		l=tmp;
	}
	if(n>m){
		tmp=n;
		n=m;
		m=tmp;
	}
	printf("%d %d %d\n", n, m, l);
	return 0;
}



Measured memory_bytes: 1832
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

# N<=8より4**8=65536通りしかないので全探索できる
INF = 10**9


def dfs(n_bamboo, a, b, c):
    if n_bamboo == N:
        if a != 0 and b != 0 and c != 0:
            # n個合成するとき、n-1回しか魔法は使わないのに"+10"をn回したから
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
        else:
            return INF
    else:
        return1 = dfs(n_bamboo+1, a, b, c)
        return2 = dfs(n_bamboo+1, a + L[n_bamboo], b, c)+10
        return3 = dfs(n_bamboo+1, a, b+L[n_bamboo], c)+10
        return4 = dfs(n_bamboo+1, a, b, c+L[n_bamboo])+10
        return min([return1, return2, return3, return4])


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
# ARC 059: C – いっしょ / Be Together
import math

n = int(input())
a = [int(s) for s in input().split()]

average_ceil = math.ceil(sum(a) / len(a))
average_floor = math.floor(sum(a) / len(a))

cost_ceil = 0
cost_floor = 0
for i in range(n):
    cost_ceil += (a[i] - average_ceil) ** 2
    cost_floor += (a[i] - average_floor) ** 2

print(min(cost_ceil, cost_floor))

Measured memory_bytes: 3064
#include<cmath>
#include<iostream>
using namespace std;
long long n,a[1000001],sum=0,x,y,ans=19198101919810,z;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	x=a[1];
	y=sum-x;
	z=abs(y-x);
	ans=min(ans,z);
	for(int i=2;i<n;i++)
	{
		x+=a[i];
		y-=a[i];
		z=abs(y-x);
		ans=min(ans,z);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
H, W = map(int, input().split())
M = list()


for i in range(H):
    temp = input()        
    if (temp.count("#") != 0):
        M.append(temp) 


H = len(M)


list_of_col = [] 

for i in range(W):
    t = ""
    for j in range(H):
        t += M[j][i]
    if (t.count("#") != 0):
        list_of_col.append(i)


for i in range(H):
    for j in range(W):
        if j in list_of_col:
            print(M[i][j],end="")
    print()

Measured memory_bytes: 42600
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef long long LL;
const int MAXN=205;
const int MOD=998244353;
int x[MAXN],y[MAXN];

LL Q_pow(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int main()
{
    int n;
    while(scanf("%lld",&n)!=EOF)
    {
        for(int i=1;i<=n;i++)
            scanf("%d%d",&x[i],&y[i]);
        LL ans=Q_pow(2,n);
        ans=(ans-1+MOD)%MOD;//空集
        ans=(ans-n+MOD)%MOD;//单元素
        ans=(ans-n*(n-1)/2+MOD)%MOD;//双元素
        int A,B,C;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                A=y[j]-y[i];
                B=x[i]-x[j];
                C=-A*x[i]-B*y[i];
                LL cnt=2;//i j
                for(int k=1;k<=n;k++)
                {
                    if(k==i||k==j) continue;
                    if(A*x[k]+B*y[k]+C!=0) continue;
                    if(k<j) break;
                    cnt++;
                }
                ans=(ans-Q_pow(2,cnt)+MOD)%MOD;
                ans=(ans+1)%MOD;
                ans=(ans+cnt)%MOD;
                ans=(ans+cnt*(cnt-1)/2)%MOD;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}


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

#define MAX 100001
#define min(a, b) ((a) < (b) ? (a) : (b))

struct work {
	char wname[32];
	int time;
};

typedef struct work elemType;

elemType Q[MAX];
int head, tail;

void init_queue()
{
	head = tail = 0;
}

int is_full()
{
	return ((tail + 1) % MAX) == head;
}

int is_empty()
{
	return head == tail;
}

void enqueue(elemType v)
{
	if (is_full())
		exit(1);
	
	Q[tail] = v;
	tail = ((tail + 1) % MAX);
}

elemType dequeue()
{
	elemType v;
	
	if (is_empty())
		exit(1);
		
	v = Q[head];
	head = ((head + 1) % MAX);
	
	return v;
}

int main(int argc, char *argv[])
{
	int n, q, i;
	int total_time = 0;
	elemType e;
	
	init_queue();
	
	scanf("%d %d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%s %d", Q[i].wname, &Q[i].time);
		tail++;
	}
		
	while (!is_empty()) {
		e = dequeue();
		total_time += min(q, e.time); 
		e.time -= min(q, e.time);
		if (0 == e.time) {
			printf("%s %d\n", e.wname, total_time);
		} else {
			enqueue(e);
		}
		
	}

	return 0;
}


Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(dt,i,a,b) for(dt i=a;i<b;i++)
#define f0(a,b) for(lli i=a;i<b;i++)
#define fn(b,a) for(lli i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define mp make_pair
#define E9 1000000007
#define E5 100007
#define INF 1e9+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sc second
#define el "\n"
#define all(a) a.begin(),a.end()
typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef map<char,int> mci;
typedef pair<long long int,long long int> pll;
typedef long long int lli;  //  e-18 to e18
void solve(){
    lli s(0),a,b,c,k;
    cin>>a>>b>>c>>k;
    while(a>0 && k>0){
        k--; 
        s++;
        a--;
    }
    while(b>0 && k>0){
        k--;
        b--; 
    }
    while(c>0 && k>0){
        k--; 
        s--;
        c--;
    }
    cout<<s<<el;
}
int main(){
    fastIO();
    lli t(1);
    // cin>>t;
    while(t--) solve();
    ret 0; 
}                                                             

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

int main() {
    int n,num;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        cin >> d.at(i);
    }
    for(int i = 0; i < n; i++){
        int max = 0;
        for(int j = 0; j < n; j++){
            if(max < d.at(j)){
                max = d.at(j);
            }
        }
        for(int j = 0; j < n; j++){
            if(max <= d.at(j)){
                d.at(j) = 0;
            }
        }
        if(max != 0){
            num++;
        }else{
            break;
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 256
from collections import Counter

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

key, val = zip(*Counter(A).most_common())
k = len(val)

for i in range(len(val)):
    if k <= K:
        break
    count += val[len(val)-i-1]
    k -= 1

print(count)


Measured memory_bytes: 41236
#include<iostream>
#include<cstdio>
using namespace std;
int n,k;
int A[100001];
int main(){
  while(1){
    scanf("%d %d",&n,&k);
    if(!n && !k) break;
    for(int i=0;i<n;i++) scanf("%d",&A[i]);
    int res=0;
    int sum=0;
    for(int i=0;i<k;i++){
      sum+=A[i];
    }
    res = sum;
    for(int i=k,j=0;i<n;i++,j++){
      sum-=A[j]; sum+=A[i];
      res = max(res,sum);
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 1576
def numba_compile(numba_config):
    import os, sys
    if sys.argv[-1] == "ONLINE_JUDGE":
        from numba import njit
        from numba.pycc import CC
        cc = CC("my_module")
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature)(func)
            cc.export(func.__name__, signature)(func)
        cc.compile()
        exit()
    elif os.name == "posix":
        exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
        for func, _ in numba_config:
            globals()[func.__name__] = vars()[func.__name__]
    else:
        from numba import njit
        for func, signature in numba_config:
            globals()[func.__name__] = njit(signature, cache=True)(func)
        print("compiled!", file=sys.stderr)

import sys
import numpy as np

def solve(N, A):
    def osa_k_construct(n_max):
        min_factor = np.arange(n_max+1)
        for i in range(2, int(n_max**0.5)+1):
            if min_factor[i] == i:
                for j in range(i*i, n_max+1, i):
                    if min_factor[j] == j:
                        min_factor[j] = i
        return min_factor

    def osa_k_factorize(min_factor, n):
        min_factor = min_factor
        # n_twoes = (n & -n).bit_length() - 1
        # res = [2] * n_twoes
        # n >>= n_twoes
        res = [0]*0
        while n > 1:
            p = min_factor[n]
            res.append(p)
            n //= p
        return res

    osa_k = osa_k_construct(1010101)
    Factors = [osa_k_factorize(osa_k, a) for a in A]
    factors = Factors[0]
    st0 = set(factors)  # 0 になれば setwize
    st1 = set(factors)  # 重複しなければ pairwise
    pairwise = True
    for factors in Factors[1:]:
        st = set(factors)
        for f in st:
            if f in st1:
                pairwise = False
            else:
                st1.add(f)
        st0 &= st
    if pairwise:
        print("pairwise coprime")
    elif not st0:
        print("setwise coprime")
    else:
        print("not coprime")

numba_compile([
    [solve, "void(i8,i8[:])"]
])

def main():
    input = sys.stdin.buffer.readline
    N = int(input())
    A = np.array(input().split(), dtype=np.int64)
    solve(N, A)

main()


Measured memory_bytes: 308624
def kei(x):
    S=0
    for i in range(1,x):
        if i%2==1:
            S=S+9*(10**(i-1))
        else:
            S=S
    return S
    
N = int(input())
ketasu=int(len(str(N)))
if ketasu%2==1:
    k=ketasu
    count=N-10**(k-1)+1+kei(k)
    print(count)
else:
    k=ketasu
    count=kei(k)
    print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n, k, m;
vector<int>v;
int main()
{
	cin >> k >> n;
	if (!(k & 1))
	{
		cout << k / 2 << ' ';
		for (int i = 0; i < n - 1; i++)
			cout << k << ' ';
	}
	else
	{
		v.resize(n, k + 1 >> 1);
		for (int i = n / 2; i; i--)
		{
			if (--v.back() == 0)
			{
				v.pop_back();
				continue;
			}
			while (v.size() < n)
				v.push_back(k);
		}
		for (int i : v)
			cout << i << ' ';
	}
}

Measured memory_bytes: 3456
import sys
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if v==w or w>v:
    print('NO')
    sys.exit()
else:
    tp=(b-a)/(v-w)
    tm=(a-b)/(v-w)
    if b>a:
        if t>=tp:
            print('YES')
        else:
            print('NO')
    else:
        if t>=tm:
            print('YES')
        else:
            print('NO')



Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL dp[1123456][2] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    string S; cin >> S;
    dp[0][1] = 1;
    int len = S.length();
    REP(i,len){
        int d = S[i] - '0';
        dp[i+1][0] = min(dp[i][0]+d, dp[i][1]+(10-d));
        dp[i+1][1] = min(dp[i][0]+d+1, dp[i][1]+(10-d)-1);
    }
    cout << dp[len][0] << endl;

}


Measured memory_bytes: 17692
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#define isset(mask,bit) ((mask&(1LL<<bit))!=0)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =5e2+10;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
lld visit[M][M];
string s[M];
lld dirx[]={0,0,1,-1};
lld diry[]={1,-1,0,0};
bool check(lld x,lld y, char ch){
	if(x<0||x>=n||y<0||y>=m)return false;
	if(ch==s[x][y])return false;
	return true;
}
pll dfs(lld x,lld y){
	visit[x][y]=1;
	lld i,j;
	lld w=0,b=0;
	if(s[x][y]=='.')w++;
	else
		b++;
	up(0,4,i){
		lld nx=x+dirx[i],ny=y+diry[i];
		if(visit[nx][ny]==0&&check(nx,ny,s[x][y])){
			pll temp=dfs(nx,ny);
			w+=temp.F;
			b+=temp.S;
		}
	}
	dg4(x,y,w,b);
	return {w,b};
}
int main()
{
  lld i,j;
  ds(n,m);
  up(0,n,i){
  	cin>>s[i];
  }
  up(0,n,i)up(0,m,j){
  	if(visit[i][j]==0){
  		pll temp=dfs(i,j);
  		dg2(temp.F,temp.S);
  		ans+=(temp.S)*temp.F;
  	}
  }
  pp(ans);
  return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M)%M;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length();
    vector<ll> cnt(2019,0);
    cnt[0]++;
    ll now = 0;
    rep(i,n){
        now += RepeatSquaring(10,i,2019)*(s[n-i-1]-'0');
        now %= 2019;
        cnt[now]++;
    }
    ll ans = 0;
    rep(i,2019){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    PRINT(ans);
}



Measured memory_bytes: 3804
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = x/100;
		if((x-a*100) <= 5*a) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
		sc.close();
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll cnt=0,ans=INF;
    string s; cin>>s;
    
    //EEEEEEEEEEEEEEEEE
    rep(i,sz(s)){
        if(s[i]=='W') cnt++;
    }
    ans=cnt;
    
    rrep(i,sz(s)){
        if(s[i]=='W') cnt--;
        chmin(ans,cnt);
        if(s[i]=='E') cnt++;
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 3880
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	vector<string> S(N);
	vector<int> P(N);	
	FDS(i,N){
		cin>>S[i]>>P[i];
	}
	//入力終わり
	vector<pair<pair<string,int>,int>> SPNum(N);//SとPとNumberの組

    FDS(i,N){
	   SPNum[i] = make_pair(make_pair(S[i],-P[i]),i+1);
    }
	VSORT(SPNum);
	FDS(i,N){
		cout<<SPNum[i].second<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve(){
  long long a,b,k;
  cin >> k >> a >> b;
  long long res;
  if(k<a)res = k+1;
  else{
    if(a+2>=b)res=k+1;
    else{
      k-=(a-1);
      res = (k/2)*b-(k/2-1)*a+k%2;
    }
  }
  cout << res << endl;

}
int main(){
  solve();
  return 0;
}


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

int main(){
    int64_t N,X;
    cin>>N>>X;
    int64_t res=0;
    vector<int64_t>a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
        a.at(i)=abs(a.at(i)-X);
    }
    res=0;
    for(int i=0;i<N;i++){
        res=__gcd(res,a.at(i));
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024