akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<cstring>
#include<utility>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int long long
#define pb push_back
#define ppb pop_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define inf 10000000000000000
#define sp setprecision(9)
float pi=3.14159265;
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
void print(vector<int>&v) {
  for (int i = 0; i < v.size(); i++)
    cout << v[i] << " ";
  cout << endl;
}
void print(int arr[],int n)
{
  for(int i=0;i<n;i++)
    cout<<arr[i]<<" ";}

int32_t main() {
  int n;
  cin >> n;
  int k = n - 1;
  int b[k];
  
  for (int i = 0; i < k; i++)
    cin >> b[i];
  
  int a[n];
  a[n - 1] = b[k - 1];
  
  for(int i = n - 2; i > 0; i--) {
    if (b[i] <= b[i - 1]) {
      a[i] = b[i];
      a[i - 1] = b[i - 1];
    } else {
      a[i] = b[i - 1];
      a[i - 1] = b[i - 1];
    }
  }
  
  int sum = 0;
  fr(i, n)
  sum += a[i];
  if (n == 2)
    sum = 2 * b[0];
  cout << sum << endl;
}


Measured memory_bytes: 256
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 2e5+7;
const ll T = 1<<17;
const ld inf = 1e18;
ll m, n, k, q;

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

    string s;
    cin >> s;

    for(auto & u : s)
        cout << (u == '?' ? 'D' : u);
    cout << endl;
}




Measured memory_bytes: 3792
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const MAX = 200002 + 1

	N, C := nextInt(), nextInt()
	pp := make([][MAX]int, C)
	for i := 0; i < N; i++ {
		s, t, c := nextInt(), nextInt(), nextInt()-1
		pp[c][s*2-1]++
		pp[c][t*2]--
	}

	ans := 0
	for i := 1; i < MAX; i++ {
		a := 0
		for j := range pp {
			pp[j][i] += pp[j][i-1]
			if pp[j][i] > 0 {
				a++
			}
		}
		ans = max(ans, a)
	}

	puts(ans)
}


Measured memory_bytes: 50432
#include <iostream>

using namespace std;

int main()
{
	int x, y;

	cin>>x>>y;

	y -= 2 *x;

	if((y>=0) && (y%2==0) && (y<=2*x)) {
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=9223372036854775806;
const int inf=2147483646;
string a;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a;
	if (a[0]==a[1]||a[1]==a[2]||a[2]==a[3])
		cout<<"Bad";
	else 
		cout<<"Good";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	int N;
	cin>>N;
	int sum=0;
	for(int i=1;i<=N;i++){
		sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n, l; cin >> n >> l;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    bool check = false;
    ll ans;
    rep(i,n-1) if(a[i]+a[i+1] >= l) { check = true; ans = i; break; }
    if(!check){ cout << "Impossible" << endl; return 0; }

    cout << "Possible" << endl;
    loop(i,0,ans) cout << i+1 << endl;
    loop(i,1,n-ans) cout << n-i << endl;
    return 0;
}



Measured memory_bytes: 4056
s = input()
n = len(s)
ans1 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != "0":
            ans1 += 1
    else:
        if s[i] != "1":
            ans1 += 1

ans2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] != "1":
            ans2 += 1
    else:
        if s[i] != "0":
            ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll sum = 0;
  int N; cin >> N;
  fN(i,N){ int a; cin >> a; sum += a;} 
  
  //main
  
  
  // output
  cout << sum-N << endl;

  return 0;
}

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

using namespace std;

int diff(const string& S, const string& temp){
	int count = 0;
	for (int i = 0; i < S.length(); i++){
		if(S[i] != temp[i]){
			count++;
		}
	}
	return count;
}

