akhauriyash/Code-Regression huggingface dataset:
a,b,c,d,e,mv=map(int,input().split())
e= e/(e+100)

ans=-1
for i in range(31):
    if 100*i*a> mv: continue
    for j in range(31):
        if i+j==0:continue
        if 100*(i*a+j*b)> mv:continue
        for k in range(2801):
            if 100*(i*a+j*b)+k*c> mv:continue
            for l in range(2801):
                water=100*(a*i+b*j)
                sugar=k*c+l*d
                if water+sugar > mv:
                    break
                pp= sugar/(water+sugar)
                
                if e>= pp and ans<pp:
                    #print("water",water,"sugar",sugar,pp)
                    ans=pp
                    ans1= water+sugar
                    ans2= sugar
print(ans1,ans2)


Measured memory_bytes: 68024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); int w = sc.nextInt();
        int [] a = new int[n+1]; int [] v = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt(); v[i] = sc.nextInt();
        }
        long [][] dp = new long[n+1][w+1];
        for (long [] arr: dp) Arrays.fill(arr, Long.MIN_VALUE);
        dp[0][0] = 0; long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= w; j++) {
                dp[i][j] = Math.max(dp[i][j], dp[i-1][j]);
                if (j - a[i] < 0) continue;
                dp[i][j] = Math.max(dp[i][j], dp[i-1][j - a[i]] + v[i]);
                ans = Math.max(ans, dp[i][j]);
            }
        }
        System.out.println(ans);
    }


}

Measured memory_bytes: 140364
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    bool check = true;
    int dame[9] = {1, 2, 3, 5, 6, 9, 10, 13, 17};
    rep(i,9){
        if(n == dame[i]) check = false;
    }
    cout << (check ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3552
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int r = 0;
        int max = 0;
        for (Character c : n.toCharArray()) {
            if (c == 'R') {
                r++;
            } else {
                max = Math.max(max, r);
                r = 0;
            }
        }
        System.out.println(Math.max(max, r));
	}
}

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

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

    std::vector<int> ps(n);
    for (auto & p : ps) std::cin >> p;

    int answer = 0;
    int min = 200'001;
    for (auto p : ps) {
      if ( p < min ) {
        min = p;
        answer++;
      }
    }

    std::cout << answer << std::endl;
}


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

