akhauriyash/Code-Regression huggingface dataset:
(defun split-with (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(let* ((read (mapcar #'parse-integer (split-with (read-line))))
       (w (car read))
       (a (cadr read))
       (b (caddr read)))
  (format t "~a~%"
          (if (< a b)
              (max 0 (- b (+ a w)))
              (max 0 (- a (+ b w))))))


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

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

int main(){
  int N,K,ans;
  cin>>N>>K;
  rep(i,N){
    int T;
    cin>>T;
  }
  ans = 1;
  N-=K;
  N=max(0,N);
  if(N%(K-1)==0){
    ans+=N/(K-1);
  }else{
    ans+=N/(K-1)+1;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime(long long num);
int main(){
    long long X;
    cin >> X;
    while(true){
        if(prime(X)){
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

bool prime(long long num){
    for(long long i=1;i<num-1;i++){
        bool flag=num%(num-i);
        if(!flag){
            return false;
        }
    }
    return true;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B;
	cin >> A >> B;
	if (A<=8&&B<=8){
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var NMX = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var OK = true;
            var ans = 2 * N;
            for (int i = 0; i < N; i++)
            {
                OK = true;
                for (int j = 0; j <= i; j++)
                {
                    if (t[j] != s[(int)N-1+j-i])
                    {
                        OK = false;
                    }
                }

                if (OK) ans = Min(ans, 2 * N-(i+1));


            }

            Console.WriteLine(ans);
            
        }


    }

}


Measured memory_bytes: 27352
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i, n) for (int i = 0; i < n; i++)
#define R(i, c, n) for (int i = c; i < n; i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a)            \
  REP(d, a.size())         \
  {                        \
    cout << a[d];          \
    if (d != a.size() - 1) \
      cout << " ";         \
    else                   \
      cout << endl;        \
  }
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) \
  sort(ALL(v));   \
  v.erase(unique(ALL(v)), v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

  int h,w;
  cin >> h >> w;
  int x,y;
  cin >> x >> y;

  int result = (h*w) - w*x - (h-x)*y;
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];

    for (int i = 0; i < 1000; ++i) {
        string t = to_string(i);
        if ((int)t.size() != N) continue;

        int j;
        for (j = 0; j < M; ++j) {
            if (t[s[j] - 1] - '0' != c[j]) break;
        }
        if (j == M) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int a,b;
    cin >> a >> b;
    rep(i,10000){
        if((i*8)/100 == a && (i/10) == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

using namespace std;
 
long long h, total;
int n, a;

int main() {
  cin >> h >> n;
  for(int ana = 0; ana < n; ana++) {
    cin >> a;
    total += a;
  }
  if(total >= h) cout << "Yes\n";
  else cout << "No\n";
}
  

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 

typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";


#define M 1000000007
#define inf 99999999999999999LL	//long long inf
#define LIM 1000003
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}

ll n, a[LIM+2],dp[LIM+2];

int main() {
	int i, j, t;
	scl(n) ;
	for(i=1;i<=n;i++)
		scl(a[i]) ;
	dp[1] = 0 ;
	dp[2] = abs(a[1]-a[2]) ;
	for(i=3;i<=n;i++)
	{
		dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout << dp[n] << endl ;



	return 0;
}




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

#define int long long

int solve(int n){
	int l = sqrt(n) ;
	int cnt = 0 ;
	for(int i = 1 ; i <= l ; i++){
		for(int j = 1 ; j <= l ; j++){
			int c = n - i*i - j*j - i*j ;
			if(c <= 0) continue ;
			double d = (i+j)*(i+j) + 4*c ;
			int x = sqrt(d) ;
			if(abs(x*x -d) <= 1e-10){
				x -= (i+j) ;
				if((x > 0) && (x%2 == 0)){
					cnt++ ;
				}
			}
		}
	}
	return cnt ;
}

int32_t main(){
	ios :: sync_with_stdio(0) ;
	cin.tie(0) ;
	int n;
	cin >> n; 
	for(int i = 1 ; i <= n ; i++){
		cout << solve(i) << '\n' ;
	}
	cout << '\n' ;
	return 0 ;
}



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

int main(){
  int d, n;
  cin >> d >> n;
  if(d == 0) cout << (n >= 100 ? 101 : n) << endl;
  else if(d == 1) cout << (n >= 100 ? 101 * 100 : 100 * n) << endl;
  else if(d == 2) cout << (n >= 100 ? 101 * 100 * 100 : n * 100 * 100) << endl;
  return 0;
}


Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

Measured memory_bytes: 3120
#include <stdlib.h>
#include <iostream>
#include <string>

int main(int argc, char* argv[])
{
	int a,b;
    std::cin>>a>>b;
	if(a<-1000 || a>1000) return 0;
	if(b<-1000 || b>1000) return 0;
	if(a==b) std::cout<<"a == b"<<std::endl;
	if(a>b) std::cout<<"a > b"<<std::endl;
	if(a<b) std::cout<<"a < b"<<std::endl;
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	string s;
	cin >> s;
	int n;
	n = s.length();

	
	char lastChar = s[0];
	int ans = n;
	for (int i = 0; i < n;i++) {
		if (s[i] != lastChar) {
			ans = min(ans, max(i, n - i));
			lastChar = s[i];
		}
	}

	
	cout << ans << endl;
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	string N; int K; cin >> N >> K; 
	long long dp[110][4][2] = {}; 
	dp[0][0][0] = 1; 
	for(int i = 1; i <= N.size(); i++){
		if(N.at(i-1) == '0'){
			dp[i][0][0] = dp[i-1][0][0]; 
			dp[i][1][0] = dp[i-1][1][0]; 
			dp[i][2][0] = dp[i-1][2][0]; 
			dp[i][3][0] = dp[i-1][3][0]; 
			dp[i][0][1] = dp[i-1][0][1]; 
			dp[i][1][1] = dp[i-1][0][1] * 9 + dp[i-1][1][1]; 
			dp[i][2][1] = dp[i-1][1][1] * 9 + dp[i-1][2][1];   
			dp[i][3][1] = dp[i-1][2][1] * 9 + dp[i-1][3][1];  
		}
		else{
			dp[i][0][0] = 0; 
			dp[i][1][0] = dp[i-1][0][0]; 
			dp[i][2][0] = dp[i-1][1][0]; 
			dp[i][3][0] = dp[i-1][2][0]; 
			dp[i][0][1] = dp[i-1][0][1] + dp[i-1][0][0]; 
			dp[i][1][1] = dp[i-1][0][1] * 9 + dp[i-1][1][1] + dp[i-1][0][0] * (N.at(i-1) - '1') + dp[i-1][1][0]; 
			dp[i][2][1] = dp[i-1][1][1] * 9 + dp[i-1][2][1] + dp[i-1][1][0] * (N.at(i-1) - '1') + dp[i-1][2][0];    
			dp[i][3][1] = dp[i-1][2][1] * 9 + dp[i-1][3][1] + dp[i-1][2][0] * (N.at(i-1) - '1') + dp[i-1][3][0];    
		}
	}
	cout << dp[N.size()][K][0] + dp[N.size()][K][1] << endl; 
}

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


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

    sort(s.begin(), s.end());

    cout<<((s[0]=='a' && s[1]=='b' && s[2]=='c')? "Yes":"No")<<endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    long MOD = (long)Math.pow(10, 9) + 7;
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int len = s.length();
    long[][] dp = new long[len][13];
    if(s.charAt(0) == '?') {
      for(int j = 0; j < 10; j++) {
        dp[0][j] = 1;
      }
    } else {
      int d = Integer.parseInt(String.valueOf(s.charAt(0)));
      dp[0][d] = 1;
    }
    for(int i = 1; i < len; i++) {
      if(s.charAt(i) == '?') {
        for(int j = 0; j < 13; j++) {
          for(int k = 0; k < 10; k++) {
            dp[i][(10 * j + k) % 13] = (dp[i][(10 * j + k) % 13] + dp[i - 1][j]) % MOD;
          }
        }        
      } else {
        for(int j = 0; j < 13; j++) {
          int d = Integer.parseInt(String.valueOf(s.charAt(i)));
          dp[i][(10 * j + d) % 13] = (dp[i][(10 * j + d) % 13] + dp[i - 1][j]) % MOD;
        }        
      }
    }
    System.out.println(dp[len - 1][5]);
  }
}


Measured memory_bytes: 59740
from fractions import gcd
 
d = gcd(*map(int, input().split()))
r = 1
i = 2
while i * i <= d:
    c = 0
    while d % i == 0:
        c += 1
        d //= i
    r += c > 0
    i += 1
print(r + (d > 1))

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

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++)
  {
    char moji = s[i];
    if (((i % 2 == 0) && (moji == 'R' || moji == 'U' || moji == 'D')) || ((i % 2 == 1) && (moji == 'L' || moji == 'U' || moji == 'D')))
    {
      if (i == s.length() - 1){
        printf("Yes\n");
      }
    }
    else {
      printf("No\n");
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  for(int i =0;i<k;i++){
    if(i%2==0){
      if(a%2==0){
        a = a/2;
        b = b+a;
      } else {
        a = (a-1)/2;
        b = b+a;
      }
    } else {
      if(b%2==0){
          b = b/2;
          a = a+b;
      } else {
        b = (b-1)/2;
        a = a+b;
      }
    }
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

long_hand = M * 6
short_hand = (H * 60 + M) * 0.5

angle = abs(long_hand - short_hand)

dist = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))

print("{:.20}".format(math.sqrt(dist)))

Measured memory_bytes: 9548
nums = []
oprs = []
loop do
  t = gets.strip
  if t == "="
    break
  elsif t.match /^\d+$/
    nums.push t.to_i
  else
    oprs.push t.to_sym
  end
end

p nums.inject{|a, b| a.method(oprs.shift).call(b) }

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

int main() {
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  int x = b - a - 1;
  if (x % 2) printf("Alice\n");
  else printf("Borys\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <vector>

#define ll long long

using namespace std;

int main()
{
    int N;
    ll sum=0;
    cin>>N;
    vector<int>l(N+1);
    vector<int>r(N+1);
    for(int i=1;i<=N;i++){
        cin>>l[i]>>r[i];
    }
    sort(r.begin(),r.end(),greater<int>());
    sort(l.begin(),l.end());
    for(int i=0;i<=N;i++){
        if(l[i]>r[i]){
            sum+=2*(l[i]-r[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, W, w[MAXN], v[MAXN];
ll dp[100010];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> W;
    FOR(i,1,n) cin >> w[i] >> v[i];
    FOR(i,1,W) dp[i] = -1e18;
    dp[0] = 0;
    FOR(i,1,n)
        FORE(j,W,0)
            if (j - w[i] < 0) break;
            else dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    ll res = -1e18;
    FOR(i,0,W) res = max(res, dp[i]);
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
def xxx(n):
    alpha = "abcdefghijklmnopqrstuvwxyz"
    ans = ""
    i = 1

    while True:
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans = alpha[n%26] + ans
                n //= 26
            return ans
        else:
            n -= 26 ** i
            i += 1


N = int(input())
print(xxx(N))

Measured memory_bytes: 9108
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int T, e;
int n;

int a[maxn];

int read() {
  if (scanf("%d%d%d", &n, &e, &T) < 3) {
    return 0;
  }
  a[0] = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i + 1);
  }
  ++n;
  return 1;
}

long long dp[maxn];
long long dpup[maxn];

void solve() {
  sort(a, a + n);

  int pos = 0;

  vector<pair<long long, int> > st;
  int left = 0;

  for (int i = 0; i < n; ++i) {
    dpup[i] = 1e18;
  }

  for (int i = 0; i < n; ++i) {
    long long &cur = dp[i];
    if (!i) {
      cur = 0;
    } else {
      cur = 1e18;
      cur = min(cur, dpup[i] + 2 * a[i]);
      while (left < sz(st) && st[left].second <= i) {
        ++left;
      }
      if (left < sz(st)) {
        cur = min(cur, st[left].first);
      }
    }
    //eprintf("dp[%d] = %lld\n", i, cur);

    if (i < n - 1) {
      while (pos < n && (a[pos] - a[i + 1]) * 2 <= T) {
        ++pos;
      }
      long long nval = cur + T;
      while (sz(st) > 0 && st.back().first >= nval) {
        st.pop_back();
        if (left == sz(st)) {
          --left;
        }
      }
      st.push_back(mp(nval, pos));
      //eprintf("nval = %lld, pos = %d\n", nval, pos);

      dpup[pos] = min(dpup[pos], cur - 2 * a[i + 1]);
      dpup[i + 1] = min(dpup[i + 1], dpup[i]);
    }
  }

  long long res = dp[n - 1] + e;
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    ll a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    vector<pair<ll,ll>> ans;
    ll tmp=a[0];
    for(int i=1;i<N-1;i++){
        if(a[i]>=0){
            ans.push_back({tmp,a[i]});
            tmp-=a[i];
        }
    }
    ans.push_back({a[N-1],tmp});
    tmp=a[N-1]-tmp;
    for(int i=1;i<N-1;i++){
        if(a[i]<0){
            ans.push_back({tmp,a[i]});
            tmp-=a[i];
        }
    }
    cout << tmp << endl;
    for(int i=0;i<N-1;i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

}


Measured memory_bytes: 6156
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		long h[]=new long[n];
		for(int i=0;i<n;i++) {
			h[i]=scan.nextLong();
		}
		scan.close();
		Arrays.sort(h);
		long sum=0;
		for(int i=0;i<n-k;i++) {
			sum+=h[i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 65012
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n>m){
        while(n--) cout<<m;
        cout<<endl;
    }
    else{
        while(m--) cout<<n;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    //次々に文字を読み込む
    /*while(1)
    {
        
        char ch;
        cin>>ch;
        if(ch=='¥n')break;
        if('a'<=ch&&ch<='z')cout<<"A ";
        else cout<<"Z ";
    }*/
    string lane;//def:string "lane" access:lane[i] access:lane.size()
    getline(cin,lane);
    for(int i=0;i<lane.size();i++)
    {
        if(lane[i]>='a'&&lane[i]<='z')lane[i]+='A'-'a';
        else if(lane[i]>='A'&&lane[i]<='Z')lane[i]+='a'-'A';
    }
    cout<<lane<<endl;
    return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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; }

void add(ll& a, ll b){a = (a+b) % MOD;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N=0,S=0,W=0,E=0;
    string s;cin>>s;
    REP(i,s.size()){
        if(s[i]=='N') N++;
        if(s[i]=='S') S++;
        if(s[i]=='W') W++;
        if(s[i]=='E') E++;
    }
    if(N>0&&S>0){
        if(W>0&&E>0){
            cout<<"Yes";
        }
        else if(W==0&&E==0) cout<<"Yes";
        else cout<<"No";
    }
    else if(W>0&&E>0){
        if(N>0&&S>0){
            cout<<"Yes";
        }
        else if(N==0&&S==0) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
}

Measured memory_bytes: 256
o=input()
e=input()
ans=['']*(len(o)+len(e))
flg=1
for i in range(len(o)):
	ans[i*2]=o[i]
for j in range(len(e)):
	ans[j*2+1]=e[j]
for k in range(len(ans)):
	print(ans[k],end="")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MSIZE = 301;

double dp[MSIZE][MSIZE][MSIZE];
double p[MSIZE][MSIZE][MSIZE];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int a, b, c;
    cin >> n;
    a = b = c = 0;
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        if (val == 1) a++;
        if (val == 2) b++;
        if (val == 3) c++;
    }
    memset(dp, 0, sizeof dp);
    memset(p, 0, sizeof p);
    p[a][b][c] = 1;

    for (int x3 = n; x3 >= 0; x3--) 
    for (int x2 = n; x2 >= 0; x2--)
    for (int x1 = n; x1 >= 0; x1--) {
        int tot = x1 + x2 + x3;
        int x0 = n - tot;
        double time = 1;
        if (p[x1][x2][x3] == 0) continue;
        if (x0) {
            double p = x0 * 1.0 / n;
            time += p / (1 - p); 
        }
        time *= p[x1][x2][x3];
        time += dp[x1][x2][x3];
        time /= tot;
        p[x1][x2][x3] /= tot;
        if (x1) {
            dp[x1 - 1][x2][x3] += time * x1; 
            p[x1 - 1][x2][x3] += p[x1][x2][x3] * x1;
        }
        if (x2) {
            dp[x1 + 1][x2 - 1][x3] += time * x2; 
            p[x1 + 1][x2 - 1][x3] += p[x1][x2][x3] * x2;
        }
        if (x3) {
            dp[x1][x2 + 1][x3 - 1] += time * x3;
            p[x1][x2 + 1][x3 - 1] += p[x1][x2][x3] * x3;
        }
    }

    cout << fixed << setprecision(10) << dp[0][0][0] << endl;
}

Measured memory_bytes: 426368
n = int(input())
ans = []
#now = (-2)^n = 1,-2,4,-8,16....
now = 1
while n != 0:
    if n % (abs(now) * 2) == 0:
        ans.append("0")
    else:
        ans.append("1")
        n -= now

    now *= -2
    #print(n, now, ans)

if ans == []:
    print(0)
else:
    out = ""
    for i in range(len(ans) - 1, -1, -1):
        out += ans[i]

    print(out)


Measured memory_bytes: 3060
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
ll pw(ll b, ll r){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%mod;
		b = (b*b)%mod;
		r>>=1;
	}
	return ans;
}
ll fact(ll n){
	ll ans = 1;
	for(int i = 1 ; i <= n ; i ++ )ans*=i;
	return ans;
}
ll findRank(ll arr[], ll n){
	ll ans = 0 ; 
	for(int i = 0 ; i < n ; i ++ ){
		ans+=fact(n-i-1)*(arr[i]-1);
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;cin>>n>>k;
	ll r,s,p;cin>>r>>s>>p;
	ll ans = 0 ; 
	string str;cin>>str;
	for(int i = 0 ; i < k ; i ++ ){
		char val = str[i];
		ll counter = 0 ; 
		for(int j = i ; j < n ; j += k){
			if(val==str[j])counter++;
			else {
				ans+=((counter/2)+(counter%2==0?0:1))*(val=='r'?p:(val=='s'?r:s));
				counter=1;
				val=str[j];
			}
		}
		ans+=(counter/2+(counter&1))*(val=='r'?p:(val=='s'?r:s));
	}
	cout<<ans<<en;
	return 0 ; 
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N); rep(i,N) cin >> A[i];
  vector<int> B(N,0);
  ll ans = 1;
  int n[3] = {0,0,0};
  rep(i,N){
    int cnt = 0;
    bool added = false;
    rep(j,3){
      if(n[j] == A[i]){
        cnt++;
        if(!added){
          n[j]++;
          added = true;
        }
      }
    }
    ans *= cnt;
    ans %= mod;
  }




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


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  int h,ans=0;
  for(int i=1;i<=N;i++){
    scanf("%d",&h);
    if(h>=K) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
package main

import (
	"fmt"
	"math"
)

const EPS float64 = 1e-8

func add(a float64, b float64) float64 {
	if math.Abs(a+b) < EPS*(math.Abs(a)+math.Abs(b)) {
		return 0.0
	}
	return a + b
}

type Point struct {
	X, Y float64
}

func (p Point) Add(q Point) Point {
	return Point{add(p.X, q.X), add(p.Y, q.Y)}
}

func (p Point) Sub(q Point) Point {
	return Point{add(p.X, -q.X), add(p.Y, -q.Y)}
}

func (p Point) Mul(d float64) Point {
	return Point{p.X * d, p.Y * d}
}

func (p Point) Dot(q Point) float64 {
	return p.X*q.X + p.Y*q.Y
}

type Line struct {
	A, B Point
}

func (l Line) Project(p Point) Point {
	base := l.B.Sub(l.A)
	t := (p.Sub(l.A)).Dot(base) / base.Dot(base)
	return l.A.Add(base.Mul(t))
}

func (l Line) Symmetry(q Point) Point {
	return l.Project(q).Sub(q).Mul(2).Add(q)
}

func main() {
	var line Line
	var q int
	var point Point
	fmt.Scan(&line.A.X, &line.A.Y, &line.B.X, &line.B.Y)
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		fmt.Scan(&point.X, &point.Y)
		result := line.Symmetry(point)
		fmt.Printf("%.8f %.8f\n", result.X, result.Y)
	}
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  vector<int> H(n);
  vector<int> Ma(n);
  for(int i=0;i<n;i++){
    cin >> H.at(i);
  }
  int a,b;
  for(int k=0;k<m;k++){
      cin >> a >> b;
    Ma.at(a-1)=max(Ma.at(a-1),H.at(b-1));
    Ma.at(b-1)=max(Ma.at(b-1),H.at(a-1));
  }
  int ans=0;
  for(int j=0;j<n;j++){
    if(Ma.at(j)<H.at(j)){
      ans++;
    }
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 4028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Needed(int N, int K, long[] A, int i)
        {
            bool[] dp1 = new bool[K];
            dp1[0] = true;
            foreach (int j in Enumerable.Range(0, N).Where(j => j != i))
            {
                bool[] dp2 = new bool[K];
                for (int k = 0; k < K; ++k)
                {
                    if (dp1[k])
                    {
                        dp2[k] = true;
                        if (k + A[j] < K) { dp2[k + A[j]] = true; }
                    }
                }
                dp1 = dp2;
            }
            return Enumerable.Range(0, K).Any(j => dp1[j] && j + A[i] >= K);
        }
        static int Solve(int N, int K, long[] A)
        {
            Array.Sort(A);
            int min = 0;
            int max = N - 1;
            if ( Needed(N, K, A, min)) { return 0; }
            if (!Needed(N, K, A, max)) { return N; }
            while (max - min > 1)
            {
                int med = (min + max) / 2;
                if (Needed(N, K, A, med)) { max = med; } else { min = med; }
            }
            return max;
        }
        static void Main(string[] args)
        {
            int[] v1 = ReadInts();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(v1[0], v1[1], A));
        }
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> P(n);
  vector<int> Q(n);
  rep(i, n) cin >> P[i];
  rep(i, n) cin >> Q[i];
  //rep(i, n) cout << P[i];
  int p=0, q=0, count=0;
  int cp = 0, cq = 0;
  iota(A.begin(), A.end(), 1);
  do {
     /*rep(i, n) cout << A[i];
     cout << endl;*/
     count++;
     //cout << count << endl;
     rep(i, n){
       //cout << A[i] << P[i] << Q[i] << endl;
       if(A[i]!=P[i]) cp = 1;
       if(A[i]!=Q[i]) cq = 1;
       if(i==n-1&&A[i]==P[i]&&cp==0) p = count;
       if(i==n-1&&A[i]==Q[i]&&cq==0) q = count;
     }
    cp = 0;
    cq = 0;
    //cout << p << q << endl;
    } while( next_permutation(A.begin(), A.end()) );     // 次の順列を生成
  int ans = max(p-q, q-p);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
ll A[N],dp[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    dp[1]=0,dp[2]=abs(A[2]-A[1]);
    for(int i=3;i<=n;i++){
        dp[i]=dp[i-1]+abs(A[i]-A[i-1]);
        for(int j=2;j<=k;j++)
        {
            if(i-j<1)
                break;
            dp[i]=min(dp[i],dp[i-j]+abs(A[i]-A[i-j]));
        }
    }
    cout<<dp[n];


}


Measured memory_bytes: 5072
#include <iostream>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        if(n==0)
            break;
        int a[n][2];
        int b; int c;
        for(int i=0;i<n;i++){
            cin >> a[i][0] >> b >> c;
            a[i][1]=b+c;
        }
        int max = a[0][1];
        int kouho =a[0][0];
        for(int i=0;i<n;i++){
            if(a[i][1] > max){
                max = a[i][1];
                kouho = a[i][0];
            }
        }
        cout << kouho << " " << max << endl;
    }
}

Measured memory_bytes: 1236
#include <cmath>
#include <iomanip>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int count = 1;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        vector<pair<int, int>> v;
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            v.emplace_back(x, y);
        }

        int s = 0;
        for (int i = 0; i < n - 1; ++i) {
            s += v[i].first * v[i + 1].second - v[i + 1].first * v[i].second;
        }
        s += v[n - 1].first * v[0].second - v[0].first * v[n - 1].second;
        cout << count << ' ' << fixed << setprecision(1) << showpoint << abs(s / 2.0)
             << endl;
        count += 1;
    }
}

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

int Num();
int Fact();
int Term();
int Exp();

int ite;
string s;

int Num() {
	int res = 0;
	while (isdigit(s[ite])) {
		res = res * 10 + s[ite] - '0';
		ite++;
	}
	return res;
}

int Fact() {
	if (s[ite] == '(') {
		ite++;
		int res = Exp();
		ite++;
		return res;
	}
	else {
		return Num();
	}
}

int Term() {
	int res = Fact();
	while (true) {
		if (s[ite] == '*') {
			ite++;
			res *= Fact();
		}
		else if (s[ite] == '/') {
			ite++;
			res /= Fact();
		}
		else {
			break;
		}
	}
	return res;
}

int Exp() {
	int res = Term();
	while (s[ite] != '=' && s[ite] != ')') {
		if (s[ite] == '+') {
			ite++;
			res += Term();
		}
		else if(s[ite] == '-') {
			ite++;
			res -= Term();
		}
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	while (n--) {
		cin >> s;
		ite = 0;
		cout << Exp() << endl;
	}
	return 0;
}

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

int main() {
  int n=1,N,K;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    if(n*2<n+K){
      n*=2;
    }else{
      n+=K;
    }
  }
  cout << n << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  for (int i = N - 1; i > 0; i--) {
    if (H[i] < H[i - 1]) {
      H[i - 1]--;
    }

    if (H[i - 1] > H[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define int long long
signed  main(){
  int N,K;
  char dif='A'-'a';
  str S1,S2,S3;
  cin>>S1>>S2>>S3;
  cout<<(char)(S1.at(0)+dif)<<(char)(S2.at(0)+dif)<<(char)(S3.at(0)+dif)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2); 
    p = (p * p); 
  
    return (y%2 == 0)? p : (x * p) ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2); 
} 
  
// To compute x^y under modulo m 


int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll ans = n%k;
    ans = min(ans,k-ans);
    cout<<ans;
   
    
    return 0;
}

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

map<string, int> mp;

int main() {
	mp.clear();

	int n; cin >> n;
	while (n--) {
		string now; cin >> now;

		mp[now] = mp[now] + 1;
	}
	int ans = 0;
	for (auto i : mp) ans = max(ans, i.second);
	for (auto i : mp) {
		if (i.second == ans) cout << i.first << '\n';
	}
	return 0;
}

Measured memory_bytes: 25216
N,K,*A = map(int, open(0).read().split())
pls = []
S = sum(A)
for i in range(1,int(S**0.5)+1):
  if S%i==0:
    pls.append(i)
    pls.append(S//i)
pls.sort()
ans = 0
for p in pls:
  B = [a%p for a in A]
  B.sort()
  i = 0
  j = N-1
  cnt = K
  while i<N:
    if B[i]!=0:
      break
    i += 1
  else:
    ans = p
    continue
  while True:
    a = B[i]
    b = B[j]
    if a<p-b:
      if cnt<a:
        break
      B[j] += a
      cnt -= a
      i += 1
    elif a>p-b:
      if cnt<p-b:
        break
      B[i] -= p-b
      cnt -= p-b
      j -= 1
    else:
      if cnt<a:
        break
      cnt -= a
      i += 1
      j -= 1
    if i>=j:
      ans = p
      break
print(ans)

Measured memory_bytes: 42860
#include <stdio.h>
int main(void)
{
    int  n, i=0, cntb=0, cntr=0;
    char s[1010];
    scanf("%d", &n);
    scanf("%s", s);

    while(s[i]!='\0'){
        if(s[i]=='R') cntr++;
        else if(s[i]=='B') cntb++;
        i++;
    }

    if(cntr>cntb) printf("Yes\n");
    else printf("No\n");
    
    return 0;
}


Measured memory_bytes: 128
from math import ceil

def check(x):
    cnt = 0
    for a in A:
        cnt += ceil(a/x)-1
    return cnt <= K

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

left = 0
right = max(A)
while left < right-1:
    mid = (left+right)//2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)


Measured memory_bytes: 31112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll ans,cnt[2200],num,t=1;
int main()
{
	cin>>s;
	for(int i=s.size()-1;i>=0;i--)
	{
		num=(num+(s[i]-'0')*t)%2019;
		cnt[num]++;
		t=t*10%2019;
	}
	for(int i=1;i<2019;i++)
	{
		if(cnt[i]>1)	ans+=(cnt[i]-1)*cnt[i]/2;		
	}
	ans+=cnt[0]*(cnt[0]+1)/2;
	cout<<ans;
return 0;
}


Measured memory_bytes: 3728
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <map>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 200005;
const ll mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;

char s[maxn];
map<int,int>mp;

int main()
{
    while(~scanf("%s",s))
    {
        int len=strlen(s);
        mp.clear();
        ll ans=1;
        for(int i=0;i<len;i++)
        {
            ans+=i-mp[s[i]-'a'];
            mp[s[i]-'a']++;
        }
        printf("%lld\n",ans);
    }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;
int64 dp[101][8] = {};

int main(void){
	int32 H, W, K;
	cin >> H >> W >> K;
	dp[0][0] = 1;
	REP(i, H){
		REP(j, W){
			REP(k, (1 << (W-1))){
				bool ok = 1;
				REP(l, W-1){
					if(((k >> l) & 3) == 3) ok = 0;
				}
				if(!ok) continue;
				if(j > 0 && (k >> (j-1))&1){
					dp[i+1][j-1] = (dp[i+1][j-1]+dp[i][j])%mod;
				}else if(j < W-1 && (k >> j)&1){
					dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%mod;
				}else{
					dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
				}
			}
		}
	}
	cout << dp[H][K-1] << endl;
}


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

int main(void)
{
    int n;
  	cin >> n;
    long a[10001] = {0},sum = 0;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    cout << *min_element(a,a+n) << " " << *max_element(a,a+n) << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = 0;
    rep(i, n) ans += b[i];

    rep(i, n-1) {
        if (a[i+1]-a[i] == 1) {
            ans += c[a[i]-1];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    char A[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin>>K;

    int ans=A[K-1];
    cout<<ans<<endl;
}


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

using namespace std;

#define pb push_back
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define mem(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

const int mn = 1e6 + 5;

int n, m;
char s[mn];
int a[mn];

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
    size_t bg = clock();
#endif

    scanf("%d",&n);
    scanf("%s",s+1);
    int ans=1e9;
    bool c=0;
    for(int i=n;i>=0;i--){
        a[i]+=a[i+1];
        if (s[i]=='.') a[i]++;
    }
    int cnt=0;
    for(int i=0;i<=n;i++){
        if (s[i]=='#') cnt++;
        ans=min({ans,a[i+1]+cnt});
    }
    cout<<ans<<"\n";

#ifdef trote
    printf("-------------------------------------------\ntime: %f\n", (double) (clock() - bg) / CLOCKS_PER_SEC);
#endif
    return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;

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

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}

long long int kaijo(long long int n){
    if(n==0) return 1;
    else return n*kaijo(n-1);
}

long long int product(long long int n, long long int k){
    long long int tmp=1;
    for(int i=k;i<=n;i++){
        if(k==0) continue;
        tmp*=i;
    }
    return tmp;
}


int main(){
    long long int n;
    bool auth=true;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                auth = false;
            }
        }
    }
    if(auth){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }
 

    return 0;
} //カモンAC


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 

int a[100005];
int tree[200005];

void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}

void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}

int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main(){
	ios_base::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    cout << maxl(a+b,maxl(a-b,a*b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    
    long long N, A, B;
    vector<long long> X;
    long long sum = 0;
    
    cin >> N;
    cin >> A;
    cin >> B;
    
    for ( int i = 0; i < N; i++ ) {
        long long x;
        cin >> x;
        X.push_back( x );
    }
    
    for ( int i = 1; i < N; i++ ) {
        sum += min( ( X[i] - X[i-1] ) * A, B );
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1400