akhauriyash/Code-Regression huggingface dataset:
prime = [3, 5]
for i in range(13, 102010, 12):
  r = int(i**(1/2))
  p = 0
  for j in range(2, r+1):
    if i % j == 0:
      p = 1
      break
  a = (i+1)//2
  r = int(a**(1/2))
  for j in range(2, r+1):
    if a % j == 0:
      p = 1
      break
  if p == 0:
    prime.append(i)
LL = []
j = 0
for i in range(100001):
  if i >= prime[j]:
    j += 1
  LL.append(j)

Q = int(input())
for i in range(Q):
  L = list(map(int, input().split()))
  L[0] -= 1
  print(LL[L[1]] - LL[L[0]])

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

int main() {
  int s;
  cin >> s;
  vector<bool> N(1000000, false);
  N.at(s) = true;
  int n = 1;
  while (true) {
    if (s % 2 == 0){
      s = s / 2;
    } else {
      s = 3 * s + 1;
    }
    n++;    
    if (N.at(s)){
      cout << n << endl;
      break;
    }
    N.at(s) = true;
  }
}


Measured memory_bytes: 384
from collections import deque


def can_cut(x):
    tmp = 0
    for a in A:
        tmp += (a-1)//x
        if tmp > K:
            return False

    return True


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    # 二分探索で答えを探す
    x_min = 0
    x_max = 10**9

    while x_max-x_min != 1:
        x = (x_max+x_min)//2
        if can_cut(x):
            x_max = x
        else:
            x_min = x

    print(x_max)


Measured memory_bytes: 32368
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
int a[101];
int main(){
  scan(n);
  rep(i,n)scan(a[i]);
  int res=0;
  rep1(i,n-1){
    if(a[i-1]==a[i]){
      a[i]=0;
      res++;
    }
  }
  prin(res);
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

template<class T> class bit {
public:
	vector<T> dat;
	ll N;

	bit() {}
	bit(ll N) : N(N) { dat.assign(N, 0); }
	// sum [0,i)
	T sum(ll i) {
		ll ret = 0;
		for (--i; i >= 0; i = (i&(i + 1)) - 1) ret += dat[i];
		return ret;
	}
	// sum [i,j)
	T sum(ll i, ll j) { return sum(j) - sum(i); }
	// add x to i
	void add(ll i, T x) {
		for (; i < N; i |= i + 1)
			dat[i] += x;
	}
};

template<class T> class bitr {
public:

	bit<T> b, c;

	bitr() {}
	bitr(ll N) {
		b = bit<T>(N);
		c = bit<T>(N);
	}
	// add x to [i,j) 
	void add(ll i, ll j, T x) {
		b.add(i, -i*x); b.add(j, j*x);
		c.add(i, x); c.add(j, -x);
	}
	// sum [0,i)
	T sum(ll i) { return b.sum(i + 1) + c.sum(i + 1)*i; }
	// sum [i,j)
	T sum(ll i, ll j) { return sum(j) - sum(i); }
};

bool ans;

void plus1(vector<ll>& number, ll add, ll base, bitr<ll>& bit) {
	add--;
	if (add < 0) {
		ans = false;
		return;
	}
	if (add >= (ll)number.size()-1)
		return;
	ll flag = bit.sum(add, add + 1);
	if (flag < 0)
		number[add] = 0;
	bit.add(add, add + 1, -flag);
	bit.add(add + 1, bit.b.N-2, -1);
	number[add]++;
	if (number[add] >= base) {
		number[add] = 0;
		plus1(number, add, base, bit);
	}
}

int main() {
	ll N;
	cin >> N;
	ll before = -10;
	vector<ll> a;
	for (int i = 0;i < N;i++) {
		ll now;
		cin >> now;
		if (now <= before)
			a.push_back(now);
		before = now;
	}
	if (a.empty()) {
		cout << 1 << endl;
		return 0;
	}
	ll l = 1;
	ll r = N;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		ans = true;
		bitr<ll> bit(N+10);
		vector<ll> number(N + 5);
		for (auto &&x : a) {
			plus1(number, x, m, bit);
		}
		if (ans)
			r = m;
		else
			l = m;
	}
	cout << r << endl;
	return 0;
}
/*
10
1 1 1 2 3 3 3 3 3 3

*/

