akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	const mod = 1000000007
	n := nextInt()
	a := nextInts(n)
	// 各aの素因数分解
	pfs := primeFactors(a)
	// 最小公倍数の素因数分解
	lcmp := lcmPrimes(pfs)

	// 最小公倍数
	lcm := 1
	for x, y := range lcmp {
		for i := 0; i < y; i++ {
			lcm = (lcm * x) % mod
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		b := lcm * modInv(a[i], mod)
		ans = (ans + b) % mod
	}
	puts(ans)
	wt.Flush()
}

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 nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

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
}

// nまでの自然数の最小の素因数
func minFactors(n int) []int {
	mf := make([]int, n+1)
	mf[0], mf[1] = -1, -1
	for i := 2; i <= n; i++ {
		for j := 1; i*j <= n; j++ {
			if mf[i*j] == 0 {
				mf[i*j] = i
			}
		}
	}
	return mf
}

// 高速素因数分解
func primeFactors(a []int) []map[int]int {
	// 各数の素因数分解結果を入れるmap配列
	m := make([]map[int]int, len(a))
	for i := range m {
		m[i] = map[int]int{}
	}
	// 最小素因数テーブル
	mf := minFactors(max(a))
	for i := range a {
		for j := a[i]; j > 1; j /= mf[j] {
			m[i][mf[j]]++
		}
	}
	return m
}

func lcmPrimes(pfs []map[int]int) map[int]int {
	m := map[int]int{}
	for x, y := range pfs[0] {
		m[x] = y
	}
	for i := 1; i < len(pfs); i++ {
		for x := range pfs[i] {
			if pfs[i][x] > m[x] {
				m[x] = pfs[i][x]
			}
		}
	}
	return m
}

func modInv(a, mod int) int {
	b := mod
	u, v := 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		u -= t * v
		a, b = b, a
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}


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

const int N=2010;
int a[N][N],b[N][N],l[N],r[N],le[N],ri[N],up[N],n,m,ans;
char s[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;ans=max(n,m);--n;--m;
	for(int i=0;i<=n;++i){
		cin>>s;
		for(int j=0;j<=m;++j)
			a[i][j]=(s[j]=='#');
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)b[i][j]=!(a[i-1][j-1]^a[i][j-1]^a[i-1][j]^a[i][j]);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)
			l[j]=(b[i][j]?l[j-1]+1:0);
		for(int j=m;j;--j)
			r[j]=(b[i][j]?r[j+1]+1:0);
		for(int j=1;j<=m;++j)
			if(b[i][j]){
				if(!up[j])le[j]=ri[j]=m+1;
				up[j]++;le[j]=min(le[j],l[j]);ri[j]=min(ri[j],r[j]);
				ans=max(ans,(up[j]+1)*(le[j]+ri[j]));
			}else up[j]=0;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        if(s.at(i)=='?') s.at(i)='D';
    }
    cout<<s;
}


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

typedef unsigned int uint;

static inline uint popcnt(uint n){
  uint s=n;
  s=(s&0x55555555)+((s&0xAAAAAAAA)>>1);
  s=(s&0x33333333)+((s&0xCCCCCCCC)>>2);
  s=(s&0x0F0F0F0F)+((s&0xF0F0F0F0)>>4);
  s=(s&0x00FF00FF)+((s&0xFF00FF00)>>8);
  s=(s&0x0000FFFF)+((s&0xFFFF0000)>>16);
  return s;
}

void run(void){
  const uint mod=1000000007;
  uint n;
  scanf("%u",&n);
  uint *a=(uint *)calloc(n,sizeof(uint));
  uint i,j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      uint x;
      scanf("%u",&x);
      if(x) a[i]|=1<<j;
    }
  }
  uint *dp=(uint *)calloc(1<<n,sizeof(uint));
  dp[0]=1;
  for(i=1;i<(1<<n);i++){
    uint k=popcnt(i)-1;
    uint local=0;
    uint bit=(a[k]&i);
    while(bit){
      uint m=bit&-bit;
      local=(local+dp[i^m])%mod;
      bit-=m;
    }
    dp[i]=local;
  }
  printf("%d\n",dp[(1<<n)-1]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;cin>>h>>w;
    int pow[10][10];
    rep(i, 10){
        rep(j, 10){
            cin>>pow[i][j];
        }
    }
    rep(i, 10){
        rep(j, 10){
            rep(k, 10){
                if(pow[j][k] > pow[j][i] + pow[i][k]) pow[j][k] = pow[j][i] + pow[i][k];
            }
        }
    }
    ll ans = 0;
    rep(i, h){
        rep(j, w){
            int t;cin>>t;
            if(t>=0) ans += pow[t][1];
        }
    }
    cout<<ans<<endl;

}


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

