akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

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

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

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  let s = {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    s
  };
  let mut iter = s.split_whitespace();
  input_inner! {
    iter,
    s: chars,
    q: usize,
  }
  use std::collections::VecDeque;
  let mut ss = VecDeque::new();
  let mut flip = false;
  ss.push_back(s);
  for _ in 0 .. q {
    input_inner! {
      iter,
      t: i32,
    }
    if t == 1 {
      flip = ! flip;
    } else {
      input_inner! {
        iter,
        f: i32,
        c: chars,
      }
      let mut c = c;
      if flip {
        c.reverse();
        if f == 1 {
          ss.push_back(c);
        } else {
          ss.push_front(c);
        }
      } else {
        if f == 1 {
          ss.push_front(c);
        } else {
          ss.push_back(c);
        }
      }
    }
  }
  if flip {
    for s in ss.iter().rev() {
      for c in s.iter().rev() {
        puts!("{}", c);
      }
    }
  } else {
    for s in &ss {
      for c in s {
        puts!("{}", c);
      }
    }
  }

  puts!("\n");
}


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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> B(N, numeric_limits<unsigned long>::max() / 5), A(N, numeric_limits<unsigned long>::max() / 5), C(N);
    copy_n(istream_iterator<unsigned long>(cin), N - 1, B.begin());
    copy(B.cbegin(), B.cend() - 1, A.begin() + 1);
    transform(A.cbegin(), A.cend(), B.cbegin(), C.begin(), [](auto i, auto j){return min(i, j);});
    cout << accumulate(C.cbegin(), C.cend(), 0UL) << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

S = input()
T = input()
N = len(S)
NN = len(T)
S = [ord(S[i]) - 97 for i in range(N)]
T = [ord(T[i]) - 97 for i in range(NN)]

ind = [[] for _ in range(26)]
cnt = [0] * 26
for i in range(N):
    s = S[i]
    ind[s].append(i)
    cnt[s] += 1

part = 0
i = 0
j = -1
cond = 0
while i < NN:
    obj = T[i]
    if cnt[obj] == 0:
        cond = 1
        break

    tmp = bisect_left(ind[obj], j)
    if tmp == cnt[obj]:
        j = ind[obj][0]
        part += 1
        i += 1
        continue
    if ind[obj][tmp] == j:
        tmp += 1

    if tmp == cnt[obj]:
        j = ind[obj][0]
        part += 1
    else:
        j = ind[obj][tmp]

    i += 1


if cond:
    ans = -1
else:

    ans = N * part + (j + 1)

print(ans)

Measured memory_bytes: 9016
n=int(input())
a=list(map(int,input().split()))
ma=max(a)
mai=a.index(ma)
mi=min(a)
mii=a.index(mi)
ans=[]
if abs(ma)>=abs(mi):
  for i in range(n):
    a[i]+=ma
    ans.append((mai+1,i+1))
  for i in range(1,n):
    a[i]+=a[i-1]
    ans.append((i,i+1))
else:
  for i in range(n):
    a[i]+=mi
    ans.append((mii+1,i+1))
  for i in range(n-2,-1,-1):
    a[i]+=a[i+1]
    ans.append((i+2,i+1))
print(len(ans))
for i in ans:print(*i)

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

