akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int cmp1(int a,int b){
	return a<b;
}
int cmp2(int a,int b){
	return a>b;
} 
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int l[m],r[m];
	for(int i=0;i<m;i++)
		scanf("%d%d",&l[i],&r[i]);
	sort(l,l+m,cmp2);
	sort(r,r+m,cmp1);
//	cout<<l[0]<<' '<<r[0]<<endl;
	int ans=r[0]-l[0]+1;
	if(ans<0)
		ans=0;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
def main():
    N, M = list(map(int, input().split()))
    if (N==1)and(M==1):
        return 1
    elif N == 1:
        return M-2
    elif M == 1:
        return N-2
    else:
        return N*M - (2*(N+M)-4)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  
  double l=0,r=inf;
  rep(i,0,100){
    double m=(l+r)/2;
    ll tot=0;
    rep(i,0,n) tot+=ll((a[i]-1)/m);
    if(tot>k) l=m;
    else r=m;
  }
  
  cout << ll(ceil(r)) << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
long long n,l=1,r=3,a,b,c,d,Min,s[200010],x,y;
int main()
{
	cin>>n;
	Min=2e9;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		s[i]=s[i-1]+x;
	}
	for(int i=2;i<n;i++)
	{
		while(l<i&&abs(s[i]-s[l+1]*2)<=abs(s[i]-s[l]*2))l++;
		while(r<n&&abs(s[n]-s[r+1]*2+s[i])<=abs(s[n]-s[r]*2+s[i]))r++;
		a=s[l];
		b=s[i]-s[l];
		c=s[r]-s[i];
		d=s[n]-s[r];
		x=min(min(a,b),min(c,d));
		y=max(max(a,b),max(c,d));
		Min=min(Min,y-x);
	}
	cout<<Min;
	return 0;
}

Measured memory_bytes: 5292
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  ll ans = 0;
  set<ll> s;
  if (d.size() % 2 == 0) {
    sort(d.begin(), d.end());
    for (int k = d[0]; k <= d[N - 1]; k++) {
      if (s.find(k) != s.end()) continue;
      bool left = d[N / 2 - 1] < k;
      bool right = d[N / 2] >= k;
      if (left && right) {
        ans++;
      }
      s.insert(k);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	fibo := make([]int, n+1)
	fibo[0] = 1
	fibo[1] = 1

	for i := 2; i <= n; i++ {
		fibo[i] = fibo[i-1] + fibo[i-2]
	}

	fmt.Println(fibo[n])
}



Measured memory_bytes: 1148
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr int INF = 0x3f3f3f3f;
int main() {
  int n;
  cin >> n;

  vector<int> cnt(26, INF);
  rep(i, 0, n) {
    string s;
    cin >> s;
    vector<int> tmp(26);
    for (char c : s) tmp[c - 'a']++;
    rep(i, 0, 26) { cnt[i] = min(cnt[i], tmp[i]); }
  }

  string ans = "";
  rep(i, 0, 26) { rep(j, 0, cnt[i]) ans += (char)(i + 'a'); }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int i, len, cnt=0;
	char str[32], str2[32]; // 20文字だから、これくらい

	scanf("%s", str);

	len = strlen(str);
	for(i=len-1; i>-1; i--){
		str2[cnt++] = str[i];
	}
	// 文字列の末尾には、必ずヌル文字\0 を入れる。
	str2[cnt] = '\0';

	printf("%s\n", str2);

	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int N,T,A,ans;
    cin>>N;
    double H[N]={},sub=MAX;
    cin>>T>>A;
    for(int i=0;i<N;i++){
        cin>>H[i];
        H[i]=(double)T-H[i]*0.006;
        if(H[i]>=A & H[i]-A<sub){
            sub=H[i]-A;
            ans=i+1;
        }else if(H[i]<A & A-H[i]<sub){
            sub=A-H[i];
            ans=i+1;
        }
    }
    cout<<ans<<endl;

    return 0;
}


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

#define M 1008001
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  int i, j;
  int key;
  
  i = 0;
  key = getKey(str);
  
  while(1){
    j = (h1(key) + i*h2(key)) % M;

    if(strcmp(H[j], str)==0)
      return 1;

    else if(H[j][0]=='\0' || i>=M){
      return 0;
    }
    
    else
      i++;
  }
}

