akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define reg register
#define maxn 300001 
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int n, m, cnt, ls[maxn * 21], now, d[maxn], rs[maxn * 21], ans, sum[maxn * 20], root[maxn];
struct node{int l, r;} a[400001];
bool cmp(node g, node h){
    if(g.l != h.l) return g.l < h.l;
    else return g.r < h.r;
}
int build(int l, int r){
    int num = ++cnt;
    int mid = l + r >> 1;
    if(l != r){
        build(l, mid); build(mid + 1, r);
    }
    return num;
}
int update(int pre, int l, int r, int pos){
    int num = ++ cnt; 
    sum[num] = sum[pre] + 1; ls[num] = ls[pre], rs[num] = rs[pre];
    if(l != r){ 
         int mid = l + r >> 1;
        if(pos <= mid) ls[num] = update(ls[pre], l, mid, pos);
        else rs[num] = update(rs[pre], mid + 1, r, pos);
    }
    return num;
}
int query(int now, int pre, int l, int r, int pos){
    if(l > pos) return 0;
    int res = 0;
    if(r <= pos){
        res += sum[now] - sum[pre]; 
        return res;
    }
    int mid = l + r >> 1;
    res += query(ls[now], ls[pre], l, mid, pos);
    if(pos > mid) res += query(rs[now], rs[pre], mid + 1, r, pos);
    return res;
}
int main()
{
    n = read(); m = read();
    for(int i = 1; i <= n; i++)
        a[i].l = read(), a[i].r = read();
    sort(a + 1, a + n + 1, cmp);
    root[0] = build(1, m); now = 1;
     for(int i = 1; i <= m; i++){
        int t = root[i - 1];
        while(a[now].l == i){
            t = update(t, 1, m, a[now].r); now++;
        }
        root[i] = t;
    }
    for(int i = 1; i <= n; i++) d[a[i].l]++;
    for(int i = 1; i <= m; i++) d[i] += d[i - 1];
    for(int i = 1; i <= m; i++){
        ans = 0;
        for(int j = i; j <= m; j += i){
            ans += d[j] - d[j - i];
            ans -= query(root[j], root[j - i], 1, m, j - 1);
        } 
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 76672
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	vector<int> list;

	int n;
	cin >> n;

	list.push_back(0);

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		list.push_back(x);
	}
	list.push_back(0);

	int size = list.size();

	int all = 0;

	for (int i = 1; i < size; i++)
	{
		all += abs(list[i-1] - list[i]);
	}

	for (int i = 1; i <= n; i++)
	{
		cout << all - abs(list[i - 1] - list[i]) - abs(list[i] - list[i + 1]) + abs(list[i - 1] - list[i + 1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    map<ll, ll> L, R;
    ll ans = 0;
    REP(i,N){
        ll A;
        cin >> A;
        ans += L[i-A];
        ans += R[i+A];
        L[i+A]++;
        R[i-A]++;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


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

int main()
{
    int n;
    cin >> n;
    int arr[n];
    int dp[n];
    for (int i = 0; i != n; ++i)
    {
        dp[i] = 1000000000;
        scanf("%d", &arr[i]);
    }
    
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i != n; ++i)
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
    
    cout << dp[n - 1];
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int n = 0;
    double pro = 0;
    scanf("%d", &n);
    if (n % 2 == 0) pro = 0.5;
    else pro =(n+1) / (double)(2*n);
    printf("%.10lf", pro);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        double x1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double y2 = sc.nextDouble();

        System.out.printf("%.8f\n",Math.sqrt(((x1 - y1) * (x1 - y1)) + ((x2 - y2) * (x2 - y2))));
    }
       
}


Measured memory_bytes: 28232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	rep(i, n) {
		int l, r;
		cin >> l >> r;
		ans += (r - l + 1);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
// typedef pair<int, int> P;
typedef complex<double> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;


const int offset = 21;
const int width = 2 * offset + 1;

struct L {
    P s, t;
};

double dot(P a, P b) {
    return a.real() * b.real() + a.imag() * b.imag();
}

double cross(P a, P b) {
    return a.real() * b.imag() - a.imag() * b.real();
}

double distanceLP(L l, P p) {
    return abs(cross(p - l.s, l.t - l.s)) / abs(l.t - l.s);
}

double distanceSP(L l, P p) {
    if (dot(l.t - l.s, p - l.s) < 0) return abs(p - l.s);
    if (dot(l.s - l.t, p - l.t) < 0) return abs(p - l.t);
    return distanceLP(l, p);
}

bool inside(double t, int r, vector<L> lines) {
    P center = P(0, - r + t);
    for (auto line : lines) {
        if (distanceSP(line, center) < r) return false;
    }
    return true;
}


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

    int R, n;
    while (cin >> R >> n && R) {
        // ??? x ??§?¨????????????????????????????????????? (??????????¨????????????????????????????)
        vector<int> highest(width + 2, 0); // highest[0] = highest[41] = 0
        rep(i, n) {
            int xl, xr, h;
            cin >> xl >> xr >> h;
            // [xl, xr)
            for (int j = xl + offset; j < xr + offset; j++) {
                highest[j] = max(highest[j], h);
            }
        }

        // ?????????????§??????????????????????
        vector<L> lines;
        P p1, p2;
        p1 = P(-offset, 0);
        rep2(i, 1, width) {
            if (highest[i] != highest[i - 1]) {
                // horizontal line
                p2 = P(i - offset, highest[i - 1]);
                lines.emplace_back((L){p1, p2});

                // vertical line
                p1 = P(i - offset, highest[i]);
                lines.emplace_back((L){p2, p1});
            }
        }
        lines.emplace_back((L){p1, P(offset, 0)});

        // cout << "hey!" << endl;
        // for (auto line : lines) {
        //     cout << line.s << " " << line.t << endl;
        // }

        // ?????????1?????????????????????????????????????????????????????°????????????
        double t = 0;
        while (inside(t, R, lines)) t++;

        // cout << t << endl;

        double l = t - 1;
        double r = t;
        rep(i, 100) {
            double m = (l + r) / 2;
            if (inside(m, R, lines)) {
                l = m;
            } else {
                r = m;
            }
        }

        printf("%.10f\n", (l + r) / 2);
    }
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    int N,T;cin>>N>>T;
    vector<int> X(N),Y(N);
    
    for(int i=0;i<N;i++) cin>>X[i]>>Y[i];
    
    vector<vector<int>> left(N+2,vector<int>(T,-INF)),right(N+2,vector<int>(T,-INF));
    
    for(int j=0;j<T;j++){
        left[0][j]=0;
        right[N+1][j]=0;
    }
    //left[0][0]=0;right[N+1][0]=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<T;j++){
            left[i+1][j]=max(left[i+1][j],left[i][j]);
            if(j+X[i]<T) left[i+1][j+X[i]]=max(left[i+1][j+X[i]],left[i][j]+Y[i]);
        }
    }
    
    for(int i=N-1;i>=0;i--){
        for(int j=0;j<T;j++){
            right[i+1][j]=max(right[i+1][j],right[i+2][j]);
            if(j+X[i]<T) right[i+1][j+X[i]]=max(right[i+1][j+X[i]],right[i+2][j]+Y[i]);
        }
    }
    
    int ans=0;
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<T;j++){
            ans=max(ans,left[i-1][j]+right[i+1][T-1-j]+Y[i-1]);
        }
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 70912
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, r;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> r;

  if(n >= 10) cout << r << endl;
  else cout << (100 * (10 - n) + r) << endl;
}