using i64 = int64_t;

int main(){
    int n, m;
    cin >> n >> m;
    map<int, int> mp, mp2;
    for(int i=0;i<n;++i){
        int x;
        cin >> x;
        mp[x]++;
        mp2[x%m]++;
    }

    int ans = 0;
    for(int i=0;i<m;++i){
        if(i == 0 || (m%2 == 0 && i == m/2)){
            int p = mp2[i] / 2;
            ans += p;
            mp2[i] -= 2*p;
        }else{
            int p = min(mp2[i], mp2[m-i]);
            ans += p;
            mp2[i] -= p;
            mp2[m-i] -= p;
        }
    }
    for(auto e: mp){
        if(mp2[e.first%m] < 2 || e.second < 2)continue;
        int p = min(e.second / 2, mp2[e.first%m] / 2);
        ans += p;
        mp2[e.first%m] -= 2*p;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9600
s = list(map(int, input()))

ans1 = 0
ans2 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == 0:
            ans1 += 1
        else:
            ans2 += 1
    else:
        if s[i] == 0:
            ans2 += 1
        else:
            ans1 += 1

print(min(ans1, ans2))


Measured memory_bytes: 3956
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  set<int> s;
  vector<int> A={3,5,7,11,13};
  
  int ans=0;
  for(int i=1;i<4;i++){
    if(27*A[i]<=n) ans++;
  }
  for(int i=0;i<=2;i++){
    for(int j=i+1;j<=3;j++){
      for(int k=j+1;k<=4;k++){
        if(A[i]*A[j]*A[k]<=n) ans++;
      }
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<sstream>
#include<bitset>
using namespace std;
#define pii pair<int,int>
#define pdd pair<double,double>
#define mp make_pair
#define pb push_back
#define ALL(x)	x.begin(),x.end()
#define fst first
#define sec second
#define PQ priority_queue
typedef long long ll;
const double eps = 1e-6;
const int maxn=1e6+10;;
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const double pi=acos(-1.0);
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} 
ll quickmod(ll a,ll b,ll c)
{
  ll res=1;
  while (b)
  {
    if(b&1) res=res*a%c;
    a=a*a%c;
    b>>=1;
  }
  return res;
  
}
ll vis[maxn],vis2[maxn],tem;
int a[maxn];
int main() {
    int n,flag=0;
    cin>>n;
    for(int i=0;i<n;++i)
    {
       scanf("%lld",&a[i]);
       vis[a[i]]++;
       if(vis[0]>=2) {flag=1;break;}
       if(a[i]>0&&vis[a[i]]>=3) {flag=1;break;}
       if(vis[a[i]]==2&&vis2[a[i]]==0) {tem++;vis2[a[i]]=1;}
    }
    if(flag) cout<<0<<endl;
    else
    {
      ll ans=quickmod(2,tem,mod);
      cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 8832
a, b = map(int, input().split())
if a>0:
    print("Positive")
elif a == 0:
    print("Zero")
else:
    if b >= 0:
        print("Zero")
    else:
        if (b-a)%2 == 0:
            print("Negative")
        else:
            print("Positive")


Measured memory_bytes: 2940
#include <stdio.h>
   
int main(void){
   
  int a,b,ans;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '+'){
      ans = a + b;
    }else if(op == '-'){
      ans = a - b;
    }else if(op == '*'){
      ans = a * b;
    }else if(op == '/'){
      ans = a / b;
    }else if(op == '?'){
      break;
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

const int INF = 1001001001;
const int d[4] = {-1,0,1,0};

int main()
{
    int ans = 0;   
    int h,w;
    cin >> h >> w;
    string s[h];
    rep(i,h) cin >> s[i];
    rep(si,h)rep(sj,w){
        if(s[si][sj] == '#') continue;
        queue<P> q;
        vector<vector<int>> dist(h, vector<int>(w,INF));
        auto update = [&](int i, int j, int x){
            if(dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i,j));
        };
        update(si,sj,0);
        while(!q.empty()){
            int i = q.front().first;
            int j = q.front().second;
            q.pop();
            rep(dir, 4){
                int ni = i + d[dir%4], nj = j + d[(dir+1)%4];
                if(ni<0||ni>=h||nj<0||nj>=w||s[ni][nj]=='#') continue;
                update(ni,nj,dist[i][j]+1);
            } 
        }
        rep(i,h)rep(j,w){
            if (dist[i][j] == INF) continue;
            ans = max(ans,dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int l, r, d, count;
  count = 0;
  cin >> l >> r >> d;

  for (int i = 0; i < 1000; i+=d)
   {
    if(l <= i && i <= r)
    count++;
   }
  cout << count << endl;
}


Measured memory_bytes: 3536
// finish date: 2018/08/13
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, K;
    cin >> N >> K;
    if (N % K == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//2^16+1,65537,3
//119*2^23+1,998244353,3
//1255*2^20+1,1315962881,3
//51*2^25+1,1711276003,29
//441*2^21+1,924844033.5
//479*2^21+1,1004535809,3

const int maxn = 131072<<2;
const int P =  924844033;
const int G = 5;

struct MOD{
	int x;
	MOD (int x_=0):x(x_){
		if(x<0)	x+=P;if(x>=P)	x-=P;
	}
	MOD operator+(const MOD& rhs)const{
		return MOD(x+rhs.x);
	}
	MOD operator-(const MOD& rhs)const{
		return MOD(x-rhs.x);
	}
	MOD operator-()const{
		return MOD(-x);
	}
	MOD operator*(const MOD& rhs)const{
		return MOD(int(1LL*x*rhs.x%P));
	}
}w[maxn+1];

MOD mypow(MOD x,int b){
	MOD res=1;
	while(b){
		if(b&1)	res=res*x;
		x=x*x;
		b>>=1;
	}
	return res;
}

void pre_ntt(){
	MOD dw = mypow(G,(P-1)/maxn);
	w[0]=1;
	for(int i=1;i<=maxn;i++)
		w[i]=w[i-1]*dw;
}
void ntt(vector<MOD>& v,int n,bool inv){
	for(int i=0,j=0;i<n;i++){
		if(i>j)	swap(v[i],v[j]);
		for(int s=n>>1;(j^=s)<s;s>>=1);
	}
	for(int s=2;s<=n;s<<=1){
		int z=s>>1;
		for(int i=0;i<n;i+=s)
			for(int j=0;j<z;j++){
				MOD x=v[i+z+j]*w[maxn/s*j];
				v[i+z+j]=v[i+j]-x;
				v[i+j]=v[i+j]+x;
			}
	}
	if(inv){
		reverse(v.begin()+1,v.end());
		MOD invn = mypow(n,P-2);
		for(int i=0;i<n;i++)	v[i]=v[i]*invn;
	}
}
vector<int> conv(const vector<int>& a,const vector<int>& b){
	int sz=1;
	while(sz<a.size()+b.size()-1)	sz<<=1;
	vector<MOD> fa(sz),fb(sz);
	for(int i=0;i<a.size();i++)
		fa[i]=a[i];
	for(int i=0;i<b.size();i++)
		fb[i]=b[i];
	ntt(fa,sz,0);ntt(fb,sz,0);
	for(int i=0;i<sz;i++)
		fa[i]=fa[i]*fb[i];
	ntt(fa,sz,1);
	vector<int> res(sz);
	for(int i=0;i<sz;i++)
		res[i]=fa[i].x;
	return res;
}

vector<int> e[200001];
int dp[200001];
vector<int> b;
int n;
void dfs(int x,int p){
	dp[x]=1;
	for(int it:e[x])
		if(it!=p){
			dfs(it,x);
			dp[x]+=dp[it];
			b[dp[it]]++;
			b[n-dp[it]]++;
		}
}
int fac[200001],inv[200001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	b.resize(n+1);
	for(int i=1,u,v;i<n;i++){
		cin>>u>>v;
		e[u].emplace_back(v);
		e[v].emplace_back(u);
	}
	dfs(1,0);
	pre_ntt();
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++)
		fac[i]=1LL*fac[i-1]*i%P;
	for(int i=2;i<=n;i++)
		inv[i]=(P-1LL*P/i*inv[P%i]%P)%P;
	for(int i=2;i<=n;i++)
		inv[i]=1LL*inv[i]*inv[i-1]%P;
	vector<int> c(n+1,0);
	for(int i=0;i<=n;i++)
		b[i]=1LL*b[i]*fac[i]%P;
	for(int i=0;i<=n;i++)
		c[i]=inv[n-i];
	auto res=conv(b,c);
	for(int i=1;i<=n;i++){
		long long int ans=1LL*n*fac[n]%P*inv[i]%P*inv[n-i]%P;
		ans=((ans-1LL*inv[i]*res[i+n])%P+P)%P;
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 33920
rate = int(input())

if rate <= 599:
    grade = 8
elif rate <= 799:
    grade = 7
elif rate <= 999:
    grade = 6
elif rate <= 1199:
    grade = 5
elif rate <= 1399:
    grade = 4
elif rate <= 1599:
    grade = 3
elif rate <= 1799:
    grade = 2
else:
    grade = 1
print(grade)

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[200005];
	long long b,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		a[i]-=i;
	}
	sort(a,a+n);
	b=a[n/2];
	for(int i=0;i<n;i++)
	{
		ans+=abs(a[i]-b);
	}
	cout<<ans;
 } 

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

int main(){
    int n,k,sum=0;
    vector<int> x;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int temp;
        cin>>temp;
        x.push_back(temp);
    }
    sort(x.begin(),x.end(),greater<int>());
    for(int i=0;i<k;i++){
        sum+=x.at(i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n;
  cin >> n;
  
  // First colour
  string col;
  cout << "? ";
  for(int i=1;i<=n;i++) cout << i << " ";
  cout << endl;

  cin >> col;

  int beg = 1, end = n+1, ans = n+1;
  while(beg <= end)
  {
    int mid = (beg + end) >> 1;
    cout << "? ";
    for(int i=mid;i<mid+n;i++) cout << i << " ";
    cout << endl;

    string temp;
    cin >> temp;

    if(temp == "-1") return 0;
    if(col == temp) beg = mid+1;
    else
    {
      end = mid-1;
      ans = mid;
    }
  }

  vector<char> v(2*n);
  vector<int> red,blue;
  for(int i=1;i<=2*n;i++)
  {
    if(i>= ans && i<ans+n-1) continue;
    cout << "? "; 
    for(int j=ans;j<ans+n-1;j++) cout << j << " ";
    cout << i << endl;

    string temp;
    cin >> temp;
    if(temp == "-1") return 0;
    v[i-1] = temp[0];
    if(temp[0] == 'R' && red.size() < n/2) red.pu(i);
    else if(temp[0] == 'B' && blue.size() < n/2) blue.pu(i);
  }

  // t(red);
  // t(blue);

  for(int i=ans;i<ans+n-1;i++)
  {
    cout << "? ";
    for(int j=0;j<blue.size();j++) cout << blue[j] << " ";
    for(int j=0;j<red.size();j++) cout << red[j] << " ";
    cout << i << endl;

    string temp;
    cin >> temp;
    v[i-1] = temp[0];
  }

  cout << "! ";
  for(int i=0;i<v.size();i++) cout << v[i];
  cout << endl;
  return 0;
}



Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    int ct = 0;

    rep(i,S.size()){
        if(i == S.size() -1){
            ct++;
        }
        else{
            if(S[i] == S[i+1]){
                i += 2;
                if(i < S.size())ct += 2;
                else ct++;
            }
            else{
                ct++;
            }
        }
    }
    cout << ct << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n, a[N], res = -INF;
string s;


void MAIN(int tc){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    set<ll> x, y;
    for(int i = a; i <= a + 3 && i <= b; i++) x.insert(i);
    for(int i = b; i >= b - 2 && i >= a; i--) x.insert(i);
    for(int i = c; i <= c + 3 && i <= d; i++) y.insert(i);
    for(int i = d; i >= d - 2 && i >= c; i--) y.insert(i);
    for(auto i: x){
        for(auto j: y){
            res = max(res, i * j);
        }
    }
    deb1(res);

}

int main(){
    ios:: sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
    cout<<fixed; cout<<setprecision(10);

    int test_cases = 1;
    //cin>>test_cases;
    for(int i = 1; i <= test_cases; i++){
        MAIN(i);
    }
}

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

int main(){
    int A[9];
    int N;
    
    for(int i=0;i<9;i++){
        cin >>A[i];
    }

    cin >> N;
    int b[N];

    for(int i=0;i<N;i++){
        cin >> b[i];
    }

    int hole[9];

    for(int i=0;i<9;i++){
        hole[i]=0;
    }

    for(int i=0;i<9;i++){
        for(int j=0;j<N;j++){
            if(A[i]==b[j])
            hole[i]=1;
        }
    }

    if(hole[0]==1&&hole[1]==1&&hole[2]==1)
        cout << "Yes" << endl;

    else if(hole[3]==1&&hole[4]==1&&hole[5]==1)
        cout << "Yes" << endl;

    else if(hole[6]==1&&hole[7]==1&&hole[8]==1)
        cout << "Yes" << endl;

    else if(hole[0]==1&&hole[3]==1&&hole[6]==1)
        cout << "Yes" << endl;    

    else if(hole[1]==1&&hole[4]==1&&hole[7]==1)
        cout << "Yes" << endl; 

    else if(hole[2]==1&&hole[5]==1&&hole[8]==1)
        cout << "Yes" << endl;   

    else if(hole[0]==1&&hole[4]==1&&hole[8]==1)
        cout << "Yes" << endl;

    else if(hole[2]==1&&hole[4]==1&&hole[6]==1)
        cout << "Yes" << endl;

    else
    {
        cout << "No" << endl;
    }
    


    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 1e5 + 10;
int n,a[MAXN],b[MAXN],c[MAXN];
ll dp[MAXN][3];
int main()
{
	si(n);
	for(int i=1;i<=n;++i)
	{
		siii(a[i],b[i],c[i]);
	}
	for(int i=1;i<=n;++i)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
	}
	ll ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
	printf("%lld\n",ans);
 } 

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

ll ma,mb;

struct item {
  ll a;ll b;ll c;
  bool operator< (const item &right) const{
    ll calcl = ma * b - mb * a;
    ll calcr = ma * right.b -  mb * right.a;
    if(calcl != calcr)
      return  calcl <  calcr;
    else
      return c < right.c;
  }
};

int main(void){
  int n;
  cin >> n >> ma >> mb;
  vector< item > items;
  for(int i = 0;i < n;++i){
    ll a,b,c;
    cin >> a >> b >> c;
    items.push_back((item){a,b,c});
  }
  ll res = inf;
  vector< item > half1;
  vector< item > half2;
  int h = n/2;
  for(int i = 1;i < (1 << h);++i){
    ll calcA = 0,calcB = 0,calcC = 0;
    for(int j = 0;j < h;++j){
      if(i & (1 << j)){
        calcA += items[j].a;
        calcB += items[j].b;
        calcC += items[j].c;
      }
    }
    if(calcA != 0 && calcB != 0 &&
       calcA * mb == calcB * ma){
      res = min(res, calcC);
    }
    half1.push_back((item){calcA,calcB,calcC});
  }
  
  for(int i = 1;i < (1 << (n-h));++i){
    ll calcA = 0,calcB = 0,calcC = 0;
    for(int j = h;j < n;++j){
      if(i & (1 << (j-h))){
        calcA += items[j].a;
        calcB += items[j].b;
        calcC += items[j].c;
      }
    }
    if(calcA != 0 && calcB != 0 &&
       calcA * mb == calcB * ma){
      res = min(res, calcC);
    }
    half2.push_back((item){calcA,calcB,calcC});
  }
  
  sort(half2.begin(),half2.end());
  vector< item > cand;
  for(item it : half2){
    if(!cand.empty()){
      item last = cand.back();
      ll calc1 = ma * last.b - mb * last.a;
      ll calc2 = ma * it.b - mb * it.a;
      if(calc1 == calc2)
        continue;
    }
    cand.push_back(it);
  }
  
  for(item it : half1){
    int l = 0,r = cand.size();
    ll target = -ma * it.b + mb * it.a;
    while(r - l > 1){
      int mid = (l+r)/2;
      ll calc = ma * cand[mid].b - mb * cand[mid].a;
      if(calc <= target){
        l = mid;
      }else{
        r = mid;
      }
    }
    ll calcA = it.a + cand[l].a;
    ll calcB = it.b + cand[l].b;
    if(calcA != 0 && calcB != 0 &&
       calcA * mb == calcB * ma){
      res = min(res,it.c + cand[l].c);
    }
  }
  if(res == inf){
    cout << "-1" << endl;
  }else{
    cout << res << endl;
  }
  return 0;
}



Measured memory_bytes: 63716
#include<bits/stdc++.h>
#define sc(v) v.size()
#define eb push_back
#define pb pop_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define TC() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define fi first
#define se second
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

const int N = 1e5 + 5;
int ar[N], ans[N];
int main()
{
	int n, k;
	cin>>n>>k;
	f(i,0,n) {
		cin>>ar[i];
		ans[i] = INT_MAX;
	}
	ans[0] = 0;
	f(i,0,n) {
		int j = i + 1;
		while (j <= i + k and j < n) {
			ans[j] = min(ans[j], ans[i] + abs(ar[i] - ar[j]));
			j++;
		}
	} 
	cout<<ans[n - 1];
    return 0;
}


Measured memory_bytes: 1024
n,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cnt = 0
if x > sum(A):
    print(n-1)
else:
    for i in range(n):
        if (x - A[i]) >= 0:
            x -= A[i]
            cnt += 1
        else:
            break
    print(cnt)

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<int> A(N); cin >> A;
        int cnt = 0;
        rep(i, N) {
            int a = A[i] - 1;
            if(A[a] - 1 == i) cnt++;
        }
        cout << cnt / 2 << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var a = new List<int>();
            for (var i = 0; i < n; i++) {
                a.Add(cin.ReadInt);
            }

            var result = 0;
            while (true) {
                for (var i = 0; i < a.Count(); i++) {
                    var v = a[i];
                    if (v%2 == 1) {
                        WriteLine(result);
                        return;
                    }
                    a[i] = v/2;
                }
                result++;
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
#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;
    cin >> n;
    set<int> st;
    REP(i,n) st.insert(in());
    cout << (st.size() == n ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>

#define m(a,b) memset(a,b,sizeof(a));
#define cpy(a,b) memcpy(a,b,sizeof(b));

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int maxn = 1e5 + 5;
const int inf = 1 << 30;

int n, m, ans = 0;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &m);
		int con = 0;
		while(m % 2 == 0){
			con ++;
			m /= 2;
		}
		ans += con;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

int main() {
    int N; cin >> N;
    ll ans = 0;
    rep(i,N) {
        ll a; cin >> a;
        ans = __gcd(a,ans);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3608
import fractions
import itertools
N = int(input())
M =[]
A = []
R = []
C = []
H = []


for i in range(N):
    name = input()
    initial = name[0]
    if initial == "M":
        M.append(name)
    elif initial == "A":
        A.append(name)
    elif initial == "R":
        R.append(name)
    elif initial == "C":
        C.append(name)
    elif initial == "H":
        H.append(name)

count = 0
S = []
if len(M) > 0:
    S.append(len(M))
if len(A) > 0:
    S.append(len(A))
if len(R) > 0:
    S.append(len(R))
if len(C) > 0:
    S.append(len(C))
if len(H) > 0:
    S.append(len(H))

if len(S) < 3:
    print("0")
    exit(0)

a = itertools.combinations(S,3)
ans = 0
for x in list(a):
    tmp = 1
    for y in x:
        tmp *= y
    ans += tmp
print(ans)






Measured memory_bytes: 12344
//Ø¨ÙØ³Ù’Ù…Ù Ù±Ù„Ù„ÙŽÙ‘Ù°Ù‡Ù Ù±Ù„Ø±ÙŽÙ‘Ø­Ù’Ù…ÙŽÙ°Ù†Ù Ù±Ù„Ø±ÙŽÙ‘Ø­ÙÙŠÙ…Ù
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define endl "\n"


int main()
{
    
    int a,b;
    cin >> a >> b;
    if ((a+b) > 9)
    	cout << "error" << endl;
    else
    	cout << (a+b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;
 
    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

Measured memory_bytes: 5612
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    dp = [INF] * (200005)
    dp[0] = 0
    for i in range(1, 200005):
        dp[i] = 1 + dp[i % bin(i).count('1')]

    n = int(input())
    X = input()
    p = X.count('1')

    if p == 0:
        ans = [1] * n
        print(*ans, sep = '\n')
        return

    if p == 1:
        idx = X.index('1')
        if idx < n - 1:
            ans = [1] * n
            ans[idx] = 0
            ans[n - 1] = 2
        else:
            ans = [2] * n
            ans[idx] = 0
        print(*ans, sep = '\n')
        return

    minus1, plus1 = 0, 0
    for c in X:
        minus1 = (minus1 * 2 + int(c)) % (p - 1)
        plus1 = (plus1 * 2 + int(c)) % (p + 1)

    ans = [None] * n
    for i, c in enumerate(X):
        if c == '0':
            ans[i] = 1 + dp[(plus1 + pow(2, n - 1 - i, p + 1)) % (p + 1)]
        else:
            ans[i] = 1 + dp[(minus1 - pow(2, n - 1 - i, p - 1)) % (p - 1)]
    print(*ans, sep = '\n')
resolve()

Measured memory_bytes: 79704
w, h, n = map(int, input().split())
S = [0,w,0,h] #[X1, X2, Y1, Y2]
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and S[0] < x:
        S[0] = x
    elif a == 2 and S[1] > x:
        S[1] = x
    elif a == 3 and S[2] < y:
        S[2] = y
    elif a == 4 and S[3] > y:
        S[3] = y
    else:
        continue
if S[1] > S[0] and S[3] > S[2]:
    print((S[1]-S[0]) * (S[3] - S[2]))
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int main() {
	string s; cin >> s;
	int gx, gy; cin >> gx >> gy;

	int xx, mode = 0, cnt = 0, spe = 1;
	vector<int>idx, idy;
	for (int i = 0; i <= s.size(); i++) {
		if (s[i] == 'T' || i == s.size()) {
			if (spe)xx = cnt, spe = 0;
			else if (mode == 0)idx.push_back(cnt);
			else idy.push_back(cnt);
			mode ^= 1; cnt = 0;
		}
		else cnt++;
	}

	set<int>canX = { 0 }, canY = { 0 };
	for (auto&& sx : idx) {
		set<int>res(canX);
		canX.clear();
		for (auto&& x: res) {
			canX.insert(x + sx); canX.insert(x - sx);
		}
	}
	for (auto&& sy : idy) {
		set<int>res(canY);
		canY.clear();
		for (auto&& y: res) {
			canY.insert(y + sy); canY.insert(y - sy);
		}
	}
	cout << (canX.count(gx - xx) && canY.count(gy) ? "Yes" : "No") << endl;

	return 0;
}

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

int dp1[3005][3005];

int main(){
    int n,t;
    cin>>n>>t;
    vector<P>p(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        p[i]=P(a,b);
    }
    sort(p.begin(),p.end());
    for(int i=0; i<n; ++i){
        for(int j=0; j<t; ++j){
            if(j-p[i].first>=0)dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j-p[i].first]+p[i].second);
            dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]);
        }
    }
    int ans=0;
    rep(i,n){
        ans=max(ans,dp1[i][t-1]+p[i].second);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 38864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int A = in(), B = in(),C = in()*2,X = in(),Y = in();
    if(X<Y){
        int tmp = X;
        X = Y;
        Y = tmp;
        tmp = A;
        A = B;
        B = tmp;
    }
    int answer = 0;
    if(A+B>C){
        answer += C*Y;
    }else{
        answer += (A+B)*Y;
    }
    if(A > C){
        answer += (X-Y)*C;
    }else{
        answer += (X-Y)*A;
    }
    cout << answer << "\n";
}

Measured memory_bytes: 256
// arc067_b.cc
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	for (auto &e : x)
		cin >> e;

	vector<long long> dp(n, LLONG_MAX);
	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		dp[i] = min(dp[i-1] + ((x[i] - x[i-1]) * a), dp[i-1] + b);
	}

	cout << dp.back();
}

Measured memory_bytes: 1792
class DisjointSet:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]


N, M, *AB = map(int, open(0).read().split())
ds = DisjointSet(N)
for a, b in zip(*[iter(AB)] * 2):
    ds.union(a - 1, b - 1)
print(-min(p for p in ds.parents))


Measured memory_bytes: 57248
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int main(){
    map<string,int>re;
    re["SUN"]=7;
    re["MON"]=6;
    re["TUE"]=5;
    re["WED"]=4;
    re["THU"]=3;
    re["FRI"]=2;
    re["SAT"]=1;
    string s;
    cin>>s;
    cout<<re[s]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll a;
int main(int argc, const char * argv[]) {
  cin >> a;
  ll ans = (a / 11) * 2;
  if (a % 11 != 0) {
    if (a % 11 <= 6) {
      ans++;
    } else {
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n, m;
    cin >> n;
    cin >> m;
    vector <int> x(m);
    rep(i, m){
        cin >> x[i];
    }
    // for(auto a: x){
    //         cout << a << endl;
    // }
    vector <int> y(m);
    sort(ALL(x));//sort as 1,2,3,4,...
    // vector<vector<int>> data(n, vector<int>(n));
    // for(int i = 0; i < n; i++){
    //     for(int j = i; j < n; j++){
    //         data.at(i).at(j) = x[j]-x[i];
    //     }
    // }
    rep(i, m-1){
        y[i] = x[i+1] - x[i];
    }
    sort(ALL(y));
    int ans = 0;
    rep(i, m-n+1){
        ans += y[i];
    }
    // for(auto a: y){
    //         cout << a << endl;
    // }
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define MOD 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    

    int n,m;
    cin >> n >> m;
    int arr[n];
    for (int i=0;i<=n-1;i++)
    {
    	arr[i]=-1;
    }

    int flag=0;
    for (int i=0;i<=m-1;i++)
    {
    	int a,b;
    	cin >> a >> b;
    	if ((arr[a-1]==-1)||(arr[a-1]==b))
    	{
    		arr[a-1]=b;
    	}
    	else
    	{
    		flag=1;
    		break;
    	}
    }

    if ((n>=2)&&(arr[0]==0))
    {
    	flag=1;
    }

    if (flag==0)
    {
    	for (int i=0;i<=n-1;i++)
    	{
    		if (arr[i]!=-1)
    		{
    			cout << arr[i];
    		}
    		else
    		{
    			if (n==1)
    			{
    				cout << "0" << endl;
    			}
    			else if (i==0)
    			{
    				cout << "1";
    			}
    			else
    			{
    				cout << "0";
    			}
    		}
    	}
    }
    else
    {
    	cout << "-1" << endl;
    }

    return 0;
}

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

int main(){

  char s[1000] = {};
  int w = 0,i = 0;

  scanf("%s",s);
  scanf("%d",&w);

  for(i= 0;i * w < strlen(s);i++){
    printf("%c",s[i*w]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,tune=native")
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define I(x, a) for(auto x : (a))
#define ins insert
#define F(i, l, r) for(auto i = (l); i < (r); i++)
#define DF(i, l, r) for(auto i = (l); i >= (r); i--)
#define E(i, l, r) for(auto i = (l); i <= (r); i++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define ret return
#define brk break
#define cont continue
#define move fjgjgjgjghd

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair<int, int> pii;

const int W = (int)1e5 + 5;

int tc = 0;
ll dp[2][W];
int n, maxw;
int w[W], v[W];


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> maxw;
	F(i, 0, n)cin >> w[i] >> v[i];
	fill(dp[1], dp[1] + W, maxw + 1);
	dp[1][0] = 0;
	F(i, 0, n){
		memcpy(dp[tc], dp[1 - tc], W * sizeof(ll));
		F(cv, v[i], W){
			dp[tc][cv] = min(dp[tc][cv], w[i] + dp[1 - tc][cv - v[i]]);
		}
		tc ^= 1;
	}
	int ans = 0;
	F(i, 0, W)
		if(dp[1 - tc][i] <= maxw)
			ans = i;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl ;
typedef pair<ll,ll> pl;
 
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define rep(i,N) for(int i=0; i < (N); i++)
#define all(v) (v).begin(),(v).end()

int main(){
	ll X;
	cin >> X;
	ll ans = 0;
	ans += (X/500)*1000;
	ans += ((X%500)/5)*5;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;char ch;bool flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 2048;
const int maxm = 100010;
char s[maxn][maxn];
int sum_node[maxn][maxn];
int sum_edgex[maxn][maxn];
int sum_edgey[maxn][maxn];
int n,m;
inline void init(){
    rep(i,1,n) rep(j,1,m){
        if(s[i][j] == '1') sum_node[i][j] = 1;
        else sum_node[i][j] = 0;
        sum_node[i][j] += sum_node[i-1][j] + sum_node[i][j-1] - sum_node[i-1][j-1];
    }
    rep(i,1,n) rep(j,1,m){
        if(s[i][j] == '1' && s[i-1][j] == '1') sum_edgex[i][j] = 1;
        else sum_edgex[i][j] = 0;
        if(s[i][j] == '1' && s[i][j-1] == '1') sum_edgey[i][j] = 1;
        else sum_edgey[i][j] = 0;
        sum_edgex[i][j] += sum_edgex[i-1][j] + sum_edgex[i][j-1] - sum_edgex[i-1][j-1];
        sum_edgey[i][j] += sum_edgey[i-1][j] + sum_edgey[i][j-1] - sum_edgey[i-1][j-1];
    }
}
inline int calc(int x2,int y2,int x1,int y1,int s[2048][2048]){
    return s[x2][y2] - s[x1-1][y2] - s[x2][y1-1] + s[x1-1][y1-1];
}
int main(){
    read(n);read(m);int q;read(q);
    rep(i,1,n) scanf("%s",s[i]+1);
    init();
    int x1,x2,y1,y2;
    while(q--){
        read(x1);read(y1);read(x2);read(y2);
        if(x1 > x2) swap(x1,x2);
        if(y1 > y1) swap(y1,y2);
        int ans = 0;
        ans -= calc(x2,y2,x1,y1+1,sum_edgey);
        ans -= calc(x2,y2,x1+1,y1,sum_edgex);
        ans += calc(x2,y2,x1,y1,sum_node);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 54912
n=int(input())
s=list(map(int,input().split()))
q=int(input())
cnt=0
t=list(map(int,input().split()))
for i in range(q):
	l=0
	r=n
	while r>l:
		mid=(l+r)//2
		if s[mid]==t[i]:
			cnt+=1
			break
		elif s[mid]>t[i]:
			r=mid
		else:
			l=mid+1
print(cnt)


Measured memory_bytes: 16704
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

Vi v[100001];
deque<int> ans;
bool chk[100001];
void dfs(int N)
{
	chk[N]=1;
	ans.pb(N);
	for(int next:v[N])
	{
		if(!chk[next])
		{
			dfs(next);
			break;
		}
	}
}
void dfs2(int N)
{
	chk[N]=1;
	ans.push_front(N);
	for(int next:v[N])
	{
		if(!chk[next])
		{
			dfs2(next);
			break;
		}
	}
}
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1);
	chk[1]=0;
	ans.pop_front();
	dfs2(1);
	printf("%d\n",ans.size());
	for(int x:ans)printf("%d ",x);
}

Measured memory_bytes: 6784