akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define V vector<int>
#define VP vector<pair<int, int> >
#define FASTIO ios_base::sync_with_stdio(0)
using namespace std;
#ifdef _WIN32
#include <windows.h>
#define print(x) PRINT(x, #x)
template<typename T> inline const void PRINT(T VARIABLE, string NAME)
{
#ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, 10);
    cerr << NAME << " = " << VARIABLE << '\n';
    SetConsoleTextAttribute(hConsole, 7);
#endif
}
#else
#define print(x) 0
#endif
struct pair_hash
{
    template<typename T1, typename T2>
    size_t operator () (const pair<T1, T2> &p) const
    {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;
    }
};
typedef long long ll;
typedef unsigned long long ull;
const ll INFLL = 2 * (ll)1e18 + 100;
const int INFINT = 2 * (int)1e9 + 100;
//ifstream fin(".in");
//ofstream fout(".out");
void die()
{
    cout << "NO";
    exit(0);
}
const int NMAX = 1e5 + 5;
const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
const double PI = atan(1) * 4;
const double EPS = 1e-12;

int n, k;
ll v[55];
ll scad[NMAX];
ll adun;


int main()
{
    FASTIO;
    cin >> n;
    for1(i, n) cin >> v[i];
    while(1)
    {
        bool no = 0;
        for1(i, n)
        {
            if(v[i] >= n) no = 1;
           // print(scad[i]);
           // print(adun);
           // v[i] += adun - scad[i];
           // print(v[i]);
           // scad[i] += v[i] / n + adun;
            adun += v[i] / n;
            for1(j, n) if(j != i) v[j] += v[i] / n;
            v[i] = v[i] % n;
        }
        for1(i, n) if(v[i] >= n) no = 1;
        if(!no) return cout << adun, 0;
       // print(adun);
       // print('\n');
    }


    return 0;
}

/*
3
3 4 5
*/


Measured memory_bytes: 256
# frozen_string_literal: true

# Generated by AtcoderGreedy on 2018-04-22
# ABC095 D
# Your code here

$N, $C = gets.chomp.split(' ').map(&:to_i)

$res = [0]

$sushi = [[0, 0]]
$normal = [0]
$reverse = [0]

$normal_max = [0]
$reverse_max = [0]

last = 0
$N.times do
  x, v = gets.chomp.split(' ').map(&:to_i)
  $sushi << [x, v]
  $normal << $normal.last + (v - (x - last))
  $normal_max << [$normal.last, $normal_max.last, 0].max
  last = x
end

last = $C
$sushi.drop(1).reverse.each do |x, v|
  $reverse << $reverse.last + (v - (last - x))
  $reverse_max << [$reverse.last, $reverse_max.last, 0].max
  last = x
end

$normal_res_max = []
$reverse_res_max = []

($N + 1).times do |i|
  $normal_res_max << $normal_max[i] + $reverse_max[- (i + 1)] - $sushi[i].first
end

($N + 1).times do |i|
  $reverse_res_max << $reverse_max[i] + $normal_max[- (i + 1)] - ($C - $sushi[- i].first)
end

puts [$normal_res_max.max, $reverse_res_max.max, $reverse_max.max, $normal_max.max].max


Measured memory_bytes: 16268
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ab = Array(n - 1) { readLine()!!.split(" ").map(String::toInt) }
    val c = readLine()!!.split(" ").map { it.toInt() }.sortedDescending().toIntArray()
    println(c.sum() - c.max()!!)

    val link = Array(n + 1) { ArrayList<Int>() }
    ab.forEach {
        link[it[0]].add(it[1])
        link[it[1]].add(it[0])
    }
    val visit = BooleanArray(n + 1) { false }
    val result = IntArray(n + 1) { 0 }
    val queue = ArrayDeque<Int>()
    visit[1] = true
    queue.add(1)
    var cursor = 1
    while (!queue.isEmpty()) {
        val node = queue.pop()
        link[node].forEach {
            if (!visit[it]) {
                visit[it] = true
                queue.add(it)
            }
        }
        result[node] = c[cursor - 1]
        cursor += 1
    }
    println(result.takeLast(n).joinToString(" "))
}