Measured memory_bytes: 8688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
  string line,ans;
	while(cin>>line){
		while(true){
			int f = line.find("@");
			if(f == -1){
				ans = ans + line;
				break;
			}
			else{
				ans = ans + line.substr(0,f);
				for(int i=0;i < (int)(line[f+1]-'0');i++){
					ans = ans + line[f+2];
				}
				line = line.substr(f+3);
			}
		}
		cout<<ans<<endl;
		line = "";
		ans = "";
	}
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int LCS(const char* a,const char* b)
{
    int m=strlen(a); int n=strlen(b); //i???????¬????a????????????j???????¬????b?????????
    int c[m+1][n+1]; //c??°???????????¨?????°???????¬????a??????i??????????¬????b??????j????????´???LCS
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int i=0;i<=n;i++) c[0][i]=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
        {
            if(a[i]==b[j]) c[i+1][j+1]=c[i][j]+1;
            else
            {
                c[i+1][j+1]=max(c[i][j+1],c[i+1][j]);
            }
        }
    return c[m][n];

}
int main()
{
    char *a=new char[1001];
    char *b=new char[1001];
    int q;
    while(cin>>q)
    {
        for(int i=0;i<q;i++)
        {
            cin>>a>>b;
            cout<<LCS(a,b)<<endl;
        }
    }
}

Measured memory_bytes: 7020
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
// #define mod  11092019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b, ll mod) { return (long long) a*b%mod;}
inline ll add(ll a, ll b, ll mod) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b, ll mod) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p, ll mod){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a, mod)) (p & 1) && (Mul(ret, a, mod), 1);
	return ret;
}
static inline void read(ll &x) { cin>>x;}


ll ar[1<<19];

inline ll G(vi &tnt){
    ll index=0;
    IFR(i, 63, 0){
        ll ind=index, ele=-INF;
        FER(j, index, sz(tnt)){
            if((tnt[j]&(1LL<<i))!=0 and tnt[j] > ele) 
                ele=tnt[j], ind=j;
        }
        if(ele==-INF) continue;
        swap(tnt[index], tnt[ind]);
        ind=index;
        FER(j, 0, sz(tnt)) {
            if(j != ind and (tnt[j]&(1LL<<i))!=0){
                tnt[j]=tnt[j]^tnt[ind];
            }
        }
        index++;
    }
    ll valor=0LL;
    // trace(sz(tnt));
    // for(auto xd: tnt) cout<<xd<<" "; cout<<endl;
    FER(i, 0, sz(tnt)) valor^=tnt[i];
    return valor;
    
}

int main(){
	fastio;
	ll n; read(n);
	ll aea = 0;
	FER(i, 0, n) read(ar[i]), aea^=ar[i];
	ll ans = 0, queda = 0;
	IFR(i, 62, 0){
		ll times = 0;
		FER(j, 0, n) if((ar[j]>>i)&1) times++;
		if(times&1){
			queda += (1LL<<i);
			FER(j, 0, n) if((ar[j]>>i)&1) ar[j]^=(1LL<<i);
		}
	}
	// trace(queda);
	vi tnt;
	FER(i, 0, n) {
		tnt.pb(ar[i]);
	}
	ll add = G(tnt);
	cout<<(add<<1) + (queda)<<"\n";
	return 0;
}

Measured memory_bytes: 5064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	string s;
	cin >> s;
	
	int len = s.size();	

	int cnt = 0;

	for (int i = 0; i < len; i++)
	{
		if (s[i] == 'x') {
			cnt++;
		}
	}

	if (cnt <= 7) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	
}

Measured memory_bytes: 256
S = input()
first = int(S[:2])
second = int(S[2:])
if 1<=first<=12 and 1<=second<=12:
  print('AMBIGUOUS')
elif 1<=first<=12:
  print('MMYY')
elif 1<=second<=12:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 2940
using System;

