akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

    if(n == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    int k = 2;

    while(1)
    {
        if(k <= n && k * 2 > n)
        {
            cout << k << endl;
            return 0;
        }

        k *= 2;
    }

    cout << k << endl;

    
    

    
   

    return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

class ModComb:
    def __init__(self, MAX, mod=10 ** 9 + 7):
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, MAX):
            fac.append(fac[i - 1] * i % mod)
            inv.append(mod - inv[mod % i] * (mod // i) % mod)
            finv.append(finv[i - 1] * inv[i] % mod)
        self.fac, self.finv, self.mod = fac, finv, mod

    def nCk(self, n, k):
        if n < k or n < 0 or k < 0:
            return 0
        fac, finv, mod = self.fac, self.finv, self.mod
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

K = int(input())
S = input()

N = len(S)
mc = ModComb(N + K + 10)

ans = 0
for i in range(K + 1):
    ans += pow(25, i, mod) * pow(26, K - i, mod) * mc.nCk(i + N - 1, N - 1)
    ans %= mod

print(ans)

Measured memory_bytes: 197228
use std::cmp::min;


fn main() {
    let s: Vec<u32> = read::<String>().chars().map(|c| c.to_digit(10).unwrap()).collect();

    let mut dp = vec![vec![0; s.len() + 1]; 2];
    dp[1][0] = 1;
    for (i, &n) in s.iter().enumerate() {
        let i = i + 1;
        dp[0][i] = min(dp[0][i-1] + n, dp[1][i-1] + 10 - n);
        dp[1][i] = min(dp[0][i-1] + n + 1, dp[1][i-1] + 10 - n - 1);
    }

    println!("{:?}", dp[0][s.len()]);
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}



Measured memory_bytes: 17656
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 2e5+10;
vi g[mxn];
int ans;
bool vis[mxn];

void dfs(int v){
	ans++;
	vis[v] = 1;
	for(int u : g[v]){
		if(!vis[u]){
			dfs(u);
		}
	}
}

int32_t main(){
		
	NINJA;

	int n,m; cin >> n >> m;
	fo(i,m){
		int u,v; cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	
	int res=0;
	for1(i,n){
		if(!vis[i]){
			ans=0;
			dfs(i);
			res=max(res,ans);
		}
	}
	cout << res << endl;

}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int H,W;

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

	cin >> H >> W;
	vector< vector<string> > S(H,vector<string>(W));
	FOR(i,0,H) FOR(j,0,W){
		cin >> S [i] [j];
	}

	FOR(i,0,H) FOR(j,0,W){
		if(S [i] [j] == "snuke"){
			char c = j + 'A';
			cout << c << i + 1 << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
  int A,B,C;

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

  if(A==B){
    printf("%d\n",C);
  } else if(A==C){
    printf("%d\n",B);
  } else {
    printf("%d\n",A);
  }

  return 0;
}


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

int main() {
	string S;
	long long Count = 0;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A') {
			long long As = 1;
			bool flagB = true;
			while (1) {
				if (i + 1 == S.size()) break;
				if (S[i + 1] == 'A') {
					if (!flagB) break;
					i++;
					As++;
				}
				else if (S[i + 1] == 'B') {
					if (flagB) {
						i++;
						flagB = false;
					}
					else break;
				}
				else if (S[i + 1] == 'C') {
					if (!flagB) {
						i++;
						Count+=As;
						flagB = true;
					}
					else break;
				}
			}
		}
	}
	cout << Count;
}

Measured memory_bytes: 640
n, h = map(int, input().split())
A = []; B = []
for i in range(n):
    a, b = map(int, input().split())
    A += a,; B += b,
a = max(A)

T = []
for i in range(n):
    if a < B[i]:
        T += B[i],
T.sort(reverse=True)
ans = 0
for t in T:
    h -= t; ans += 1
    if h <= 0:
        break
if h > 0:
    ans += (h + a - 1) // a
print(ans)



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

#define ll long long int
const int N=100010;
int arr[N];

int calc(int n) {
    vector<int> v(n+10, INT_MAX);
    v[0] = INT_MIN;
    int L[N];
    for (int i=0;i<n;i++)arr[i]*=-1;
    for (int i=0;i<n;i++) {
        auto it = upper_bound(v.begin(), v.end(), arr[i]);
        *it = arr[i];
        L[i] = it-v.begin();
    }
    return *max_element(L+1, L+n+1);
}
int main () {
    int n;
    cin>>n;
    for (int i=0;i<n;i++)cin>>arr[i];
    
    cout<<calc(n);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(void){
  
  int a,b;
  cin>>a>>b;
  int c=a+b;
  
  if(c==24){
      cout<<0<<endl;
  }
  
  else if(c>24){
      cout<<c-24<<endl;
  }
  
  else{
      cout<<c<<endl;
  }
}


Measured memory_bytes: 3628
#sizeありversion
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}
        self._size = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0
        self._size[x] = 1

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
            self._size[x] += self._size[y]
            ##self._size[y] = 0
        else:
            self.p[x] = y
            self._size[y] += self._size[x]
            #self._size[x] = 0
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    #頂点xが属するグループと同じグループに属する頂点数を得る
    def size(self, x):
        return self._size[self.findSet(x)]

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]


N, M = map(int, input().split())
l = [[int(i) for i in input().split()] for i in range(M)]

ds = DisjointSet()
for i in range(N):
    ds.makeSet(i+1)

ans = [0] * M
ans[M-1] = N * (N - 1) // 2

for i in range(M-1, 0, -1):
    a, b = l[i]
    if ds.same(a, b):
        ans[i-1] = ans[i]
    else:
        x = ds.size(a)
        y = ds.size(b)
        ans[i-1] = ans[i] - x * y
        ds.unite(a, b)

for a in ans:
    print(a)

Measured memory_bytes: 47980
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
int main(void){
    int n;ll k;cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<mint> b(2010,0),c(2010,0);
    rep(i,n){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])b[i]+=1;//見る数内での転倒数
        }
        for(int j=0;j<i;j++){
            if(a[i]>a[j])c[i]+=1;
        }
    }
    mint res=0;
    rep(i,n){
        mint buf=(b[i]*k+(b[i]+c[i])*k*(k-1)/2);
        res+=buf;
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 3648
h,w,a,b = map(int,input().split())
if b > h//2 or a > w//2:
    print("No")
    exit(0)
for _ in range(h-b):
    print("0"*(w-a) + "1"*a)
for _ in range(b):
    print("1"*(w-a) + "0"*a)

Measured memory_bytes: 3956
fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    val (n, q) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    var list = Array(n) { 0 }
    for (i in 0 until n) {
        if (i == 0) continue
        if (s[i] == 'C' && s[i - 1] == 'A') {
            list[i] = list[i - 1] + 1
        } else {
            list[i] = list[i - 1]
        }
    }

    Array(q) {
        val (start, end) = readLine()!!.split(" ").map(String::toInt)
        println(list[end - 1] - list[start - 1])
    }
}