Measured memory_bytes: 256
#include<iostream>//头文件~~~ 
using namespace std;//emm……
int main(){
    string a;   bool v[2]={0};//这个初始化害人不浅啊 
    cin>>a;//读入 
    for(int i=0;i<a.length();i++){//a[0]==>a[n-1]全部看一遍 
        if(a[i]=='C') v[0]=1;//出现了C 
        if(a[i]=='F'&&v[0])  v[1]=1;//出现了F 
    }
    if(v[1]) cout<<"Yes";//可以 
    else cout<<"No";//不行 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[111111];
int main() {
	int n, l;
	cin >> n >> l;
	for(int i(1); i <= n; i++) {
		cin >> a[i];
	}
	for(int i(1); i < n; i++) {
		if(a[i] + a[i + 1] >= l) {
			cout << "Possible" << endl;
			for(int j(1); j < i; j++) {
				cout << j << endl;
			}
			for(int j(n - 1); j >= i; j--) {
				cout << j << endl;
			}
			return 0;
		}
	}
	cout << "Impossible" << endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int K = Input.nextInt();
        int S = Input.nextInt();
        int Counter = 0;
        for (int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {

                if (0 <= S - (X + Y) && S - (X + Y) <= K) {
                    Counter++;
                }
            }
        }
        System.out.println(Counter);
    }
}


Measured memory_bytes: 23252
package main