int main (){

  int cards[4][13],k,l,r,p,num,g;
  char pat;
  
  for(k=0;k<=3;k++){
    
    for(l=0;l<=12;l++){ 
      cards[k][l] = 0;
    }
  }
  
  cin >>r ;
  for(k =0;k <r;k++){
    
    cin >>pat >>num ;

    switch(pat){
    case 'S':
      p = 0;
      break;
    case 'H':
      p = 1;
      break;
    case 'C':
      p = 2;
      break;
    case 'D':
      p = 3;
      break;
    }
    num = num -1;
    cards[p][num] = 1;
  }
  
  for(k=0;k<=3;k++){
    
    for(l=0;l<=12;l++){ 
      g = cards[k][l];
	
      if(g == 0){
	l = l+1;
	switch(k){
	case 0:
	  printf("S %d\n",l);
	  break;
	case 1:
	  printf("H %d\n",l);
	  break;
	case 2:
	  printf("C %d\n",l);
	  break;
	case 3:
	  printf("D %d\n",l);
	  break;
	}
	l = l-1;
      }
      
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int N,M;
    cin>>N>>M;
    vector<pair<ll,int> > ab(N);

    for(int i=0;i<N;i++){
        int b;
        ll a;
        cin>>a>>b;
        ab[i] = make_pair(a,b);
    }
    sort(ab.begin(),ab.end());

    ll res = 0;
    int cnt = M;
    for(int i=0;i<N;i++){
        if(cnt<=0)break;

        if(cnt>=ab[i].second){
            cnt -= ab[i].second;
            res += ab[i].first*ab[i].second;
        }else{
            res += ab[i].first * cnt;
            cnt = 0;
        }    
    }
    cout<<res;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
	static final long MOD = 1000000007;
	static final int MAX = 200001;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int[] vals = new int[N];
		Set<Integer>[] got = new Set[MAX];
		for (int i = 0; i < vals.length; i++) {
			vals[i] = sc.nextInt();
			Set<Integer> gg = got[vals[i]];
			if (gg == null) {
				gg = new HashSet<>();
				got[vals[i]] = gg;
			}
			gg.add(i);
		}
		long[] table = new long[N+1];
		long[] sum = new long[MAX];
		table[N] = table[N-1] = 1;
		sum[vals[N-1]] = 1;
		for (int i = N-2; i >= 0; i--) {
			table[i] = table[i+1];
			if (vals[i] != vals[i+1]) {
				table[i] += sum[vals[i]];
				table[i] %= MOD;
				sum[vals[i]] += table[i+1];
				sum[vals[i]] %= MOD;
			}
		}
		out.println(table[0]);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 80488
using System;
 
class Program
{
    static void Main()
    {
        var data1 = Console.ReadLine().Split(' ');
        int n = int.Parse(data1[0]);
        int m = int.Parse(data1[1]);
        int[,] A = new int[n, m];
        int[]  B = new int[m];
 
        for (int i = 0; i < n; i++)
        {
            var data2 = Console.ReadLine().Split(' ');
            for (int j = 0; j < m; j++)
            {
                A[i, j] = int.Parse(data2[j]);
            }
        }
        for (int i = 0; i < m; i++)
        {
            B[i] = int.Parse(Console.ReadLine());
        }
        for (int i = 0; i < n; i++)
        {
            int a = 0;
            for (int j = 0; j < m; j++)
            {
                 a += A[i, j] * B[j];
            }
            Console.WriteLine(a);
        }
    }
}

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

int main() {
  ll k,a,b;
  cin >> k >> a >> b;
  if(a+2<b) {
    if(k-a+1>0) {
      cout << a+(k-a+1)/2*(b-a)+(k+1-a)%2 << endl;
    }
    else {
      cout << k+1 << endl;
    }
  }
  else {
    cout << k+1 << endl;
  }
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll k,n;cin>>k>>n;
	vi a(n),b(n);
	rep(i,0,n) cin>>a[i],b[i]=k-a[i];
	ll mx = *max_element(a.begin(), a.end());
	ll mn = *min_element(a.begin(), a.end());

	ll ans = mx-mn;
	rep(i,1,n) ans=min(ans,k-(a[i]-a[i-1]));
	cout<<ans<<"\n";

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("No"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  vi b(n);
  cin>>a>>b;
  ll s = 0;
  rep(i,n) s -= a[i];
  rep(i,n) s += b[i];
  if (s < 0) dame;
  ll sa = 0, sb = 0;
  rep(i,n) {
    ll d = a[i] - b[i];
    if (d < 0) {
      d = -d;
      sa += (d+1)/2;
      sb += d%2;
    } else {
      sb += d;
    }
  }
  if (s < sa) dame;
  if (s < sb) dame;
  cout<<"Yes"<<endl;
  return 0;
}






















Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> arrays = new ArrayList<Integer>();
		for(int i=0; i<10; i++) {
             int a = sc.nextInt();
             arrays.add(a);
		}

		Collections.sort(arrays);

		for(int j = arrays.size(); j >arrays.size()-3; j--) {
			System.out.println(arrays.get(j - 1));
		}
	}

}

Measured memory_bytes: 26244
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s, t;
    cin >> s >> t;

    int n = s.size();

    int r = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3796
n = int(input())
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
    s = input()
    if s == 'AC':
        c1 += 1
    elif s == 'WA':
        c2 += 1
    elif s == 'TLE':
        c3 += 1
    else:
        c4 += 1
print('AC x %d' % c1)
print('WA x %d' % c2)
print('TLE x %d' % c3)
print('RE x %d' % c4)

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


int main (){
    int N;
    cin>>N;
    vector <int> P(N);
    int Sum=0;
    for(int i =0; i<N; i++){
        cin>>P.at(i);
        Sum+= P.at(i);
    }
    sort(P.begin(), P.end());
    cout<<Sum-P.at(N-1)/2<<endl;
}

Measured memory_bytes: 256
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	string cad;
	cin >> cad;
	bool ok = cad[2] == cad[3] && cad[4] == cad[5];
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
ryori_list = list(map(int, input().split()))
manzoku_list = list(map(int, input().split()))
tuika_list = list(map(int, input().split()))

point = 0
before_r = 100
for r in ryori_list:
    point += manzoku_list[r-1]
    if r == before_r + 1:
        point += tuika_list[before_r-1]
    before_r = r
print(point)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll MOD=(ll)1e9+7;
ll qpow(ll a,ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
ll c(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        ret*=qpow(i,MOD-2);
        ret%=MOD;
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
ll p(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        /* ret*=qpow(i,MOD-2);
        ret%=MOD; */
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<c(n-1,k-1)<<endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

void InpAr(int *array, int n){
    REP(i,n) cin >> array[i];
}

int main(void){
    string s, t;
    cin >> s >> t;
    cout << t << s;
    
    return 0;
}

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

int calc(char s[]){
	int d;
	int sum=0;
	int count=0;

	while(1){
		d = s[count];
		if((d>=48) && (d<=57)){
			sum+=(s[count]-48);
		}else{
			break;
		}
		count++;
	}

	return sum;
}

int main(void){
	char s[1000];

	while(1){
		scanf("%s",s);
		if(s[0]=='0'){break;}
		printf("%d\n",calc(s));
		//printf("%s\n",s);
	}
}


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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int cnt = 0;
    while (b <= a)
        b *= 2, cnt++;
    while (c <= b)
        c *= 2, cnt++;

    if (cnt <= k)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}

//      *   *  *****  *   *  *   *   ****  ****    ****     **    **
//     *   *  *      **  *  *   *  *      *   *  *        * *   * *
//    *****  *****  * * *  *   *  *      ****   *       *  *     *
//   *   *      *  *  **  *   *  *      *  *   *       *****    *
//  *   *  *****  *   *   ***    ****  *   *    ****     *   *****

//      *****  *****  *   *  *      *****  *   *  *****  *****
//        *   *   *  *   *  *        *    **  *    *    *   *
//       *   *   *  *****  *        *    * * *    *    *****
//   *  *   *   *    *    *        *    *  **    *    *
//  ****   *****    *    *****  *****  *   *    *    *


Measured memory_bytes: 3640
s = gets.chomp

prefix = 7
7.times do |i|
  l = i + 1
  if s[0, l] != 'keyence'[0, l]
    prefix = l - 1
    break
  end
end
suffix = 7
7.times do |i|
  l = i + 1
  if s[-l, l] != 'keyence'[-l, l]
    suffix = l - 1
    break
  end
end
if prefix + suffix >= 7
  puts('YES')
else
  puts('NO')
end


Measured memory_bytes: 1788
#![allow(unused)]

use std::cmp::{max, min};
use std::io::stdin;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|x| x.parse()).collect()
}

fn main() {
    let (x, y): (usize, usize) = {
        let v = input_vec().unwrap();
        (v[0], v[1])
    };

    let mut ans = (0..)
        .map(|i| x * 2usize.pow(i as u32))
        .take_while(|i| *i <= y)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

string s;
long long dp[100010][13];
const long long MOD = 1000000007;
int main() {
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;

    rep(i, 0, n) {
        int t;
        if(s[i] == '?') {
            t = -1;
        } else {
            t = s[i] - '0';
        }

        rep(j, 0, 13) {
            if(t != -1) {
                int nx = (j * 10 + t) % 13;
                dp[i + 1][nx] += dp[i][j];

            } else {
                rep(k, 0, 10) {
                    int nx = (j * 10 + k) % 13;
                    dp[i + 1][nx] += dp[i][j];
                }
            }
        }
        rep(j, 0, 13) { dp[i + 1][j] %= MOD; }
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int mod = 1000000007;
        long[] dp = new long[K + 1];
        dp[0] = 1;
        for(int i = 0; i < N; i++){
            for(int j = K - a[i] - 1; j >= 0; j--) {
                dp[j + a[i] + 1] += mod - dp[j];
                if(dp[j + a[i] + 1] >= mod) dp[j + a[i] + 1] -= mod;
            }

            for(int j = 0; j <= K; j++){
                if(j > 0) {
                    dp[j] += dp[j - 1];
                    if(dp[j] >= mod) dp[j] -= mod;
                }
            }
        }
        System.out.println(dp[K]);
        /*
        long[][] dp = new long[N + 1][K + 1];
        dp[0][0] = 1;

        for (int i = 1; i <= N; i++) {
            dp[i][0] = 1;
            for (int j = 0; j < K; j++) {
                dp[i][j + 1] = dp[i][j] + dp[i - 1][j + 1];
                if (dp[i][j + 1] >= m) dp[i][j + 1] -= m;
                if (j - a[i] >= 0) {
                    dp[i][j + 1] -= dp[i - 1][j - a[i]];
                    if (dp[i][j + 1] >= m) dp[i][j + 1] -= m;
                }
            }

        }
        System.out.println(dp[N][K]);
         */
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, a, b, c, x, y);
  c *= 2;

  int ans = 1001001001;
  rep(i, 100001) {
    int z = i * c + max(0, x - i) * a + max(0, y - i) * b;
    ans = min(ans, z);
  }

  cout << ans << endl;
}

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

string S;

bool f(int x) {
    for(int i = 0; i < 26; i++) {
        int len = 0;
        bool ok = true;
        for(int j = 0; j < S.size(); j++) {
            if(S[j] == 'a' + i) len = 0;
            else len++;
            if(len > x) {
                ok = false;
                break;
            }
        }
        if(x < len) ok = false;
        if(ok) return true;
    }
    return false;
}

int main() {
    cin>>S;
    int s = 0, e = S.size() - 1;
    int x;
    while(s <= e) {
        int m = (s + e)>>1;
        if(f(m)) {
            x = m;
            e = m - 1;
        }
        else s = m + 1;
    }
    printf("%d", x);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/agc022_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;

  int N = S.size();
  vector<int> c(26, 0);
  rep(i, N) { c[S[i] - 'a']++; }

  if (N < 26) {
    rep(i, 26) {
      if (!c[i]) {
        cout << S << char('a' + i) << endl;
        return 0;
      }
    }
  }
  for (int i = N - 1; i >= 1; i--) {
    // printf("%c %c %d\n", S[i - 1], S[i], S[i - 1] < S[i]);
    c[S[i] - 'a']--;
    if (S[i - 1] < S[i]) {
      rep(j, 26) {
        char t = ('a' + j);
        if (!c[j] && t > S[i - 1]) {
          cout << S.substr(0, i - 1) << char(t) << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int x,a; cin >> x >> a;
  int ans=10;
  if (x<a) ans = 0;
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 256
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;
fn main() {
    input! {
        l: i32, r: i32
    }

    let mut ans = std::i32::MAX;
    for i in l..min(r+1, l+2020) {
        for j in i+1..min(r+1, l+2020) {
            ans = min(ans, (i % 2019) * (j % 2019) % 2019)
        }
    }

    println!("{}", ans);
}


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

int main(){
	string N;
	cin>>N;
	int S=0;
	rep(i,N.size()){
		S+=N[i]-'0';
	}
	if(stoi(N)%S==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
// AT - A - Haiku

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

int main(){
  string s; cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == ',')
      cout <<" ";
    else
      cout << s[i];
  }
  cout <<"\n";
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int m1,d1,m2,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define LL long long
#define maxn 100005
using namespace std;
int n,a[maxn],deg[maxn],cnt[maxn];
bool vis[maxn];
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt; deg[u]++;
}
void dfs(int u,int fa)
{
	if(deg[u]==1) { cnt[u]=a[u]; return; }
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs(v,u);
		cnt[u]+=2*a[v]-cnt[v];
		if(2*a[v]-cnt[v]>a[v]||2*a[v]-cnt[v]>a[u]||cnt[u]>2*a[u]) { printf("NO\n"); exit(0); }
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	if(n==2) { printf("%s\n",a[1]==a[2]?"YES":"NO"); return 0; }
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(deg[i]!=1)
		{
			dfs(i,0); 
			if(cnt[i]!=2*a[i]) { printf("NO\n"); return 0; }
			break;
		}
	printf("YES\n");
}


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

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    long long ans = 0;
    int count = 0;
    while (!s.empty()) {
        int n = s.size();
        if (s.back() == 'A') {
            ans += count;
            s.pop_back();
            continue;
        }
        if (s.size() < 3) {
            break;
        }
        if (s[n-2] == 'B' && s[n-1] == 'C') {
            count++;
            s.resize(n-2);
        }
        else {
            count = 0;
            s.pop_back();
        }
    }
    cout << ans << '\n';
}


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

int top,S[1000]; //

void push(int x);     //topを1つ増やし、S[top]にxを代入
int pop();            //S[top]の値を返し、topを1つ減らす

int main(void){
    int a,b;
    top=0;
    char s[100];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if(s[0]=='-'){
            b=pop();     //後入れ先出しに注意
            a=pop();
            push(a-b);
        }else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{           //数字のとき
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    return 0;
}

void push(int x){
    S[++top]=x;
}

int pop(){
    top--;
    return S[top+1];
}



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int d=0, r=0;
		double f=0.00000; 
		
		d = a/b;
		r = a%b;
		f = (double)a/b;
		
		System.out.println(d+" "+r+" "+String.format("%5f", f));	
	}
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    ll ans = 0;
    while (n>0) {
        ans++;
        n/=k;
    }
    cout << ans << '\n';
    return 0;
}

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

#define lson l, m, rt*2
#define rson m + 1, r, rt*2+1
#define xx first
#define yy second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;

const int N = 1e5 + 10, inf = 1<<20;
int a[N], cost[N];

vector<int> tree[N];

void dfs(int u) {
  int sz = tree[u].size();
  vector<int> vec;
  for (int i = 0; i < (int)tree[u].size(); i++) {
    int v = tree[u][i];
    dfs(v);
    vec.push_back(cost[v]);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < sz; i++) {
    cost[u] = max(cost[u], vec[i] + sz - i);
  }
}

int main() {
#ifdef JUDGE
  freopen("case.in", "r", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    scanf("%d", a + i);
    tree[a[i]].push_back(i);
  }
  dfs(1);
  cout << cost[1] << endl;
  return 0;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=2e5+23;
const int mod=1e9+7;
int a[maxn],b[maxn],n;
int cnt=3,tot=1e5,A=0,B=1,tA,tB,A0,A1,B0,B1;
int pow2[110],p1[110],p2[110],cur[110];

void work1(){
	for(int i=30;i>=0;i--){
		printf("+ %d %d %d\n",pow2[i],A0,A1);
		p1[i] = ++cnt;
		printf("< %d %d %d\n",A1,tA,p1[i]);
		cur[0] = ++tot;
		printf("+ %d %d %d\n",p1[i],cur[0],cur[0]);
		for(int j=1;j<=i;j++){
			cur[j]=++tot;
			printf("+ %d %d %d\n",cur[j-1],cur[j-1],cur[j]);
		}
		printf("+ %d %d %d\n",A0,cur[i],A0);
	}
}

void work2(){
	for(int i=30;i>=0;i--){
		printf("+ %d %d %d\n",pow2[i],B0,B1);
		p2[i]=++cnt;
		printf("< %d %d %d\n",B1,tB,p2[i]);
		cur[0]=++tot;
		printf("+ %d %d %d\n",p2[i],cur[0],cur[0]);
		for (int j=1;j<=i;++j){
			cur[j]=++tot;
			printf("+ %d %d %d\n",cur[j-1],cur[j-1],cur[j]);
		}
		printf("+ %d %d %d\n",B0,cur[i],B0);
	}
}

void work3(){
	for(int i=0;i<=30;i++){
		for(int j=0;j<=30;j++) {
			cur[0]=++tot;
			printf("+ %d %d %d\n",p1[i],p2[j],cur[0]);
			printf("< %d %d %d\n",pow2[0],cur[0],cur[0]);
			for(int k=1;k<=i+j;k++) {
				cur[k]=++tot;
				printf("+ %d %d %d\n",cur[k-1],cur[k-1],cur[k]);
			}
			printf("+ %d %d %d\n",2,cur[i+j],2);
		}
	}
}

int main(){
	puts("32925");
	puts("+ 0 1 3");
	puts("< 4 3 3");
	pow2[0]=3;
	for(int i=1;i<=30;i++){
		pow2[i]=++cnt;
		printf("+ %d %d %d\n",pow2[i-1],pow2[i-1],pow2[i]);
	}
	tA=++cnt,tB=++cnt;
	printf("+ %d %d %d\n",A,pow2[0],tA);
	printf("+ %d %d %d\n",B,pow2[0],tB);
	A0=++tot,A1=++tot,B0=++tot,B1=++tot;
	
	work1();
	work2();
	work3();	
}

Measured memory_bytes: 3760
// 2013/04/19 Tazoe

#include <iostream>
#include <vector>
using namespace std;

bool isSequence(vector<int>& t)
{
	for(int i=1; i<t.size()-1; i++){
		if(t[i+1]-t[i]!=t[1]-t[0])
			return false;
	}

	return true;
}

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

		if(n==0)
			break;

		vector<int> h(n+1);
		for(int i=0; i<n+1; i++){
			cin >> h[i];
		}

		for(int i=0; i<n+1; i++){
			vector<int> tmp = h;
			tmp.erase(tmp.begin()+i);

			if(isSequence(tmp)){
				cout << h[i] << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef pair<ll, ll> l_l;
    typedef pair<int , int> i_i;
    typedef vector<ll> vl;
    typedef vector<int> vi;
    typedef vector<char> vec;
    typedef vector<bool> veb;
    typedef vector<string> ves;
    typedef vector<vector<ll>> vvl;
    typedef vector<vector<int>> vvi;
    typedef vector<vector<char>> vvec;
    typedef vector<vector<bool>> vveb;
    typedef vector<vector<string>> vves;
    #define rep(i,n) for(int i=0;i<(int)(n);i++)
    #define rep1(i,n) for(int i=1;i<(int)(n);i++)
    #define rep2(i,n) for(int i=2;i<(int)(n);i++)
    #define repk(i,k,n) for(int i=k;i<(int)(n);i++)
    #define fs first
    #define sc second
    #define pb push_back
    #define pp pop_back
    #define all(a) a.begin(),a.end()
    #define rall(a) a.rbegin(),a.rend()
    #define maxel(a) *max_element(all(a))
    #define minel(a) *min_element(all(a))
    #define acc accumulate
    #define EPS (1e-7)
    #define INF (1e9)
    #define PI (acos(-1))
    #define mod (1000000007)
    typedef long long int64;
    //const int64 INF = 1LL << 58;
    #define dame { puts("-1"); return 0;}
    #define YES { cout << "YES" << endl; return 0; }
    #define NO { cout << "NO" << endl; return 0; }
    #define Yes { cout << "Yes" << endl; return 0; }
    #define No { cout << "No" << endl; return 0; }
    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 (a>b) { a=b; return 1; } return 0; }
    int dx[] = {0, 0, -1, 1};
    int dy[] = {1, -1, 0, 0};
     
    int main(){
    	cin.tie(0);
    	ios::sync_with_stdio(false);
     
		int n;
      	cin >> n;
      	
      	map<string,int> mp;
      	rep(i,n){
        	string s;
          	cin >> s;
          	mp[s]++;
        }
      	int mx=0;
      	for(auto p : mp) mx = max(mx,p.second);
      	for(auto p :mp){
        	if(p.second == mx) cout << p.first << endl;
        
        }
       	return 0;
    	
    }

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

#define SIZE 3

using namespace std;

int main() {
	string str, value[SIZE] = {"the", "this", "that"};
	bool judge;
	while (getline(cin, str)) {
		judge = false;
		for (;;) {
			for (int j = 0; j < str.size(); j++) {
				if ('a' <= str[j] && str[j] <= 'y') {
					str[j]++;
				}
				else if (str[j] == 'z') {
					str[j] = 'a';
				}
			}

			for (int j = 0; j < SIZE; j++) {
				if (str.find(value[j]) != str.npos) {
					judge = true;
				}
			}

			if (judge) {
				cout << str << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
#define kokekoke int 
#define wannwann int 
using namespace std;


int main(){
    kokekoke N,a=0,b=0,c,d,count;
    int ans=0;
    vector<wannwann> aheahe;


    cin>>N;

    for(int i=0;i<N;i++){ 
        cin>>count;
        aheahe.push_back(count);
    }

    sort(aheahe.begin(), aheahe.end(),greater<int>());

    for(int i=0;i<N;i++){
        if(i%2==0){
            a=a+aheahe[i];
        }else{ 
            b=b+aheahe[i];
        }
    }

    cout<< a-b <<endl;

}

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

int A[2000001], H=1;

void swap(int a, int b){
  int temp=0;

  temp = A[a];
  A[a] = A[b];
  A[b] = temp;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void insert(int i){
  int p = parent(i);
  if(p == 0) return;

  if(A[i] > A[p]) {
    swap(i, p);
    insert(p);
  }
}

void extract(int i){
  int l = left(i);
  int r = right(i);
  int largest;

  if(l<=H && A[l]>A[i]) largest = l;
  else  largest = i;

  if(r<=H && A[r]>A[largest]) largest = r;

  if(largest != i){
    swap(i, largest);
    extract(largest);
  }
}

void printer(){
    for(int i=1; i<H; i++){
      printf("%d ",A[i]);
    }
    puts("");
}

int main(){
  char cmd[10];

  while(scanf("%s ",cmd) != EOF){
    if(!strcmp(cmd, "end")) break;
    else if(!strcmp(cmd, "extract")) {
      printf("%d\n",A[1]);
      A[1] = A[--H];
      extract(1);
    } else {
      scanf("%d ",&A[H]);
      insert(H++);
    }
    // printf("%s\n",cmd);
    // printer();
  }
  return 0;
}



Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define FastIO ios::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
typedef long long ll;


int main()
{
	FastIO;
	int n;
	cin >> n;
	int x = 0;
	for (int i = 1; i <= n; i++) {
		if (i & 1) x++;
	}
	cout << (double)x / n;
}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

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

    string s; cin >> s;

    size_t N = s.length();
    int head = INF, tail = 0;
    for (int i = 0; i < N; ++i) {
        chmin(head, (s[i] == 'A' ? i : INF));
        chmax(tail, (s[i] == 'Z' ? i : 0));
    }

    cout << (tail - head + 1) << "\n";

    return 0;
}


Measured memory_bytes: 720
import math
def main():
    N =int(input())
    sum=0

    X=[0]*N
    Y=[0]*N
    for index in range(N):
        X[index],Y[index]=  map(int, input().split())

    for i in range(N):
        for j in range(N):
            sum += math.sqrt((X[i]-X[j])**2 + (Y[i]-Y[j])**2)
    
    print (sum/N)

    
if __name__ == '__main__':
    main()


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

class Main {

	void solve () {

		int H = in.nextInt(), W = in.nextInt(), h = in.nextInt(), w = in.nextInt();
		out.println(H*W - (h*W + w*H - h*w));
		
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

}

Measured memory_bytes: 21204
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  s.push_back(s[0]);
  s.push_back(s[1]);
  vector<char> t(n + 5);
  
  for(int i = 0; i < 4; i++) {
    if(i < 2) {
      t[0] = 'S';
      t[n + 1] = 'S';
    } else {
      t[0] = 'W';
      t[n + 1] = 'W';
    }
    if(i % 2 == 0) {
      t[1] = 'S';
    } else {
      t[1] = 'W';
    }
    for(int j = 1; j <= n; j++) {
      if(t[j] == 'S') {
        if(s[j] == 'o') {
          t[j + 1] = t[j - 1];
        } else {
          if(t[j - 1] == 'S') {
            t[j + 1] = 'W';
          } else {
            t[j + 1] = 'S';
          }
        }
      } else {
        if(s[j] == 'o') {
          if(t[j - 1] == 'S') {
            t[j + 1] = 'W';
          } else {
            t[j + 1] = 'S';
          }
        } else {
          t[j + 1] = t[j - 1];
        }
      }
    }
    if(t[n] == t[0] && t[n + 1] == t[1]) {
      for(int j = 0; j < n; j++) {
        cout << t[j];
      }
      cout << endl;
      return 0;
    }
    t.clear();
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
import * as fs from 'fs'
import {debug} from '../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').split(' ')

const a = parseInt(input[0], 10)
const b = parseInt(input[1], 10)

const result = a - b * 2

result > 0 ? console.log(result) : console.log(0)

Measured memory_bytes: 7372
using System;

namespace ABC047
{
    class C
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            int count = 0;
            for (int i = 0; i < S.Length - 1; i++)
            {
                if (S[i] != S[i + 1]) { count++; }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11488
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Raag4924 ios_base::sync_with_stdio(0);
#define fastio cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Raag4924
    fastio
 
  
  
    int n;
    cin>>n;

    int arr[n+1][3];

    for(int i=1;i<=n;i++)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

    int dp[n+1][3];

    memset(dp,0,sizeof dp);

    for(int i=0;i<3;i++)
    dp[1][i] = arr[1][i];

    for(int i=2;i<=n;i++)
    {
        dp[i][0] = arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = arr[i][2]+max(dp[i-1][1],dp[i-1][0]);

    }
 
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))

sum = 0
b = a[1:]
x = 0

for i, j in zip(a, b):
    i = i + abs(x)
    x = j - i
    if  x < 0:
        sum += abs(x)
    else:
        x = 0

print(sum)



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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

const int INF = 1001001001;

int main() {
  int H, W, K;
  std::cin >> H >> W >> K;
  std::vector<std::string> S(H);
  rep(i, H) {
    std::cin >> S[i];
  }

  int ans = INF;
  rep(div, 1 << (H - 1)) {
    int g = 0;
    std::vector<int> id(H);
    rep(i, H) {
      id[i] = g;
      if(div >> i & 1) {
        ++g;
      }
    }
    ++g;

    std::vector<std::vector<int>> c(10, std::vector<int>(1005));
    rep(i, H) rep(j, W) {
      c[id[i]][j] += (S[i][j] - '0');
    }

    int num = g - 1;
    std::vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if (now[i] > K) return false;
      return true;
    };
    rep(j, W) {
      if(!add(j)) {
        ++num;
        now = std::vector<int>(g);
        if(!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = std::min(ans, num);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256