int main(){
	string S, temp1, temp2;
	cin >> S;

	for (int i = 0; i < S.length(); i++){
		temp1 += (i % 2) ? '0' : '1';
		temp2 += (i % 2) ? '1' : '0';
	}

	cout << min(diff(S, temp1), diff(S, temp2)) << endl;
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	int64_t N, K;

	cin >> N >> K;
	vector<int64_t>A;
	vector<int64_t> route;
	for (int64_t i = 0; i < N; i++) {
		int64_t a;
		cin >> a;
		a -= 1;
		A.push_back(a);

	}

	int64_t next = 0;
	vector<int64_t>count(N);
	count[0]++;
	route.push_back(0);

	std::vector<int64_t>::iterator itr;
	std::size_t d;
	for (int64_t i = 0; i < N; i++) {
		count[A[next]]++;
		if (count[A[next]] == 2) {
			itr = std::find(route.begin(), route.end(), A[next]);
			d = std::distance(route.begin(), itr);
			break;
		}
		route.push_back(A[next]);



		next = A[next];

	}

	//8 10
	//	3 1 5 7 4 1 8 4

	int64_t loop;
	loop = route.size() - d;
	
	if (K < route.size()) {
		cout<<route[K]+1;
		return 0;
	}
	else {
		K=K - d ;
		K = K % loop;
		cout << route[d + K]+1;
		return 0;
	}



}

Measured memory_bytes: 9564
#include<bits/stdc++.h>
using namespace std;
int a;
int b,c,d[100];
int main()
{
	
	cin>>a>>b>>c;
	d[1]=a;
	d[2]=b;
	d[3]=c;
	sort(d+1,d+3+1);
	cout<<d[3]-d[1]<<endl;
}

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


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

		int l[] = new int[n];
		
		for(int i=0; i<n; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		
		int p = 0;
		
		for(int i=0; i<n-2;i++) {
			for(int j=i+1; j<n-1; j++) {
				for(int k=j+1; k<n; k++){
					
					if(
					   l[j] < l[k] + l[i] &&
					   l[k] < l[i] + l[j]    ) {
						p++;
					}
					
				}
			}
		}
		
		
		System.out.println(p);
		sc.close();
	}

}

Measured memory_bytes: 28812
// Author : Epsilon573
// If it works, don't touch it.

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ll mod  = 1e9+7;
const ld eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

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

    ll n;
    cin >> n;

    vector<ll> v(n);
    ll mul=1;

    for(ll i=0 ; i<n ; ++i) cin >> v[i];

    if( count(v.begin(),v.end(),0)!=0 )
    {
        cout << 0; return 0;
    }    
    
    for(ll i=0 ; i<n ; ++i)
    {
        if( (ld)v[i] > (ld)1e18/(ld)mul ) 
        {
            cout << -1 ;
            return 0;
        }

        mul *= v[i];
    }

    cout << mul;

    return 0;
} 

Measured memory_bytes: 3992
N = int(input())
S = list(input())
flag=1
count=0

txt = ['A','B','C']
for i in range(N-2):
    for j in range(3):
        if S[i+j]!=txt[j]:
           flag=0
           break
    if flag==1:
        count+=1
    flag=1
print(count)



Measured memory_bytes: 3060
#include<stdio.h>

#include<string.h>
#define max(x,y) ((x)<(y)?(y):(x))
#define REP(i,j,n) for(int i=(j);(i)<(n);(i)++)
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int n;
int x[25],y[25],c[25],r[25];
int b[25];
char dp[1<<24];
int power(int x,int n){
    int ans=1;
    rep(i,n) ans*=x;
    return ans;
}
int intersects(int i,int j){
    int dist1=power(x[i]-x[j],2)+power(y[i]-y[j],2);
    int dist2=power(r[i]+r[j],2);
    return dist2 > dist1;
}
int main(){
    int n;
    while(1){
        scanf("%d",&n);
        if(n==0) break;
        rep(i,n){
            scanf("%d%d%d%d",&x[i],&y[i],&r[i],&c[i]);
            b[i]=0;
            rep(j,i) if(intersects(i,j)) b[i]|=(1<<j);
        }
        int ans=0;
        int to=(1<<n);
        memset(dp,-1,sizeof(dp));
        dp[0]=0;
        rep(i,to){
            if(dp[i]==-1) continue;
            ans=max(ans,(int)dp[i]);
            //消せる円盤のペア(j,k)を探す
            rep(j,n-1){
                //すでに円盤jは消えている or 円盤jの上の円盤が邪魔して消せない
                if((i & (1<<j)) != 0 || (i & b[j]) != b[j]) continue;
                
                for(int k=j+1;k<n;k++){
                    //jとkの色が違う or すでに円盤kは消えている or 円盤kの上の円盤が邪魔
                    if(c[j] != c[k] || (i & (1<<k)) != 0 || (i & b[k]) != b[k]) continue;
                    //next = 円盤jとkを消した状態(ビット管理)
                    int next = i | (1<<j) | (1<<k);
                    dp[next] = max((int)dp[next],dp[i]+2);
                }
            }
        }
        printf("%d\n",ans);
    }
}



