akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()) cout<<x[i]<<" "; cout<<endl;

#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl prinf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)

#define tc() int tcase; cin >> tcase ; rep(tc,1,tcase+1)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair

// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

ll gcd(ll a,ll b){ return ((b==0)? a:gcd(b,a%b) ); }

int main()
{
    SYNC
    ll n,a,b;
    cin>>n>>a>>b;
    int c1=0,c2=0,c3=0;
    rep(i,0,n)
    {
        int x;
        cin>>x;
        if(x <= a)
            c1++;
        else if(x > a && x<=b)
            c2++;
        else
            c3++;
    }
    c1 =min(c1,c2);
    c1 = min(c1,c3);
    cout<<c1;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

def check(cnt, min, n, x)
  return 1 if x.zero? && cnt.zero?
  return 0 if cnt.zero?

  k = 0
  (min..n).each do |i|
    k += check(cnt - 1, i + 1, n, x - i) unless x - i < 0
  end

  k
end

while (n, x = gets.chomp.split.map(&:to_i)) != [0, 0]
  puts check(3, 1, n, x)
end

Measured memory_bytes: 6884
day = input()

aa = day[:2]
bb = day[2:]

if 1 <= int(aa) <= 12 and 1 <= int(bb) <= 12:
  print('AMBIGUOUS')
elif 1 <= int(aa) <= 12 and 0 <= int(bb) <= 99:
  print('MMYY')
elif 0 <= int(aa) <= 99 and 1 <= int(bb) <= 12:
  print('YYMM')
else:
  print('NA')

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

using namespace std;

const int inf = 2e5 + 9;

int arr[inf];
vector<pair<int, int>> v;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	for (int i = 0; i < n; i++) v.emplace_back(arr[i], i);
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	static int ans[inf];
	for (int i = 0; i < n; i++) {
		if (v[0].second == i) ans[i] = v[1].first;
		else ans[i] = v[0].first;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << '\n';
	}
}


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

int main(void){
    long long int n,k,ma=0,mi=0,ans =0,s;
    long long  int MOD = 1000000007;
    cin >> n >> k;
    for(int i=k;i<=n+1;i++){
        if(i==k){
        for(int j=0;j<=i-1;j++){
            mi += j;
        }
        for(int j=n;j>n-i;j--){
            ma += j;
        }
        s = n-i;
        }else{
            mi += i-1;

            ma += s;
            s--;
        }
    ans += ma + 1 - mi;
    }
    cout << ans % MOD<< endl;
}

Measured memory_bytes: 3200
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    cout << (n / 100 == n % 10 ? "Yes" : "No") << endl;
}

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

using ll = long long;
const int MOD = 1000000007;
#ifdef LOCAL_ENV
    #define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
    #define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) {
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


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

	string a={S[5],S[6]};
  	int i=stoi(a);
  
  	if(i>4)p("TBD");
  	else p("Heisei");
  
    return 0;
}



Measured memory_bytes: 256
a,b = input().split()

c= int(a)+int(b)
d= int(a)-1 + int(a)
e =int(b)-1 + int(b)

if c > d:
    if c > e:
        print(c)
    else:
        print(e)
else:
    if d > e:
        print(d)
    else:
        print(e)




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    priority_queue<ll> S;
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C);
    for (int i = 0; i < A; i++) cin >> P[i];
    for (int i = 0; i < B; i++) cin >> Q[i];
    for (int i = 0; i < C; i++) cin >> R[i];
    sort(P.begin(), P.end()), reverse(P.begin(), P.end());
    sort(Q.begin(), Q.end()), reverse(Q.begin(), Q.end());
    sort(R.begin(), R.end()), reverse(R.begin(), R.end());
    for (int i = 0; i < X; i++) S.push(P[i]);
    for (int i = 0; i < Y; i++) S.push(Q[i]);
    for (int i = 0; i < min(X + Y, (int)R.size()); i++) S.push(R[i]);
    ll ans = 0;
    for (int i = 0; i < X + Y; i++) {
        ans += S.top();
        S.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n,a,b;
  int p1;
  
  cin >> n >> a >> b;

  p1 = a * n;
  
  if (p1 < b) {
	cout << p1 << endl;
   }
  else {
	cout << b << endl;
  }
}

Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
s = input()