int insert(char str[]){
  int i, j;
  int key;

  i = 0;
  key = getKey(str);

  while(1){
    j = (h1(key) + i*h2(key)) % M;

    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }
    
    else
      i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15544
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265359
int main(){
    int N;cin>>N;N=N%26;
    string S;cin>>S;
    int tmp=0;
    size_t size=S.length();
    for(int i=0;i<size;i++){
        if(S[i]+N<=90){
            S[i]=S[i]+N;
        }
        else if(S[i]+N>90){
            tmp=(S[i]+N)-90;
            S[i]=tmp+'A'-1;
        }
    }
    cout<<S;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  string s;
  cin>>s;
  if(s.size()%2==1){
    int mid=s.size()/2;
    char c=s[mid];
    int res=mid;
    for(int i=0;i<=mid;i++){
      if(s[mid+i]!=c || s[mid-i]!=c){
	break;
      }
      res++;
    }
    cout<<res<<endl;
  }
  else{
    if(s[s.size()/2]!=s[s.size()/2-1]){
      cout<<s.size()/2<<endl;
    }
    else{
      int mid=s.size()/2;
      char c=s[mid];
      int res=mid;
      for(int i=0;i<=mid;i++){
	if(s[mid+i]!=c || s[mid-1-i]!=c){
	  break;
	}
	res++;
      }
      cout<<res<<endl;
    }

  }
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		if (b.charAt(0)=='A'){
			System.out.println('T');
		}else if (b.charAt(0)=='C'){
			System.out.println('G');
		}else if (b.charAt(0)=='G'){
			System.out.println('C');
		}else{
			System.out.println('A');
		}
	}

}


Measured memory_bytes: 35484
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int r,g,b,n;
   cin>>r>>g>>b>>n;
   ll ans=0;
   for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
         int k=n-(i*r)-(j*g);
         if(k%b!=0 or k<0)continue;
         if(i*r+j*g+k==n)ans++;
      }
   }
   cout<<ans<<endl;
   return 0;    
}

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

using namespace std;
typedef long long ll;
const int MAXN = 310;
const ll MOD = 1e9 + 7;