import (
	"fmt"
)

func main() {
	var n int
	var result uint64
	fmt.Scanf("%d", &n)
	arr := make([]uint64, n)
	for i:=0; i<n; i++ {
		fmt.Scanf("%d", &arr[i])
		if arr[i] == 0 {
			fmt.Printf("%d", 0)
			return
		}
	}
	result = 1
	for _,value := range arr {
		if result > 1e18/value {
			fmt.Printf("-1")
			return
		}
		result *= value
	}
	fmt.Printf("%d", result)
}


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

using psin=pair<string,int>;
using psinin=pair<psin,int>;

int main(){
  int N;cin>>N;
  vector<psinin> M;
  for(int i=0;i<N;i++){
    string S;int P;cin>>S>>P;
    psinin X = make_pair(make_pair(S,-P),i+1);
    M.push_back(X);
  }
  //sort(M,M+N);
  sort(M.begin(),M.end());
  for(int i=0;i<N;i++) cout<<M.at(i).second<<endl;
}
  


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

int main() {
    long long N, P;
    cin >> N >> P;

    vector<pair<long long, long long>> res = {};
    long long Q = P;
    for (int i = 2; i <= sqrt(P); i++) {
        int cnt = 0;
        while (Q % i == 0) {
            Q /= i;
            cnt++;
        }
        if (cnt > 0) {
            res.push_back(make_pair(cnt, i));
        }
    }
    res.push_back(make_pair(1, P));

    long long ans = 1;
    sort(res.begin(), res.end());
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); i++) {
        if (res[i].first >= N) {
            ans *= pow(res[i].second, res[i].first / N);
        }
    }

    if (N > 1) {
        cout << ans << endl;
    }
    else {
        cout << P << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;
#define N (int)1e6+1

int dp[100000+1];
vector <vector <int> > v(100000+1);
int f(int i)
{
	if(dp[i]!=-1)return dp[i];
	dp[i]=1;
	for(int j=0;j<v[i].size();j++)
	{
		dp[i]=max(dp[i],f(v[i][j])+1);
	}
	return dp[i];
}

int main()
{
	ios
	int n,m,a,b;
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		v[a].pb(b);
	}
	int ans=0;
	f(1);
	for(int i=1;i<=n;i++)
		ans=max(ans,f(i));
	cout<<ans-1<<nl;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int N,m,P[200010]={},ans=0;
    cin>>N;
    m=N;

    for(int i=1;i<=N;i++){
        cin>>P[i];
        if(m>=P[i]){
            ans++;
            m=P[i];
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long>  a;
    long long sum,res, tmp1, tmp2, ans;
    sum = 0;
    for(int i=0;i<n;i++){
        cin >> tmp1;
        a.push_back(tmp1 - i);
        sum += tmp1 - i;
    }
    res = 0;
    ans = abs(sum * (n+1));
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        tmp2 = abs(sum - res - (n - 2* i)* a[i]);
        if(tmp2 < ans){ 
            ans = tmp2;
        }
        sum -= a[i];
        res += a[i];
    }
    cout << ans << "\n"; 
    return 0;
}


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

int main() {
  
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  
  bool judge = true;
  
  if (x-r < 0 || x+r > W) {
    judge = false;
  }
  if (y-r < 0 || y+r > H) {
    judge = false;
  }
  
  if (judge) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
 
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    str s; cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int A[1000000], n;

/* 二分探索 */
int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; /* keyを発見 */
    if(key > A[mid]) left = mid + 1; /* 後半を探索 */
    else if(key < A[mid]) right = mid; /* 前半を探索 */
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2112
fun main (args:Array<String>){
    var (a , b , c , k) = readLine()!!.split(" ").map(String::toLong)

    var maxVal = 0L

    // Aのカードを選択
    if (a >= k) {
        maxVal += k * 1
        print(maxVal)
        return
    } else {
        maxVal += a * 1
        k -= a
    }

    // Bのカードを選択
    if (b >= k) {
        maxVal += k * 0
        print(maxVal)
        return
    } else {
        maxVal += b * 0
        k -= b
    }

    // cのカードを選択
    maxVal += k * -1

    print(maxVal)
}


Measured memory_bytes: 36436
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
using namespace std;
using ll = long long;
int main(){
    char X, Y;
    cin >> X >> Y;
    if(X<Y) cout << '<' << endl;
    else if(X>Y) cout << '>' << endl;
    else if(X==Y) cout << '=' << endl;
    return 0;
}

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

using ll = long long;

int main(int argc, char **argv)
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  string s; cin >> s;
  for(int i=0; i<3; i++) {
    if(s[i] == s[i+1]) {
      cout << "Bad" << endl;
      exit(0);
    }
  }

  cout << "Good" << endl;

  return 0;
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

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

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;
  vll v(4);
  rep(i, 4) {
    v[i] = s[i] - '0';
  }

  rep(ptn, 1 << 3) {
    ll sum = v[0];
    rep(i, 3) {
      if (ptn & (1 << i)) {
        sum += v[i + 1];
      } else {
        sum -= v[i + 1];
      }
    }

    if (sum == 7) {
      cout << v[0];
      rep(i, 3) {
        if (ptn & (1 << i))
          cout << '+';
        else
          cout << '-';
        cout << v[i + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3596
/**
 * This line was copied from template
 * This is dsol.cpp
 * 
 * @author: Nikolay Kalinin
 * @date: Sat, 23 Mar 2019 16:34:52 +0300
 */
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 5005;
const ll inf = 1e18;

ll ans[maxn];
int a[maxn];
int n, A, B;


int main()
{
    scanf("%d%d%d", &n, &A, &B);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i <= n; i++) ans[i] = inf;
    ans[0] = 0;
    for (int i = 0; i < n; i++)
    {
        ll ourbest = inf;
        for (int t = 0; t < a[i]; t++)
        {
            ourbest = min(ourbest, ans[t]);
            ans[t] += A;
        }
        ans[a[i]] = ourbest;
        for (int t = a[i] + 1; t <= n; t++) ans[t] += B;
//         for (int t = 0; t <= n; t++) cout << ans[t] << ' ';
//         cout << endl;
    }
    cout << *min_element(ans, ans + n + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	int ans = 1;
	FOR(i, 1, n) {
		if (i * i > n) break;
		ans = i * i;
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,a;
    cin>>n;
    int R[n];
    for(int i=0;i<n;i++) cin>>R[i];
    int minv=R[0],maxv=-1000000000;
    for(int j=1;j<n;j++){
        a=R[j]-minv;
        if(R[j]<minv) minv=R[j];
        if(a>maxv) maxv=a;
    }
    cout<<maxv<<endl;
    return 0;
    
}


Measured memory_bytes: 3892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H = sc.nextLong();
		long W = sc.nextLong();
		long[] A = new long[N];
		long[] B = new long[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			B[i] = sc.nextLong();
		}
		sc.close();
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] >= H && B[i] >= W) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26708
n, m, x = map(int, input().split())
cl = list(list(map(int, input().split())) for _ in range(n))

ans = float('inf')
for i in range(2**n):
    tmp = [0]*m
    cost = 0
    for j in range(n):
        if (i >> j) & 1:
            for k in range(m):
                tmp[k] += cl[j][k+1]
            cost += cl[j][0]
    for t in tmp:
        if t < x:
            break
    else:
        ans = min(ans, cost)

if ans == float('inf'):
    print(-1)
else:
    print(ans)


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

using ll = long long;
using str = string;
using ss = stringstream;

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

    str s;
    ll k;
    cin>>s>>k;

    int ans=1;
    int cnt=0;

    for(int i=0;i<s.size();i++)if(s[i]!='1')
    {
        ans=s[i]-'0';
        cnt=i;
        break;
    }

    if(k>cnt)cout<<ans<<"\n";
    else cout<<1<<"\n";

    return 0;
}


Measured memory_bytes: 3656
N,D=map(int,input().split())

X=[]

for i in range(N):
    x=list(map(int,input().split()))
    X.append(x)
C=0
L=[]
for i in X:
    for j in X:
        if i==j:
            break
        else:
            S=0
            for k in range(D):
                S += (i[k]-j[k])**2
            l=S**(1/2)
            if l%1==0:
                C+=1
print(C)

Measured memory_bytes: 3060
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

al=factorization(a) 
bl=factorization(b)

a_s=set()
b_s=set()
for i in range(len(al)):
    a_s.add(al[i][0])
for j in range(len(bl)):
    b_s.add(bl[j][0])
    

s=a_s&b_s
s.add(1)    

print(len(s))

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

int main(){
   int N;
   cin >> N;
   string S;
   cin >> S;
   for(int i=0; i<S.size(); i++){
       char A = S[i] + N;
       if(A > 'Z'){A -= 26;}
       cout << A ;
   }
   cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int maxn=105;
typedef short sh;
sh a[maxn][maxn],b[maxn][maxn],dp[maxn][maxn][maxn][maxn],ans;
int n,m,tx,ty;char ch;
short X(int x,int l,int r){return b[x][r]-b[x][l-1];}
short Y(int y,int l,int r){return a[r][y]-a[l-1][y];}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n) rep(j,1,m){
		scanf(" %c",&ch);
		if(ch=='o') a[i][j]=b[i][j]=1;
		else if(ch=='E') tx=i,ty=j;
	}
	rep(i,1,n) rep(j,1,m) a[i][j]+=a[i-1][j],b[i][j]+=b[i][j-1];
	rep(i,0,tx-1) rep(j,0,ty-1) rep(x,0,n-tx) rep(y,0,m-ty){
		if(i&&tx-i>x)
			dp[i][j][x][y]=max(dp[i][j][x][y],(sh)(dp[i-1][j][x][y]+X(tx-i,max(ty-j,y+1),min(ty+y,m-j))));
		if(j&&ty-j>y)
			dp[i][j][x][y]=max(dp[i][j][x][y],(sh)(dp[i][j-1][x][y]+Y(ty-j,max(tx-i,x+1),min(tx+x,n-i))));
		if(x&&tx+x<=n-i)
			dp[i][j][x][y]=max(dp[i][j][x][y],(sh)(dp[i][j][x-1][y]+X(tx+x,max(ty-j,y+1),min(ty+y,m-j))));
		if(y&&ty+y<=m-j)
			dp[i][j][x][y]=max(dp[i][j][x][y],(sh)(dp[i][j][x][y-1]+Y(ty+y,max(tx-i,x+1),min(tx+x,n-i))));
		ans=max(ans,dp[i][j][x][y]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 225920
//If there is no outward edge then ,length of longest path=0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
map<ll,list<ll>> graph;
ll dp[100003];
ll solve(ll y)
{
	if(dp[y]!=-1)
		return dp[y];
	if(graph[y].size()==0)
	{
		return 0;
	}
	ll ans=0;
	for(auto it:graph[y])
	{
		ans=max(ans,solve(it));
	}
	return dp[y]=1+ans;
}
int main()
{
	ll n,m;
	cin>>n>>m;
	for(ll p=0;p<m;p++)
	{
		ll x,y;
		cin>>x>>y;
		graph[x].push_back(y);
	}
	ll ans=0;
	for(ll p=1;p<=n;p++)
		dp[p]=-1;
	for(ll r=1;r<=n;r++)
	{
		ans=max(ans,solve(r));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  cin>>s;
  int x=s[0]-'0';
  int y=s[1]-'0';
  int n=10*x+y;
  int a=s[2]-'0';
  int b=s[3]-'0';
  int c=10*a+b;
  if(n<=12&&n>0)
  {
    	if(c<=12&&c>0)
          	cout<<"AMBIGUOUS";
    	else
          	cout<<"MMYY";
  }
  else
  {
	if(c<=12&&c>0)
      	cout<<"YYMM";
    else
      	cout<<"NA";
  }

  
  
}

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

int main() {
  string s, t = "";
  int w, tmp = 0;
  cin >> s >> w;
  while(tmp < s.size()){
    t += s[tmp];
    tmp += w;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


struct Node{
    ll flag=-1;
};
Node node[500010];

struct edge{ll to,cost; };
vector<edge> G[500010];
ll d[500010];
bool ans=true;

void dijkstra(ll s){
    fill(d,d+500010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second%500000;
        ll u=p.second/500000;
        if(d[v]<p.first)continue;
        if(u>0){
            if(node[v].flag==-1){
                node[v].flag=u;
            }else if(node[v].flag!=u){
                ans=false;
                break;
            }
        }
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to+500000*v));
                }
            }
        }
    }
}


int main(){fastio
    ll n,m;cin>>n>>m;
    rep(i,0,m-1){
        ll a,b;
        cin>>a>>b;
        edge e;
        e.to=b;
        e.cost=1;
        G[a].pb(e);
        e.to=a;
        G[b].pb(e);
    }
    dijkstra(1);
    if(ans){
        cout<<"Yes"<<endl;
        rep(i,2,n){
            cout<<node[i].flag<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    
    
    return 0;
}



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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else if (a == 1) cout << "Alice" << endl;
  else if (b == 1) cout << "Bob" << endl;
  else if (a > b) cout << "Alice" << endl;
  else cout << "Bob" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,kotae[100],z,m,kazu;
	kazu=0;
	while(scanf("%d%d",&a,&b)!=EOF){
		kazu=kazu+1;
		m=a+b;
		kotae[kazu]=0;
		while(m!=0){
			m=m/10;
			kotae[kazu]=kotae[kazu]+1;
		}
	}
	a:;
	for(z=1;z<=kazu;z++){
		printf("%d\n",kotae[z]);
	}
	return 0;
}


Measured memory_bytes: 1980
N, W = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  w, v = map(int, input().split())
  for j in range(W+1):
    if j - w < 0:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v)

print(dp[-1][-1])

Measured memory_bytes: 149216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int x;cin>>x;
  if(x<1200)cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=405;
const int mod=1e9+7;
int n,C;
int a[maxn],b[maxn];
int pw[maxn][maxn],f[maxn][maxn],dp[maxn][maxn];

void prepare(){
	REP(i,400){
		pw[i][0]=1;
		REP(j,400)pw[i][j]=(ll)pw[i][j-1]*(ll)i%mod;
	}
	REP(i,400)rep(j,401){
		f[i][j]=(f[i-1][j]+pw[i][j])%mod;
	}
}

int main(){
	prepare();
	scanf("%d%d",&n,&C);
	REP(i,n)scanf("%d",&a[i]);
	REP(i,n)scanf("%d",&b[i]);
	dp[0][0]=1;
	REP(i,n)rep(j,C+1){
		rep(k,j+1){
			dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-k]*(ll)(f[b[i]][k]-f[a[i]-1][k]+mod)%mod)%mod;
		}
//		cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
	}
	printf("%d",dp[n][C]);
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
using namespace std;
long ans,n,a[6];
string s;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		a[s[0]=='M'?0:s[0]=='A'?1:s[0]=='R'?2:s[0]=='C'?3:s[0]=='H'?4:5]++;
	}
	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			for(int k=j+1;k<5;k++)
			{
				ans+=a[i]*a[j]*a[k];
			}
		}
	}
	cout<<ans<<endl;
}

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