ans = "Yes"
# 岩判定
for i in range(A - 1, C):
    if i != 0 and s[i-1:i+1] == "##":
        ans = "No"
        break

for i in range(B - 1, D):
    if i != 0 and s[i-1:i+1] == "##":
        ans = "No"
        break

# スペース >= 2 判定
spaceFlg = False
for i in range(max(A, B) - 1, min(C, D)):
    if s[i-1:i+2] == "...":
        spaceFlg = True
        break

if (A - B) * (C - D) < 0 and not spaceFlg:
    ans = "No"

print(ans)


Measured memory_bytes: 40048
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
 
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
 
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
  

int main() {
    int N; cin >> N;
    int A[110];
    rep(i,N) cin >> A[i];

    ll res = INF;
    repr(n,-100,101) {
        ll tmp = 0;
        rep(i,N) {
            tmp += pow(A[i]-n, 2);
        }
        res = min(res, tmp);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
    int a, b, c;
    int S;
    cin >> a >> b >> c;

    double s = (a + b + c) / 2;
    double S_1 = sqrt(s * (s - (double) a) * (s - (double) b) * (s - (double) c));
    int S_0 = int (S_1);
    cout << S_1 << endl;
    return 0;
}

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

int main(void){
	double x1,x2,x3,y1,y2,y3,xp,yp,a,b,c,d,r;
	int i,l,n;
	long s;
	
	scanf("%d",&n);
	
	for(;n>0;n--){
		
		scanf(" %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		
		//printf("%lf %lf %lf %lf %lf %lf\n",x1,y1,x2,y2,x3,y3);
		
		//(-x1+x2)*2xp+x1^2-x2^2+(-y1+y2)*2yp+y1^2-y2^2
		//(-x1+x3)*2xp+x1^2-x3^2+(-y1+y3)*2yp+y1^2-y3^2
		
		//y=a*x+b
		//y=c*x+d
		//この形に変換
		
		//printf("test\n");
		
		if(y1!=y2){
			a=(-x1+x2)/(y1-y2);
			
			//b=(pow(x1,2)-pow(x2,2)+pow(y1,2)-pow(y2,2))/(2*(y1-y2));
			
			b=0;
			b+=x1*x1-x2*x2+y1*y1-y2*y2;
			b/=2*(y1-y2);
		}
		
		else
		xp=(x1+x2)/2;
		
		
		//printf("test\n");
		
		if(y1!=y3){
			c=(-x1+x3)/(y1-y3);
			//d=(pow(x1,2)-pow(x3,2)+pow(y1,2)-pow(y3,2))/(2*(y1-y3));
			
			
			d=0;
			d+=x1*x1-x3*x3+y1*y1-y3*y3;
			d/=2*(y1-y3);
		}
		
		else
		xp=(x1+x3)/2;
		
		//printf("test\n");
		
		//printf("%lf %lf %lf %lf\n",a,b,c,d);
		if(y1!=y2 && y1!=y3)
		xp=(-b+d)/(a-c);
		if(y1!=y2)
		yp=a*xp+b;
		if(y1!=y3)
		yp=c*xp+d;
		
		r=sqrt(pow(x1-xp,2)+pow(y1-yp,2));
		
		s=xp*10000;
		s=s%10;
		if(s>=5)s=1;
		else s=0;
		if(s==1)xp+=0.001*xp/abs(xp);
		if(xp<0 && xp>-0.001)xp=0;
		
		s=yp*10000;
		s=s%10;
		if(s>=5)s=1;
		else s=0;
		if(s==1)yp+=0.001*yp/abs(yp);
		if(yp<0 && yp>-0.001)yp=0;
		
		s=xp*10000;
		s=s%10;
		if(s>=5)s=1;
		else s=0;
		if(s==1)r+=0.001*r/abs(r);
		if(r<0 && r>-0.001)r=0;
		
		
		
		printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
    ll N;
    cin>>N;
    vector<ll> H(N);
    FOR(i,N){
        cin>>H[i];
    }
    ll num=0;
    ll mnum=0;
    ll car=H[N-1];
    for(int i=N-2;i>=0;--i){
        if(car<=H[i]){
            num ++;
            car = H[i];
        }else{
            num = 0;
            car = H[i];
        }
        if(mnum<num){
            mnum = num;
        }
    }
    cout<<mnum<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] T = new int[N];
		for(int i = 0 ; i < N ; i++) {
			T[i] = sc.nextInt();
		}
		int M = sc.nextInt();
		int[] P = new int[M];
		int[] X = new int[M];
		for(int i = 0 ; i < M ; i++) {
			P[i] = sc.nextInt();
			X[i] = sc.nextInt();
		}
		for(int i = 0 ; i < M ; i++) {
			int total = 0;
			for(int j = 0 ; j < N ; j++) {
				if(P[i] == j + 1) {
					total += X[i];
				} else {
					total += T[j];
				}
			}
			System.out.println(total);
		}
	}
}


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

int main(void){
    int y,m,d;
    char a,b;
    cin >> y >> a >> m >> b >> d;
    if(m>4){
        cout << "TBD";
    }
    else{
        cout << "Heisei";
    }
    
    return 0;
}




































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int S, L, R;
  cin >> S;
  L = S / 100;
  R = S % 100;
  
  if(1 <= L && L <= 12){
    if(1 <= R && R <= 12){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if(1 <= R && R <= 12){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    int n; cin >> n;
    int maxi = 0,mini = 1001;
    rep(i,n){
        int a; cin >> a;
        maxi = max(a,maxi);
        mini = min(a,mini);
    }
    cout << maxi - mini << endl;

}




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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;
	vector<ll> a(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }

	vector<vector<ll>> dp(N + 1, vector<ll>(2, -1e18));
	dp[1][0] = a[1];
	for (int i = 2; i <= N; ++i) {
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
		dp[i][1] = max(dp[i - 1][0] - 2*a[i - 1], dp[i - 1][1] + 2*a[i - 1]) - a[i];
	}

	ll res = max(dp[N][0], dp[N][1]);
	cout << res << endl;

	return 0;
}


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

#define ll long long

int main() {
	int n, count = 0;
	ll x, y, d;
	cin >> n >> d;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		count = (x*x + y*y <= d*d) ? count+1 : count;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3532
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
 vector<int> A(N);
  rep(i,N) {
cin >>A.at(i);
  }
  vector<pair<int,int>> vec(N);
  rep(i,N) {
    vec.at(i).first=A.at(i);
    vec.at(i).second=i+1;
  }
sort(all(vec));
  rep(i,N) {
cout<<vec.at(i).second;
    cout<<" ";
  }
  
}

 

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll A, B;
    cin >> A >> B;
    ll C = B / A;
    int cnt = 0;
    while(C){
        C >>= 1;
        cnt++;
    }
    output(cnt);
    
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 34000, mod = 1e9 + 7;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	ll ans = 1ll<<60;
	int n;
	cin >> n;
	vi a(n);
	for(auto &i : a) cin >> i;
	for(int i = -100; i <= 100; i++) {
		ll cur = 0;
		for(auto j : a) cur += (j-i)*(j-i);
		ans = min(ans, cur);
	}
	cout << ans << '\n';
}


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

int main() {
  int n;
  cin >> n;
  char str1[n], str2[n];
  for (int i = 0; i < n; i++) {
    cin >> str1[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> str2[i];
  }
  for (int i = 0; i < n; i++) {
    cout << str1[i] << str2[i];
  }
  return 0;
}

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

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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll cost;
    if (a+b >= 2*c) {
        cost = 2 * c * min(x, y);
        if (x > y) cost += (x - y) * a;
        else cost += (y - x) * b;
        cost = min(cost, (ll)2*c*max(x, y));
    } else {
        cost = a * x + b * y;
    }

    cout << cost << endl;

    return 0;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
// #define fat 1000000007
#define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, d, u, v, x, y;
    ll ans = 0;

    ll l = 0, r = 0;
    bool poss = true;

    boost;
    string sa, sb;

    // cin >> tt;  
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> a;
        string db;
        cin >> db;
        
        b = (db[0] - '0')*100 + (db[2] - '0')*10 + (db[3] - '0');
        
        ans = a*b;
        sa = to_string(ans);

        if(sz(sa) < 3) {
            cout << 0;
        }
        else for(i = 0; i < sz(sa) - 2; i++) cout << sa[i];
        cout << nl;
    }   

    return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(void) {

	int h, w;

	while (1) {

		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}

		for (int h_i = 0; h_i < h; h_i++) {
			for (int w_i = 0; w_i < w; w_i++) {
				if (w_i % 2 == 0 && h_i % 2 == 0 || w_i % 2 == 1 && h_i % 2 == 1) {
					printf("#");
				}
				else {
					printf(".");
				}

				if (w_i == w - 1) {
					puts("");
				}
			}
		}

		puts("");
	}

	return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define repr(i, n) for(int i=(n-1); 0<=i; i--)
#define repr2(i, from, to) for(int i=(from-1); (int)(to)<=i; i--)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

int main(void){
	string s; cin >> s;
	string tmp;
	tmp.push_back(s[0]);
	string tmp2;
	int ans = 1;
	rep2(i, 1, s.length()){
		tmp2.push_back(s[i]);
		if(tmp != tmp2){
			ans++;
			tmp = tmp2;
			tmp2.clear();
		}
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll A,B;

    cin >> A >> B;
    if(A<B*2){
        cout << "0" << endl;
    }else{
        cout << A-B*2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n;
int a,b;
bool ans;

int main(){
  cin>>n;

  rep(i,n){
    int c;
    cin>>c;
    if(c%2) a++;
    else b++;
  }

  if(a%2)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;

  return 0;
}


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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int N = 200005;

vector<int> v[N];
ll cnt = 0;
bool vis[N];

void dfs(int s)
{
    ++cnt;
    vis[s]=true;
    for(int j:v[s])
        if(!vis[j])
            dfs(j);
}

int _runtimeTerror_()
{
    ll n,m;
    cin>>n>>m;
    for(int i=1;i<=m;++i)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y),v[y].pb(x);
    }
    ll ans = 0;
    for(int i=1;i<=n;++i)
    {
        if(!vis[i])
        {
            cnt = 0;
            dfs(i);
            amax(ans,cnt);
        }
    }
    cout<<ans<<"\n";
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 20968
N = int(input())
A = list(map(int, input().split()))

A.insert(0, 0)
A.append(0)
sum = 0
for i in range(N + 1):
    sum += abs(A[i + 1] - A[i])
    
count = 0
for i in range(1, N + 1):
    ans = sum - ((abs(A[i + 1] - A[i]) + abs(A[i] - A[i - 1])) - abs(A[i + 1] - A[i - 1]))
    print(ans)

Measured memory_bytes: 14048
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var d = o.l().sort((a,b)=>a-b);
  return d[n/2]-d[n/2-1];
}

Measured memory_bytes: 28284
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 11:39:06
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int sum(int n)
{
    if (n < 10) return n;
    else return n%10 + sum(n/10);
}

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x = sum(i);
        if (x >= a && x <= b) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/




signed main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];


	for(int i = 0; i < n-1; ++i){
		if(a[i] > a[i-1] || i == 0){
			a[i]--;
		}
	}
	for(int i = 0; i < n-1; ++i){
		if(a[i] > a[i+1]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    deque<int> dq(N);
    for(int i = 0; i < N; ++i) cin >> dq[i];
    dq.push_front(0); dq.push_back(0);
    long long sum = 0;
    for(int i = 1; i < N+2; ++i){
        sum += abs(dq[i] - dq[i-1]);
    }
    for(int i = 1; i < N+1; ++i){
        cout << sum - abs(dq[i] - dq[i-1]) - abs(dq[i+1] - dq[i]) + abs(dq[i-1] - dq[i+1]) << '\n';
    }
    return 0;
}

Measured memory_bytes: 4056
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

def main():
    n,m = mi()
    tree = [[] for _ in range(n)]
    for i in range(m):
        s,t = mi()
        tree[s-1].append(t-1)
    dp = [0]*n
    dpl = [0]*n
    for i in range(n-1):
        dpl[i] = len(tree[i])
    for i in reversed(range(n-1)):
        for k in tree[i]:
            dp[i] += dp[k] 
        dp[i] /= dpl[i]
        dp[i] += 1
    ans = dp[0]
    
    def func(ss,tt):
        tmp = 0
        for l in tree[ss]:
            if l == tt:
                continue
            tmp += dp[l]
        tmp = tmp/(dpl[ss] -1) + 1
        if tmp > dp[ss]:
            return dp[0]
        else:
            dp[ss] = tmp
        
        for a in reversed(range(ss)):
            tmp = 0
            for b in tree[a]:
                tmp += dp[b]
            dp[a] = tmp/dpl[a] + 1
        
        return dp[0]
    
    for i in range(n-1):
        if len(tree[i]) == 1:
            continue
        for k in tree[i]:
            ans = min(ans,func(i,k))
    print(ans)

main()

Measured memory_bytes: 60632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;
 
vector<vector<int> > s;
vector<int> c;

ll score(vector<int> held,int k){
    vector<int> ld(26,0);
    ll ans=0;

    rep(i,held.size()){
        int t=held[i];
        ld[t]=i+1;
        ans+=s[i][t];
        rep(j,26){
            ans-=c[j]*(i+1-ld[j]);
        }
    }
    for(int q=held.size(); q<held.size()+k; q++)
    rep(i,26){
        ans-=c[i]*(held.size()+k+1-ld[i]);
    }

    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> cc(26);
    c=cc;
    rep(i,26) cin >> c[i];
    vector<vector<int> > ss(d);
    s=ss;
    rep(i,d)rep(j,26){
        int a; cin >> a;
        s[i].push_back(a);
    }
 
    //vector<int> ld(26,0);
    vector<vector<int> > ds(26);
    vector<int> ans;
    rep(p,26){
        vector<int> days(0);
        ll tmps=-INF;
    rep(i,d){
        ll now=-INF;
        int whatday;
        rep(j,26){
            vector<int> tmp=days;
            tmp.push_back(j);
            ll sc=score(tmp,p);
            if(sc>now){
                whatday=j;
                now=sc;
            }
        }
        days.push_back(whatday);
    }
    ll nows=score(days,0);
    if(tmps<nows){
        ans=days;
        tmps=nows;
    }
    }
    rep(i,d) cout << ans[i]+1 << endl;
return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <map>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;


int main(){
    string s;
    vector<string> ans;
    int n,l;
    cin >> n>>l;
    fol(i,n){
        cin >>s;
        ans.push_back(s);
    }
    sort(ans.begin(),ans.end());
    fol(i,n){
    cout << ans[i];
    }
    cout << endl;
    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 P = pair<int,int>;

int main(){
  int a,b;
  cin >> a >> b;
  string A = to_string(a);
  string B = to_string(b);
  string ansA,ansB;
  rep(i,b){
    ansA += A;
  }
  rep(i,a){
    ansB += B;
  }
  string ans = min(ansA,ansB);
  cout << ans << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;
 
signed main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N - 1; i++) cin >> C[i];
    int ans = 0, before = -10;
    for (int i = 0; i < N; i++) {
        ans += B[A[i] - 1];
        if (before + 1 == A[i]) ans += C[before - 1];
        before = A[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define rep(i,n) for(int i=1;i<=n;i++)
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  998244353 ;

int n, m, ans;

void solve()
{
    scanf("%d%d", &n, &m);
    if(m>=n) puts("unsafe");
    else puts("safe");
//    printf("%d\n", ans);
}


int main()
{
//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d", &n))
//    while(scanf("%d", &n)&&n)
    solve();
    return 0;
}


Measured memory_bytes: 3660
/*
	        ######## ##   ## #######          ##########
	           ##    ##   ## ##                 ##    ##
	           ##    ####### ######             ##    ##
	           ##    ##   ## ##                 ##    ##
	           ##    ##   ## ####### ######## ##########
	    */
	    #include<bits/stdc++.h>
	    #include <iomanip>
	    #define int         long long
	    #define ll          long long
	    #define pb          push_back
	    #define pii         pair<int,int>
	    #define vi          vector<int>
	    #define vii         std::vector<vector<int> > v;
	    #define all(a)      (a).begin(),(a).end()
	    #define F           first
	    #define S           second
	    #define sz(x)       (int)x.size()
	    #define hell        1000000007
	    #define rep(i,a,b)    for(int i=a;i<b;i++)
	    #define lbnd        lower_bound
	    #define ubnd        upper_bound
	    #define bs          binary_search
	    #define mp          make_pair
	    #define maxc(v)     max_element(all(v))
	    #define minc(v)     min_element(all(v))
	    #define endl        "\n"
	    using namespace std;
	    #define N  100005
	    //#define M  1000003
	    #define rn return
	    #define B 100000000
	    int modularExponentiation(int x,int n,int M = hell)
		{
	    	if(n==0)
	        	return 1;
	    	else if(n%2 == 0)
	        	return modularExponentiation((x*x)%M,n/2,M);
	    	else
	        	return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

		}
		int abs(int a, int b){
	        if(a>b) return a-b;
	        else return b-a;
	    }
	    void solve();
	    signed main()
	    {
	        ios_base::sync_with_stdio(false);
	        cin.tie(0);
	        cout.tie(0);
	        int TESTS=1;
	        //cin>>TESTS;
	        while(TESTS--)
	        {
	            solve();
	        }
	        return 0;
	    }
	    void solve(){
	    	int n,k = 2;
	    	cin>>n;
	    	int h[n], dp[n];
	    	rep(i,0,n) {
	    		cin>>h[i];
	    		dp[i] = hell;
	    	}
	    	dp[0] = 0;
	    	rep(i,1,n){
	    		for(int j = 1; j <= min(i, k); j++){
	    			dp[i] = min(dp[i],dp[i-j] + abs(h[i], h[i-j]));
	    		}
	    	}
	    	cout<<dp[n-1]<<endl;
	    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)(2e18)

int A, B, C, D;

int solve(int N, map<int, int> &mp){
//	printf("solve(%lld)\n", N);
	if(mp.find(N) == mp.end()){
		int res;
		if(N > inf / D){
			res = inf;
		}
		else{
			res = N * D;
		}
		res = min(res, A + D * (N - N / 2 * 2) + solve(N / 2, mp));
		res = min(res, A + D * ((N + 1) / 2 * 2 - N) + solve((N + 1) / 2, mp));
		res = min(res, B + D * (N - N / 3 * 3) + solve(N / 3, mp));
		res = min(res, B + D * ((N + 2) / 3 * 3 - N) + solve((N + 2) / 3, mp));
		res = min(res, C + D * (N - N / 5 * 5) + solve(N / 5, mp));
		res = min(res, C + D * ((N + 4) / 5 * 5 - N) + solve((N + 4) / 5, mp));
		mp[N] = res;
	}
	return mp[N];
}

signed main(){
	int T;
	scanf("%lld", &T);
	while(T--){
		int N;
		map<int, int> mp;
		scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
		mp[0] = 0;
		mp[1] = D;
		printf("%lld\n", solve(N, mp));
	}
	return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  vector<int> x(m), diff(m - 1);
  rep(i, 0, m) cin >> x[i];
  sort(x.begin(), x.end());

  ll sum_diff = 0;
  rep(i, 1, m) {
    diff[i - 1] = x[i] - x[i - 1];
    sum_diff += diff[i - 1];
  }
  sort(diff.rbegin(), diff.rend());
  chmin(n, (int)(diff.size() + 1));
  rep(i, 1, n) sum_diff -= diff[i - 1];
  cout << sum_diff << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (y1 < y2)
    {
        if (x1 < x2)
        {
            int sy = abs(y2 - y1);
            int sx;
            if (x1 >= x2)
            {
                sx = abs(x1 - x2);
            }
            else
            {
                sx = abs(x2 - x1);
            }
            int x3 = x2 - sy;
            int y3 = y2 + sx;
            int x4 = x3 - sx;
            int y4 = y3 - sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
        if (x1 >= x2)
        {
            int sy = abs(y2 - y1);
            int sx;
            if (x1 >= x2)
            {
                sx = abs(x1 - x2);
            }
            else
            {
                sx = abs(x2 - x1);
            }
            int x3 = x2 - sy;
            int y3 = y2 - sx;
            int x4 = x3 + sx;
            int y4 = y3 - sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
    }

    if (y1 == y2)
    {
        if (x1 > x2)
        {
            int sy = abs(y2 - y1);
            int sx = abs(x2 - x1);
            int x3 = x2 + sy;
            int y3 = y2 - sx;
            int x4 = x3 + sx;
            int y4 = y3 + sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
        if (x1 < x2)
        {
            int sy = abs(y2 - y1);
            int sx = abs(x1 - x2);
            int x3 = x2 - sy;
            int y3 = y2 + sx;
            int x4 = x3 - sx;
            int y4 = y3 - sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
    }

    if (y1 > y2)
    {
        if (x1 > x2)
        {
            int sy = abs(y2 - y1);
            int sx;
            if (x1 >= x2)
            {
                sx = abs(x1 - x2);
            }
            else
            {
                sx = abs(x2 - x1);
            }
            int x3 = x2 + sy;
            int y3 = y2 - sx;
            int x4 = x3 + sx;
            int y4 = y3 + sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
        if (x1 <= x2)
        {
            int sy = abs(y2 - y1);
            int sx;
            if (x1 >= x2)
            {
                sx = abs(x1 - x2);
            }
            else
            {
                sx = abs(x2 - x1);
            }
            int x3 = x2 + sy;
            int y3 = y2 + sx;
            int x4 = x3 - sx;
            int y4 = y3 + sy;
            std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
dists = [0 for i in range(n+1)]

for i in range(1, n+1):
  for j in range(i+1, n+1):
    dist = min(abs(j-i), 1 + abs(x-i)+abs(y-j), 1 + abs(y-i)+abs(x-j))
    dists[dist]+=1
    
for i in range(1, n):
  print(dists[i])

Measured memory_bytes: 3444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int n;
int c;
int k;
int a[100005];

int main()
{
    while(~scanf("%d %d %d",&n,&c,&k))
    {
        for(int i=0;i<n;++i)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int sum=0;
        int now=1;
        int time=a[0];
        int limit=a[0]+k;
        for(int i=1;i<n;++i)
        {
            now++;
            time=a[i];
            if(time>limit)
            {
                now=0;
                sum++;
                limit=time+k;
            }
            if(now==c)
            {
                now=0;
                sum++;
                limit=time+k;
            }
        }
        printf("%d\n",sum+1);
    }
}


Measured memory_bytes: 640
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, p;
  scanf("%lld%lld", &n, &k);
  double a[n], ans = 0.0, now = 0.0;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &p);
    a[i] = (p + 1) / 2.0;
    if(i < k) now += a[i];
    else now += a[i] - a[i - k];
    if(now > ans) ans = now;
  }
  printf("%lf", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  LLI t1,t2;
  LLI a1,a2,b1,b2;
  while(cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2){
    LLI ans = 0;

    LLI p = (a1-b1) * t1;
    LLI q = (a2-b2) * t2;

    if(p > 0){
      p = -p;
      q = -q;
    }

    if(p + q == 0){
      cout << "infinity" << endl;
    }else if(p + q > 0){
      LLI s = (-p) / (p+q);
      LLI t = (-p) % (p+q);

      if(t == 0){
        ans = s * 2;
      }else{
        ans = s * 2 + 1;
      }
      
      cout << ans << endl;
    }else{
      cout << 0 << endl;
    }
    
  }

  return 0;
}


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


string f (int D, int T, int S)
{
	return S*T >= D ? "Yes" : "No"; 	


}


int main ()
{
	int S, T, D;
	cin >> S >> T >> D;
	
	cout << f (S, T, D);
	
	
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;
 
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll mod(ll a, ll b) { return (a%b+b)%b; }
ll gcd(ll x, ll y) { return __gcd(x, y); }
ll lcm(ll x, ll y) { return x * 1ll * y / gcd(x, y); }
 
 
const ll MAXN = 1e9 + 9;
const ll SIZE = 1e5 + 5;
const ll MOD  = 1e9 + 7;

ll N, rem;
string s;

int main() { speedhack()

	cin >> N;

	while (N > 0) {
		--N;
		rem = N % 26;
		char c = char(96);
		for (int i = 0; i <= rem; i++)
			++c;
		s += c;
		N /= 26;
	}

	reverse (all(s));
	cout << s;
	
	
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
template <class T> void dwrite(T o){
	std::cout << o << std::endl;
}

struct place{int num;int votes;};

bool psort(const place& l, const place& r){
	if(l.votes == r.votes)return l.num < r.num;
	return l.votes > r.votes;
}

int main(){
	int n, m;
	while(std::cin >> n >> m, n && m){
		place p[100] = {{0,0}};
		int f;
		while(n--){
			for(int i=0;i<m;i++){
				std::cin >> f;
				p[i].num = i + 1;
				p[i].votes += f;
			}
		}
		std::sort(p,p+100,psort);
		std::cout << p[0].num;
		for(int i=1;i<m;i++){
			std::cout << " " << p[i].num;
		}
		std::cout << "\n";
	}
}

Measured memory_bytes: 864