main(){

  ll n,q;
  cin>>n>>q;
  vector<vector<ll>> adj(n);
  rep(i,n-1){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<ll> cost(n);
  rep(i,q){
    ll p,x;
    cin>>p>>x;
    p--;
    cost[p]+=x;
  }

  vector<vector<ll>> adj2(n);
  vector<bool> used(n,false);
  queue<ll> que;
  que.push(0);
  while(!que.empty()){
    ll v=que.front();
    que.pop();
    used[v]=true;
    for(const auto& nv:adj[v]){
      if(used[nv])continue;
      que.push(nv);
      adj2[v].push_back(nv);
    }
  }

  queue<ll> que2;
  que2.push(0);
  while(!que2.empty()){
    ll v=que2.front();
    que2.pop();
    for(const auto& nv:adj2[v]){
      que2.push(nv);
      cost[nv]+=cost[v];
    }
  }

  for(auto x:cost)cout<<x<<" ";cout<<endl;

}

Measured memory_bytes: 25856
H, W, A, B =  (int(i) for i in input().split())

def power(a, b):
	if b == 0:
		return 0
	elif b == 1:
		return a % 1000000007
	elif b % 2 == 0:
		return (power(a, b//2) ** 2) % 1000000007
	else:
		return (power(a, b//2) ** 2 * a) % 1000000007
 
def divide(a, b):
	return (a * power(b, 1000000005)) % 1000000007


#階乗の逆元を求める
fac_lim = 300000
fac = [None]*(fac_lim+1)
fac[0] = 1
for i in range(fac_lim):
    fac[i+1] = fac[i] * (i+1)
    fac[i+1] = fac[i + 1] % 1000000007

fac_inv = [None]*(fac_lim+1)
fac_inv[fac_lim] = power(fac[fac_lim], 1000000005)
for i in range(fac_lim, 0, -1):
    fac_inv[i-1] = (fac_inv[i] * i)  % 1000000007

def conv(a, b):
    return (fac[a] * fac_inv[a-b] * fac_inv[b]) % 1000000007

res = conv(H+W-2, H-1)
for i in range(A):
    res -= conv(H-A+i + B-1, B-1) * conv(A-1-i + W-B-1, W-B-1)
    res = res % 1000000007

print(res)

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

using namespace std;

#define MN 200
#define M 101

int N;
int V[MN][3];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) cin >> V[i][j];
    }
    int point[N]; memset(point, 0, sizeof(point));
    for (int j = 0; j < 3; j++) {
        int cnt[M]; memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < N; i++) {
            cnt[V[i][j]]++;
        }
        for (int i = 0; i < N; i++) {
            if (cnt[V[i][j]] == 1) {
                point[i] += V[i][j];
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << point[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second



int main()
{
    vector<int>ms;
    int N=300000;
    rep(i,6,N)
    {
        if(i%7==1||i%7==6)
        {
            bool flag=1;
            double ii=sqrt(i);
            REP(j,ms.size())
            {
                if(ms[j]>ii)break;
                if(!(i%ms[j])){flag=0;break;}
            }
            if(flag)
            {
                ms.push_back(i);
                //N=300000/i;N++;
            }
        }
    }
    //for(auto x:ms)cout<<x<<endl;
    int num;
    while(cin>>num,(num!=1))
    {
        cout<<num<<":";
        for(auto x:ms)if(!(num%x))cout<<" "<<x;
        cout<<endl;
    }
    
}


Measured memory_bytes: 3244
#include <stdio.h>

int main(void)
{
    int x;
    int i = 1;
    
    while (1) {
        scanf("%d", &x);
        
        if (x == 0) break;
        
        printf("Case %d: %d\n", i, x);
        i++;
    }
    
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<long long> a(n), b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  vector<long long> c(m), d(m);
  for(int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }

  vector<int> ans(n, -1);
  for(int i = 0; i < n; i++){
    long long mind = 999999999;
    for(int j = 0; j < m; j++){
      long long cur = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(cur < mind){
        mind = cur;
        ans[i] = j + 1;
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int func(int start,string s,char *t,char *d,int Q,int N);
int main(void){
    int N;cin>>N;
    int Q;cin>>Q;
    string s;cin>>s;
    int min;
    int max;
    char t[Q];
    char d[Q];
    for(int i=0;i<Q;i++){
        cin>>t[i];
        cin>>d[i];
    }
    int A;A=0;
    int B;B=N-1;
    int C;
    for(int k=0;k<N;k++){
        
        if(func(0,s,t,d,Q,N)>=0){
            min=0;
            break;
        }
        if(func(N-1,s,t,d,Q,N)<0){
            min=N;
            break;
        }
        C=(A+B)/2;
 
        if(func(C,s,t,d,Q,N)<0){
            A=C;
        }else{
            B=C;
        }
        if(A+1==B&&func(A,s,t,d,Q,N)<0&&func(B,s,t,d,Q,N)>=0){
            min=B;
            break;
        }
    }
    A=0;
    B=N-1;
    for(int l=0;l<N;l++){
        if(func(N-1,s,t,d,Q,N)<N){
            max=N-1;
            break;
        }
        if(func(0,s,t,d,Q,N)>=N){
            max=-1;
            break;
        }
        C=(A+B)/2;
        if(func(C,s,t,d,Q,N)>=N){
            B=C;
        }else{
            A=C;
        }
        if(A+1==B&&func(A,s,t,d,Q,N)<N&&func(B,s,t,d,Q,N)>=N){
            max=A;
            break;
        }
    }
 
    cout<<max-min+1<<endl;
}
int func(int start,string s,char *t,char *d,int Q,int N){
    for(int i=0;i<Q;i++){
        if(i>0){
            ++t;++d;
        }
        if(*t==s[start]){
            if(*d=='R'){
                start++;
            }else{
                start=start-1;
            }
            if(start<0||start>=N){
                return start;
                break;
            }
        }
    }
    
    return start;
}

Measured memory_bytes: 1228
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll a,b,n;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>a>>b;
	for(ll i=a;i<=b;i++){
		if(i%n==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<tuple<int, int, ll> > edge(M);
  vector<vector<int> > edge1(N), edgeN(N);
  int A, B, C;
  for(int i=0;i<M;++i){
    cin>>A>>B>>C;
    A--;
    B--;
    edge[i] = make_tuple(A, B, -C);
    edge1[A].push_back(B);
    edgeN[B].push_back(A);
  }

  // 頂点1から到達できるか、頂点Nへ行けるかチェック
  bool reach1[N], reachN[N];
  for(int i=0;i<N;++i){
    reach1[i] = false;
    reachN[i] = false;
  }

  queue<int> que1, queN;
  que1.push(0);
  queN.push(N-1);
  int state;

  while(!que1.empty()){
    state = que1.front();que1.pop();
    if(reach1[state]==true) continue;
    reach1[state] = true;
    for(int i=0;i<edge1[state].size();++i){
      que1.push(edge1[state][i]);
    }
  }

  while(!queN.empty()){
    state = queN.front();queN.pop();
    if(reachN[state]==true) continue;
    reachN[state] = true;
    for(int i=0;i<edgeN[state].size();++i){
      queN.push(edgeN[state][i]);
    }
  }

  bool reach[N];
  for(int i=0;i<N;++i) reach[i] = reach1[i] & reachN[i];

  bool neg = false;
  ll dist[N];
  for(int i=0;i<N;++i){
    dist[i] = big;
  }
  dist[0] = 0;
  int from, to;
  ll score;
  for(int i=0;i<N;++i){
    for(int j=0;j<M;++j){
      from = get<0>(edge[j]);
      to = get<1>(edge[j]);
      score = get<2>(edge[j]);
      if(reach[from]==false || reach[to]==false) continue;
      if(dist[to] > dist[from] + score) {
        dist[to] = dist[from] + score;
        if(i==N-1) neg = true;
      }
    }
  }
  if(neg) cout<<"inf"<<endl;
  else cout<<-dist[N-1]<<endl;
}



Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 ll n;
 cin >> n;
 ll sum=0;
 for(ll i=1;i<n+1;i++){
 	sum+=(n/i)*((n/i)+1)/2*i;
 }
 cout << sum;
  return 0;
}

Measured memory_bytes: 3620
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    p = list(map(int, readline().split()))
    t = 10 ** 6
    cnt = 0
    for i in range(n):
        t = min(t, p[i])
        if t >= p[i]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 69488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P, P> PP;
constexpr ll MOD = ll(1e9 + 7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

set<P> g[1005][1005];

bool visited[1005][1005];
int deg[1005][1005], len[1005][1005];

int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int pre;
        for(int j=0;j<n-1;j++){
            int k;
            cin >> k;
            k--;
            if(j>0){
                g[min(i,pre)][max(i,pre)].insert({min(i,k),max(i,k)});
                deg[min(i,k)][max(i,k)]++;
            }
            pre = k;
        }
    }
    queue<P> que;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(deg[i][j]==0){
                que.push({i,j});
            }
        }
    }
    while(!que.empty()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
        visited[x][y] = true;
        for(auto e : g[x][y]){
            int nx = e.first, ny = e.second;
            deg[nx][ny]--;
            len[nx][ny] = max(len[nx][ny], len[x][y]+1);
            if(deg[nx][ny]==0){
                que.push({nx,ny});
            }
        }
    }
    bool ok = true;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ok &= visited[i][j];
        }
    }
    if(ok){
        int ans = 0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                ans = max(ans, len[i][j]);
            }
        }
        cout << ans+1 << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 103296
#include <iostream>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#include <string>
#include <vector>
#include <algorithm>
#include <map>
//long int dp[1001][1001];


int main() {
	vector<string> s(8);
	int h, w, cnt=0;
	cin >> h >> w;
	rep(i, h)
		cin >> s[i];
	rep(i, h)
		rep(j, w)
		if (s[i][j] == '#')
			cnt++;
	h+w - 1 == cnt ? cout << "Possible" << endl : cout << "Impossible" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = ""
d1 = {}
d2 = {}
for i in range(n):
  s = input()
  if s not in d1:
    d1[s] = 1
  else:
    d1[s] += 1
m = int(input())

for j in range(m):
  s = input()
  if s not in d2:
    d2[s] = 1
  else:
    d2[s] += 1
k1 = d1.keys()
k2 = d2.keys()
a = 0
temp = 0
for x in k1:
  if x not in k2:
    if a < d1[x]:
      a = d1[x]
  else:
    temp = d1[x] - d2[x]
    if a < temp:
      a = temp
print(a)

Measured memory_bytes: 3064
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int n,m;
	cin>>n>>m;
	if(n==m)
		cout<<"Yes";
	else
		cout<<"No";
}
int main()
{
//code
	int t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e5+10;char a[maxn];
int n,k,tot,b[maxn],m=-1;long long ans;
int main(){
    scanf("%s",a+1),n=strlen(a+1);read(k);
    for(rg int i=1;i<=n;i++){
	if(a[i]!=a[i-1]){
	    b[++m]=tot;
	    tot=1;
	}
	else tot++;
    }
    b[++m]=tot;
    if(m==1)ans=1ll*b[1]*k/2;
    else {
	for(rg int i=2;i<m;i++)ans+=b[i]/2;
	if(k>1){
	    if(a[1]==a[n]){ans*=k;ans+=1ll*(b[1]+b[m])/2*(k-1);ans+=b[1]/2+b[m]/2;}
	    else ans+=b[1]/2+b[m]/2,ans*=k;
	}
	else ans+=b[1]/2+b[m]/2;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
bool chmin(ll&a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll&a,ll b){if(a<b){a=b;return true;}return false;}

signed main(){
  
  ll n,m;
  cin>>n>>m;
  vector<ll> l(m),r(m);
  rep(i,m)cin>>l[i]>>r[i];

  ll lmx=l[0],rmn=r[0];
  rep(i,m){
    chmax(lmx,l[i]);
    chmin(rmn,r[i]);
  }
  if(lmx>rmn)cout<<0<<endl;
  else cout<<rmn-lmx+1<<endl;

  return 0;
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n;
string s;
map<string,ll> f;
ll ans;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        ans+=f[s];
        f[s]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 11264
#abc100 c
n=int(input())
a=list(map(int,input().split()))

def waru(x):
    cnt=0
    while x%2==0:
        x=int(x/2)
        cnt+=1
    return cnt
ans=0
for num in a:
    if num%2==0:
        ans+=waru(num)
print(ans)


Measured memory_bytes: 4212
#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 rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const int mod=998244353;
//const int mod=1e9+7;
//const int inf=1e9+7;
const int maxn=1e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}

int t,n,m,k;
int main(){
    double pai=3.1415926535;
    scanf("%d",&t);
    printf("%.3f\n",pai*2*t);
	return 0;
}




//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


Measured memory_bytes: 3816
#include <iostream>

using namespace std::literals;

namespace abc086
{
	namespace task_A
	{
		struct PairIntegers
		{
			public: unsigned int a;
			public: unsigned int b;

			private: unsigned int Product (/* no argument */)
			{
				return (this->a) * (this->b);
			}

			private: bool IsProductEven (/* No argument */)
			{
				return (this->Product() % 2U) == 0U;
			}

			public: void Answerer (/* No argument */)
			{
				if   ( this->IsProductEven() ) std::cout << "Even"s;
				else                           std::cout << "Odd"s;

				std::cout << "\n"s;
			}
		};
	} // namespace task_A
	
} // namespace abc086


int main (void)
{
	// variables for main process
	abc086::task_A::PairIntegers given_data;

	// STEP.01
	// read out the given data
	std::cin >> given_data.a >> given_data.b;

	// STEP.02
	// output the answer of this task
	given_data.Answerer();

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
# 解説AC
# 約数75になる条件は、素因数分解した際の約数の数p, q,..について
# (p+1)*(q+1)*..=75となること
# 先に上式を満たす(p,q, ..)組み合わせを列挙して、
# N!の素因数分解に対して、各組み合わせを満たすものを数え上げる

n = int(input())

# 素因数分解
def prime_factorization(n):
    Primes = []
    while n % 2 == 0:
        Primes.append(2)
        n = int(n/2)
    f = 3
    while f*f <= n:
        if n % f == 0:
            Primes.append(f)
            n = int(n/f)
        else:
            f += 2
    if n != 1:
        Primes.append(n)
    return Primes

Primes_count = [0 for _ in range(n+1)]

for i in range(2,n+1):
    Primes = prime_factorization(i)
    for prime in Primes:
        Primes_count[prime] += 1

# 75 = 3*5*5 = (1*75) = (3*25) = (3*5*5) = (5*15)
def count(n, Primes_count):
    return len(list(filter(lambda x:x>=n-1, Primes_count)))

ans = 0
# 1*75
ans += count(75, Primes_count)

# 3*25 3に対する-1は25以上とのかぶりを避けるため。
ans += (count(3, Primes_count)-1) * count(25, Primes_count)

# 5*15 上と同様
ans += (count(5, Primes_count)-1) * count(15, Primes_count)

# 3*5*5 5以上を一つ決める->残りから5以上を一つ決める->残りから3以上を1つ決める->5同士の入れ替えが起きるので2で割り切り捨てる
ans += (count(5, Primes_count)) * (count(5, Primes_count) -1) * (count(3, Primes_count)-2) // 2

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 n, a, b;
  cin >> n >> a >> b;
  int64 k = n / (a + b);
  cout << k * a + min(a, n % (a + b)) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    while(true) {
        int N;
        cin >> N;
        if(N==0) {
            break;
        }

        pair<int, int> rw[1000];
        rep(i, N) {
            int r, w;
            cin >> r >> w;
            rw[i] = make_pair(r, w);
        }

        sort(rw, rw+N, greater< pair<int, int> >());
        int others = 0;
        REP(i, 1, N) {
            others += rw[i].first;
        }

        // cout << others << endl;
        // cout << rw[0].first << endl;
        int ans = 0;
        rep(i, N) {
            ans += rw[i].first;
            ans += rw[i].second;
        }
        if(rw[0].first <= others) {
            cout << ans << endl;
        } else {
            // DP
            int w_lim = rw[0].first - others;
            int dp[1000][1001] = {0};
            REP(w, 1, w_lim+1) {
              REP(b, 2, N+1) {
                dp[w][b] = dp[w][b-1];
                if (w >= rw[b-1].second) {
                  dp[w][b] = max(dp[w][b-1],
                    dp[w - rw[b-1].second][b-1] + rw[b-1].second);
                }
              }
            }
            // rep(i, w_lim+1) {
            //   rep(j, N+1) {
            //     cout << dp[i][j] << " ";
            //   }
            //   cout << endl;
            // }
            cout << ans + w_lim - dp[w_lim][N] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 7048
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"reflect"
	"sort"
)

func main() {
	defer writer.Flush() // Use printf, scanf

	// CODE
	var N, x int
	scanf("%d %d\n", &N, &x)
	a := make([]int, N)
	for i := 0; i < N-1; i++ {
		scanf("%d ", &a[i])
	}
	scanf("%d\n", &a[N-1])
	sort.Stable(IntSlice(a))

	var i, ans int
	for x >= a[i] && i < N-1 {
		x -= a[i]
		ans++
		i++
	}
	// last child
	if i == N-1 && x == a[N-1] {
		ans++
	}
	printf("%d\n", ans)
}

// I/O {{{
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

// }}}
// Math {{{
func maxInt(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

// }}}
// {{{ dummy
func dummy() {
	fmt.Printf("Hello, World\n")
	fmt.Printf("%v", reflect.TypeOf(0))

	arr := []int{10, 9, 8, 7, 1}
	sort.Ints(arr)
	fmt.Println(arr)
}

// }}}
// PriorityQueue {{{
// Usage:
// type Person struct {
// 	name string
// 	age  int
// }
//
// func (p1 Person) Less(p2 interface{}) bool {
// 	return p1.age < p2.(Person).age
// }
//
// func main() {
// 	sc.Split(bufio.ScanWords)
// 	defer out.Flush() // Use printf
//
// 	// CODE
// 	q := NewPriorityQueue()
// 	q.Push(Person{name: "B", age: 11})
// 	q.Push(Person{name: "A", age: 10})
// 	q.Push(Person{name: "C", age: 12})
//
// 	for q.Len() > 0 {
// 		p := q.Pop().(Person)
// 		printf("%s %d\n", p.name, p.age)
// 	}
// }
func NewPriorityQueue() *PriorityQueue {
	q := &PriorityQueue{s: new(sorter)}
	heap.Init(q.s)
	return q
}

func (q *PriorityQueue) Pop() Comparable {
	return heap.Pop(q.s).(Comparable)
}

func (q *PriorityQueue) Top() Comparable {
	if len(*q.s) > 0 {
		return (*q.s)[0].(Comparable)
	}
	return nil
}

func (q *PriorityQueue) Fix(x Comparable, i int) {
	(*q.s)[i] = x
	heap.Fix(q.s, i)
}

func (q *PriorityQueue) Remove(i int) Comparable {
	return heap.Remove(q.s, i).(Comparable)
}

func (q *PriorityQueue) Len() int {
	return q.s.Len()
}

type Comparable interface {
	Less(other interface{}) bool
}

type sorter []Comparable

func (s *sorter) Push(x interface{}) {
	*s = append(*s, x.(Comparable))
}

func (s *sorter) Pop() interface{} {
	n := len(*s)
	if n > 0 {
		x := (*s)[n-1]
		*s = (*s)[0 : n-1]
		return x
	}
	return nil
}

func (s *sorter) Len() int {
	return len(*s)
}

func (s *sorter) Less(i, j int) bool {
	return (*s)[i].Less((*s)[j])
}

func (s *sorter) Swap(i, j int) {
	(*s)[i], (*s)[j] = (*s)[j], (*s)[i]
}

// Define priority queue struct
type PriorityQueue struct {
	s *sorter
}

func (q *PriorityQueue) Push(x Comparable) {
	heap.Push(q.s, x)
}

// }}}
// Sort {{{
// sort.Stable(IntSlice(a))
type IntSlice []int

func (a IntSlice) Len() int {
	return len(a)
}
func (a IntSlice) Less(i, j int) bool {
	return a[i] < a[j]
}
func (a IntSlice) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

// }}}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll long long
#define fi first
#define se second
#define PB push_back
#define uint unsigned
#define ull unsigned ll 
using namespace std;
const int N=200005;
int n,a[N],b[N];
ll ans;
priority_queue<pii> Q;
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,n) scanf("%d",&b[i]);
	For(i,1,n) Q.push(pii(b[i],i));
	while (!Q.empty()){
		int x=Q.top().se; Q.pop();
		if (a[x]>b[x]) return puts("-1"),0;
		if (a[x]==b[x]) continue;
		int pre=(x==1?n:x-1);
		int suf=(x==n?1:x+1);
		int S=b[pre]+b[suf];
		int times=(b[x]-a[x])/S;
		if (times==0) return puts("-1"),0;
		ans+=times; b[x]-=times*S;
		if (b[x]<a[x]) return puts("-1"),0;
		Q.push(pii(b[x],x)); 
	} 
	printf("%lld\n",ans);
}

Measured memory_bytes: 3956
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if Ls[i] < Ls[j]+Ls[k] and Ls[j] < Ls[k]+Ls[i] and Ls[k] < Ls[j]+Ls[i]:
                    if Ls[i] != Ls[j] and Ls[j] != Ls[k] and Ls[k] != Ls[i]:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    solve()


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

int main(){
	int cnt[5] = {1,1,1,1,1};
	for(int i=0;i<3;++i){
		int a,b;
		cin >> a >> b;
		cnt[a] <<= 1;cnt[b] <<= 1;
	}
	int ch = 0;
	for(int i=1;i<=4;++i){
		ch |= cnt[i];
	}
	cout << (ch & 0x8 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#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 DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 100005;
LL a[MAXN], b[MAXN];

int n;

int main() {
    GI(n);

    FORN(i, n) {
        GLL(a[i]); GLL(b[i]);
    }

    LL res = 0;

    FORD(i, n) {
        LL need = b[i] - (a[i] + res) % b[i];
        if (need == b[i]) need = 0;
        res += need;
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <string>
using namespace std;

int main (){
   string current_chess;
   cin >> current_chess;
   if (current_chess.length() == 0 ){
        cout << 0 << endl;
        return 0;
   }
   if (current_chess.length() == 1 ){
        cout << 0 <<endl;
        return 0;
   }
   char current_char = current_chess[0];
   int counter = 0;
   for (int i = 1; i < current_chess.length(); i ++ ){
        if (current_chess[i] != current_char) {
             counter ++;
             current_char = current_chess[i];
        } 
        else {
             continue;
        }
   }
   cout << counter << endl;
   return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll n,a,b,c,i;
        cin>>n;
        ll dp[n][3];
        cin>>a>>b>>c;
        dp[0][0]=a; dp[0][1]=b; dp[0][2]=c;
        for(i=1;i<n;i++){
            cin>>a>>b>>c;
            dp[i][0]=max(dp[i-1][1],dp[i-1][2]);
            dp[i][0]+=a;
            dp[i][1]=max(dp[i-1][0],dp[i-1][2]);
            dp[i][1]+=b;
            dp[i][2]=max(dp[i-1][1],dp[i-1][0]);
            dp[i][2]+=c;
        }
      ll p=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
      cout<<p<<endl;
      }
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    int h, i, m1=0, m2=0, m3=0, t;
    for(i=0;i<10;i++){
        scanf("%d", &h);
        if(m3<h)m3=h;
        if(m2<m3){t=m2;m2=m3;m3=t;}
        if(m1<m2){t=m1;m1=m2;m2=t;}
    }
    printf("%d\n%d\n%d\n", m1, m2, m3);
    return 0;
}


Measured memory_bytes: 2032
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int k,s;
	cin >> k >> s;
	int a=0;
	for (int i=0;i<=k;i++) {
		for (int j=0;j<=k;j++) {
			int b=s-i-j;
			if (0<=b && b<=k) a++;
		}
	}
	cout << a;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int n, m;
vector<pair<int, int> > graph[100001];
bool is_reached[100001];
ll dist[100001];
bool flg;
ll mi, ma;

ll llmax(ll x, ll y){
	if (x > y) return x;
	return y;
}

ll llmin(ll x, ll y){
	if (x > y) return y;
	return x;
}

void dfs(int now, ll d){
	is_reached[now] = true;
	dist[now] = d;
	for (auto x : graph[now]){
		if (is_reached[x.first]){
			if (dist[now] + x.second != dist[x.first]){
				flg = true;
			}
		}else{
			mi = llmin(mi, dist[now] + x.second);
			ma = llmax(ma, dist[now] + x.second);
			dfs(x.first, dist[now] + x.second);
		}
	}
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int l, r, d;
		cin >> l >> r >> d;
		graph[l].push_back(make_pair(r, d));
		graph[r].push_back(make_pair(l, -d));
	}
	for (int i = 1; i <= n; i++){
		if (!is_reached[i]){
			mi = 0, ma = 0;
			flg = false;
			dfs(i, 0);
			if (ma - mi > 1000000000 || flg){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 15744
import java.util.*;
import java.io.*;

public class Main {


	public static void main(String[] args) {
		Main answer = new Main();
		System.out.println(answer.solve());
	}

	private double solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int one=0,two=0,three=0;
		for(int i=0;i<N;i++){
			int val = sc.nextInt();
			if (val==1) one++;
			else if (val==2) two++;
			else if (val==3) three++;
		}

		double [][][] dp = new double [301][301][301];
	  /*	
      for(int i=0;i<300;i++){
			for(int j=0;j<300;j++){
				for(int k=0;k<300;k++){
					dp[i][j][k] = -1.0;
				}
			}
		}
		*/

		solve(dp, one, two, three, N);

		return dp[one][two][three];
	}

	double solve(double[][][] dp, int one, int two, int three, int N) {
	
        if (one==0 && two==0 && three==0) return 0;
		if (one<0 || two<0 || three<0) return 0;

		if (dp[one][two][three] >0) return dp[one][two][three];
		 
		double exp = N + (one * solve(dp, one-1,two, three, N))
							   + (two * solve(dp, one+1, two-1, three, N))
							   + (three * solve(dp, one, two+1, three-1, N));
      	double r = (one+two+three);
      	dp[one][two][three] = exp/r;

		return dp[one][two][three];
	}

}


Measured memory_bytes: 274020
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for (i=a; i <=b; i++)
    {
        if(c%i == 0)
             ans++;
    }
    cout << ans << endl;
} 


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long lint;

int main() {
  int N;
  cin >> N;
  vector<lint> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  lint ans = 0;
  while (1) {
    bool finish = true;
    for (int i = 0; i < N; i++) {
      if (A[i] >= N) {
        finish = false;
        lint cnt = A[i] / N;
        ans += cnt;
        A[i] -= cnt * N;
        for (int j = 0; j < N; j++) {
          if (i != j) {
            A[j] += cnt;
          }
        }
      }
    }
    if (finish) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 768
a, b, c, x, y = [int(i) for i in input().split()]

p = [a * x + b * y, c * max(x, y) * 2]
if x != y:
    p.append(c * y * 2 + a * (x-y)) if x > y else p.append(c * x * 2 + b * (y-x))

print(min(p))


Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=2005,TT=1000000007;
int n,K,fac[maxn*maxn],inv[maxn*maxn],F[maxn][maxn];
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
inline int QP(int a,int b)
{
	int ret=1,w=a;
	while(b)
	{
		if(b&1) ret=(LL)ret*w%TT;
		w=(LL)w*w%TT;b>>=1;
	}
	return ret;
}
inline int C(int n,int m){return (LL)fac[n]*inv[m]%TT*inv[n-m]%TT;}
int main()
{
	n=read();K=read();fac[0]=1;
	for(int i=1;i<=4000000;i++) fac[i]=(LL)fac[i-1]*i%TT;
	inv[4000000]=QP(fac[4000000],TT-2);
	for(int i=4000000-1;i>=0;i--) inv[i]=(LL)inv[i+1]*(i+1)%TT;
	if(K==1)
	{
		printf("%d\n",1);
		return 0;
	}
	F[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
			F[i][j]=(F[i-1][j]+(j?((LL)F[i][j-1]*(n-j+1)%TT*C(n*K-i-(j-1)*(K-1)-1,K-2)%TT):0))%TT;
	printf("%d\n",F[n][n]);
	return 0;
}

Measured memory_bytes: 46336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(C>=A && C<=B){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }

	}


    public static int intsum(int[] x){
        int t = 0;
        for (int a:x){
            t += a;
        }
        return t;
    }
    public static long longsum(long[] x){
        long t = 0;
        for (long a:x){
            t += a;
        }
        return t;
    }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int , int>mp;
    int x,m;
    cin>>x;
    for(int i=1;i<=x-1;i++)
    {
        cin>>m;
        mp[m]++;
    }
    for(int i=1;i<=x;i++)
    {
        cout<<mp[i]<<endl;
    }
}


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

using namespace std;

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

    int retval = 0;
    int tmp, prev = 0;

    for (int i = 0; i < n; i++) {
        cin >> tmp;
        if (tmp - prev > t) {
            retval += tmp - prev - t;
        }
        prev = tmp;
    }

    retval = tmp + t - retval;

    cout << retval << endl;

    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	double ans = 0;
	for (int ii = 0; ii < N; ++ii){
		double tmp;
		cin >> tmp;
		ans += 1.0 / tmp;
	}

	cout << fixed << setprecision(10) << 1.0 / ans << "\n";


	return 0;
}


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

int main(){
	int n,t,g;
	int data[101];
	cin >> n >> t >> g;
	for(int i=0;i<n;i++){
		cin >> data[i];
	}
	int ans = -1;
	for(int i=0;i<n;i++){
		int now = data[i];
		int bi = 2;
		while(now <= t + g){
			if(now >= t-g && now <= t+g){
				ans = i+1;
				break;
			}
			else {
				now = data[i] * bi;
				bi++;
			}

		}
		if(ans != -1) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;
int main() {
	int n,num;
	cin >> n;

	for (int i=0; i < n; ++i) {
		cin >> num;
		if (num % 2 == 0 && (num % 3 == 0 || num % 5 == 0))continue;
		else if(num%2==0) {
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007


#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec (N,0);
  int check = 1;
  int check2 = 1;
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
     if(vec[i] == 0)check = 0;
     if(vec[i] > 1000000000000000000)
     {
       check2 = 0;
     }
  }
  sort(ALL(vec));
  reverse(ALL(vec));  
  int ANS = check;
  if(check == 0)
  {
    cout<<0<<endl;
    return;
  }
  if(check2 == 0)
  {
    cout<<-1<<endl;
    return;
  }
  int pre = -1;
  for (int i = 0; i < N; i++)
  {
    ANS *= vec[i];
    if(ANS > 1000000000000000000 || ANS < pre)
    {
      cout<<-1<<endl;
      return;
    }
    pre = ANS;
  }
  cout<<ANS<<endl;
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<int> arr(N, 0);
    for(int i = 1; i < N; i++) {
        if (S[i-1] == 'R' && S[i] == 'L') {
            int l = i-1, r = i;
            while (l-1 >= 0 && S[l-1] == 'R')
                l--;
            while (r+1 < N && S[r+1] == 'L')
                r++;
            // cout << "LR = " << l << " " << r << endl;
            int odd = 0, even = 0;
            for(int k = l; k <= r; k++) {
                odd += ((k % 2) == 1);
            }
            if (i % 2 == 1) {
                arr[i] = odd;
                arr[i-1] = r-l+1 - odd;
            } else {
                arr[i] = r-l+1 -odd;
                arr[i-1] = odd;
            }
        }
    }
    for(int i = 0; i < N; i++)
        cout << arr[i] << " ";
    return 0;
}



Measured memory_bytes: 1104
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int mp[1001][1001];
bool used[1001][1001];
int hw_count;
int h, w;

int main()
{
	int first_count = 0;
	cin >> h >> w;
	queue<pair<int,int>> q;
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) {
			if (s[j] == '#') {
				mp[i][j] = 1;
				first_count++;
				q.push(make_pair(i,j));
			} else {
				mp[i][j] = 0;
			}
		}
	}
	int count = first_count;
	int ans_count = 0;
	hw_count = h * w;
	if (first_count == hw_count) {
		cout << 0 << endl;
		exit(0);
	}
	while(1) {
		if (count == hw_count || q.empty()) {
			break;
		}
		ans_count++;
		queue<pair<int,int>> q2;
		while(!q.empty()) {
			pair<int,int> qq = q.front();
			int qi = qq.first;
			int qj = qq.second;
			q.pop();
			if (mp[qi][qj] == 1) {
				if (used[qi][qj] == true) {
					continue;
				}
				used[qi][qj] = true;
				if (qi + 1 < h) {
					if (mp[qi + 1][qj] == 0) {
						count++;
						mp[qi + 1][qj] = 1;
						q2.push(make_pair(qi + 1,qj));
					}
				}
				if (qj + 1 < w) {
					if (mp[qi][qj + 1] == 0) {
						count++;
						mp[qi][qj + 1] = 1;
						q2.push(make_pair(qi,qj + 1));
					}
				}
				if (qi - 1 >= 0) {
					if (mp[qi - 1][qj] == 0) {
						count++;
						mp[qi - 1][qj] = 1;
						q2.push(make_pair(qi - 1, qj));
					}
				}
				if (qj - 1 >= 0) {
					if (mp[qi][qj - 1] == 0) {
						count++;
						mp[qi][qj - 1] = 1;
						q2.push(make_pair(qi, qj - 1));
					}
				}	
			}
		}
		q = q2;
	}
	cout << ans_count << endl;
	return 0;
}

Measured memory_bytes: 13312