Measured memory_bytes: 54280
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll ans=0;
	string s;
	cin >> s;
	ll n=s.size();
	rep(i,0,n){
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int len[]=new int[n];
		for(int i=0;i<n;i++) {
			len[i]=sc.nextInt();
		}
		Arrays.sort(len);
		int[][] start=new int[n][n];
		int[][] end=new int[n][n];
		int a=0;
		int sum=0;
		for(int i=0;i<n;i++) {

			for(int j=i+1;j<n;j++) {
				a=Math.max(j, start[i][j-1]);
				int sa=len[j]-len[i];
				int wa=len[j]+len[i];
				for(;a<n;a++) {
					if(len[a]>sa&&a!=i&&j!=a) {
						start[i][j]=a;
						break;
					}
					if(a==n-1) {
						start[i][j]=-1;
					}
				}
				int b=end[i][j-1];
				if(b==0) {
					b=a;
				}
				for(;b<n;b++) {
					if(len[b]>=wa&&b!=i&&b!=j) {
						end[i][j]=b-1;
						break;
					}
					if(b==n-1) {
						end[i][j]=b;
					}
				}
				if(start[i][j]!=-1&&end[i][j]>=start[i][j]) {
					sum+=end[i][j]-start[i][j]+1;
					/*if(i>=start[i][j]&&i<=end[i][j]) {
						sum--;
					}
					if(j>=start[i][j]&&j<=end[i][j]) {
						sum--;
					}*/

				}
			}
		//	System.out.println(sum);
		}
		/*for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				System.out.print(i+" "+j+ " ");
				System.out.print(start[i][j]+" ");
				System.out.println(end[i][j]);
			}
		}*/
		System.out.println(sum);
	}
}


Measured memory_bytes: 81124
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;

struct edge {
	int to, cost;
};
class dijkstra {
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<P>> que;
	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}
	int find(int e) {
		return d[e];
	}
};
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}
	void Union(int x, int y) {
		if (same(x, y)) return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}
	bool same(int x, int y) {
		return Find(x) == Find(y);
	}
	int get_Size(int a) {
		return s[a];
	}
};
signed main() {
	int a,p;
	cin>>a>>p;
	p+=a*3;
	cout<<p/2<<endl;
}


Measured memory_bytes: 256
main = do
  [n,a,b] <- map read . words <$> getLine 
  s <- getLine 
  mapM putStrLn (solve (a,b) s)

solve :: (Int,Int) -> [Char] -> [String]
solve _ [] = []
solve (a,b) ('a':ss) 
  | a+b > 0 = "Yes" : solve (a-1,b) ss
solve (a,b) ('b':ss)
  | a+b > 0 && b > 0 = "Yes" : solve (a,b-1) ss
solve (a,b) (_:s) = "No" : solve (a,b) s

Measured memory_bytes: 7036
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 998244353;
const double dancila = 3.14159265359; // PI 
const double eps = 1e-9;

int n;

vector<pair<int, int> >ar[2000002];
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> n;
	int dif = 0;
	int dif2 = 0;
	for(int i = 1; i <= n; ++i)
	{
		string s;
		cin >> s;
		deque<char> d;
		for(int j = 0; j < s.size(); ++j)
		{
			if(!d.empty() && s[j] == ')' && d.back() == '(')
				d.pop_back();
			else
				d.pb(s[j]);
		}
		if(!d.empty() && d[0] == '(')
			dif += d.size();
		else
		{
			int dsc = 0;
			int cl = 0;
			for(int j = 0; j < d.size(); ++j)
				if(d[j] == '(')
					dsc++;
				else
					cl++;
			if(!dsc)
				dif2 += cl;
			else
			{
				ar[1000000 + dsc - cl].pb({cl, dsc});
			}
		}
	}
	multiset<pair<int, int> >prd;
	for(int i = 1000001; i <= 2000000; ++i)
		for(auto pr : ar[i])
			prd.insert(pr);
	while(!prd.empty())
	{
		pair<int, int> xx = *prd.begin();
		if(dif >= xx.fi)
			dif = dif - xx.fi + xx.se, prd.erase(prd.lower_bound(xx));
		else
		{
			cout << "No";
			return 0;
		}
	}
	for(int i = 1000000; i >= 0; --i)
	{
		for(auto pr : ar[i])
		{
			if(dif < pr.fi)
			{
				cout << "No";
				return 0;
			}
			dif = dif - pr.fi + pr.se;
		}
	}
	dif -= dif2;
	if(dif == 0)
		cout << "Yes";
	else
		cout << "No";
    return 0;
}


