akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int a,b,c;
    int x,y;
    while (scanf("%d%d%d%d%d",&a,&b,&c,&x,&y)!=EOF) {
        if((a+b)<=2*c){
            if(x<y){
                if(b<2*c)printf("%d\n",(a+b)*x+(y-x)*b);
                else printf("%d\n",(a+b)*x+(y-x)*2*c);
            }
            else if(x>y)
            {
                if(a<2*c)printf("%d\n",(a+b)*y+(x-y)*a);
                else printf("%d\n",(a+b)*y+(x-y)*2*c);
            }
            else printf("%d\n",a*x+b*y);
        }
        else {
            if(x<y){
                if(b<2*c)printf("%d\n",2*c*x+(y-x)*b);
                else printf("%d\n",2*c*x+(y-x)*2*c);
            }
            else if(x>y)
            {
                if(a<2*c)printf("%d\n",2*c*y+(x-y)*a);
                else printf("%d\n",2*c*y+(x-y)*2*c);
            }
            else printf("%d\n",2*c*x);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int n,ok=-1;
string s;
string ans[4]={"SS","SW","WS","WW"};
signed main(){
    cin>>n>>s;
    rep(i,4){
        for(int j=1;j<n;j++){
            if((s[j]=='o')^(ans[i][j-1]==ans[i][j]))ans[i]+='W';
            else ans[i]+='S';
        }
        if(ans[i][0]==ans[i][n]&&((s[0]=='o')^(ans[i][0]=='S')^(ans[i][1]==ans[i][n-1])))ok=i;
    }
    if(ok==-1)cout<<-1<<endl;
    else cout<<ans[ok].substr(0,n)<<endl;
	return 0;
}


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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int xa, xb;
  
  if(x < a) xa = a - x;
  else xa = x - a;
  
  if(x < b) xb = b - x;
  else xb = x - b;
  
  if(xa < xb) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    string a, b, c;
    cin >> a >> b >> c ;
    //*/
    
    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    /*
    if(a <= b){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    */
    
    cout << a.at(0) << b.at(1) << c.at(2) << endl;

    return 0; 
}


Measured memory_bytes: 3588
import java.util.*;
import java.math.BigInteger;

public class Main{
    
    static final int MOD = (int)1e9+7;
    static HashMap<Integer, Integer> memo;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        BigInteger x = new BigInteger(s, 2);
        int popcount = x.bitCount();
        
        BigInteger y = x.remainder(new BigInteger((popcount+1) + ""));
        BigInteger z = BigInteger.ZERO;
        if(popcount>1){
             z = x.remainder(new BigInteger((popcount-1) + ""));
        }
        
        int[] modx = {Integer.parseInt(y.toString(10)),Integer.parseInt(z.toString(10))};
        int[][] mod2beki = new int[n][2];
        mod2beki[0][0] = 1%(popcount+1);
        if(popcount>1){
            mod2beki[0][1] = 1%(popcount-1);
        }
        
        for(int i=1; i<n; i++){
            mod2beki[i][0] = mod2beki[i-1][0]*2%(popcount+1);
            if(popcount>1){
                mod2beki[i][1] = mod2beki[i-1][1]*2%(popcount-1);
            }
        }
        
        for(int i=0; i<n; i++){
            char c = s.charAt(i);
            if(popcount==1 && c=='1'){
                System.out.println(0);
                continue;
            }
            
            int j = Integer.parseInt(c + "");
            int res = modx[j];
            if(c=='0'){
                //mod popcount+1
                res += mod2beki[n-1-i][j];
                res %= popcount+1;
            }else{
                //mod popcount-1
                res -= mod2beki[n-1-i][j] - (popcount-1);
                res %= popcount-1;
            }
            System.out.println(calc(res)+1);
        }
    }
    
    public static int calc(int n){
        if(n==0){
            return 0;
        }
        
        int popcount = Integer.bitCount(n);
        int res = n%popcount;
        
        return calc(res)+1;
    }
}


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