namespace abc136A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int D = A - B;
            if (C > D)
            {
                int E = C - D;
                Console.WriteLine(E);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


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



int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  if(S == U){
    A--;
  }
  else{
    B--;
  }
  cout << A << " " << B << endl;
  
}


Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc122_a.cpp
 * time   : Fri May  1 16:16:40 2020
 * quest  : A - Double Helix
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char ch;
  cin >> ch;
  cout << (ch == 'A' ? 'T' : (ch == 'T' ? 'A' : (ch == 'G' ? 'C' : 'G'))) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
int H[100];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    rep(i,0,N) cin>>H[i];
    int m=H[0];
    int ans=1;
    rep(i,1,N){
        if(H[i]>=m){
            m=H[i];
            ans++;
        }
    }
    cout <<ans<<"\n";
}

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

int main() {
  int X, Y; cin >> X >> Y;

  if (Y % 2 == 0 && Y / 2 >= X && 2 * X - Y / 2 >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3576
import sys
input = sys.stdin.readline #for input speed

H, W = map(int, input().split())
M = [list(input().strip()) for _ in range(H)]
M_yoko = [[0 for _ in range(W)] for _ in range(H)]
M_tate = [[0 for _ in range(W)] for _ in range(H)]

for row in range(H):
    walls = [-1]
    for col in range(W):
        if M[row][col] == '#':
            walls.append(col)
    walls.append(W)
    for i in range(len(walls)-1):
        st = walls[i]
        ed = walls[i+1]
        for j in range(st+1, ed):
            M_yoko[row][j] = ed - st - 1

for col in range(W):
    walls = [-1]
    for row in range(H):
        if M[row][col] == '#':
            walls.append(row)
    walls.append(H)
    for i in range(len(walls)-1):
        st = walls[i]
        ed = walls[i+1]
        for j in range(st+1, ed):
            M_tate[j][col] = ed - st - 1

ans = 0
for row in range(H):
    for col in range(W):
        ans = max(ans, M_yoko[row][col] + M_tate[row][col])

print(ans-1)


Measured memory_bytes: 253064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

	if (a % 2 == 0 && b % 2 == 1) {
		if ((b - a + 1) / 2 % 2 == 1) cout << 1 << endl;
		else cout << 0 << endl;
	}
	else if (a % 2 == 0 && b % 2 == 0) {
		if ((b - a) / 2 % 2 == 1) cout << b + 1 << endl;
		else cout << b << endl;
	}
	else if (a % 2 && b % 2) {
		if ((b - a) / 2 % 2 == 1) cout << a - 1 << endl;
		else cout << a << endl;
	}
	else {
		if ((b - a) / 2 % 2 == 1) cout << ((a^b)^1) << endl;
		else cout << (a^b) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstdio>
using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long>PLL;
typedef queue<int> QI;
typedef priority_queue<int> maxpq;
typedef priority_queue<int, vector<int>, greater<int> > minpq;

struct edge{int to, cost;};

void begin(){cin.tie(0); ios::sync_with_stdio(false);};
int gcd(int a, int b){if(a%b==0){return(b);}else{return(gcd(b,a%b));}};
int lcm(int m, int n){if((0 == m)||(0 == n)){return 0;} return ((m / gcd(m, n)) * n);};
unsigned long long comb(long n, long m){unsigned long long c = 1; m = (n - m < m ? n - m : m);
    for(long ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++){c *= ns; c /= ms;} return c;};

void warshallFloyd(int d[100][100], int n){
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j)
                if(d[i][k] != -1 && d[k][j] != -1){
                    if(d[i][j] == -1){
                        d[i][j] = d[i][k] + d[k][j];
                    }else{
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    }
                }
};


// d:隣接行列  n:グラフのサイズ  s:始点  dist:始点からの距離が入る配列
void dijkstra(int d[1000][1000], int n, int s, int dist[1000]){
    FOR(i, n) dist[i] = -1;
    dist[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII> > q;
    q.push(PII(0, s));
    while (!q.empty()) {
        PII p = q.top(); q.pop();
        int i = p.second;
        if(dist[i] < p.first) continue;
        for(int j = 0; j < n; j++){
            if(d[i][j] == -1) continue;
            if(dist[j] == -1){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }else if(dist[j] > dist[i] + d[i][j]){
                dist[j] = dist[i] + d[i][j];
                q.push(PII(dist[j], j));
            }
        }
    }
};

int main(int argc, const char * argv[]){
    begin();
    int a, b;
    while(cin >> a >> b){
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
}

Measured memory_bytes: 1200
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
import math
def sol(n):
    A = math.floor(math.ceil(n/1.08) * 1.08) == n
    if A:
        return math.ceil(n/1.08)
    B = math.floor(math.floor(n/1.08) * 1.08) == n
    if B:
        return math.floor(n/1.08)
    return ":("



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    #k = int(parsed_lines[0][1])
    #S = parsed_lines[0][0]
    return n


if not do_submit:
    S = input_parse("""
    432
    """)
    print(sol(S))

    S = input_parse("""
    1079
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    #A, B = list(map(int, input().split()))
    S = int(input())
    print(sol(S))

    # S = input().strip()
    # print(sol(S))


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

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d\n", n - k + 1);
}

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


int main() {
    int N; cin >> N;
    multiset<int, greater<int>> Targets;
    vector<int> Slimes;

    for (int i = 0; i < 1 << N; i++) {
        int s; cin >> s;
        Targets.insert(s);
    }
    Slimes.push_back(*Targets.begin());
    Targets.erase(Targets.begin());

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 1 << i; j++) {
            multiset<int,greater<int>>::iterator x=Targets.upper_bound(Slimes[j]);
            if (x == Targets.end()) {
                cout << "No" << endl;
                return 0;
            }
            Slimes.push_back(*x);
            Targets.erase(x);
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 13692
n = int(input())
a = list(map(int, input().split()))
ans = 0
cur = a[0]
for i in range(1, n):
    if cur <= a[i]:
        cur = a[i]
    else:
        ans += cur - a[i]
        a[i] = cur
        cur = a[i]
print(ans)

Measured memory_bytes: 105196
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        loop:
        while ((input = br.readLine()) != null) {
            String[] st = input.split(" ");
            int a = Integer.parseInt(st[0]);
            int b = Integer.parseInt(st[2]);
            switch (st[1]) {
                case "+":
                    bw.append((a + b) + "\n");
                    break;
                case "-":
                    bw.append((a - b) + "\n");
                    break;
                case "*":
                    bw.append((a * b) + "\n");
                    break;
                case "/":
                    if (a > 0 && b > 0) {
                        bw.append((a / b) + "\n");
                    }
                    else{
                        bw.append("0\n");
                    }
                    break;
                case "?":
                    break loop;
            }
        }
        bw.flush();

    }


}


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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    string S_dash=in<string>();
    string T=in<string>();
    string ans;ans="UNRESTORABLE";
    if(S_dash.length()<T.length()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    bool onceRestore;onceRestore=false;
    bool canRestore;
    canRestore=true;
    string minS;
    REP(i,S_dash.length()){
        //debug(S_dash.length()-i);debug(T.length());
        if(S_dash.length()-i<T.length()){
            break;
        }
        minS=S_dash;
        canRestore=true;
        REP(j,T.length()){
            //debug(S_dash[i+j]);debug(T[j]);
            if(S_dash[i+j]=='?'||S_dash[i+j]==T[j]){
                minS[i+j]=T[j];
            }else{
                canRestore=false;
                break;
            }
        }
        //debug(canRestore);
        if(canRestore){
            onceRestore=true;
            //debug(minS);
            REP(j,minS.length()){
                if(minS[j]=='?'){
                    minS[j]='a';
                }
            }
            //debug(minS);
            //debug(ans);
            if(ans=="UNRESTORABLE"){
                ans=minS;
            }else{
                if(minS<ans)ans=minS;
            }
        }
    }
    if(onceRestore){
        cout<<ans<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
			i--;
		}
	}

	cout << ans << endl;
	return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N;
const int MAX_N = 100005;
int h[MAX_N][3];
int dp[MAX_N][3];

void solve() {
    cin >> N;
    rep(i, N)rep(j, 3) cin >> h[i][j];

    rep(i, 3) dp[0][i] = 0;
    Rep1(i, 0, N){
        rep(j, 3){
            rep(k, 3){
                if(j == k) continue;
                dp[i+1][j] = max(dp[i+1][j], dp[i][k]+h[i][k]);
            }
        }
    }

    int res = 0;
    rep(i, 3) res = max(res, dp[N][i]);
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6656
#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;
using ll = long long;

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

int main()
{
  ll N, M; cin >> N >> M;
  vector<ll> p(M); vector<string> S(M); REP(i, M) cin >> p[i] >> S[i];

  map<ll, vector<string>> PS;
  REP(i, M) {
    PS[p[i]].push_back(S[i]);
  }

  ll ac = 0, wa = 0;
  for (auto v : PS) {
    for (int i = 0; i < v.second.size(); ++i) {
      if (v.second[i] == "AC") {
        ac++;
        break;
      }
      wa++;

      if (v.second.size()-1 == i) {
        wa -= v.second.size();
      }
    }
  }

  cout << ac << " " << wa << endl;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"
ll Ceil(ll val,ll div){	return (1 + (val - 1) / div);}

void Main()
{
	ll N,H;
	ll result=0;
	cin>>N>>H;
	VI A(N),B(N);
	REP(i, N) cin >> A[i]>>B[i];
	SORTR(A);
	ll maxA=A[0];
	SORTR(B);
	ll sumB=SUM(B);
	REP(i,N) {
		if(maxA>B[i]) continue;
		H -= B[i];
		result++;
		if (H<=0){
			COUT(result);
			return;
		}
	}
	result+=Ceil(H,maxA);
	cout << result << "\n";
	return;
}

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


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

const int M = 924844033, N = 2010;
long long dp[N][N][4];
long long ways[N][N];
long long dp2[N];
long long fac[N];


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

    dp[0][0][0] = 1;
    for (int i=1; i+5<N; i++) {
        for (int p=0; p<=i+1; p++) {
            dp[i][p][0] = (dp[i-1][p][0]+dp[i-1][p][1]+dp[i-1][p][2]+dp[i-1][p][3])%M;
            dp[i][p+1][1] = (dp[i-1][p][0]+dp[i-1][p][1])%M;
            dp[i][p+1][2] = (dp[i-1][p][0]+dp[i-1][p][2])%M;
            dp[i][p+2][3] = dp[i-1][p][0];
        }
    }

    for (int i=0; i+5<N; i++) {
        for (int j=0; j<=i+2; j++) {
            ways[i][j] = (dp[i][j][0] + dp[i][j][1] + dp[i][j][2] + dp[i][j][3])%M;
        }
    }

    fac[0] = 1;
    for (int i=1; i<N; i++)     fac[i] = (fac[i-1]*i)%M;

    int n, k;
    cin>>n>>k;

    dp2[0] = 1;
    for (int i=0; i<k; i++) {
        int cnt = n/k + (i<n%k);
        for (int cur=n; cur>=0; cur--) {
            long long vv = 0;
            for (int j=0; j<=cur && j<=cnt; j++)
                vv = (vv + dp2[cur-j]*ways[cnt-1][j])%M;
            dp2[cur] = vv;
        }
    }

    long long ans = 0;

    for (int i=0; i<=n; i++) {
        if (i%2==0) ans = (ans + dp2[i]*fac[n-i])%M;
        else        ans = (ans - dp2[i]*fac[n-i])%M;
    }
    ans = (ans%M+M)%M;
    cout<<ans<<endl;
}


Measured memory_bytes: 97100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;

    cout << n*(n+1)/2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    string s;
    cin>>s;
    int n = s.size();
    if(s[n-1]=='s')cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
    return 0;
}

///Alhamdulillah


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <climits>
#include <set>
#define endl '\n'
#define ll long long

using namespace std;

ll dp[101][100001];

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    auto w = new int[N+1]();
    auto v = new int[N+1]();
    
    for(int i = 1; i <= N; i++) { cin >> w[i] >> v[i]; }
    
    for(int i = 1; i <= N; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(j - w[i] >= 0)
            {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    
    ll ret = 0;
    for(int i = 0; i <= W; i++) ret = max(ret, dp[N][i]);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B,C,X,Y;

	scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);

	int ans = BIG_NUM;

	//Cを買う枚数を全探索
	for(int i = 0; i <= 2*(X+Y); i++){

		int num_a = i/2;
		int num_b = i/2;

		int rest_a = max(0,X-num_a);
		int rest_b = max(0,Y-num_b);

		ans = min(ans,rest_a*A+rest_b*B+C*i);
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3772
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N, M, A[100009], B[100009], C[100009], P[100009], sum[100009];
int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) scanf("%d", &P[i]), P[i]--;
	for (int i = 0; i < N - 1; i++) scanf("%d%d%d", &A[i], &B[i], &C[i]);
	for (int i = 1; i < M; i++) {
		int pl = P[i - 1], pr = P[i];
		if (pl > pr) swap(pl, pr);
		sum[pl]++; sum[pr]--;
	}
	for (int i = 1; i < N; i++) sum[i] += sum[i - 1];
	long long ret = 0;
	for (int i = 0; i < N - 1; i++) ret += min(1LL * A[i] * sum[i], 1LL * B[i] * sum[i] + C[i]);
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 4688
#include "bits/stdc++.h"

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    vector<pair<char, int>> vec;
    int cnt = 0;
    char last = s[0];
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == last) {
            ++cnt;
        } else {
            vec.emplace_back(last, cnt);
            cnt = 1;
            last = s[i];
        }
    }
    vec.emplace_back(last, cnt);
    int maxv = 0;
    for (int i = 1; i < vec.size() - 1; ++i) {
        if (vec[i - 1].first == 'J' && vec[i].first == 'O' && vec[i + 1].first == 'I') {
            if (vec[i - 1].second >= vec[i].second && vec[i].second <= vec[i + 1].second) {
                maxv = max(maxv, vec[i].second);
            }
        }
    }
    cout << maxv << "\n";
    return 0;
}



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

int main(){
  int n,d;
  cin >> n;
  int ans = 0;
  bool check[100];
  for(int i=0; i<101; i++){
    check[i] = true;
  }
  for(int i=0; i<n; i++){
    cin >> d;
    if(check[d]){
      check[d] = false;
      ans += 1;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> D[100010];
    rep(i,n){
        int a, b;
        cin >> a >> b;
        D[a].pb(b);
    }
    int ans = 0;
    priority_queue<int> que;
    for (int i = 1; i <= m; i++) {
        rep(j,D[i].size()) que.push(D[i][j]);
        if(que.empty()) continue;
        int ma = que.top();
        que.pop();
        ans += ma;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string S,T="";
  cin >> S;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      T.push_back('0');
    }
    else if(S.at(i)=='1'){
      T.push_back('1');
    }
    else if(T.size()){
      T.pop_back();
    }
  }
  cout << T << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
int main() {
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll res = INF;
	rep(i, max(x + 1, y + 1)) {
		ll cnt = 0;
		cnt += c * 2 * i;
		if (x - i >= 0) {
			cnt += a * (x - i);
		}
		if (y - i >= 0) {
			cnt += b * (y - i);
		}
		chmin(res, cnt);
	}
	/*rep(i, x + 1) {
		rep(j, y + 1) {
			ll cnt = 0;
			cnt += a * i + b * j;
			cnt += c * 2 * max(x - i, y - j);
			chmin(res, cnt);
		}
	}*/
	cout << res << endl;
}


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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

signed main() {
    int N;
    cin >> N;
    vector<string> s(N);
    for(int i=0; i<N; i++) cin >> s[i];

    vector<int> va,vb,vba;
    int ans=0;
    for(int i=0; i<N; i++){
        for(int j=0; j<s[i].length()-1; j++){
            //DEBUG(s[i]);
            if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
        }
        if(s[i][0]=='B' && s[i][s[i].length()-1]=='A') vba.push_back(i);
        else if(s[i][0]=='B') vb.push_back(i);
        else if(s[i][s[i].length()-1]=='A') va.push_back(i);
    }

    int ca=va.size(), cb=vb.size(), cba=vba.size();

    if(va.size()>0 && vb.size()>0){
        cout << ans + cba+1 + min(ca-1,cb-1) << endl;
    }
    else if(ca > 0 || cb > 0){
        cout << ans + cba << endl;
    }
    else if(cba > 1){
        cout << ans + cba-1 << endl;
    }
    else {
        cout << ans << endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m;
	cin>>m;
	int a,b,ans=0;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		ans+=(b-a+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import itertools

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    ans=0
    for aa in itertools.combinations(arr,3):
        aa=list(aa)
        aa.sort()
        if aa[2] == aa[0]:
            continue
        if aa[2] == aa[1]:
            continue
        if aa[1] == aa[0]:
            continue
        if aa[2] < (aa[0]+aa[1]):
            ans+=1
    print(ans)

    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16216
#include<cstdio>
#include<iostream>
using namespace std;
int n;
inline int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int main()
{
	n=read();
	if(n>=30)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3632
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto tpr = readInts();
		auto t = tpr[0];
		auto p = tpr[1];
		auto r = tpr[2];
		if((t | p | r) == 0) return;

		auto w = new int[][](t, p);
		auto c = new int[][](t, p);
		auto penalty = new int[](t);
		for(int i; i < r; ++i) {
			auto l = readln.chomp.split;
			auto tid = l[0].to!int-1;
			auto pid = l[1].to!int-1;
			auto time = l[2].to!int;
			auto mess = l[3];
			if(mess == "CORRECT") {
				if(c[tid][pid] == 0) {
					c[tid][pid] = time;
					penalty[tid] += w[tid][pid] * 1200 + time;
				}
			} else {
				++w[tid][pid];
			}
		}
		int[] cp;
		for(int i; i < t; ++i) {
			cp ~= filter!("a > 0")(c[i]).array.length.to!int;
		}
		auto tid = iota(1, t+1).array;
		zip(cp, penalty, tid).sort!((a,b) => a[0] > b[0] || (a[0] == b[0] && a[1] < b[1]) || (a[0] == b[0] && a[1] == b[1] && a[2] < b[2]));
		for(int i; i < t; ++i) {
			writeln(tid[i], " ", cp[i], " ", penalty[i]);
		}
	}
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	int cnt=1;
	rep(i,n){
		if(a[i]%2==0)cnt*=2;
	}
	cout<<power(3,n)-cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
k = int(input())

def get_below(a):
    s = str(a)
    if len(s) == 1:
        return a
    else:
        ret = 0
        for i in range(len(s)):
            ret += sum(nums[i][1:])

        for i in range(1, int(s[0])):
            ret += nums[len(s)][i]

        def dfs(ss):
            # start: fixed
            if len(ss) == 1:
                return 1
            if int(ss[0]) > int(ss[1]) + 1:
                return 0
            elif int(ss[0]) == int(ss[1]) + 1:
                return dfs(ss[1:])
            elif int(ss[0]) == int(ss[1]):
                ret = 0
                if int(ss[1]) != 0:
                    ret += nums[len(ss) - 1][int(ss[1]) - 1]
                return ret + dfs(ss[1:])
            elif int(ss[0]) + 1 == int(ss[1]):
                ret = 0
                if int(ss[1]) >= 1:
                    ret += nums[len(ss) - 1][int(ss[1]) - 1]
                if int(ss[1]) >= 2:
                    ret += nums[len(ss) - 1][int(ss[1]) - 2]
                return ret + dfs(ss[1:])
            else:
                return nums[len(ss)][int(ss[0])]

        return ret + dfs(str(a))

if k <= 10:
    print(k)
else:
    nums = [[0] * 10 for _ in range(11)]
    nums[1] = [1] * 10

    for i in range(11):
        for j in range(10):
            if j != 0:
                nums[i][j] += nums[i-1][j-1]
            if j != 9:
                nums[i][j] += nums[i-1][j+1]
            nums[i][j] += nums[i-1][j]

    lo = 0
    hi = 10 ** 10
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if get_below(mid) - k >= 0:
            hi = mid
        else:
            lo = mid

    print(hi)


Measured memory_bytes: 3192
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let mut iter = buf.split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let mut ans = 0;

    for i in a..b + 1 {
        if c % i == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5024