Measured memory_bytes: 67720
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    t = S()
    n = len(s)
    d = defaultdict(list)
    for i in range(n):
        d[s[i]].append(t[i])
    d2 = defaultdict(list)
    for i in range(n):
        d2[t[i]].append(s[i])
    for i in d.keys():
        k = d[i]
        k = list(set(d[i]))
        if len(k) > 1:
            print("No")
            quit()
    for i in d2.keys():
        k = d2[i]
        k = list(set(d2[i]))
        if len(k) > 1:
            print("No")
            quit()
    print("Yes")
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 72380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            out.println(str.charAt(0) + "" + (str.length() - 2) + str.charAt(str.length() - 1));
        }

    }
}



Measured memory_bytes: 23764
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll ans[2005];
    for (int i = 0; i <= 2; i++) ans[i] = 0;
    ans[3] = 1;
    for (int i = 4; i < 2005; i++) {
        ans[i] = 1;
        for (int j = 3; j <= i; j++) {
            ans[i] += ans[i-j];
            ans[i] %= MOD;
        }
        ans[i] = (ans[i]+MOD)%MOD;
    }
    int n;
    cin >> n;
    cout << ans[n] << endl;
    return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n,m;
    ll di=1000000007;
    cin>>n>>m;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }
    else{
        if(n==m){
            ll tmp=2;
            while(n>=1){
                tmp=((tmp*n)%di)*n;
                tmp%=1000000007;
                n--;
                // cout<<tmp<<endl;
            }
            cout<<tmp<<endl;
        }
        else{
            ll tmp=max(n,m);
            ll tmp_1=tmp;
            tmp_1--;
            while(tmp_1>=1){
                tmp=((tmp*tmp_1)%di)*tmp_1;
                tmp%=1000000007;
                tmp_1--;
                // cout<<tmp<<endl;
            }
            cout<<tmp<<endl;
        }
    }





    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,T = I()
ans = INF
for i in range(N):
    c,t = I()
    if t <= T:
        ans = min(ans,c)
if ans == INF:
    print('TLE')
else:
    print(ans)

Measured memory_bytes: 72664
<?php
// $n = (int)trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));

$r = (int)$input[0];
$d = (int)$input[1];
$x = (int)$input[2];

$results = [];