Measured memory_bytes: 52092
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
int main(){
 
  int N,c0=0,c1=0,c2=0,c3=0;
  string S;
  
  cin >> N;
  
  for(int i=0; i<N; i++){
    
    cin >> S;
    
	    if(S[0]=='A') c0++;
        if(S[0]=='W') c1++;
        if(S[0]=='T') c2++;
        if(S[0]=='R') c3++;
    
  }

	cout << "AC x " <<c0 <<"\n";
    cout << "WA x " <<c1 <<"\n";
    cout << "TLE x " <<c2 <<"\n";
    cout << "RE x " <<c3;
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main()
{
    int i;
    char O[51],E[51];
    scanf("%s %s",O,E);
    for(i=0;i<strlen(O);i++){
        printf("%c",O[i]);
        if(E[i]!='\0') printf("%c",E[i]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 128
N=int(input())
if N&1==1:
    M=(N-1)*(N-1)//2
    print(M)
    for n in range(1,N):
        for k in range(n+1,N):
            if n+k==N:
                continue
            print(n,k)
    for n in range(1,N):
        print(N,n)
else:
    M=N*(N-2)//2
    print(M)
    for n in range(1,N+1):
        for k in range(n+1,N+1):
            if n+k==N+1:
                continue
            print(n,k)


Measured memory_bytes: 3612
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):
    return map(type,input().split())

#%%code
def resolve():
    N=int(input())
    A=[tuple(pin())for i in range(N)]
    A.sort(key=lambda x:x[0]+x[1])
    ans=0
    jama=-10000000000#int value
    for i in range(N):
        if A[i][0]-A[i][1]>=jama:
            jama=sum(A[i])
            ans+=1
            
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 21380
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
    string S;
    cin >> S;
    int n = S.size();
    for(int i = 0; i < n; i++){
        cout << "x";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def input_from_console():
    s= input().strip()
    return s


def solve(s):
    buffer = [0] * 10
    result = 'Good'
    prev = ''
    for item in s:
        if item == prev:
           result = 'Bad'
           break
        else:
            prev = item
    return result


def main():
    s = input_from_console()
    print(solve(s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


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

int main(void){
  string s, output = "";
  int i;
  cin >> s;
  for(i = 0; i < (int)s.length(); i++){
    if(s[i] == '0') output.push_back('0');
    if(s[i] == '1') output.push_back('1');
    if(s[i] == 'B' && output != "") output.pop_back();
  }
  cout << output << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
int main(){
    double n,m,d;
    cin>>n>>m>>d;
    double sad;
    if(d==0){
        sad=n;
    }else{
        //sad+=n-(n-d);
        //sad+=d;
        //sad+=2*((n-d)-d);
        sad=2*(n-d);
    }
   
  
    cout<<setprecision(16);
    cout<<(sad/(n*n))*(m-1)<<endl;

    
return 0;
}


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

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

    int n, k;
    cin >> n >> k;
    vector<double> A(n), B(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
        B[i] = A[i] * (A[i] + 1) / 2 / A[i];
    }

    vector<double> C(n + 1, 0.0);
    for(int i = 0; i < n; i++){
        C[i + 1] = C[i] + B[i];
    }

    double ans = 0.0;
    for(int i = k; i <= n; i++){
        ans = max(ans, C[i] - C[i - k]);
    }

    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}

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

    	int[][] A=new int[100][100];
    	int[] B=new int[100];
      int C;
     int n =scan.nextInt();
     int m = scan.nextInt();
      for (int s = 0;s<n;s++) {
        for(int t =0;t<m;t++){
        A[s][t]=scan.nextInt();
      }}
    	for (int s = 0;s<m;s++)   {
         B[s]=scan.nextInt();
      }
      
      for(int s=0;s<n;s++){C=0;
        for(int t=0;t<m;t++){
          C += A[s][t]*B[t];
        }
        System.out.println(C);
      }
}}

Measured memory_bytes: 40224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(ll i=0;i<(int)(x);i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll gcl(ll a, ll b){
    return a / gcd(a, b) * b;
}

using namespace std;

int main()
{
    ll n, d;
    cin >> n >> d;
    ll pp = 2 * d + 1;

    ll ans;
    if(n % pp == 0) ans = n/pp;
    else ans = n / pp + 1;

    cout << ans;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
typedef long long         ll;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
#define pb					push_back
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif

}
ll v[100007], w[100007], we, n, mxwe;
ll mem[101][100005];
ll knap(int i, ll rem)
{
	if (i > n) {
		return rem == 0 ? 0 : 1e10;
	}
	if (!rem)return 0;
	ll& ret = mem[i][rem];
	if (~ret)return ret;
	ll choice1 = knap(i + 1, rem);
	ll choice2 = 1e10;

	if (rem - v[i] >= 0)
		choice2 = knap(i + 1, rem - v[i]) + w[i];

	return ret = min(choice1, choice2);
}
int main()
{
	//GOAT();
	clr(mem, -1);
	cin >> n >> we;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];
	//cout << knap(0, we) << endl;
	for (int i = 100001; i >= 0; i--)
	{

		ll mx = i, ans = knap(0, mx);
		if (ans <= we)
		{
			return cout << mx << endl, 0;
		}
	}




}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bit_search(bit, 3)
  {
    int res = s[0] - '0';
    string op = "";
    REP(i, 3)
    {
      if (bit_check(bit, i))
      {
        res += s[i+1] - '0';
        op += "+";
      }
      else
      {
        res -= s[i+1] - '0';
        op += "-";
      }
    }
    if (res == 7)
    {
      cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] << "=7";
      return 0;
    }
  }

  return 0;
}


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


int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+5];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    ll x=1,sum=0;
    for(int i=n;i>=1;i--)
    {
       if(k>=x)
       {
           x++;
       }
       else{
        sum+=a[i];
       }

    }
    cout<<sum<<endl;
    return 0;
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _f64 a, b, c, d, e, f, x, y;
        while(cin >> a >> b >> c >> d >> e >> f) {
            x = (c * e - f * b) / (a * e - d * b) + DBL_EPSILON;
            y = (c - a * x) / b + DBL_EPSILON;
            cout << fixed << setprecision(3) << x << " " << y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3260
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var weathers = new string[] { "Sunny", "Cloudy", "Rainy" };

        var input = Console.ReadLine();

        foreach( var index in Enumerable.Range(0, weathers.Length) )
        {
            if (index == weathers.Length - 1)
            {
                Console.WriteLine(weathers[0]);
                return;
            }

            if (input.Equals(weathers[index]))
            {
                Console.WriteLine(weathers[index + 1]);
                return;
            }
        }
    }
}