Measured memory_bytes: 18124
#include <bits/stdc++.h>
using namespace std;
multiset<long long>s;
vector<long long>v;
long long n;
long long read(){
    long long ans=0;
    char last=' ',ch=getchar();
    while(ch<'0' || ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		v.push_back(read());
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	long long ans=0;
	for(int i=0;i<v.size();i++)
	{
		long long x=v[i];
		if(s.size()==0)
		{
			s.insert(x);
			continue;
		}
		auto it=s.end();
		it--;
		long long num=*it;
		ans+=num;
		s.erase(s.find(num));
		s.insert(x);
		s.insert(x);
	}
	cout<<ans;
}

Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200010],vis[200010];
vector<int>v;
int main(){
   int n;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }int ans=1,mn=a[0];
   for(int i=1;i<n;i++)
   {
       if(a[i]<mn){ans++;mn=a[i];}
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 1000000


int dp[102];
int main(){
	int N;
	int a[3];
	vector<string> res;
	
	while(cin>>a[0]>>a[1]>>a[2]>>N&&a[0]!=0&&a[1]!=0&&a[2]!=0){
		sort(a,a+3);
		double bd=sqrt(a[1]*a[1]+a[0]*a[0]);
		double t;
		REP(i,N){
			cin>>t;
			if(t*2<=bd)cout<<"NA"<<endl;
			else cout<<"OK"<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    long double r;
    cin >> r;
    // printf("%0.20Lf\n", (long double)(2 * 3.141592653589793238 * r));
    long double ans = 2.0 * 3.141592653589793238 * r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
using namespace std;
static const int64_t INFL = 0x3F3F3F3F3F3F3F3FLL;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll x, k;
        in >> x >> k;
        vll r(k + 1);
        rep(i, k) in >> r[i];
        r[k] = INFL;
        ll q;
        in >> q;
        vll t(q), a(q);
        rep(i, q) in >> t[i] >> a[i];
        ll now = 0;
        ll leftPoint = 0;
        ll leftValue = 0;
        ll rightPoint = x;
        ll rightValue = x;
        ll tp = 0;
        rep(i, k + 1) {
            while (tp < q && t[tp] <= r[i]) {
                ll nowA;
                if (a[tp] <= leftPoint) {
                    nowA = leftValue;
                }
                else if (a[tp] >= rightPoint) {
                    nowA = rightValue;
                }
                else {
                    nowA = leftValue + (a[tp] - leftPoint);
                }
                if (i % 2 == 0) {
                    nowA -= (t[tp] - now);
                }
                else {
                    nowA += (t[tp] - now);
                }
                if (nowA < 0) {
                    nowA = 0;
                }
                if (nowA > x) {
                    nowA = x;
                }
                out << nowA << '\n';;
                tp++;
            }
            ll move = r[i] - now;
            if (i % 2 == 0) {
                leftValue -= move;
                if (leftValue < 0) {
                    leftPoint -= leftValue;
                    leftValue = 0;
                }
                rightValue -= move;
                if (rightValue < 0) {
                    rightValue = 0;
                }
            }
            else {
                leftValue += move;
                if (leftValue > x) {
                    leftValue = x;
                }
                rightValue += move;
                if (rightValue >= x) {
                    rightPoint -= (rightValue - x);
                    rightValue = x;
                }
            }
            now = r[i];
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    double a[n];
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0) return 0;
    }
        
    double answer;
    
    double a_inverse[n];
    
    for (int i = 0; i < n; i++)
    {
        a_inverse[i] = 1 / a[i];
    }    
    
    for (int i = 0; i < n; i++)
        answer += a_inverse[i];
        
        
    if (answer == 0)
        return 0;
    
    answer = 1 / answer;
    
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>       // printf,scanf
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;

using namespace std;

void printDir(int cnt,char c){
    REP(i,cnt){
        cout << c;
    }
}

int main(void){

    int sx,sy,gx,gy;
    cin >> sx >> sy;
    cin >> gx >> gy;

    int xDiff = gx - sx;
    int yDiff = gy - sy;

    // 1週目
    printDir(xDiff,'R');
    printDir(yDiff,'U');
    printDir(xDiff,'L');
    printDir(yDiff,'D');

    // 2週目 s → g
    cout << "D";
    printDir(xDiff+1,'R');
    printDir(yDiff+1,'U');
    cout << "L";

    // 2週目 g → s
    cout << "U";
    printDir(xDiff+1,'L');
    printDir(yDiff+1,'D');
    cout << "R";
    cout << endl;
    return 0;
}


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

int six[7] = {1, 6, 36, 216, 1296, 7776, 46656};
int nine[6] = {1, 9, 81, 729, 6561, 59049};

int func(int num, int ans){
    if(num < 6) return ans + num;
    int i6, i9;
    i6 = upper_bound(six, six + 7, num) - six;
    i6 = max(0, i6 - 1);
    i9 = upper_bound(nine, nine + 6, num) - nine;
    i9 = max(0, i9 - 1);
    ans++;
    return min(func(num - six[i6], ans), func(num - nine[i9], ans));

} 

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

    int n;
    cin >> n;

    cout << func(n, 0) << endl;

    return 0;
}


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

total=0
for i in range(N+1):
    N_str=str(i)
    N_sum=sum(list(map(int,N_str)))
    if N_sum<=B and N_sum>=A:
        total+=i
print(total)

Measured memory_bytes: 9188
while 1:
	n=list(raw_input())
	if n==["0"]*4: break
	elif n[0]==n[1]==n[2]==n[3]:
		print "NA"
		continue
	count=0
	while 1:
		if n==["6","1","7","4"]:
			print count
			break
		l=int("".join(map(str,sorted(n)[::-1])))
		s=int("".join(map(str,sorted(n)[n.count("0"):])))
		n=list(str(l-s))
		for i in range(4-len(n)):
			n.insert(0,"0")
		count+=1

Measured memory_bytes: 4236
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  int n = s.size();
  rep(i,n){
    if(s[i]=='P'||s[i]=='D'){
      cout << s[i];
    } else {
      cout << 'D';
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3724
# include <iostream>
using namespace std;
bool binary_search(int *a,int n,int tar)
{
	int left = 0,right = n;
	while(right-left > 3)
	{
		int mid = (left+right)/2;
		if(a[mid] > tar) right = mid;
		else left = mid;
	} 
	for(int i = left;i < right;i++) if(a[i] == tar) return true;
	return false;
}
int main(void)
{
	int *a,ans = 0,n,m,k;
	scanf("%d",&n); a = new int [n];
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	scanf("%d",&m);
	for(int i = 0;i < m;i++) 
	{
		scanf("%d",&k);
		ans += binary_search(a,n,k);
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=3;
    int a[n+1];
    for(int i=1; i<=n; i++) cin >> a[i];
    sort(a+1, a+n+1);
    int m=a[2];
    long long res=0;
    for(int i=1; i<=n; i++){
        res+=abs(a[i]-m);
    }
    cout << res;
    return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int32_t main(){
sp;
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; ++i)
        cin>>a[i];
    map<int,int> mp;
    ++mp[a[0]];
    map<int,int> ::iterator it;
    for(int i=1; i<n; ++i){
        it=mp.lower_bound(a[i]);
        if(it==mp.begin())
            ++mp[a[i]];
        else{
            --it;
            int x=it->first;
            int y=it->second;
            mp.erase(it);
            if(y-1>=1)
                mp[x]=y-1;
            mp[a[i]]++;
        }
    }
    int ans=0;
    for(auto &it:mp)
        ans+=it.second;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 7168
import javax.swing.border.EmptyBorder

fun main(args:Array<String>):Unit{
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    f(n, m)
}
tailrec fun f(n:Int, m:Int):Unit{
    if (n != 0 && m != 0){
        val maxHighScore = Array(n){0}
        val minLowScore = Array(n){0}
        for (i in 1 .. m){
            val args = readLine()!!.split(' ').map(String::toInt).toIntArray()
            for (idx in 2 until args.size){
                maxHighScore[args[idx] - 1] += args[0]
            }
            if (args[1] == 1) minLowScore[args[2] - 1] += args[0]
        }
        val min = minLowScore.mapIndexed { index, i -> Man(index, i) }.sortedBy(Man::score)
        val max = maxHighScore.mapIndexed{index, i -> Man(index, i)}.sortedByDescending(Man::score)
        if (max.first().number != min.first().number){
            println(max.first().score - min.first().score + 1)
        }else{
            println(max(max.first().score - min[1].score, max[1].score - min.first().score) + 1)
        }
        val (nn, mm) = readLine()!!.split(' ').map(String::toInt)
        f(nn, mm)
    }
}
fun max(a:Int, b:Int):Int = if (a > b) a else b
data class Man(val number:Int, val score:Int)


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

typedef long long ll;

int main()
{
	ll a,b,x;
	cin >> a >> b >> x;
	
	if(a==0)
		cout << b/x+1 << endl;
	else if(a==1)
		cout << b/x << endl;
	else
		cout << b/x-(a-1)/x << endl;
	return 0;
}


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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <functional>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(var,init,end) for(int var=init;var<end;var++)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8)
	{
		cout << ":(";
	}
	else {
		cout << "Yay!";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define STU_NUM 30
#define NYUURYOKU 28

using namespace std;

int main(){
	int a[STU_NUM] = { 0 };
	int temp = 0;
	int n[2] = { 0 };

	for(int i = 0; i < NYUURYOKU; i++){
		cin >> temp;
		a[temp - 1] = 1;
	}
	int i, j;

	for(i = 0; i < STU_NUM; i++){
		if(a[i] == 0){
			cout << i + 1 << endl;
		}
	}

	// if(n[0] > n[1]){
	// 	cout << n[0] + " " + n[1] << endl;
	// }else{
	// 	cout << n[1] + " " + n[0] << endl;
	// }
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for (ll i = 0; i < n; ++i)
    {
        if (x < a[i]) break;
        if (i == n - 1 && x != a[i]) break;
        x -= a[i];
        if (x >= 0) ++ans;
        else break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep(i, N) cin >> P[i];
    ll minp = P[0];
    ll ans = 0;
    rep(i, N) {
        if(P[i] <= minp) ans++;
        chmin(minp, P[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<iomanip>
#include<map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1e9 + 7;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };

int w, h;
int s[55][55];
void dfs(int y, int x) {

	s[y][x] = 0;

	for (int i = 0; i < 8; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];

		if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == 1) {
			dfs(ny, nx);
		}


	}


}



int main() {

	while (cin >> w >> h ) {
		if (w == 0)break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> s[i][j];
			}
		}

		int cnt = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == 1) {

					dfs(i, j);
					cnt++;
				}


			}


		}


		cout << cnt << endl;

	}



	return 0;
}



Measured memory_bytes: 3172
import java.util.Scanner;

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

        if ((a * 10 + b) %4 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

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

int main(){
    int n; cin>>n;
    ll ans = 0;
    vector<ll> A(n),B(n);
    for(int i=0; i<n; i++){
        cin >> A[i] >> B[i];
    } 
    for(int i=0; i<n; i++){
        A[n-1-i]+=ans;
        ans += (A[n-1-i]%B[n-1-i]==0?0:(B[n-1-i]-A[n-1-i]%B[n-1-i]));
    }    
    cout << ans << endl;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int p[2*m];
  for (int i = 0; i < 2*m; ++i) cin >> p[i];
  
  int ans[2] = {1, n};
  
  for (int i = 0; i < m; ++i) {
    if ((ans[0] > p[2*i + 1]) || (ans[1] < p[2*i])) {
      ans[0] = 1;
      ans[1] = 0;
      break;
    }
    else if (ans[0] >= p[2*i]) {
      if (ans[1] > p[2*i + 1]) {
        ans[1] = p[2*i + 1];
      }
    }
    else{
      ans[0] = p[2*i];
      if (ans[1] > p[2*i + 1]) {
        ans[1] = p[2*i + 1];
      }
    }
  }
  cout << ans[1] - ans[0] + 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#define endl "\n"

using namespace std;

const long mod = 1e9 + 7;
int N;
long dp[110][6][6][6][6];

long find(int now, int back1, int back2, int back3, int back4) {
  if (dp[now][back1][back2][back3][back4] != -1) {
    return dp[now][back1][back2][back3][back4];
  }
  if (back2==0 and back3==1 and back4==2) {
    return 0;
  }
  if (back2==0 and back3==2 and back4==1) {
    return 0;
  }
  if (back2==1 and back3==0 and back4==2) {
    return 0;
  }
  if (back1==0 and back3==1 and back4==2) {
    return 0;
  }
  if (back1==0 and back2==1 and back4==2) {
    return 0;
  }

  if (now == N) {
    return 1;
  }
  long ans = 0;
  for (int i = 0; i < 4; i++) {
    ans += find(now+1, back2, back3, back4, i);
  }
  return dp[now][back1][back2][back3][back4] = ans % mod;
}

int main() {
  cin >> N;
  memset(dp, -1, sizeof(dp));
  cout << find(0, 4, 4, 4, 4) << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> a(n);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int c;
      cin >> c;
      c--;
      a[c] = true;
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == false) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B._105
{
    class Program
    {
        static void Main(string[] args)
        {
            var num = int.Parse(Console.ReadLine());
            int div_cnt = 0;
            int ans = 0;

            for (int i = 1; i <= num; i++)
            {
                div_cnt = 0;

                for (int j = 1; j <= i; j++)
                    if ((i % 2 == 1) && (i % j == 0)) div_cnt++;

                if (div_cnt == 8) ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b < a) swap(a, b);
    if (c < b) swap(b, c);
    if (b < a) swap(a, b);
    int ans = 0;
    int d = c - b;
    ans += d;
    b += d;
    a += d;
    if ((b - a) % 2 == 0) {
        cout << ans + (b - a) / 2 << endl;
    } else {
        cout << ans + (b - a + 1) / 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = (ll)1000000007;
const ll HIGHINF = (ll)1e18;

ll powmod(ll x, ll k) {
    if (k == 0) return 1;
    else {
        ll tmp = powmod(x, k/2);
        if (k&1) return ((tmp*tmp)%MOD)*x%MOD;
        else return tmp*tmp%MOD;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, c; cin >> n >> c;
    vll a(n); REP(i, n) cin >> a[i];
    vll b(n); REP(i, n) cin >> b[i];
    vvll abc(401, vll(c+1, 0));  // abc[i][j]: iのj乗
    rep(i, 1, 401) abc[i][0] = 1;
    abc[0][0] = 0;
    rep(i, 1, 401) rep(j, 1, c+1) abc[i][j] = abc[i][j-1] * i % MOD;
    rep(i, 1, 401) REP(j, c+1) {
        abc[i][j] += abc[i-1][j];
        if (abc[i][j] >= MOD) abc[i][j] -= MOD;
    }
    vvll dp(n+1, vll(c+1, 0));
    dp[0][0] = 1;
    rep(i, 1, n+1) REP(j, c+1) {
        REP(k, j+1) {
            // cout << abc[b[i]][k]-abc[a[i]-1][k] << '\n';
            ll accsum = abc[b[i-1]][k]-abc[a[i-1]-1][k];
            if (accsum < 0) accsum += MOD;
            dp[i][j] += dp[i-1][j-k] * accsum % MOD;
            if (dp[i][j] >= MOD) dp[i][j] -= MOD;
        }
    }
    cout << dp[n][c] << '\n';
    return 0;
}


Measured memory_bytes: 2816
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  static int mod = 1000000007;

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    String s = cin.next();
    int[] dict = new int[26];

    for (int i = 0; i < n; i++) {
      dict[s.charAt(i) - 'a']++;
    }
//    System.out.println(Arrays.toString(dict));
    long res = dict[0]+1;
    for (int i = 1; i < 26; i++) {
      res = res * (dict[i] + 1) % mod;
    }
    System.out.println(res-1);

  }
}


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

void solve(std::string s) {
    ll ans = 1000;
    rep(i, 26) {
        char c = 'a' + i;
        string tmps = s;
        ll cnt = 0;
        rep(k, tmps.size()) {
            if (tmps[k] == c) {
                cnt++;
            }
        }
        if (cnt == tmps.size()) {
            ans = min(ans, 0LL);
            continue;
        }

        rep(j, s.size() - 1) {
            rep(k, tmps.size()) {
                if (tmps[k] == c || tmps[k + 1] == c) {
                    tmps[k] = c;
                }
            }
            tmps.pop_back();
            ll cnt = 0;
            rep(k, tmps.size()) {
                if (tmps[k] == c) {
                    cnt++;
                }
            }
            if (cnt == tmps.size()) {
                ans = min(ans, j + 1);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var ok = true
    for (i in 1..n - k) {
        println(if (a[i - 1] < a[k + i - 1]) "Yes" else "No")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 58760
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  int res=0;
  if(a+b<2*c)
  {
    res=x*a+y*b;
  }
  else if((x<y&&b<2*c)||(x>=y&&a<2*c))
  {
    res=x*a+y*b-min(x,y)*((a+b)-2*c);
  }
  else
  {
    res=max(x,y)*2*c;
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 256
def dist(a, b):
  if a * b < 0:
    return 2 * min(abs(a), abs(b)) + max(abs(a), abs(b))
  else:
    return max(abs(a), abs(b))

def solve(A, K):
  ans = dist(A[0], A[K-1])
  for i in range(len(A)-K+1):
    ans = min(ans, dist(A[i], A[i+K-1]))
  return ans
               
N, K, *A = map(int, open(0).read().split())
print(solve(A, K))

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

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int main() {

    int n;
    cin>>n;
    ANS(n*n);
    return 0;
}


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

int main() {
	ll h;
	cin>>h;
	
	int count=0;
	while(h>1){
		h=h/2;
		count++;
	}
	
	ll ans=pow(2,count+1)-1;
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int dx = x2 - x1;
  int dy = y2 - y1;
  int x = x2;
  int y = y2;
  
  for (int i = 0; i < 2; i++) {
    int nx = -dy;
    int ny = dx;
    x += nx;
    y += ny;

    dy = ny;
    dx = nx;
    cout << x << " " << y;
    if (i) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n+1);
  rep2(i, n) cin >> a[i];
  
  vl plus(n+1), minus(n+1);
  rep2(i, n) {
    plus[min(i+a[i], n)]++;
    minus[max(i-a[i], ll(0))]++;
  }
  
  ll ans=0;
  rep2(i, n-1) ans += plus[i] * minus[i];
  cout << ans << newl;
  return 0;
}

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

#define sz 100005
#define nl printf("\n");
#define ll long long int

char f,g;
bool flag;
pair < int ,int > pi;
map < int , int > mp;
vector < int > v,va,vb;
int arr[sz],brr[sz],crr[sz];



int main(){

    int ans=INT_MAX;
    int n,m, i,j,k, x=0,y=0,z=0, a,b,c;

    cin>>n>>m;
    for(i=1; i<=n; i++){
        cin>>a>>b;
        if(b<=m and a<ans)
            ans=a;
    }
    if(ans==INT_MAX)cout<<"TLE"<<endl;
    else cout<<ans<<endl;


    return 0;

}


Measured memory_bytes: 764
#!/usr/bin/env python3
#ARC85 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

"""
山札がなくなると終了かつ必ず1枚は引かなくてはいけない
⇒最後の1枚は必ずどちらかの手になる(山札が1枚の場合、必ず自分の手になる)
先攻はそれを自分の手にするか、相手の手にするかを選べる
自分の手にする場合、1ターン目で全部の手札を取る
相手の手にする場合、1ターン目で最後から2番目まで全部取る
この2通りなのでこれの大きい方を選択
"""
n,z,w = LI()
a = LI()
if n == 1:
    ans = abs(a[0] - w)
else:
    ans = max(abs(a[-2]-a[-1]),abs(a[-1]-w))
print(ans)

Measured memory_bytes: 40304
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n, m) = get!(usize, usize);
    for i in 0..m {
        if i % 2 == 0 {
            println!("{} {}", i / 2 + 1, i / 2 + 1 + m - i);
        } else {
            println!("{} {}", m + i / 2 + 2, m + i / 2 + 2 + m - i);
        }
    }
}


Measured memory_bytes: 2240