$prev = $x;
for ($i=0; $i < 10; $i++) { 
	$tmp = $prev * $r - $d;
	$results[] = $tmp;
	$prev = $tmp;
}

echo implode(PHP_EOL, $results);

Measured memory_bytes: 4728
#40 ABC131D
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab=sorted(ab,key=lambda x:x[1])
j=True
x=0
for a,b in ab:
	x+=a
	if x>b:
		j=False
		break
print("Yes" if j else "No")

Measured memory_bytes: 89816
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

void koch_curve(int n,double L_x,double L_y,double R_x,double R_y){
  if(n==0) return;
  double S_x,S_y,U_x,U_y,T_x,T_y;
  //keisan{
    S_x=((L_x*2.0)+R_x)/3.0;
    S_y=((L_y*2.0)+R_y)/3.0;
    T_x=(L_x+(R_x*2.0))/3.0;
    T_y=(L_y+(R_y*2.0))/3.0;
    U_x=((T_x-S_x)/2.0)-(((T_y-S_y)/2)*sqrtf(3.0))+S_x;
    U_y=(((T_x-S_x)/2.0)*sqrtf(3.0))+((T_y-S_y)/2.0)+S_y;
  //}
  koch_curve(n-1,L_x,L_y,S_x,S_y);
  cout<<S_x<<" "<<S_y<<endl;
  koch_curve(n-1,S_x,S_y,U_x,U_y);
  cout<<U_x<<" "<<U_y<<endl;
  koch_curve(n-1,U_x,U_y,T_x,T_y);
  cout<<T_x<<" "<<T_y<<endl;
  koch_curve(n-1,T_x,T_y,R_x,R_y);
}

int main (){
  cout << setprecision(15) << std::fixed;
  int n;
  cin>>n;
  cout<<fixed;
  cout<<0.0<<" "<<0.0<<endl;
  koch_curve(n,0,0,100,0);
  cout<<100.0<<" "<<0.0<<endl;
}


Measured memory_bytes: 3256
from collections import defaultdict, deque
N, M = map(int, input().split())
G = defaultdict(list)
for _ in range(M):
    u, v = map(int, input().split())
    G[(u-1, 0)].append((v-1, 1))
    G[(u-1, 1)].append((v-1, 2))
    G[(u-1, 2)].append((v-1, 0))
S, T = map(int, input().split())
dist = defaultdict(lambda : -1)
que = deque([(S-1, 0)])
dist[(S-1, 0)] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for nv in G[v]:
        if dist[nv]>=0:
            continue
        dist[nv] = d+1
        que.append(nv)