int N, M;
vector <pair <int, int> > cond[MAXN];
ll dp[MAXN][MAXN][MAXN]; //

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int l, r, x;
        cin >> l >> r >> x;
        cond[r].push_back(make_pair (l, x));
        if (r == 1 && x != 1)
        {
            cout << "0\n";
            return 0;
        }
    }

    dp[1][0][0] = 3;
    for (int i = 2; i <= N; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            for (int k = 0; k <= j; k++)
            {
                if (!dp[i-1][j][k]) continue;
                dp[i][j][k] += dp[i-1][j][k];
                dp[i][i-1][k] += dp[i-1][j][k];
                dp[i][i-1][j] += dp[i-1][j][k];
            }
        }

        for (int j = 0; j <= i; j++)
        {
            for (int k = 0; k <= j; k++)
            {
                if (!dp[i][j][k]) continue;
                dp[i][j][k] %= MOD;
                for (pair <int, int> c : cond[i])
                {
                    int l = c.first, v = c.second;
                    if (v == 1 && l <= j) dp[i][j][k] = 0;
                    else if (v == 2 && (l <= k || l > j)) dp[i][j][k] = 0;
                    else if (v == 3 && (l > k)) dp[i][j][k] = 0;
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i <= N; i++)
        for (int j = 0; j <= N; j++)
            ans = (ans + dp[N][i][j]) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 225536
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(string n) {
  for (auto c : n) {
    cout << 10 - (c - '0');
  }
  cout << endl;
}

int main() {
  cout << setprecision(10);
  string n;
  cin >> n;
  solve(n);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
char s[300020];
int t[8][2];
int n,f[300020][8];

inline void pre(){
	t[0][0]=2;t[0][1]=1;
	t[1][0]=3;t[1][1]=5;
	t[2][0]=4;t[2][1]=7;
    t[3][0]=6;t[3][1]=1;
	t[4][0]=2;t[4][1]=2;
	t[5][0]=5;t[5][1]=5;
	t[6][0]=3;t[6][1]=3;
	t[7][0]=2;t[7][1]=1;
}

int main() {
	int i,j;
	pre();
	scanf("%s",s);
	n=strlen(s);
	f[n][1]=1;
	f[n][5]=1;
	for(i=n-1;i>=0;--i){
		for(j=0;j<8;++j){
			if(s[i]!='1')
				f[i][j]+=f[i+1][t[j][0]];
			if (s[i]!='0')
				f[i][j]+=f[i+1][t[j][1]];
			f[i][j]%=mod;
		}
	}
	printf("%d\n", f[0][0]);
}

Measured memory_bytes: 9856
ans = []

while True:
    n, p = map(int, input().split())
    if n == 0 and p == 0:
        break
    player = [0 for i in range(n)]
    turn = 0
    max_p = p
    while True:
        if p == 0:
            p = player[turn]
            player[turn] = 0
        else:
            p -= 1
            player[turn] += 1

        if player[turn] == max_p:
            ans.append(turn)
            break
        if turn == n - 1:
            turn = 0
        else:
            turn += 1

for i in ans:
    print(i)


Measured memory_bytes: 5600
package main

import (
	"fmt"
)

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	hs := make([]int, N)
	for i := range hs {
		fmt.Scan(&hs[i])
	}

	dp := make([]int, N)

	for i := range dp {
		if i == 0 {
			continue
		}

		dp[i] = int(1e18)
	}

	for i := range hs {
		for k := 1; k <= K; k++ {
			if i+k >= N {
				break
			}

			cost := dp[i] + abs(hs[i]-hs[i+k])
			if cost < dp[i+k] {
				dp[i+k] = cost
			}
		}
	}

	fmt.Println(dp[N-1])
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}


Measured memory_bytes: 5504
#include <iostream>


class Control
{
public:
    bool Run();

private:
    bool Read();

    void Sort();

    void Write();

    bool isValid(int target);

private:

    class BubbleSort
    {
    public:
        int size;
        int* data;

        int cnt;

        BubbleSort();

        void Sort();
    };

    BubbleSort bubble_sort;

};

bool Control::Run()
{
    if (!Read())
        return false;

    Sort();

    Write();

    return true;
}

bool Control::Read()
{
    std::cin >> bubble_sort.size;

    if (!isValid(bubble_sort.size))
        return false;

    bubble_sort.data = new int[bubble_sort.size];

    for (int i = 0; i < bubble_sort.size; i++) {
        
        std::cin >> bubble_sort.data[i];
    }

    return true;
}

void Control::Sort()
{
    bubble_sort.Sort();
}

void Control::Write()
{
    for (int i = 0; i < bubble_sort.size; i++) {

        i == bubble_sort.size - 1 ? std::cout << bubble_sort.data[i] << std::endl : std::cout << bubble_sort.data[i] << " ";

    }

    std::cout << bubble_sort.cnt << std::endl;

    delete[] bubble_sort.data;
    bubble_sort.data = NULL;
}

bool Control::isValid(int target)
{
    const int MIN = 1;
    const int MAX = 100;

    if (MIN > target || MAX < target)
        return false;

    return true;
}

Control::BubbleSort::BubbleSort()
    : data(NULL)
    , size(0)
    , cnt(0)
{

}

void Control::BubbleSort::Sort()
{
    int flag = 1;

    while (flag) {

        flag = 0;

        for (int j = size - 1; j >= 1; j--) {
            
            if (data[j] < data[j - 1]) {
                int t = data[j];
                data[j] = data[j - 1];
                data[j - 1] = t;
                flag = 1;
                cnt++;
            }
        }
    }
}

int main()
{
    if (!Control().Run())
        return 1;

    return 0;
}


Measured memory_bytes: 3096
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 


using namespace std; 

int main(){

	int n;
	const double eps=1e-8;
	while(true){

		cin>>n;

		if(n==0) return 0;

		//必ず1つは囲める
		int ans=1;

		vector< double > x(n),y(n);

		for(int i=0;i<n;i++) cin>>x[i]>>y[i];

		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				const double d=hypot(x[i]-x[j],y[i]-y[j]);
				if(d>2.0-eps) continue;

				//中点
				const double mx=(x[i]+x[j])/2.0;
				const double my=(y[i]+y[j])/2.0;

				//方向ベクトル
				const double dvx=(x[i]-x[j])/d;
				const double dvy=(y[i]-y[j])/d;

				//(x[i],y[i]),(x[j],y[j])が円周上にある半径1の円の中心1
				const double cx1=mx+dvy*sqrt(1.0-d*d/4.0);
				const double cy1=my-dvx*sqrt(1.0-d*d/4.0);

				//(x[i],y[i]),(x[j],y[j])が円周上にある半径1の円の中心2
				const double cx2=mx-dvy*sqrt(1.0-d*d/4.0);
				const double cy2=my+dvx*sqrt(1.0-d*d/4.0);

				//2点は円周上にあるので確定(誤差死回避)
				int res=2;
				for(int k=0;k<n;k++){
					if(k==i || k==j) continue;
					if((x[k]-cx1)*(x[k]-cx1)+(y[k]-cy1)*(y[k]-cy1)<1.0+eps) res++;
				}
				
				ans=max(ans,res);

				res=2;
				for(int k=0;k<n;k++){
					if(k==i || k==j) continue;
					if((x[k]-cx2)*(x[k]-cx2)+(y[k]-cy2)*(y[k]-cy2)<1.0+eps) res++;
				}

				ans=max(ans,res);

			}
		}

		cout<<ans<<endl;

	}

	return 0;
}