Measured memory_bytes: 11220
n = int(input())
s = [str(input()) for _ in range(n)]
 
from collections import Counter
s = Counter(s).most_common()
 
b =[]
a = s[0][1]
for i in range(len(s)):
    if s[i][1] == a :
        b.append(s[i][0])
b= sorted(b)
for i in range(len(b)):
    print(b[i])

Measured memory_bytes: 45072
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A,B,T,m=0;
    cin>>A>>B>>T;
    while(T>=A){
        T=T-A;
        m++;
    }
    cout<<B*m<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    string t,p;

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>t>>p;

    for(int i=0;i+p.length()<=t.length();i++)
    {
        int j;
        for(j=0;j<p.length()&&p[j]==t[i+j];j++);
        if(j==p.length()) cout<<i<<endl;
    }

    return 0;
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
int n;
string word[105];
int main() {
	cin>>n;
	for(int i=0;i<n;i++) cin>>word[i];
	for(int i=1;i<n;i++) {
		for(int j=0;j<i;j++) 
			if(word[i]==word[j]) {cout<<"No";return 0;}
		if(word[i-1][word[i-1].length()-1]!=word[i][0]) 
			{cout<<"No";return 0;}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX (40000)

int prime[MAX + 1];

int main(void)
{
	int i, j, num;
	int n;
	
	prime[0] = prime[1] = 0;
	
	for (i = 2; i <= MAX; i++){
		prime[i] = 1;
	}
	
	for (i = 2; i * i <= MAX; i++){
		for (j = i * i; j <= MAX; j += i){
			prime[j] = 0;
		}
	}
	
	while (scanf("%d", &n), n){
		i = 0;
		j = n;
		num = 0;
		
		while (i <= j){
			if (prime[i] && prime[j] && i + j == n){
//				printf("%d %d %d %d\n", i, prime[i], j, prime[j]);
				num++;
			}
			i++;
			j--;
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    int n;
    cin>>n;
    int b[n-1];
    rep(i,n-1)cin>>b[i];
    ll ans = 0;
    int a[n];
    a[n-1] = b[n-2];
    for(int i=n-2;i>0;i--){
        a[i] = b[i-1];
        if(a[i]>b[i] || a[i]>b[i-1]){
            a[i] = b[i];
        }
    }
    a[0] = b[0];
    rep(i,n){
        ans += a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char ch[10];
int main(){
	int i,len;
	while(scanf("%s",ch)!=EOF){
		int flag=0;
		len=strlen(ch);
		for(i=0;i<len-1;i++){
			if(ch[i]=='A'&&ch[i+1]=='C'){
				flag=1;
				break;
			}
		}
		if(flag==1){
			printf("Yes\n");
		}
		else
			printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,b:i64
    }

    let ans = max(a + b, max(a - b, a * b));
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
   	str s, t;
   	cin >> s >> t;
   	cout << t + s << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N;
	cin >> N;
	string S[N];
	FOR(i,0,N)cin >> S[i];
	ll ans = 0;
	FOR(i,0,N){
		char c[N][N];
		FOR(j,0,N)FOR(k,0,N){
			c[j][k] = S[(j+i)%N][k];
		}
		bool flag = 1;
		FOR(j,0,N)FOR(k,0,N){
			if(c[j][k] != c[k][j])flag = false;
		}
		if(flag)ans++;
	}
	cout << ans*N << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val sDash = readLine()?.split("").orEmpty().drop(1).dropLast(1)
    var answer = ""
    val opeList = listOf<String>("+++","++-","+-+","+--","-++","-+-","--+","---")

    run loop@{
        opeList.forEach{
            var result = sDash[0].toInt()
            result += if(it[0] == '+') sDash[1].toInt() else - sDash[1].toInt()
            result += if(it[1] == '+') sDash[2].toInt() else - sDash[2].toInt()
            result += if(it[2] == '+') sDash[3].toInt() else - sDash[3].toInt()

            if(result == 7){
                answer = sDash[0] + it[0] +sDash[1] + it[1] +sDash[2] + it[2] +sDash[3] + "=7"
                return@loop
            }
        }


    }



    println(answer)
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, k;
void solve(){
	cin >> n >> k;
	
	double ans = 0;
	for(int i = 1; i <= n; i++){
		int a = i;
		int cnt = 0;
		while(a < k){
			a *= 2;
			cnt++;
		}
		ans += pow(0.5,cnt)/n;
	}
	printf("%.10f\n", ans);
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int abs(int a, int b){
    if(a - b < 0){return b - a;}
    else{return a - b;}
}

int max(int a){
    if(a < 0){return 0;}
    else{return a;}
}

int main()
{
    int n;
    int cx, cy, ch;
    std::cin >> n;
    int x[n], y[n], h[n];
    for(int i = 0; i < n; ++i){
        std::cin >> x[i] >> y[i] >> h[i];
    }

    for(int i = 0; i < n; ++i){
        if(h[i] > 0){
            for(cx = 0; cx <= 100; ++cx){
                for(cy = 0; cy <= 100; ++cy){
                    ch = h[i] + abs(cx, x[i]) + abs(cy, y[i]);
                    int flg = 1;
                    for(int j = 0; j < n; ++j){
                        if(j == i) {/*do nothing*/
                        } else if( max(ch - abs(cx, x[j]) - abs(cy, y[j])) != h[j]){flg = 0;}
                    }
                    if(flg == 1){
                        std::cout << cx << ' ' << cy << ' ' << ch << std::endl;
                        return 0;
                    }
                    
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

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

        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }

        int[] b = new int[n];
        for (int i = 0; i < n; ++i) {
            b[a[i] - 1] = i + 1;
        }

        for (int i = 0; i < n; ++i) {
            System.out.print(b[i] + " ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 63008
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int counter = 0;
		for (int i = 1; i <= n/2; i++) {
			int sum = 0;
			for (int j = i; sum <= n; j++) {
				sum += j;
				if (sum == n) {
					counter++;
					break;
				}
			}
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 2 * N + 5;

int n = 3;
int a[3], b[] = {5, 5, 7};

int main(){
    for(int i = 0 ; i < 3 ; ++i)
        scanf("%d", a + i);
    sort(a, a + n);
    for(int i = 0 ; i < 3 ; ++i)
        if(a[i] != b[i])
            exit((puts("NO"), 0));
    puts("YES");
}


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

using namespace std;

typedef long long int lli;

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

    int n, g[2], s[2], b[2];

    cin >> n;
    for (int i=0; i<2; i++) cin >> g[i] >> s[i] >> b[i];

    vector<lli> dp(n+1, n);
    for (int i=1; i<=n; i++) {
        lli gg = (i-g[0] < 0) ? dp[i-1] : max(dp[i-1], dp[i-g[0]]-g[0]+g[1]),
            ss = (i-s[0] < 0) ? dp[i-1] : max(dp[i-1], dp[i-s[0]]-s[0]+s[1]),
            bb = (i-b[0] < 0) ? dp[i-1] : max(dp[i-1], dp[i-b[0]]-b[0]+b[1]);

        dp[i] = max(max(dp[i-1], gg), max(ss, bb));
    }

    int nn = dp[n];
    dp = vector<lli>(nn+1, nn);
    for (int i=1; i<=nn; i++) {
        lli gg = (i-g[1] < 0) ? dp[i-1] : max(dp[i-1], dp[i-g[1]]-g[1]+g[0]),
            ss = (i-s[1] < 0) ? dp[i-1] : max(dp[i-1], dp[i-s[1]]-s[1]+s[0]),
            bb = (i-b[1] < 0) ? dp[i-1] : max(dp[i-1], dp[i-b[1]]-b[1]+b[0]);

        dp[i] = max(max(dp[i-1], gg), max(ss, bb));
    }

    cout << dp[nn] << endl;

    return 0;
}


Measured memory_bytes: 195584
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const ll inf=1e18;
const int N=5010;
ll dp[N][2*N],pre[N][2*N];
int per[N],p[N],n;
int A,B;

int main() {
	rd(n),rd(A),rd(B);
	for(int i=1;i<=n;++i) rd(per[i]),p[per[i]]=i;
	memset(dp,0x3f,sizeof(dp));
	dp[0][1]=0;
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=2*n+1;++j) pre[i-1][j]=min(j>1 ? pre[i-1][j-1] : inf,dp[i-1][j]);
		for(int j=1;j<=2*n+1;++j)
			dp[i][j]=pre[i-1][j&1 ? j : j-1]+(j<p[i]*2)*B+(j>p[i]*2)*A;
	}
	ll res=inf;
	for(int j=1;j<=2*n+1;++j)
		res=min(res,dp[n][j]);
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 784640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

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

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, r;
  cin >> n >> r;
  int ans;
  if(n >= 10) {
    ans = r;
  }
  else {
    ans = r + 100 * (10 - n);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#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 N;
int A[20], B[20];
int DP[(1<<20)][20];

int solve(int S, int x) {
  if(DP[S][x]>0) return DP[S][x];
  int tmpnum = 0;
  for(int i=0;i<x;++i) {
    if((S&(1<<i))==0) tmpnum++;
  }
  if(S==0) {
    return DP[S][x] = tmpnum;
  }
  DP[S][x] = inf;
  int num = -1; // Sのうちの最後の値のインデックス
  for(int i=0;i<N;++i) {
    if((S&(1<<i))!=0) num++;
  }
  int tmp1, tmp2;
  for(int i=0;i<N;++i) {
    if((S&(1<<i))==0) continue;
    if((x-(num+1))%2==0) tmp1 = A[x];
    else tmp1 = B[x];
    if((i-num)%2==0) tmp2 = A[i];
    else tmp2 = B[i];
    if(tmp1<tmp2) continue;
    DP[S][x] = min(DP[S][x], solve(S^(1<<i), i)+tmpnum);
  }
  return DP[S][x];
}

int main() {
  cin>>N;
  for(int i=0;i<N;++i) cin>>A[i];
  for(int i=0;i<N;++i) cin>>B[i];
  int ans = inf;
  int S = (1<<N) - 1;
  for(int i=0;i<N;++i) {
    ans = min(ans, solve(S^(1<<i), i));
  }
  if(ans==inf) cout<<-1<<endl;
  else cout<<ans<<endl;
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;
  n--;

  vector<char> c(26);
  for (ll i = 0; i < 27; ++i) {
    c[i] = i+'a';
  }

  deque<char> ans;
  while (n >= 0) {
    ll x = n % 26;
    n /= 26;
    n--;
    ans.push_front(c[x]);
  }

  each (i, ans) {
    cout << i;
  }
  cout << endl;
  
  return 0;
}


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

int main(void)
{
    int a, b;
    while(cin >> a >> b) {
        int c = a + b;
        for (int i = 1; i < 10; ++i) {
            c /= 10;
            if (c == 0) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

char getAlph(int num)
{
    if (num == 0)
    {
        return 'z';
    }
    return 'a' + num - 1;
}

void Main()
{
    ll N;
    cin >> N;

    vector<char> ans;

    for (ll i = N; i > 0L; i /= 26L)
    {
        int tmp = i % 26L;
        tmp = tmp == 0 ? 26 : tmp;
        ans.push_back(getAlph(tmp));
        i -= (ll)tmp;
    }

    REPD(i, ans.size())
    {
        cout << ans.at(i);
    }
    cout << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n + 1), B(n);
    for(int& i: A) cin >> i;
    for(int& i: B) cin >> i;
    long long tot = 0;
    for(int i = 0; i < n; i++){
        int d = min(B[i], A[i]);; 
        tot += d;
        A[i] -= d;
        B[i] -= d;
        d = min(B[i], A[i + 1]);;
        tot += d;
        A[i + 1] -= d;
        B[i] -= d;
    }
    cout << tot << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t H;
    cin>>H;

    int64_t ans=floor(log2(H));
    ans++;
    ans=pow(2,ans)-1;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long m = in.nextInt();
        long ans = 0;
        
        if(n==2 || m==2){
        	ans = 0;
        }else if(n==1||m==1){
        	if(n==1&&m==1)
        		ans=1;
        	else
        		ans =n*m-2;
        }else{
        	ans = (n-2)*(m-2);
        }
        
        System.out.println(ans);


        in.close();
    }
}


Measured memory_bytes: 21716
#include<stdio.h>
int main(void)
{
	int a,b,x;
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(b%a==0) {
		x=b+a;
	}
	else {
		x=b-a;
	}
	printf("%d\n",x);
	return 0;
}
	

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	map<ll,ll> mp;
	rep(i,n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	vector<ll> b(n+1),c(n+1);
	for(int i=1; i<n+1; i++) {
		//cout << "mp[" << i << "] " << mp[i] << endl;
		if(mp[i] == 0) {
			b[i] = 0;
			c[i] = 0;
			continue;
		}
		b[i] = mp[i] * (mp[i] - 1) / 2;
		//cout << "b[" << i << "] " << b[i] << " ";
		c[i] = (mp[i] - 1) * (mp[i] - 2) / 2;
		//cout << "c[" << i << "] " << c[i] << endl;
		
	}
	ll bsum = 0;
	for(int i=1; i<n+1; i++) {
		bsum += b[i];
	}
	//cout << "bsum" << bsum << endl;
	/*rep(i,n) {
		cout << a[i] << endl;
	}*/
	rep(i,n) {
		cout << setprecision(15) << bsum - b[a[i]] + c[a[i]] << endl;
	}
	
  return 0;
}


Measured memory_bytes: 18944