float ca(int a, int per) {
    return (float)(a * (100 + per)) / 100.0;
}

float cb(int a, int per) {
    return (float)(a / (100 + per)) * 100.0;
}

int g(int a, int c, int per, int cnt) {
    int d = (int)ca(c, per);
    if (d == a) {
        return c;
    } else if (cnt > 100) {
        return c - cnt;
    } else {
        return g(a, c + 1, per, cnt + 1);
    }
}

int f(int a, int per) {
    float b = cb(a, per);
    int c = (int) b;
    return g(a, c, per, 0);
}



int sum(int a, int b, int per) {
    float ra = ca(a, per);
    float rb = ca(b, per);
    return (int)ra + (int)rb;
}

void ma(int pre, int after, int psum) {
    int max = 0;
    for (int a = 1; a < psum / 2 + 1; a++) {
        int b = psum - a;
        int ra = f(a, pre);
        int rb = f(b, pre);
        int m = sum(ra, rb, after);
        if (m > max) {
            max = m;
        }
    }
    cout << max << endl;
}

int main() {
    int pre, after, psum;
    while (true) {
        cin >> pre >> after >> psum;
        if (pre == 0 && after == 0 && psum == 0 ) break;
        ma(pre, after, psum);
    }
    return 0;
    
}




Measured memory_bytes: 3004
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 char b;
 cin>>b;

 if(b=='A')cout<<"T"<<endl;
 else if(b=='T')cout<<"A"<<endl;
 else if(b=='C')cout<<"G"<<endl;
 else cout<<"C"<<endl;
 return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
    public static final int BIG_NUM = 2000000000;
    public static final int MOD = 1000000007;
    
    public static void main(String[] args) {
        BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
        Deque<Integer> LOC = new ArrayDeque<>();
        Deque<Info> POOL   = new ArrayDeque<>();
    
        int tmp_S, tmp_start, tmp_end, sum = 0;
        
        try {
            char array[] = br.readLine().toCharArray();
            
            for(int i = 0; i < array.length; i++) {
                if(array[i] == '\\') {
                    LOC.addFirst(i);
                }else if(array[i] == '/') {
                    if(LOC.isEmpty()) continue;
                    
                    tmp_start = LOC.getFirst();
                    LOC.removeFirst();
                    tmp_end = i;
                    
                    tmp_S = tmp_end - tmp_start;
                    sum += tmp_S;
                    
                    while(!(POOL.isEmpty()) && POOL.getFirst().getStart() > tmp_start && POOL.getFirst().getEnd() < tmp_end) {
                        tmp_S += POOL.getFirst().getS();
                        POOL.removeFirst();
                    }
                    
                    POOL.addFirst(new Info(tmp_start, tmp_end, tmp_S));
                }else {
                    //Do nothing
                }
            }
            
            System.out.println(sum);
            
            StringBuilder ans = new StringBuilder();
            ans.append(Integer.toString(POOL.size()));
            
            while(!POOL.isEmpty()) {
                ans.append(" ").append(Integer.toString(POOL.getLast().getS()));
                POOL.removeLast();
            }
            
            System.out.println(ans.toString());
        }catch(NumberFormatException e) {
            e.printStackTrace();
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}  

class Info {
    private int start;
    private int end;
    private int S;
    
    Info(int start, int end, int S) {
        this.start = start;
        this.end = end;
        this.S = S;
    }
    
    public int getStart() {
        return start;
    }
    public void setStart(int start) {
        this.start = start;
    }
    
    public int getEnd() {
        return end;
    }
    public void setEnd(int end) {
        this.end = end;
    } 
    
    public int getS() {
        return S;
    }
    public void setS(int S) {
        this.S = S;
    }
}


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

int main(){
	int n,m;
	cin>>n>>m;
	int l[m],r[m];
	int left=0,right=n;
	rep(i,m){
		cin>>l[i]>>r[i];
		left=max(left,l[i]);
		right=min(right,r[i]);
	}
	if(right-left>=0)cout<<right-left+1<<endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 1024
# coding:utf-8

from collections import Counter


def inpl(): return list(map(int, input().split()))


S = input()
C = Counter(S)
if len(S) == 1:
    print(0)
    exit()

ans = 100
for key in C.keys():
    prev_S = list(S)
    cnt = 0
    t = len(S) - 1
    while t > 0:
        if all([1 if s == key else 0 for s in prev_S]):
            ans = min(ans, cnt)
            break
        SS = []
        for i in range(t):
            if key in prev_S[i: i + 2]:
                SS.append(key)
            else:
                SS.append(prev_S[i])
        cnt += 1
        t -= 1
        prev_S = SS[:]
    # print(cnt, prev_S)

print(ans)


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll X;
    cin >> X;

    ll ans = 0;
    if (X <= 6) {
        ans += 1;
    }
    else {
        ans += X / 11 * 2;
        ll d = X % 11;
        if (d >= 1 && d <= 6) {
            ans += 1;
        }
        else if (d >= 7) {
            ans += 2;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"I=lambda:map(int,input().split());n,m,x=I();s=sum(a<x for a in I());print(min(s,m-s))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    ll p[a],q[b],r[c];
    vector<pll> v;
    rep(i,0,a){cin>>p[i];v.push_back({p[i],0});}
    rep(i,0,b){cin>>q[i];v.push_back({q[i],1});}
    rep(i,0,c){cin>>r[i];v.push_back({r[i],2});}
    ll ans=0;
    sort(v.begin(),v.end(),greater<pll>());
    ll cnt[3]={0,0,0};
    rep(i,0,v.size()){
        int num=v[i].second;
        if(num==2){
            cnt[num]++;
            ans+=v[i].first;
        }
        else if(num==1){
            if(cnt[1]<y){
                cnt[1]++;
                ans+=v[i].first;
            }
        }
        else{
            if(cnt[0]<x){
                cnt[0]++;
                ans+=v[i].first;
            }
        }
        if(cnt[0]+cnt[1]+cnt[2]==x+y)break;
    }
    cout<<ans<<endl;
}







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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1e9+7;

vector<ll> p;
vector<ll> smp;

void createSieve(ll n)
{
	smp = vector<ll>(n+1);

	for(ll i = 2; i <= n; i++)
	{
		if(smp[i] == 0)
		{
			smp[i] = i;
			p.pb(i);
		}

		for(ll j = 0; j < p.size() and p[j] <= smp[i] and i*p[j] <= n; j++)
			smp[i*p[j]] = p[j];
	}
}

ll fact_pow (ll n, ll k) {
    int res = 0;
    while (n) {
        n /= k;
        res += n;
    }
    return res;
}

int main()
{
  	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n;
	cin >> n;

	createSieve(n+1);
  
  	ll ans = 1;
  
  	for(ll x: p)
    {
      ans *= fact_pow(n, x)+1;
      ans %= mod;
    }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mod 1000000007
vector<pair<int,int>> vp;
pair<int,int> pp;
vector<int> vv,vv1;
map<int,int> mp;
int mat[502][502];
//int dp[1000+4][32];
int ara[21];
bool visited[1000];
int main()
{
    ull x;
    ull ans = 0;
    cin>>x;
    if(x%2!=0){
        cout<<"0"<<"\n";
    }else{
        while(x){
            ans+=x/10;
            x/=5;
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 256
function toNum (str) {
	return parseInt(str, 10);
}

// inputに入力データ全体が入る
function Main(input) {
	var N = toNum(input.split('\n')[0].split(' ')[0]);
	var T = toNum(input.split('\n')[0].split(' ')[1]);
	var roots = input.split('\n');
	roots.shift();
	var roots_2 = roots.filter(n => toNum(n.split(' ')[1]) <= T);
	if ( roots_2.length == 0 ) {
		console.log('TLE');
	} else {
		roots_2 = roots_2.map(n => n.split(' ')[0]);
		console.log(Math.min(...roots_2));
	}
}

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<cstdio>

int main(){
	int x, y;
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;
		if(x>y){
			printf("%d %d\n", y, x);
		}else{
			printf("%d %d\n", x, y);
		}
	}

		return 0;
	}

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
using namespace std;
#define INF 1050000000
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>H(N);
  for (int i=0;i<N;++i){
    cin>>H[i];
  }
  vector<int>c(N,INF);
  c[0]=0;
  for (int i=1;i<N;++i){
    for (int j=1;j<=min(i,K);++j){
      c[i]=min(c[i],c[i-j]+abs(H[i]-H[i-j]));
    }
  }
  cout<<c[N-1]<<endl;
}                                    
                                    


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007

int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K + 1; i <= N; i++)
    {
        ll t = ((N - K) / i);
        ll s = t * (i - K);
        s += min(N + 1, (t + 1) * i) - (K + t * i);
        if (K == 0)
            s--;
        ans += s;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

struct seg
{
	ll l, r, d;
	inline int operator<(const seg &a) const {return d > a.d;}
} s[10010];

const ll inf = (1ll<<62) - 1;
int n, m;
ll f[5010][5010][2];

int main()
{
	ios::sync_with_stdio(0);
	
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> s[i].l >> s[i].r;
		s[i].d = s[i].l + s[i].r;
	}
	sort(s+1, s+n+1);
	m = n >> 1;
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j <= m; ++j)
			f[i][j][0] = f[i][j][1] = inf;
	f[0][0][0] = 0;
	
	for (int i = 0; i <= m; ++i)
		for (int j = 0; j <= m && i+j < n; ++j)
			for (int k = 0; k <= 1 && i+j+k < n; ++k)
			{
				const ll tmp = f[i][j][k]; const seg p = s[i+j+k+1];
				if (i < m)	f[i+1][j][k] = min(f[i+1][j][k], tmp + p.r + i*p.d);
				if (j < m)	f[i][j+1][k] = min(f[i][j+1][k], tmp + p.l + j*p.d);
				if (!k)		f[i][j][k|1] = min(f[i][j][k|1], tmp + m * p.d);
			}
	
	cout << f[m][m][n&1] << endl;
	
	return 0;
}

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

struct rest
{
	string name;
	int mark;
	int num;
};

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

	int n, p;
	string cur;

	cin >> n;

	vector<rest> all(n);

	for (int i = 0; i < n; i++)
	{
		cin >> cur >> p;
		all[i] = { cur, p, i + 1 };
	}

	sort(all.begin(), all.end(), [&](const rest &a, const rest &b)
	{
		if (a.name == b.name)
			return a.mark > b.mark;
		else
			return a.name < b.name;
	});

	for (auto each : all)
		cout << each.num << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <algorithm>
#include <string.h>
#include <memory.h>

using namespace std;

typedef long long ll;
int const N = 1e5 + 5, oo = 2e9 + 1;
int n, m, q, k, a[N], fr[N];
vector<vector<int> > g;

int main() {
	scanf("%d", &n);
	for(int i = 0, tmp; i < n; ++i) {
		scanf("%d", &tmp);
		++fr[tmp];
	}

	int res = fr[0] + fr[1];
	for(int i = 1; i < N - 1; ++i) {
		res = max(res, fr[i] + fr[i - 1] + fr[i + 1]);
	}
	res = max(res, fr[N] + fr[N - 1]);

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

    return 0;
}


Measured memory_bytes: 640