Measured memory_bytes: 1260
a,b,w,n,i,t[31];
main(){
    for(i=0;i<=30;){
        t[i]=++i;
    }
    scanf("%d%d",&w,&n);
    for(;~scanf("%d,%d",&a,&b);t[a]^=t[b]^=t[a]^=t[b]);
    for(i=0;i<w;printf("%d\n",t[++i]));
}

Measured memory_bytes: 1692
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>
 
#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;
 
int num[3];
 
int main()
{
	string str;cin >> str;
	
	REP(i,str.size())
	{
		num[str[i] - 'a']++;
	}
	
	if(max(max(num[0],num[1]),num[2]) - min(min(num[0],num[1]),num[2]) < 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
using namespace std;
typedef long long int ll;


int main() {

	int N, X;
	ll m = INF;
	int li[100000]{ 0 };
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		li[i] = abs(a - X);
		m = min((ll)m, (ll)li[i]);
	}

	for (int i = m; i >= 1; i--) {
		if (m % i == 0) {
			for (int j = 0; j < N;j++) {
				if (li[j] % i != 0) {
					break;
				}
				if (j == N - 1) {
				cout << i << endl;
				return 0; 
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 640
input_str = input()

A, B, C, X, Y = input_str.split(" ")

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

answer = 0
ave_AB = (A + B) / 2
if ave_AB <= C:
    answer = X*A + Y*B
else:
    xy_min = min(X,Y)
    answer = xy_min * C * 2
    tmp = X - Y
    if tmp > 0:
        if A < C*2:
            answer += tmp*A
        else:
            answer += tmp*C*2
    elif tmp < 0:
        if B < C*2:
            answer += -tmp*B
        else:
            answer += -tmp*C*2
print(answer)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 200020
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
char s[N];
int n;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i){
		putchar(s[i]=='P'?'P':'D');
	}
	return 0;
}



Measured memory_bytes: 3932
n = int(input())
for i in range(n):
    xa, ya, ra, xb, yb, rb = map(float, input().split())
    distsq = (xa-xb)**2 + (ya-yb)**2
    if distsq < (ra-rb)**2:
        if ra < rb:
            print(-2)
        else:
            print(2)
    elif (ra-rb)**2 <= distsq <= (ra+rb)**2:
        print(1)
    else:
        print(0)

Measured memory_bytes: 7484
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readb(a, b)

    if(a >= 13) print(b)
    else if(a >= 6 && a <= 12) print(b/2)
    else print(0)

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int bit[11234567], bit_n;

int bit_sum(int i)
{
    int s = 0;
    while (i > 0)
    {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}

void bit_add(int i, int x)
{
    while (i <= bit_n)
    {
        bit[i] += x;
        i += i & -i;
    }
}

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

    int n, p[112345], q[112345];

    cin >> n;
    REP(i, n)
    {
        cin >> p[i];
        q[p[i]] = i;
    }

    multiset<int> s;

    ll res = 0;

    s.insert({-1, -1, q[n], n, n});

    for (int i = n - 1; i > 0; i--)
    {
        int pos = q[i];

        int l2 = *----s.lower_bound(pos);
        int l1 = *--s.lower_bound(pos);
        int r1 = *s.lower_bound(pos);
        int r2 = *++s.lower_bound(pos);

        res += (ll)(pos - l1) * (r2 - r1) * i;
        res += (ll)(r1 - pos) * (l1 - l2) * i;

        s.emplace(pos);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = n / 2 + 1;
        if (n % 2 == 0) {
            double ans = (double) 1/ 2;
            System.out.println(ans);
        } else {
            double ans = (double) h/n;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21972
N,M=map(int,input().split())
A=list(map(int, input().split()))
A.sort(reverse=True)
x=0
for i in range(M):
    if A[i]>=(sum(A)/(4*M)):
        x+=1
    else:
        break
if x==M:
    print("Yes")
else:
    print("No")

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

int main(void){
	string s;
	int lflag;
	long long cnt,k,ans,front,end;
    cin >> s;
	cin >> k;
	lflag=0;
	cnt=0;
	ans=0;
	// 文字列Sで何文字変えればよいか
	for(int i=0;i<(signed int)s.size()-1;i++){
		if(s[i] == s[i+1]){
			cnt++;
			if(cnt % 2 == 1){
				ans++;
				// 最後の文字を変えたか判定する
				if(i+1 == (signed int)s.size()-1){
					lflag = 1;
				}
			}
		}
		else{
			cnt=0;
		}
	}

	// 前後同じ文字の場合何文字続くか
	if(s[0] == s[(signed int)s.size()-1]){
		front=1;
		end=1;
		for(int i=0;i<(signed int)s.size()-1;i++){
			if(s[i] == s[i+1]){
				front++;
			}
			else{
				break;
			}
		}
		for(int i=(signed int)s.size()-1;i>0;i--){
			if(s[i] == s[i-1]){
				end++;
			}
			else{
				break;
			}
		}
		if((front+end) % 2 == 1){
			lflag = 1;
		}
	}

	if(cnt == (signed int)s.size()-1){
		cout << (signed int)s.size() * k / 2 << endl;
	} 
	else if(s[0] == s[(signed int)s.size()-1] && lflag == 0){
		cout << ans * k + k - 1 << endl;
	}
	else{
		cout << ans * k << endl;
	}
}

Measured memory_bytes: 256
use std::io;
fn main() {
    let mut l1 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    let mut iter = l1.split_whitespace();
    let v1: i32 = iter.next().unwrap().parse().unwrap();
    let v2: i32 = iter.next().unwrap().parse().unwrap();
    if v1 < 10 {
        println!("{}", (v2 + (100 * (10 - v1))));
    } else {
        println!("{}", v2);
    }
}


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

int main() {
  int a,b,i,ans=0;
  cin >> a >> b;
  for(i=a; i<=b; i++){
    if(i/10000==i%10 && (i/1000)%10==(i/10)%10) ans++;
  }
  cout << ans;
}

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
vector<long long> X,Y ;
int n,m ; 
const long long MOD = 1e9 + 7 ;
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    cin >> n >> m ;
    long long a ;
    for(int i = 0 ; i < n ; i++){
        cin >> a ;
        X.push_back(a) ;
    }
    for(int i = 0 ; i < m ; i++){
        cin >> a ;
        Y.push_back(a) ;
    }
    sort(X.begin(), X.end()) ;
    sort(Y.begin(), Y.end()) ;
    for(int i = 0 ; i < n ; i++){
        if(X[i] < 0) X[i] += MOD ;
    }
    for(int i = 0 ; i < m ; i++){
        if(Y[i] < 0) Y[i] += MOD ;
    }
    long long ans = 0 ;
    long long vx1 = 0 , vx2 = 0 , vy1 = 0 , vy2 = 0 ;
    vx2 = (1ll*(n - 1)*X[0])%MOD ;
    for(int i = 1 ; i < n ; i++){
        vx1 = (vx1 + (1ll*i*X[i])%MOD)%MOD ;
        vx2 = (vx2 + (1ll*(n - 1 - i)*X[i])%MOD)%MOD; 
    }
    vy2 = (1ll*(m - 1)*Y[0])%MOD ;
    for(int i = 1 ; i < m ; i++){
        vy1 = (vy1 + (1ll*i*Y[i])%MOD)%MOD ;
        vy2 = (vy2 + (1ll*(m - 1 - i)*Y[i])%MOD)%MOD; 
    }
    ans = (ans + (vx1*vy1)%MOD )%MOD ;
    ans = (ans  + MOD - (vx1*vy2)%MOD)%MOD ;
    ans = (ans + MOD - (vx2*vy1)%MOD)%MOD ;
    ans = (ans + (vx2*vy2)%MOD)%MOD ;
    while(ans < 0) ans += MOD ;
    while(ans >= MOD) ans -= MOD ;
    cout << ans << endl ;
    return 0 ; 
}

Measured memory_bytes: 2548
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] < A[j]) {
				res += K * (K - 1) / 2;
			}
			else if (A[i] > A[j]) {
				res += K * (K + 1) / 2;
			}
			res %= MOD;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id,id1,id2,id3,id4,lim,from,to;


int main()
{
    scanf("%lld",&n);

    printf("%lld\n",(n)+(n*n)+(n*n*n));
    return 0;
}

/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3756
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int check = 1;
		if(N == 1)
			System.out.println("Yes");
		for(int i=2; i<10; i++)
		{
			int f = N%i;
			if(f == 0)
			{
				int a = N/i;
				if(a > 0 && a < 10)
				{
					check = 2;
					System.out.println("Yes");
					return;
				}
			}
			if(i == 9 && check == 1 && N != 1)
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
	int A , B;
	cin >> A >> B;

	int res = A + B;

	if(res >= 24) cout << res - 24 << endl;
	else cout << res << endl;
 	return 0;
}

Measured memory_bytes: 256
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 c = scan.nextInt();

		if(a==b && b==c){
			System.out.println("1");
		}else if(a==b | b==c | c==a){
			System.out.println("2");
		}else{
			System.out.println("3");
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s;
    while(cin >> s) {
        int cnt = 0;
        cnt += s[0] & 15;
        cnt += s[1] & 15;
        cnt += s[2] & 15;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int X,A,B;
    cin >> X >> A >> B;
    if(abs(X-A) > abs(X-B)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 1e2+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    string s;
    int l;
    cin >> s;
    l = s.length();
    if(s[l-1]=='s')
        s+="es";
    else
        s+="s";
    cout << s;
}

Measured memory_bytes: 3592
N=int(input())
A=list(map(int,input().split(' ')))
ans = float('inf')
l = []
for n,i in enumerate(A):
    l.append(i-n-1)
l = sorted(l)
for i in l[N//2-1:N//2+2]:
    tmp = 0
    for j in l:
        tmp += abs(j-i)
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 26180
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int min,result=1,temp,i=0;
	cin>>min;
	n--;
	for(;i<n;i++){
		cin>>temp;
		if(temp<min){
			result++;
			min=temp;
		}
	}
	cout<<result<<endl;
	return 0;
}

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

const int N=2e6+20,MOD=(int)(1e9)+7;

int f[N],ie[N],n1,m1,n2,m2;

int power(int a,int b)
{
	int num=a,ans=1;
	for(int i=0;i<31;i++)
	{
		if(b&(1<<i)) ans=(1ll*ans*num)%MOD;
		num=(1ll*num*num)%MOD;
	}
	return ans;
}

int inverse_euler(int n)
{
	return power(n,MOD-2);
}

int ncr(int n,int r)
{
	return (1LL*f[n]*((1LL*ie[r]*ie[n-r])%MOD))%MOD;
}

void precompute()
{
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=(1LL*f[i-1]*i)%MOD;
	for(int i=0;i<N;i++) ie[i]=inverse_euler(f[i]);
}

long long fn(long long n,long long m)
{
	long long ans=0;
	for(int i=0;i<=n;i++) ans=(ans+ncr(i+m+1,m))%MOD;
	return ans;
}

int main()
{
	precompute();

	cin>>n1>>m1>>n2>>m2;
	cout<<(fn(n2,m2)-fn(n1-1,m2)-fn(n2,m1-1)+fn(n1-1,m1-1)+3LL*MOD)%MOD;
}

Measured memory_bytes: 15872
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const MOD: u64 = 1_000_000_000 + 7;
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut ans = 0u64;

    for bit in 0..61 {
        let mut zeros = 0u64;
        let mut ones = 0u64;
        for i in 0..n {
            if (a[i] >> bit) & 1 == 0 {
                zeros += 1;
            } else {
                ones += 1;
            }
        }

        ans += (2_u64.pow(bit) % MOD) * ((zeros  * ones) % MOD);
        ans %= MOD
    }
    println!("{}", ans);
}


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

int main() {
	char s;
	cin >> s;
	if (s == 'a' || s == 'i' || s == 'u' || s == 'e' || s == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	//system("pause");
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoderPractice0802
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            double A = AB[0];
            double B = AB[1];
            int cnt = 0;
            int ans = 0;
            //せいぜい１万円まで

            for(var i = 1; i <=10000;i++)
            {
                int X = (int)(i * 0.08);
                int Y = (int)(i * 0.10);

                if(A == X && Y == B)
                {
                    ans = i;
                    cnt++;
                    break;
                }

            }

            if(cnt != 0)
            {
                Console.WriteLine(ans);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }
}


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back
#define K 600001

int n;
int a[K];
LL s[K];

int main() {
	scanf("%d", &n);
	
	FOE(i, 0, n) scanf("%d", &a[i]);
	FOD(i, n, 0) s[i] = s[i + 1] + a[i];
	
	LL ma = 1;
	LL ret = 0;
	FOE(i, 0, n) {
	//	printf("?? %lld\n", s[i]);
		ma = min(ma, s[i]);
	//	printf("ma = %lld for %d\n", ma, i);
		ret += ma;
		if (ma < a[i]) {
			puts("-1");
			return 0;	
		}

		ma -= a[i];
		
		ma *= 2;	
	}
	
	printf("%lld\n", ret);
}

Measured memory_bytes: 5016
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;

#define ll long long
#define db double
#define clr(a, b) memset(a, b, sizeof(a))
#define vi vector<int>


const int maxn = 5e5 + 10;

int n, t;
db ans;
db cnt;
int step;
int vis[20];

struct node{
    db x, y;
} point[20];

db getdis(node a,node b)
{
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
void dfs(int id,db length)
{
    if(cnt==n)
    {
        ans += length;
        step++;
        return;
    }
        
    for (int i = 1; i <= n;i++)
    {
        if(!vis[i])
        {
            vis[i] = 1;
            cnt++;
            dfs(i,length+getdis(point[id], point[i]));
            vis[i] = 0;
            cnt--;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    step = 0, ans = 0;
    for (int i = 1; i <= n;i++)
        cin >> point[i].x >> point[i].y;

    for (int i = 1; i <= n; i++)
    {
        vis[i] = 1;
        cnt = 1;
        dfs(i,0);
        vis[i] = 0;
    }
    cout.precision(20);
    cout << ans / (db)step << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)

ll GCD (ll x, ll y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}

int main() {
    int k;
    cin >> k;
    ll sum = 0;
    rep1(a,k) {
        rep1(b,k) {
            rep1(c,k) {
                ll tmp = GCD(a,b);
                sum += GCD(tmp,c);
            }
        }
    }    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
#define ll long long
typedef unsigned long long ull;
typedef long double ld;

#define pii         pair<ll ,ll >
#define vi          vector<ll >
#define vii         vector<pii>
#define mi          map<ll ,ll >
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define pb          push_back
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        1000005


#define allr(c) (c).rbegin(),(c).rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}


void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=max(a,b);
	ll y=max(c,d);
	ll xx=min(a,b);
	ll yy=min(c,d);
	vi v;
	v.pb(x);
	v.pb(xx);
	vi z;
	z.pb(y);
	z.pb(yy);
	ll k=x*y;
	for(auto w:v)
	{
		for(auto ww:z)
		{
			k=max(k,w*ww);
		}
	}
	cout<<k<<endl;
}

int main()
    {
    	ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
      
        ll t;
        
        t=1;
        
    
   // cin>>t;
        while(t--)
        solve();
    }

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

int main() {
  bool j = true;
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) {
    rep(j, 3) {
      cin >> c.at(i).at(j);
    }
  }
  int a0, a1, a2, b0, b1, b2;
  a0 = 0;
  b0 = c.at(0).at(0);
  b1 = c.at(0).at(1);
  b2 = c.at(0).at(2);
  if (c.at(1).at(0) - b0 != c.at(1).at(1) - b1) {
    j = false;
  }
  else if (c.at(1).at(1) - b1 != c.at(1).at(2) - b2) {
    j = false;
  }
  else if (c.at(1).at(2) - b2 != c.at(1).at(0) - b0) {
    j = false;
  } 
  if (c.at(2).at(0) - b0 != c.at(2).at(1) - b1) {
    j = false;
  }
  else if (c.at(2).at(1) - b1 != c.at(2).at(2) - b2) {
    j = false;
  }
  else if (c.at(2).at(2) - b2 != c.at(2).at(0) - b0) {
    j = false;
  } 
  if (j) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main()
{
    int n; cin >> n;
    vector<tuple<string, int, int>> guide_book(n);
    for (int i=0; i<n; i++)
    {
        string shop_name;
        int point;
        cin >> shop_name >> point;
        guide_book.at(i) = make_tuple(shop_name, point, i+1);
    }

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

    vector<tuple<string, int, int>> a(n);
    for (int i=0; i<n;)
    {
        a.at(0) = make_tuple(get<0>(guide_book.at(i)), get<1>(guide_book.at(i)), get<2>(guide_book.at(i)));
        i++;
        int j = 1;
        while (i < n && get<0>(a.at(0)) == get<0>(guide_book.at(i)))
        {
            a.at(j) = make_tuple(get<0>(guide_book.at(i)), get<1>(guide_book.at(i)), get<2>(guide_book.at(i)));
            i++; j++;
        }
        for (j-=1; j>=0; j--)
        {
            cout << get<2>(a.at(j)) << endl;
        }
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
long long dp[2][(int)1e5+9];
main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    long long n,w;
    cin >> n >> w;
    for(int i = 1 ; i <= n ; ++i)
    {
        int x,y;
        cin >> x >> y;
        for(int j = 0 ; j < x ; ++j)
        dp[i%2][j]=dp[(i+1)%2][j];
        for(int j = x ; j <= w ; ++j)
        {
        dp[i%2][j]=max(dp[(i+1)%2][j-x]+y,dp[(i+1)%2][j]);
        }
        /*for(int i = 0 ; i < 2 ; ++i)
        {
        cout << endl;
        for(int j = 0 ; j < w ; ++j)
        cout << dp[i][j] << ' ';

        }
        cout << endl;*/
    }
    cout << max(dp[n%2][w],dp[(n+1)%2][w]);
}


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

int n,A[1010];

void insert(int n,int A[]){
    for(int i=1;i<n;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int k=0;k<n;k++){
            if(k>0) cout<<" ";
            cout<<A[k];
        }
        cout<<endl;
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    for(int k=0;k<n;k++){
        if(k>0) cout<<" ";
        cout<<A[k];
    }
    cout<<endl;
    insert(n,A);
}


Measured memory_bytes: 3096
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 16 August 2020 12:09:24 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;

    vector<int> v(n);

    int ans=0;

    for(int i=0; i<n; ++i){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            if(v[i] == v[j]) continue;
            for(int k = j+1; k<n; ++k){
                if(v[j] == v[k]) continue;
                if(v[i]+v[j] > v[k]) ++ans;
            }
        }
    }
    cout<<ans<<endl;
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long x;
	cin >> x;
	
	cout << (x / 500 * 1000 + (x % 500) / 5 * 5) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
    int n, d;
    cin >> n;
    set<int> kagamimochi;
    for (int i=0; i<n; ++i){
        cin >> d;
        kagamimochi.insert(d);
    }
    cout << kagamimochi.size() << endl;
    return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
point = [0]*N
for i in range(Q):
  a = A[i]
  point[a-1] += 1
for i in range(N):
  point[i] -= (Q-K)
for p in range(N):
  if point[p] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 16784