n = int(input())
b = list(map(int, input().split()))

a = [0] * (len(b) + 1)
a[0] = max(b)

for i in range(n-1):
    a[i] = min(a[i], b[i])
    a[i+1] = b[i]

print(sum(a))


Measured memory_bytes: 9180
#include <iostream>
#include <queue>
using namespace std;
//プロセスが完了した順に、各プロセスの名前と終了時刻を空白で区切って１行に出力してください
struct process{
	string name;
	int time; 
};
int main(){
	queue<process> q;
	int n, q_time, ans = 0;
	cin >> n >> q_time;
	process p;
	while(cin >> p.name >> p.time) q.push(p);
	while(!q.empty()){
		if(q.front().time - q_time > 0){
			int tmp = q.front().time - q_time;
			process tmpP;
			tmpP.time = tmp;
			ans += q_time;
			tmpP.name = q.front().name;
			q.pop();
			q.push(tmpP);
		}else{
			ans += q.front().time;
			cout << q.front().name << ' ' << ans << '\n';
			q.pop();
		}
	}
}



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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ma=0,ans=0;
    cin>>n;
    int p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
        ans+=p[i];
        ma=max(ma,p[i]);
    }
    cout << ans-ma/2<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  if(C>=A&&C<=B)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [int(input()) for _ in range(N)]
step = [True for _ in a]

count = 0
n = 1
while step[n-1]:
    count += 1
    if a[n-1] == 2:
        print(count)
        exit()
    step[n-1] = False
    n = a[n-1]
print(-1)

Measured memory_bytes: 7852
module Main (main) where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import Control.Monad
import Data.List
import Data.Function
import Data.Char
main :: IO ()
main = do
  n <- read <$> getLine
  js <- replicateM n $ do
    a:b:_ <- unfoldr (B8.readInt . B8.dropWhile isSpace) <$> BS.getLine
    return (a,b)
  putStrLn $ if solve js
             then "Yes"
             else "No"
  return ()

solve :: [(Int,Int)] -> Bool
solve xs = loop 0 $ sortBy (compare `on` snd) xs
  where
    loop :: Int -> [(Int,Int)] -> Bool
    loop t0 ((t,d):xs)
      | t0 + t <= d = loop (t0 + t) xs
      | otherwise  = False
    loop t0 [] = True


Measured memory_bytes: 53628
from itertools import permutations
from math import factorial
def d(a, b):
  x1, y1 = a
  x2, y2 = b
  return ((x1-x2)**2 + (y1-y2)**2)**0.5

cnt = 0
n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]
for l in permutations(XY):
  for i in range(n-1):
    cnt += d(l[i], l[i+1])
cnt /= factorial(n)
print(cnt)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
	// write your code here
        FastScanner f = new FastScanner();
        int n = f.nextInt();
        String a = "ACL";
        for(int i=1;i<n;i++)
        {
            a += "ACL";
        }
        System.out.println(a);

    }
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

#define ff first
#define ss second
#define all(abcc) (abcc).begin(), (abcc).end()
#define endl '\n'
#define left aba
#define right abc

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N=100002;

int n;

int a[N], b[N], c[N];
int dp[N][3];

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

    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[0][0]=a[0], dp[0][1]=b[0], dp[0][2]=c[0];
    for(int i=1; i<n; ++i) {
        for(int j:{1, 2}) {
            dp[i][0]=max(dp[i][0], a[i]+dp[i-1][j]);
        }

        for(int j:{0, 2}) {
            dp[i][1]=max(dp[i][1], b[i]+dp[i-1][j]);
        }

        for(int j:{0, 1}) {
            dp[i][2]=max(dp[i][2], c[i]+dp[i-1][j]);
        }
    }

    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])<<endl;

    //cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<'\n';
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int a,b,c;
int n,m;
double d,e,f;
string s,t,u;
vector<int> v,w,x;