print(dist[(T-1, 0)]//3)


Measured memory_bytes: 130040
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  long N;
  cin >> N;
  vector<pair<long, long>> reds, blues;
  rep (i, N) {
    long a, b;
    cin >> a >> b;
    reds.push_back(make_pair(a, b));
  }
  rep (i, N) {
    long c, d;
    cin >> c >> d;
    blues.push_back(make_pair(c, d));
  }
  sort(reds.rbegin(), reds.rend());
  sort(blues.rbegin(), blues.rend());
  vector<bool> used(N, false);
  long result = 0;
  for (long i = 0; i < N; i++) {
    long minimum = -1;
    for (long j = 0; j < N; j++) {
      if (reds[i].first >= blues[j].first) break;
      if (used[j]) continue;
      if (reds[i].second < blues[j].second and (minimum == -1 or blues[j].second < blues[minimum].second)) minimum = j;
    }
    if (minimum != -1) {
      result++;
      used[minimum] = true;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,d=0,r=0;
	double f=0.0;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}


Measured memory_bytes: 2108
// E - Simple String Queries

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N, Q;
	string S;
	cin >> N >> S >> Q;

	map<char, set<int>> sets;

	for (int i=0; i<S.size(); i++) {
		sets[S[i]].insert(i);
	}

	char c;
	int t, i, l, r;
	vector<int> ans;
	for (int k=0; k<Q; k++) {
		cin >> t;
		if (t == 1) {
			cin >> i >> c;
			i--;
			for (char ch='a'; ch<='z'; ch++) {
				sets[ch].erase(i);
			}
			sets[c].insert(i);
		}

		if (t == 2) {
			cin >> l >> r;
			l--;
			r--;
			int cnt = 0;
			for (char ch='a'; ch<='z'; ch++) {
				auto itr = sets[ch].lower_bound(l);
				if (itr != sets[ch].end() && *itr <= r) cnt++;
			}
			ans.push_back(cnt);
		}
	}

	for (int a : ans) {
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 24452
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
#define init(x,n) static int x[N];memset(x,0,4*n);
const int N=1e5+5,K=8e3+5,B=2e2+5,p=998244353,G=3;
int n,m,ans,len,L,a[K<<2],b[K<<2],f[B][K<<2],fac[K<<2],inv[K<<2];
in void M(int&x) {x-=p,x+=x>>31&p;}
in int add(int x,int y) {return M(x+=y),x;}
in int sub(int x,int y) {return M(x+=p-y),x;}
in int c(int n,int m) {return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;}
in int qpow(int x,int y) {int z=1;for(;y;y>>=1,x=1ll*x*x%p) if(y&1) z=1ll*x*z%p;return z;}
in void read(int *a,int n) {for(int i=0;i<n;i++) a[i]=read();}
in void print(int *a,int n) {for(int i=0;i<n;i++) write(a[i]," \n"[i==n-1]);}
int r[N],ny[N],o[N],_o[N];
in void calrev(int len,int L)
{
	for(int i=1;i<=len;i++) r[i]=(r[i>>1]>>1)|((i&1)<<(L-1));
	o[0]=1;o[1]=qpow(G,(p-1)/len);
	for(int i=2;i<=len;i++) o[i]=1ll*o[1]*o[i-1]%p;
	for(int i=0;i<len;i++) _o[i]=o[len-i];
}
in void ntt(int *a,int n,int op)
{
	for(int i=0;i<n;i++) if(i<r[i]) swap(a[i],a[r[i]]);int *w=(op==1)?o:_o;
	for(int i=1;i<n;i<<=1) for(int j=0,d=i<<1;j<n;j+=d) for(int k=j,x,y;k<j+i;k++)
	x=a[k],y=1ll*w[n/d*(k-j)]*a[i|k]%p,M(a[k]=x+y),M(a[i|k]=x+p-y);
	if(op==1) return; int inv=qpow(n,p-2);for(int i=0;i<n;i++) a[i]=1ll*a[i]*inv%p;
}
int main()
{
	n=read()+1,m=read();L=ceil(log2(2*n-1)),calrev(len=1<<L,L);
	fac[0]=fac[1]=inv[0]=inv[1]=1;for(int i=2;i<=n+1;i++) inv[i]=1ll*(p-p/i)*inv[p%i]%p;
	for(int i=2;i<=n+1;i++) inv[i]=1ll*inv[i]*inv[i-1]%p,fac[i]=1ll*fac[i-1]*i%p;
	for(int i=0;i<n;i++) f[m][i]=c(n-1,n-i-1);for(int i=1;i<n;i++) a[i]=inv[i+2];ntt(a,len,1);
	for(int i=m-1;~i;i--)
	{
		for(int j=0;j<n;j++) b[j]=1ll*f[i+1][j]*fac[n+1-j]%p;memset(b+n,0,4*(len-n));
		ntt(b,len,1);for(int j=0;j<len;j++) b[j]=1ll*a[j]*b[j]%p;ntt(b,len,-1);
		for(int j=0;j<n;j++) M(f[i][j]=1ll*b[j]*inv[n-j-1]%p+1ll*f[i+1][j]*(c(n-j,2)+1)%p);
	}
	write(f[0][n-1],'\n');return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 11108
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var s = Console.ReadLine().ToCharArray().ToList();
        s.Reverse();
        for (var i = 0; 8 > i; i++)
        {
            s.RemoveAt(0);
        }
        s.Reverse();
        Console.WriteLine(new String(s.ToArray()));
    }
}

Measured memory_bytes: 26412
import scala.collection.mutable.ArrayBuffer
import scala.util.control.Breaks
import java.lang.Math
object Main{
  def main(args:Array[String]) = {

    val sc = new java.util.Scanner(System.in)
    var N = sc.nextInt
    val K = sc.nextInt

    val hate = List.fill(K)(sc.nextInt)
    val all = List(0,1,2,3,4,5,6,7,8,9)

    val buf = new ArrayBuffer[Int]
    all.foreach(l =>{
      if(!hate.contains(l))buf+=l
    })
    val like = buf.toList

    var loop: Boolean = true
    var candidate: Int = N
    while(loop) {
      val candList = candidate.toString.toCharArray
      val check = candList.map(c => like.contains(c.toInt-48)).foldLeft(true)(_ && _)
      if(check){
        loop=false
      }else{
        candidate+=1
      }
    }

    println(candidate)


  }
}

Measured memory_bytes: 37748
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    string s;
    cin>>n;
    cin>>s;
    int max_cnt = INT_MIN;
    for(int i=1;i<n;i++){
        set<char> x,y;
        int cnt=0;
        for(int j=0;j<i;j++)    x.insert(s[j]);
        for(int k=i;k<n;k++)    y.insert(s[k]);
        for(auto it:x){
            if(y.count(it)) cnt++;
        }
        max_cnt = max(max_cnt, cnt);
    }
    cout<<max_cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define setp(x) setprecision(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> u[i];
    double sum = 0;
    for(int i = 0; i < N; ++i){
        if(u[i] == "BTC") sum += x[i] * 380000.0;
        else sum += x[i];
    }
    cout << sum << setp(10);
}

Measured memory_bytes: 256
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b):
    if a == 2:
        return 'No'
    elif b == 2:
        return 'No'
    else:
        return 'Yes'
    
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func bsearch(a []int, k int) bool {
	left, right := 0, len(a)-1
	for left <= right {
		mid := left + (right-left)/2
		if a[mid] == k {
			return true
		} else if a[mid] < k {
			left = mid + 1
		} else {
			right = mid - 1
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt(sc)
	}
	sort.Ints(a) // 二分探索のためにソートする
	m := nextInt(sc)
	b := make([]int, m)
	for i := range b {
		b[i] = nextInt(sc)
	}
	wtr := bufio.NewWriter(os.Stdout)
	ok := true
	for i := range b {
		if !bsearch(a, b[i]) {
			ok = false
			break
		}
	}
	if ok {
		fmt.Fprintln(wtr, 1)
	} else {
		fmt.Fprintln(wtr, 0)
	}
	wtr.Flush()
}



Measured memory_bytes: 7008
# test

def main():
    import sys
    from fractions import gcd
    input = sys.stdin.readline

    def init(init_val):
        #set_val
        for i in range(n):
            seg[i+num-1]=init_val[i]    
        #built
        for i in range(num-2,-1,-1) :
            seg[i]=gcd(seg[2*i+1],seg[2*i+2]) 
        
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = gcd(seg[k*2+1],seg[k*2+2])
        
    def query(p,q):
        if q<=p:
            return ide_ele
        p += num-1
        q += num-2
        res=ide_ele
        while q-p>1:
            if p&1 == 0:
                res = gcd(res,seg[p])
            if q&1 == 1:
                res = gcd(res,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = gcd(res,seg[p])
        else:
            res = gcd(gcd(res,seg[p]),seg[q])
        return res



    n = int(input())
    a = tuple(map(int,input().split()))

    #####単位元######
    ide_ele = 0

    #num:n以上の最小の2のべき乗
    num =2**(n-1).bit_length()
    seg=[ide_ele]*2*num
    init(a)

    ans = -1
    for i in range(n):
        ans = max(ans,gcd(query(0,i),query(i+1,n)))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 88160
Q = int(input())
L = [0]*Q
R = [0]*Q
 
for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
    
MAX = 10 ** 5
a = [0] * MAX
sum = [0] * (MAX + 1)
for i in range(MAX):
    if i % 2 == 0:
        continue
    if is_prime(i) and is_prime((i+1)/2):
        a[i] = 1;
        
for i in range(MAX):
    sum[i+1] = sum[i] + a[i]

for i in range(Q):
    print(sum[R[i] + 1] - sum[L[i]])

Measured memory_bytes: 15508
s = input().rstrip()
t = input().rstrip()
S = []
T = []
count = 0
for i in s:
  S.append(i)
for i in t:
  T.append(i)
for i in range(len(S)):
  if S[i] != T[i]:
    S[i] = T[i]
    count += 1
print(count)

Measured memory_bytes: 12592
#include <stdio.h>

int main() {
    int num = 0, sum = 0;
    for (int i = 0; i < 3; i++) {
        scanf(" %d", &num);
        sum += num;
    }

    if (sum >= 22)
        printf("bust\n");
    else
        printf("win\n");

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define qwq(x) cerr<<"# "<<#x<<" = "<<x<<endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=5005;
const ll inf=1e18;
int s[N][N],a[N],n,m,A,B;
ll f[N][N],ans;

int S(int l,int r,int d,int u){
	return l>r?0:s[r][u]-s[l-1][u]-s[r][d-1]+s[l-1][d-1];
}

int main(){
	read(n),read(A),read(B);
	rep(i,1,n)read(a[i]),s[i][a[i]]=1;
	rep(i,1,n)rep(j,1,n)
		s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
	ans=(ll)min(A,B)*(n-1);
	memset(f,0x3f,sizeof f);
	a[0]=1,f[0][0]=0;
	rep(i,1,n){
		rep(j,0,i-1)
			if(f[i-1][j]<inf){
				f[i][j]=f[i-1][j];
				if(a[j]<=a[i]){
					f[i][i]=min(f[i][i],f[i-1][j]
							+(ll)A*S(j+1,i-1,a[j],n)
							+(ll)B*S(j+1,i-1,1,a[i]));
				}
			}
		ans=min(ans,f[i][i]	+(ll)A*S(i+1,n,a[i],n)
							+(ll)B*S(i+1,n,1,a[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 293760
N = int(input())
S1 = input()
S2 = input()
MOD = 1_000_000_007
i = 0
directions = []
while i < N:
    if S1[i] == S2[i]:
        directions.append("V")
        i += 1
    else:
        directions.append("H")
        i += 2
prev = directions[0]
ans = 3 if prev == "V" else 6
for d in directions[1:]:
    if prev == "V" and d == "V" or prev == "V" and d == "H":
        ans *= 2
    elif prev == "H" and d == "H":
        ans *= 3
    ans %= MOD
    prev = d
print(ans)



Measured memory_bytes: 9204
N = int(input())
S = input()
#print(S)
ans = 0
kari = 0
for i in range(N):
        if S[i] == ".":
                ans += 1
                kari += 1
for j in range(N):
        if S[j] == "#":
                kari += 1
        elif S[j] == ".":
                kari -= 1
        if kari < ans:
                ans = kari
print(ans)


Measured memory_bytes: 3500
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
events = []
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    events.append((a, 1, i))
    events.append((b, 0, i))
events.sort()
ans = 0
removed = set()
started = set()
for x, t, i in events:
    if t == 0:
        if i not in removed:
            removed |= started
            started = set()
            ans += 1
    if t == 1:
        started.add(i)
print(ans)


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

using namespace std;

char a[10][10];

int main() {
  
  int n, m, k, ans = 0;
  
  cin >> n >> m >> k;
  
  for(int i = 0; i < n; i++)
  for(int j = 0; j < m; j++) {
     cin >> a[i][j];
  }
  
  for(int i = 0; i < (1 << n); i++) {
     for(int j = 0; j < (1 << m); j++) {
        int cur = 0;
        for(int z = 0; z < n; z++) {
           for(int p = 0; p < m; p++) {
              if (a[z][p] == '#' && ((i >> z) & 1) && ((j >> p) & 1)) {
                 cur++;
              }
           }
        }
        if (cur == k) {
           ans++;
        }
     }
  }
  
  cout << ans;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <functional>
#include <map>
#include <set>
using namespace std;



int main() 
{
    long long n, k;
    cin >> n >> k;

    if (n < k) {
        cout << min(n, k - n);
        return 0;
    }
    else if (n == k) {
        cout << 0;
        return 0;
    }
    long long mod = n % k;
    cout << min(mod, k - mod);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long int x[5];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
    }

    int tmp;
    for(int i = 0; i < 5; i++){
        for(int j = i + 1; j < 5; j++){
            if(x[i] < x[j]){
                tmp = x[i];
                x[i] = x[j];
                x[j] = tmp;
            }
        }
    }
    for(int i = 0; i < 5; i++){
        cout << x[i];
        if(i != 4) cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #define _CRT_SECURE_NO_WARNINGS
    #pragma warning(disable:4996)
#endif

#define ll long long
#define vi vector<ll>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

ll INF = 1e9 + 7;



int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size(); int k = t.size();
    vector<vi> dp(n + 1, vi(k + 1, 0));
    for(int i = 1; i <= n; i++)
        for (int j = 1; j <= k; j++)
        {
            if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    string ans = "";
    int i = n, j = k;
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            ans += s[i - 1];
            i--;
            j--;
        }
        else if (dp[i - 1][j] == dp[i][j]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

int D;
const int N=26;
vector<vector<int>>s;
vector<int>c;

ll score(vector<int>&t){
  ll score=0;
  ll ans=0;
  vector<int>last(N,-1);
  for(int i=0;i<D;i++){
    ans+=s[i][t[i]];
    last[t[i]]=i;
    for(int j=0;j<N;j++){
      if(last[j]==-1)ans-=c[j]*(i+1);
      else ans-=c[j]*(i-last[j]);
    }
    score+=max(ans+1000000,0ll);
  }
  return score;
}

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

  cin>>D;
  c.resize(N);
  for(int i=0;i<N;i++)cin>>c[i];
  s.resize(D,vector<int>(N));
  for(int i=0;i<D;i++)for(int j=0;j<N;j++)cin>>s[i][j];

  vector<int>t(D,0);
  ll S=score(t);
  for(int i=0;i<100000;i++){
    vector<int>s(D);
    for(int j=0;j<D;j++)s[j]=t[j];
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<>randD(0,D-1);
    uniform_int_distribution<>randN(0,N-1);
    int d=randD(mt);
    int n=randN(mt);
    s[d]=n;
    ll SS=score(s);
    if(S<SS){
      S=SS;
      t[d]=n;
    }
  }

  for(auto it:t)cout<<it+1<<endl;
  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cctype>
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vll;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define sortA(v) sort(v.begin(), v.end())
#define fill(a) memset(a, 0, sizeof(a))

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


void test() {
    int n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }
    ll sum = 0;
    ll high = a[0];
    FOR(i, 1, n) {
        if(a[i] < high) {
            sum += high - a[i];
        }
        else {
            high = a[i];
        }
    }
    cout << sum << endl;
}   
 
int main ()     
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}


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

struct abcd {
    int a;
    int b;
    int c;
    int d;
};

int N, M, Q;
vector<int> A;
vector<struct abcd> V;

int64_t dfs(int n, int m, int64_t d) {
    for (int i = m; i <= M; i++) {
        A[n] = i;

        if (n != N - 1) {
            d = max(d, dfs(n + 1, i, d));
        } else {
            int64_t D = 0;
            for (const auto &v : V) {
                if (A[v.b - 1] - A[v.a - 1] == v.c) {
                    D += v.d;
                }
            }

            d = max(d, D);
        }
    }

    return d;
}

int main() {
    cin >> N >> M >> Q;

    V.resize(Q);
    for (auto &&v : V) {
        cin >> v.a >> v.b >> v.c >> v.d;
    }

    A.resize(N);
    for (auto &&a : A) {
        a = 1;
    }

    int A_MAX = 2;
    int A_MAX_I = A.size() - 1;

    int64_t D = dfs(0, 1, 0);

    cout << D << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if(a+b<2*c) { cout << a*x+b*y << endl; return 0; }
  int res = c*2*(min(x, y));
  if(x>y) res+=((a>2*c) ? 2*c*(x-y) : a*(x-y));
  else res+=((b>2*c) ? 2*c*(y-x) : b*(y-x));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<limits>
using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int gcd(int a, int b);

int main() {
	int n, x;
	cin >> n;
	VI a(n+1);
	for (int i = 0; i < n+1; i++) cin >> a[i];
	sort(a.begin(), a.end());

	int ans = a[1] - a[0];
	auto it = a.begin();
	bool flag = false;

	for (int i = 1; i < n + 1; i++) {
		ans = gcd(a[i] - a[i - 1],ans);
	}

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

int gcd(int a, int b)
{
	if (b == 0) return a;
	a %= b;
	return gcd(b, a);
}

Measured memory_bytes: 640
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from numpy.random import randint
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    # D = 365
    D = int(readline())
    C = list(map(int, readline().split()))
    S = list(list(map(int, readline().split())) for _ in range(D))

    for _ in range(D):
        print(randint(1,26))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27416
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999

n = int(input())
A = [-INF] + get_nums_l()

log(n)
log(A)

edges = [ [] for _ in range(n+1) ]
for _ in range(n-1):
#for line in map(lambda s: s.strip(), sys.stdin.readlines()):
    line = input()
    log(line)
    u,v = map(int, line.split())
    edges[u].append(v)
    edges[v].append(u)

def dfs(dp, u, p=None):

    # log(u)
    # log(dp)

    # dpの中でA[u]以上の値が入っている最小のindex
    i = bisect_left(dp, A[u])

    old = dp[i]
    dp[i] = A[u]

    # 有効値(INF以外)が入っている最大のindex
    ans[u] = bisect_left(dp, INF) - 1

    for v in edges[u]:
        if v == p:
            continue
        dfs(dp, v, u)

    # 巻き戻し
    dp[i] = old

# ans[i] = ノード1からノードiへの経路中の最長増加部分列長
ans = [0] * (n+1)

# dp[i] = 最長増加部分列長がiの場合の末尾ノード値の最小
# dp[0]は使用しないので負の無限大を入れておく
dp = [INF] * (n+1)
dp[0] = -INF

dfs(dp, 1, None)

for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 364972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    ll Q;
    cin >> N >> S >> Q;
    vector<set<int>> charIndexes(26, set<int>()); //0-basedではなく1-basedのため注意
    for (int i = 0; i < S.size(); i++)
    {
        charIndexes.at(S.at(i) - 'a').insert(i + 1);
    }
    for (int i = 0; i < Q; i++)
    {
        int type;
        int answer = 0;
        cin >> type;
        if (type == 1)
        {
            int index;
            char C;
            cin >> index >> C;
            charIndexes.at(S.at(index - 1) - 'a').erase(index);
            S.at(index - 1) = C;
            charIndexes.at(C - 'a').insert(index);
        }
        else if (type == 2)
        {
            int L, R;
            cin >> L >> R;
            int charCount;
            for (int i = 0; i < 26; i++)
            {
                auto ite = charIndexes.at(i).lower_bound(L);
                if (ite == charIndexes.at(i).end())
                {
                    continue;
                }
                if (*ite <= R)
                {
                    answer++;
                }
            }
            cout << answer << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24220
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;

  vector<vector<int>> A(2);
  rep(i, A.size()) {
    A[i].resize(N);
    rep(j, N) {
      cin >> A[i][j];
    }
  }

  vector<vector<int>> sum(2);
  sum[0].resize(N);
  rep(j, N) {
    if (j == 0) sum[0][j] = A[0][j];
    else sum[0][j] = sum[0][j-1] + A[0][j];
  }
  sum[1].resize(N);
  rep(j, N) {
    rep(j, N) {
      if (j == 0) sum[1][N-1-j] = A[1][N-1-j];
      else sum[1][N-1-j] = sum[1][N-j] + A[1][N-1-j];
    }
  }

  int mx = 0;
  rep(j, N) {
    if (mx < sum[0][j] + sum[1][j]) mx = sum[0][j] + sum[1][j];
  }

  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc113/tasks/abc113_b
# Ruby 3rd Try
TEISU = 0.006
n = gets.chomp.to_i
t,a = gets.chomp.split(' ').map(&:to_f)
hi = gets.chomp.split(' ').map(&:to_f)
answer = 0
difftemp = ((t-hi[0]*TEISU)-a).abs
for j in 1..(n-1) do
    heretemp =  ((t-hi[j]*TEISU)-a).abs
    if heretemp <= difftemp
        answer = j
        difftemp = heretemp
    end
end
answer = answer+1
puts(answer)

Measured memory_bytes: 1788
n, m = gets.split.map(&:to_i)

path = Array.new(n + 1)
m.times do
    a, b = gets.split.map(&:to_i).sort
    c, d = path[a], path[b]

    if c && d
        path[c] = d
        path[d] = c
        path[a] = path[b] = nil
    elsif c
        path[a] = nil
        path[b] = c
        path[c] = b
    elsif d
        path[a] = d
        path[b] = nil
        path[d] = a
    else
        path[a] = b
        path[b] = a
    end
end

puts path.compact.empty? ? "YES" : "NO"

Measured memory_bytes: 3324
<?php
	$s=fgets(STDIN);
	$c=0;
	$t="";
	for($i=strlen($s)-1;$i>=0;$i--)
	{
		if($s[$i]=='B')$c++;
		else
		{
			if($c>0)$c--;
			else $t=$s[$i].$t;
		}
	}
	echo $t;


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  if (a + b <= c && 4 * a * b < (c - a - b) * (c - a - b)) {
     cout << "Yes" << endl;
   }
   else {
     cout << "No" << endl;
   }
   return 0;
}

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

int main(){
    string a, b, c;
    int anum = 0;
    int bnum = 0;
    int cnum = 0;
    string next = "a";
    cin >> a >> b >> c;
    while(true){
        if(next == "a"){
            if(anum >= (int)a.size()){
                cout << "A" << "\n";
                return 0;
            }
            next = a[anum];
            anum++;
        }
        else if(next == "b"){
            if(bnum >= (int)b.size()){
                cout << "B" << "\n";
                return 0;
            }
            next = b[bnum];
            bnum++;
        }
        else if(next == "c"){
            if(cnum >= (int)c.size()){
                cout << "C" << "\n";
                return 0;
            }
            next = c[cnum];
            cnum++;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const ll MOD = 1e9 + 7;
double L;

int main() {
   cin>>L;
  double side = L / 3.0;
  printf("%lf\n", side * side *side);
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  string ans="";
  while(n!=0){
  	if(n%2==0){
    	ans= "0" + ans;
    }
    else{
      	n--;
    	ans= "1" + ans;
    }
    n/= -2;
  }

  if(ans=="") cout << 0 << endl;
  else cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	ll mod = 1000000000+7;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll dp[n+10] = {0};
		dp[3] = 1;
		dp[4] = 1;
		for(int i=5; i<=n; i++) {
			dp[i]++;
			for(int j=3; j<=i-3; j++) {
				dp[i] += dp[i-j];
				dp[i] %= mod;
			}
			
		}
		cout<<dp[n]<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 3644
#!/usr/local/gnu/bin/bash
read n m
r=()
for i in `seq $n`
do
    r[$i]=0
done
for i in `seq $m`
do
    read a b
    r[$a]=$((r[a]+1))
    r[$b]=$((r[b]+1))
done
echo ${r[@]} | tr ' ' '\n'


Measured memory_bytes: 640