int main(void) {
    cin >> n;
    long l = 1;
    REP(i,n){
        l=(l*(i+1))%1000000007;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random 

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

N, K = LI()
a = LI()
"""

dp = np.zeros(K+1, dtype=np.int64)
dp[0:a[0]+1] = 1

for i in range(1,N):
    acc = np.cumsum(dp)
    for j in range(K+1)[::-1]:
        if (j-a[i]<=0):
            dp[j] = acc[j]%mod
        else:
            dp[j] = (acc[j] - acc[j-a[i]-1])%mod

print(dp[K])

"""
dp = [0]*(K+1)
acc = [0]*(K+2)

for i in range(K+1):
    if (i <= a[0]):
        dp[i] =  1
    acc[i+1] = acc[i] + dp[i]

for i in range(1,N):
    #for i in range(K):
        #acc[i+1] = acc[i] + dp[i]
    #print(acc)
    for j in range(K+1)[::-1]:
        dp[j] = (acc[j+1] - acc[max(j-a[i], 0)])%mod

    acc[0] = 0
    for j in range(K+1):
        acc[j+1] = (acc[j] + dp[j])%mod

print(dp[K])

Measured memory_bytes: 43372
N, K = map(int, input().split())
max = (N-1)*(N-2)//2
if K > max:
    print(-1)
    exit()

add = max - K
print(N-1 + add)
for i in range(N-1):
    print(1, i+2)
a1, a2 = 2, 2
for i in range(add):
    if a2 == N:
        a1 += 1
        a2 = a1 + 1
    else:
        a2 += 1
    print(a1, a2)

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double x,t;cin>>t>>x;
  double ans = t/x;
  printf("%.10f",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto d = io.read_vec<int>(N);
    sort(d.begin(), d.end());
    int ans = N;
    for(int i = 0; i < N - 1; i++){
        if(d[i] == d[i + 1]) ans--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		var a = 0;
		var b = 0;
		for (var i = 0; i <= 1000; i++) {
			for (var j = -1000; j <= 1000; j++) {
				var value = (long)Math.pow(i, 5) - (long)Math.pow(j, 5);
				if (value == x) {
					a = i;
					b = j;
					break;
				};
			}
		}

		System.out.println(String.format("%d %d", a, b));
	}
}

Measured memory_bytes: 35720
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	ll a[n];
	memset(a,0,sizeof(a));
	ll co=0;
	for(ll i=0;i<n;i++)
	{
		if(i==0&&s[i]=='L')
		{
			a[i]=1;
		}
		else
		{
			if(s[i]!=s[i-1]&&s[i]=='L')
			{
				a[i]=2;
			}
			else if(s[i]==s[i-1])
				co++;
		}
	}
	sort(a,a+n);
	
	for(ll i=n-1;i>=n-k;i--)
	{
		co+=a[i];
	}
	cout<<min(co,n-1)<<endl;
	return 0;
}


Measured memory_bytes: 1232
#include <stdio.h>
#define MAX 1000000007
int main(void){
    // Your code here!
    long int N,K;
    long int A[40002];
    scanf("%ld %ld\n",&N,&K);
    long int i,j,min;
    min = 2001;
    
    for(i=1;N>=i;i++){
        scanf("%ld",&A[i]);
        A[i+N] = A[i];
        if(min > A[i]) min = A[i];
    }
    long int count = 0;
    long int ct,tmp;
    for(i=1;N>=i;i++){
        for(j=i+1;N+i>=j;j++){
           ct = 0; 
            //printf("%d:%d %d\n",j,A[i],A[j]);
            if(A[i] > A[j]){
                tmp = j;
                //ct = 0;
                /*while(N*K+1>=tmp){
                    tmp += N;
                    ct++;
                }*/
                ct = (N*K-tmp)/N+1;
                //printf("ct:%d\n",ct);
                count += ct*(1+ct)/2;
                if(count >= MAX) count = count%MAX;
            }
            
        }
    }
    
    printf("%ld",count);
    return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
template<typename T>
using v=vector<T>;
template<typename T>
using vv=vector<vector<T>>;
template<typename T>
using vvv=vector<vector<vector<T>>>;
template<typename T>
using pql=priority_queue<T,vector<T>,greater<T>>;
template<typename T>
using li=list<T>;
template<typename T>
using fl=forward_list<int>;
template<typename T>
using st=stack<T>;
template<typename T>
using qu=queue<T>;
template<typename T>
using dq=deque<T>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define rbe rbegin()
#define en end()
#define ren rend()
#define sz(x) x.size()
#define all(x) x.be,x.en
#define ral(x) x.rbe,x.ren
#define Vsort(v) sort(v.begin(), v.end());
#define Vrev(v) reverse(v.begin(), v.end());
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)
#define repr(i, n) rep2(i,n,0)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define chmin(mi, val) mi = min(mi, val)
#define chmax(ma, val) ma = max(ma, val)
#define MOD 1e9+7

int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
template<typename T> void In(T &e){cin>>e;}
template<typename T,typename U>void Inparray(T &f,U n){for(U i=0;i<n;i++) cin>>f[i];}
template<typename T,typename U>void Inparray2(T &f,U n){for(U i=0;i<n;i++)for(U j=0;i<n;i++)cin>>f[i][j];}
template<typename T,typename U,typename V>void Inparray3(T &f,U a,V b){for(U i=0;i<a;i++)for(U j=0;i<b;i++)cin>>f[i][j];}
template<typename T> void co(T e){cout<<e;}
template<typename T> void co2(T e){cout<<e<<"\n";}
template<typename T,typename U>void Printarray(T f,U n){for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i]<<"\n";}
template<typename T,typename U>void Printarray2(T f,U n){for(int i=0;i<n;i++){cout<<f[i]<<"\n";}}
template<typename T,typename U,typename V>void Printarray3(T f,U n){for(U i=0;i<n;i++){for(U j=0;j<n;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T,typename U,typename V>void Printarray4(T f,U a,V b){for(U i=0;i<a;i++){for(U j=0;j<b;j++){cout<<f[i][j];}cout<<"\n";}}
template<typename T,typename U>void flagfunc(bool flag,T A,U B){flag ? cout<<A<<"\n" : cout<<B<<"\n";}
void flag2func(bool flag){cout<<(flag?"Yes":"No")<<"\n";}
void flag3func(bool flag){cout<<(flag?"YES":"NO")<<"\n";}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n,ans;cin>>n;
  bool flag=false;
  for(int i=0;i<n+1;i++){
    if(floor(i*1.08)==n){
      ans=i;
      flag=true;
      break;
    }
  }
  flagfunc(flag,ans,":(");
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  int min = a[0], max = a[0];
  for(int i = 0; i < n; i++){
    if(min > a[i]) min = a[i];
    if(max < a[i]) max = a[i];
  }
  cout << max - min << endl;
  return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

constexpr lli MOD = 1e9+7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;


int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	cout << X * min(K, N) + Y * max(N - K, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import groupby

N=int(input())
S=input()
def condition(num):
    if num==0:
        return True
    else:
        flag=0
        data=[]
        for i in range(0,N-num+1):
            data.append([S[i:i+num],i])
        data.sort()
        partdata=[data[i][0] for i in range(0,len(data))]
        partdata=groupby(partdata)
        subdata=[]
        for key,group in partdata:
            g=len(list(group))
            subdata.append(g)
        s=0
        t=subdata[0]-1
        if len(subdata)==1:
            if data[t][1]-data[s][1]>=num:
                flag=1
        for i in range(0,len(subdata)-1):
            if data[t][1]-data[s][1]>=num:
                flag=1
            s=t+1
            t=t+subdata[i+1]
        if data[t][1]-data[s][1]>=num:
            flag=1
        return flag==1

start=0
end=N
while end-start>1:
    test=(end+start)//2
    if condition(test):
        start=test
    else:
        end=test
if condition(end):
    print(end)
else:
    print(start)


Measured memory_bytes: 9856
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		HashSet<Integer> set=new HashSet<>();
		for(int i=0;i<N;++i) {
			set.add(sc.nextInt());
		}
		System.out.println(set.size()==N?"YES":"NO");
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(5e3) + 17;

int n, m;
int p[MAXN];
int S[MAXN][MAXN];
ll a[MAXN], add[MAXN];
ll b[MAXN][MAXN];

bool read() {
    if (!(cin >> n >> m))
        return false;
    
    forn (i, n - 1)
        cin >> a[i];

    forn (i, n)
        forn (j, m)
            cin >> b[i][j];

    return true;
}

void solve() {
    forn (i, m)
        p[i] = MAXN;

    ll ans = -INF * INF;

    for (int i = n - 1; i >= 0; --i) {
        forn (j, m) {
            int& pt = p[j];

            for (; pt < MAXN && b[S[j][pt]][j] <= b[i][j]; ++pt) {
                int k = S[j][pt];
                add[k] -= b[k][j];

                if (pt + 1 < MAXN)
                    add[S[j][pt + 1]] += b[k][j];
            }

            if (pt < MAXN)
                add[S[j][pt]] -= b[i][j];

            add[S[j][--pt] = i] += b[i][j];
        }

        ll cur = 0;

        for (int j = i; j < n; ++j)
            ans = max(ans, (cur += add[j] - (j > i ? a[j - 1] : 0ll)));
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 199168
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

char str[1005];

int main() {
	int w, n;
	cin >> str >> w;
	n = strlen(str);
	REP(i, n) {
		if (i % w == 0)printf("%c", str[i]);
	}
	printf("\n");
	return 0;
}

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

int f(int x) {
  int a, b = 0;
  for (int i = 0; i < 5; i++ ) {
    if (x / pow(10, i) > 0) {
      a = i;
    }
  }
  for (int i = 0; i <= a; i++) {
    b += x % 10;
    x = (x - x % 10) / 10;
  }
  return b;
}

int main() {
  int N, A, B, ans;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    if (A <= f(i) && f(i) <= B) {
      ans += i;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int l;
int b[30];
void make_bit(){
  int a=1;
  rep(i,25){
    b[i]=a;
    a*=2;
  }
}
int bit_search(int x){
  if(x==0) return 0;
  int i=0;
  while(b[i]<=x) i++;
  return i-1;
}
void solve(){
  make_bit();
  int n=bit_search(l);
  int N=n+1,M=2*n;
  int res[70][5];
  int k=0;
  rep1(i,N-1){
    res[k][0]=i;
    res[k][1]=i+1;
    res[k][2]=0;
    res[k+1][0]=i;
    res[k+1][1]=i+1;
    res[k+1][2]=b[i-1];
    k+=2;
  }
  int mx=b[n];
  while(l>mx){
    int nn=bit_search(l-mx);
    res[k][0]=nn+1;
    res[k][1]=N;
    res[k][2]=mx;
    k++;
    mx+=b[nn];
    M++;
  }
  prin2(N,M);
  rep(i,M){
    rep(j,3){
      cout<<res[i][j]<<" ";
    }
    cout<<"\n";
  }
}
int main(){
  cin>>l; 
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
const ll N = 1e5+7;
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<a*a-b<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long int cnt=1,bar1=0,bar2=0;
  for(int i=1; i<n; i++){
    if(a[i-1] == a[i]){
      cnt++;
    }else{
      cnt=1;
    }
    if(cnt == 2){
      if(bar1 == 0){
        bar1 = a[i];
      }else{
        bar2 = a[i];
        break;
      }
    }else{
      if(cnt == 4 && bar1 == a[i]){
        bar2 = a[i];
        break;
      }
    }
  }
  cout << bar1*bar2 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,k,j,dist;
    cin>>n>>k;
    vector<long long int> h(n);
    long long int mi[n];
    for(i=0;i<n;i++)
    cin>>h[i];
    mi[n-1]=0;
    mi[n-2]=abs(h[n-1]-h[n-2]);
    for(i=n-3;i>=0;i--)
    {   
        for(j=i+1;j<n&&j-i<=k;j++)
        {
            dist=mi[j]+abs(h[j]-h[i]);
            if(j==i+1)
            mi[i]=dist;
            else if(dist<mi[i])
            mi[i]=dist;
        }
    }
    cout<<mi[0];
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
a2=0
for i in range(1,n,2):
    a2+=a[i]
ans[0]=sum(a)-2*a2
for i in range(1,n):
    ans[i]=2*a[i-1]-ans[i-1]
for i in range(n):
    ans[i]=str(ans[i])
print(" ".join(ans))


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

#define endl '\n'

long long s[123456];

int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for(int i=0; i<n; i++) {
    int x;
    cin >> x;
    s[x]++;
    sum += x;
  }
  int q;
  cin >> q;
  while(q--) {
    long long b, c;
    cin >> b >> c;
    sum -= b*s[b];
    sum += c*s[b];
    s[c] += s[b];
    s[b] = 0;
    cout << sum << endl;
  }
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int count = 1;
		while (i + 1 < n&&a[i] == a[i + 1]) {
			count++;
			i++;
		}
		if (count % 2 != 0) {
			ans++;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
N,W=map(int,input().split())
dp=[0]*(W+1)
# dp[w] := 上限の容量wのときの価値の最大値

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

Measured memory_bytes: 74228
#include<bits/stdc++.h>
using namespace std;
int main(){
	int K,S;
  	cin >> K >> S;
  	int res = 0;
  	for(int x=0;x<=K;x++){
      	for(int y=0;y<=K;y++){
            if(0<=S-x-y && S-x-y<=K)res++;
        }
    }
  	cout << res << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
n, A, B, C =map(int,input().split())
l=[]
for i in range(n):
    l.append(int(input()))
inf=10**9
"""
解法
それぞれの竹について「Aの材料」、「Bの材料」、「Cの材料」、「使わない」の4択を決める(4**n通り)
"""
def dfs(cur, a, b, c):
    if cur==n:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 9160
import string

s = list(input())
flag = True
if s[0] != "A":
    flag = False
count = 0
for i in range(1, len(s)):
    if s[i] in string.ascii_uppercase:
        if i == 1 or i == len(s) - 1 or s[i] != "C":
            flag = False
        count += 1

if flag and count == 1:
    print("AC")
else:
    print("WA")


Measured memory_bytes: 9920
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  int n; cin >> n;
  int a[n][3];
  f (i, 0, n) {
    f (j, 0, 3) cin >> a[i][j];
  }
  int dp[n][3];
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  f (i, 1, n) {
    dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0]);
  }
  cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);

  return 0;
}

Measured memory_bytes: 4992
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let mut k: Vec<usize> = vec![];
    let mut s: Vec<Vec<usize>> = vec![vec![];m];
    for i in 0..m {
        k.push(iter.next().unwrap().parse().unwrap());
        for _ in 0..k[i] {
            s[i].push(iter.next().unwrap().parse::<usize>().unwrap() - 1);
        }
    }
    let mut p: Vec<u64> = vec![];
    for _ in 0..m {
        p.push(iter.next().unwrap().parse().unwrap());
    }

    let mut cnt = 0u64;
    for mask in 0..1<<n {
        let mut is_ok = true;
        for i in 0..m {
            let mut ons = 0u64;
            for j in 0..k[i] {
                if mask >> s[i][j] & 1 == 1 {
                    ons += 1;
                }
            }
            if ons % 2 != p[i] % 2 {
                is_ok = false;
            }
        }
        if is_ok {
            cnt += 1;
        }
    }

    println!("{}", cnt);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        int K = scanner.nextInt();
        scanner.nextLine();
        char[][] cake = new char[H][W];
        for (int i = 0; i < H; i++) {
            cake[i] = scanner.nextLine().toCharArray();
        }

        int[][] ans = new int[H][W];
        int id = 0;
        for (int i = 0; i < H; i++) {
            int left = -1;
            for (int j = 0; j < W; j++) {
                if (cake[i][j] == '#') {
                    left = j;
                    id++;
                }
                if (left >= 0) {
                    ans[i][j] = id;
                }
            }
            int right = -1;
            for (int j = W - 1; j >= 0; j--) {
                if (cake[i][j] == '#') {
                    right = j;
                }
                if (right >= 0 && ans[i][j] == 0) {
                    ans[i][j] = ans[i][right];
                }
            }
        }
        for (int i = 1; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (ans[i][j] == 0) {
                    ans[i][j] = ans[i - 1][j];
                }
            }
        }
        for (int i = H - 2; i >= 0; i--) {
            for (int j = 0; j < W; j++) {
                if (ans[i][j] == 0) {
                    ans[i][j] = ans[i + 1][j];
                }
            }
        }

        for (int i = 0; i < H; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < W; j++) {
                sb.append(ans[i][j]);
                sb.append(' ');
            }
            System.out.println(sb.toString().trim());
        }

    }

}



Measured memory_bytes: 35228
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(),k=sc.nextInt();
			if(n+k==0)break;
			int[] a = new int[k];
			for(int i=0;i<k;i++){
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			List<int[]>list=new ArrayList<int[]>();
			int max=-1;
			for(int i=0;i<k;i++){
				if(a[i]==0)continue;
				int tmpi=i;
				int tmp=a[i];
				int cnt=1;
				for(int j=i+1;j<k;j++){
					if(a[j]==tmp+1){
						tmp++;
						i++;
						cnt++;
					}
				}
//				System.out.println(a[tmpi]+" "+a[i]);
				max=Math.max(max,a[i]-a[tmpi]+1);
				list.add(new int[]{a[tmpi],a[i]});
			}
//			System.out.println(max);
			int[][] b = list.toArray(new int[0][0]);
			if(a[0]==0){
				for(int i=0;i<b.length-1;i++){
					if(b[i][1]==b[i+1][0]-2){
//						System.out.println(i);
//						System.out.println(b[i][0]+" "+b[i][1]);;
//						System.out.println(b[i+1][0]+" "+b[i+1][1]);;
						max=Math.max(max, (b[i][1]-b[i][0]+1) + 1 + (b[i+1][1]-b[i+1][0]+1));
					}
				}				
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 63000
#define _USE_MATH_DEFINES
#define FAST ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <bits/stdc++.h>
#define Loop(x, l, r) for(int x = l; x < r; ++x)
#define LoopR(x, l, r) for(int x = r-1; x >= l; --x)
#define all(x) x.begin(), x.end()
#define Kill(x) return cout << x << '\n', 0
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

const int N = 200'010;
vector<int> A[N];
bool vis[N] = {};
int ans = 0;
int n, m;

int dfs(int u)
{
    int cnt = 1;
    vis[u] = true;
    for(auto v : A[u])
        if(!vis[v])
            cnt += dfs(v);
    return cnt;
}

int main()
{
    FAST;
    cin >> n >> m;
    Loop(i,0,m)
    {
        int u,v;
        cin >> u >> v;
        A[u].push_back(v);
        A[v].push_back(u);
    }
    Loop(i,0,n)
        if(!vis[i])
            ans = max(ans, dfs(i));
    cout << ans << '\n';
}


Measured memory_bytes: 24064
import qualified Data.Set as Set
main = do
    [k,s] <- map read . words <$> getLine
    let a = [ x + y | x <- [0..k], y <- [0..k], x + y <= s ]
        k'= Set.fromList [0..k]
    print $ length [ 1 | xy <- a, Set.member (s - xy) k']


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<' '<<x<<'\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
}



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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define VSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    int a,b;

    cin>>a>>b;

    cout<<max(0,a-2*b);
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[2005][2005];//黒,白
int gyaku[2][2005];
int rui1[4005][2005];//黒
int rui2[4005][2005];//白
int main(){
    int n;
    cin >> n;
    vector<bool>c(2*n);
    vector<int>a(2*n);
    rep(i,2*n){
        char k;
        cin >> k >> a[i];
        if(k == 'B'){
            c[i] = true;
        }else{
            c[i] = false;
        }
        gyaku[c[i]][a[i]] = i;
    }
    rep(i,2*n){
        for(int j = 1; j <= n; j++){
            if(a[i] == j){
                if(c[i]){
                    rui1[i][j] = rui1[i][j-1] + 1;
                }else{
                    rui2[i][j] = rui2[i][j-1] + 1;
                }
            }else{
                rui1[i][j] = rui1[i][j-1];
                rui2[i][j] = rui2[i][j-1];
            }
        }
    }
    rep(i,2*n){
        for(int j = 1; j <= n; j++){
            rui1[i+1][j]+=rui1[i][j];
            rui2[i+1][j]+=rui2[i][j];
        }
    }
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            int x;
            //calc dp[i][j]
            int cnt;
            dp[i][j] = INT_MAX;
            if(i==0 and j== 0)dp[i][j] = 0;
            //dp[i-1][j];黒
            if(i){
                x = gyaku[1][i];
                cnt = rui1[2*n-1][i-1] - rui1[x][i-1] + rui2[2*n-1][j] - rui2[x][j];
                dp[i][j] = min(dp[i-1][j]+cnt,dp[i][j]);
            }
            if(j){
                x = gyaku[0][j];
                cnt = rui1[2*n-1][i] - rui1[x][i] + rui2[2*n-1][j-1] - rui2[x][j-1];
                dp[i][j] = min(dp[i][j-1]+cnt,dp[i][j]);
            }
        }
    }
    cout << dp[n][n] << endl;
}

Measured memory_bytes: 78720
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int p[22];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
	int ans=0; 
	for(int i=2;i<n;i++){
		if(p[i]<p[i-1]&&p[i]>p[i+1])ans++;
		if(p[i]>p[i-1]&&p[i]<p[i+1])ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

Measured memory_bytes: 1144
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt();
		int ans=0;
		while(n-->0){
			int l=sc.nextInt();
			int r=sc.nextInt();
			ans+=r-l+1;
		}
		pw.println(ans);
		pw.flush();
		pw.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> x(n), origin(n);
    for(int i = 0; i < n; i++){
        std::cin >> x[i];
        origin[i] = x[i];
    }

    std::sort(x.begin(), x.end());

    int middle = (n - 2) / 2;
    for(int i = 0; i < n; i++){
        auto iter = std::lower_bound(x.begin(), x.end(), origin[i]);
        int pos = std::distance(x.begin(), iter);
        if(pos > middle){
            std::cout << x[middle] << std::endl;
        }else{
            std::cout << x[middle + 1] << std::endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if k >= N:
            flag = 1
            break
        elif List_BC[i][1] > List_A[k]:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))

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



long long GCD(long long a, long long b){
    if (b == 0)
    {   
        return a;
    }else{
        return GCD(b, a % b);
    }
}

long long GCD3(long long a, long long b, long long c){
    long long d = GCD(b, c);
    return GCD(a, d);
}

int main(){
    int K;
    cin >> K;
    int ans = 0;

    for (int i = 1; i < K + 1; i++)
    {
        for (int j = 1; j < K + 1; j++)
        {
            for (int k = 1; k < K + 1; k++)
            {
                ans += GCD3(i, j, k);
            }
            
        }
        
    }
    
    cout << ans << "\n";
    
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 10005;

typedef pair<int, int> pii;
typedef pair<int, pii> node;

int n, m, x, y, a[105], b[105];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m >> x >> y;
    int z = 1e9, mn = -1e9, mx = -1e9;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        mn = max(mn, a[i]);
    }
    for(int i = 0; i < m; i++)
    {
        cin >> b[i];
        z = min(z, b[i]);
    }
    z = min(y, z);
    
    if(z > mn && z > x)
        cout << "No War" << endl;
    else 
        cout << "War" << endl;

    return 0;
}


Measured memory_bytes: 256