akhauriyash/Code-Regression huggingface dataset:
import heapq
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)
for _ in range(m):
    val = heapq.heappop(a) * (-1)
    heapq.heappush(a, (val // 2) * (-1))
print(-sum(a))


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    static int N, K;
    static int[] arr;

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inStr = br.readLine().split(" ");
        N = Integer.parseInt(inStr[0]);
        K = Integer.parseInt(inStr[1]);
        arr = new int[N + 5];
        inStr = br.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            arr[i] = Integer.parseInt(inStr[i]);
        }

        int min = Integer.MAX_VALUE;
        int left, right, num;
        for (int i = 0; i < N - K + 1; i++) {
            left = arr[i];
            right = arr[i + K - 1];
            if (right < 0) {
                num = Math.abs(left);
                min = Math.min(min, num);
                continue;
            }
            if (left >= 0) {
                num = right;
                min = Math.min(min, num);
                continue;
            }
            if (left < 0 && right >= 0) {
                num = Math.min(Math.abs(left) * 2 + right, Math.abs(left) + right * 2);
                min = Math.min(min, num);
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 39636
N = int(input())

table = [0] * (N + 1)

for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        table[j] += 1

ans = 0
for i in range(N):
    i += 1
    ans += i * table[i]

print(ans)

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A%3==0 || B%3==0 || (A+B)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


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

using namespace std;
#define ll long long
#define M 1000000007


int main()
{
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>>arr(n+1);
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        ll a,b;
        cin>>a>>b;
        sum+=b;
        arr[i].first=a;
        arr[i].second=b;
    }
    ll dp[n+1][sum+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=sum;j++)
            {
                if( j==0)
                    dp[i][j]=0;
                else
                dp[i][j]=INT_MAX;
            }
    }
    dp[0][0]=0;
    ll ans=-1;
    for(ll i=1;i<=n;i++)
    {
        ll val=arr[i].second;
        for(ll j=1;j<=sum;j++)
        {

            dp[i][j]=dp[i-1][j];
            if(j>=val)
            {
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-val]+arr[i].first);
            }
            if(dp[i][j]<=w && dp[i][j]!=INT_MAX)
            ans=max(ans,j);
        // if(dp[i][j]==INT_MAX)
        //     cout<<0<<" ";
        // else
        // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define PRINT(s) cout << s << endl;
#define FOR(i, a, b) for (unsigned int i = (a); i < (b); i++)
#define REP(i, n) FOR((i), 0, (n))

int main() {
    string s, t;
    cin >> s >> t;
    long long ans = 0;
    REP(i, s.length()) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 3916
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int k;
  cin>>k;
  
  int r,c;
  vector<int> A(8),B(8);
  rep(i,8) A[i]=i;
  rep(i,8) B[i]=-1;
  rep(i,k){
    cin>>r>>c;
    B[r]=c;
  }
  
  char C[8][8];
  rep(i,8){
    rep(j,8) C[i][j]='.';
  }
  
  set<int> p,q;
  do{
    bool b=true;
    rep(i,8){
      if(B[i]!=-1 && B[i]!=A[i]) b=false;
    }
    if(b==false) continue;
    rep(i,8) p.insert(i+A[i]);
    rep(i,8) q.insert(i-A[i]);
    if(p.size()!=8 || q.size()!=8){
      p.clear(); q.clear();
      continue;
    }
    rep(i,8) C[i][A[i]]='Q';
    break;
  }while(next_permutation(ALL(A)));
  
  rep(i,8){
    rep(j,8) cout<<C[i][j];
    cout<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3108
#include<iostream>
using namespace std;
int main(){
	int a,b,c,x;
	int ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				int js=i*500+j*100+k*50;
				if(js==x) ans++;
				if(js>x) break; 
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def calc(grid, x, y)
  grid.flatten.size.times do
    v = grid[y][x]
    return [x, y] if v == '.'
    if v == '>'
      x += 1
    elsif v == '<'
      x -= 1
    elsif v == '^'
      y -= 1
    elsif v == 'v'
      y += 1
    end
  end

  false
end

while line = gets
  h, w = line.chomp.split.map(&:to_i)
  break if h == 0 && w == 0
  grid = []

  h.times do
    grid << gets.chomp.split('')
  end

  res = calc(grid, 0, 0)
  puts (res) ? res.join(' ') : :LOOP
end

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


// bool check(ll mid){

// }

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    //solve(A, B, N);

    // ll ng=-1, ok=N;
    // while(abs(ok-ng)>1){
    //     int mid=(ok+ng)/2;
    //     if(check(mid)){
    //         ok=mid;
    //     }else{
    //         ng=mid;
    //     }
    // }

    ll ma=0;

    if(B-1<=N){
        ll b = B-1;
        cout << floor(A*b*1.0/B) - A*floor(b*1.0/B) << endl;
    }else{
        ll b = N;
        cout << floor(A*b*1.0/B) - A*floor(b*1.0/B) << endl;
    }

    return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <climits>
#include <cmath>
using namespace std;
int main() {
  int A, B, C, X, Y, Z = 0, total = 0;
  cin >> A >> B >> C >> X >> Y;
  if (A + B < 2 * C) { // AピザとBピザを別々の方が安い
    total = X * A + Y * B;
  } else { // ABピザの方が安い
    Z = min(X, Y);
    total = 2 * C * Z;
    int restX = max(0, X - Z);
    int restY = max(0, Y - Z);
    if (restX > 0) {
      if (A < 2 * C) { // Aピザを別に買った方が安い
        total += A * restX;
      } else { // ABピザの方が安い
        total += 2 * C * restX;
      }
    }
    if (restY > 0) {
      if (B < 2 * C) {
        total += B * restY;
      } else {
        total += 2 * C * restY; 
      }
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	ll X, Y;
	scanf("%lld %lld", &X, &Y);
	if (X%Y == 0) printf("-1\n");
	else printf("%lld\n", X);
	return 0;
}
//*/

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

typedef long double ld;

ld dist(pair<int, int> a, pair<int, int> b) {
	return hypot(a.first - b.first, a.second - b.second);
}

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

	cout << fixed << setprecision(16);

	int n;
	cin >> n;
	vector<int> ind(n);
	iota(ind.begin(), ind.end(), 0);
	vector<pair<int, int>> a(n);
	for (auto &t : a) {
		cin >> t.first >> t.second;
	}
	ld ans = 0;
	do {
		for (int i = 0; i + 1 < n; i++) {
			ans += dist(a[ind[i]], a[ind[i + 1]]);
		}
	} while (next_permutation(ind.begin(), ind.end()));
	for (int i = 1; i <= n; i++) {
		ans /= i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter
s = input()

n = len(s)
dp = [0] * (n + 1)

for i in range(n - 1, -1, -1):
    dp[i] = (dp[i + 1] + pow(10, (n - i - 1), 2019) * int(s[i])) % 2019

c = Counter(dp)

ans = 0
for i in c.values():
    ans += i * (i - 1) // 2

print(ans)

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */


long long facctorialMethod(long long k) {
    ll sum = 1;
    for (ll i = 1; i <= k; ++i) {
        sum = (sum * i) % (1000000007);
        //sum = sum % (1000000007);
    }
    return sum;
}

int main() {
    ll N, M;
    cin >> N >> M;
    ll ma = max(N, M);
    ll mi = min(N, M);
    if (ma - mi > 1) {
        cout << 0 << endl;
        return 0;
    }

//    cout << ma << mi << endl;
    ll k = facctorialMethod(ma);
    ll kk = facctorialMethod(mi);
//    cout << k << endl;
//    co`
    ll ans;
    if (ma != mi) {
        ans = (k * kk) % (1000000007);
    }
    if (ma == mi) {
        ans = (k * kk * 2) % (1000000007);
    }
//    cout << ans << endl;
    ans = ans % (1000000007);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	string s,t1,t2;cin>>s;
	int ans=0;
	for(int i=0;i<s.length();i++){
		t1+=s[i];
		if(t1!=t2){
			ans++;t2=t1;t1="";
		}
	}
	cout<<ans;
}


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

using namespace std;
int LCS(const char* a,const char* b)
{
    int m=strlen(a); int n=strlen(b); //i???????¬????a????????????j???????¬????b?????????
    int c[m+1][n+1]; //c??°???????????¨?????°???????¬????a??????i??????????¬????b??????j????????´???LCS
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int i=0;i<=n;i++) c[0][i]=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
        {
            if(a[i]==b[j]) c[i+1][j+1]=c[i][j]+1;
            else
            {
                c[i+1][j+1]=max(c[i][j+1],c[i+1][j]);
            }
        }
    return c[m][n];

}
int main()
{
    char *a=new char[1001];
    char *b=new char[1001];
    int q;
    while(cin>>q)
    {
        for(int i=0;i<q;i++)
        {
            cin>>a>>b;
            cout<<LCS(a,b)<<endl;
        }
    }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename C> struct Flow {
	int V;
	C INF;
	struct E { int t, r; C c; };
	vector<vector<E>> g;
	vector<bool> used;
	
	Flow() { }
	Flow(int v, C inf) { init(v, inf); }
	void init(int v, C inf) {
		V = v;
		INF = inf;
		g.resize(V);
		used.resize(V);
	}
	
	void add(int f, int t, C c) {
		assert(inID(f, 0, V));
		assert(inID(t, 0, V));
		int gt = g[t].size();
		int gf = g[f].size();
		g[f].PB({ t, gt, c });
		g[t].PB({ f, gf, 0 });
	}
	
	C dfs(int f, int t, C c) {
		if(f == t) { return c; }
		used[f] = true;
		inc(i, g[f].size()) {
			E & e = g[f][i];
			if(used[e.t] || e.c <= 0) { continue; }
			C v = dfs(e.t, t, min(c, e.c));
			if(v > 0) {
				e.c -= v;
				g[e.t][e.r].c += v;
				return v;
			}
		}
		return 0;
	}
	
	C max_flow(int S, int T) {
		assert(inID(S, 0, V));
		assert(inID(T, 0, V));
		C ans = 0;
		while(true) {
			inc(i, V) { used[i] = false; }
			C f = dfs(S, T, INF);
			ans += f;
			if(f == 0) { break; }
		}
		return ans;
	}
};

// ----

LL n, a[101];

int main() {
	cin >> n;
	inc1(i, n) { cin >> a[i]; }
	
	Flow<LL> f(n * 3 + 2, 1e12);
	
	int S = 0;
	int T = 1;
	inc1(i, n) {
		f.add(        S, i * 3 - 1, f.INF);
		f.add(i * 3 - 1, i * 3 + 0, max(a[i], 0LL) - a[i]);
		f.add(i * 3 + 0, i * 3 + 1, max(a[i], 0LL) -  0LL);
		f.add(i * 3 + 1,         T, f.INF);
	}
	inc1(i, n) {
		for(int j = i * 2; j <= n; j += i) { f.add(i * 3, j * 3, f.INF); }
	}
	
	LL ans = -f.max_flow(S, T);
	
	inc1(i, n) { ans += max(a[i], 0LL); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int a, b; cin >> a >> b;
  cout << (a <= 9 && b <= 9 ? a * b : -1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n, max, ans, i;
int main(void){
  scanf("%d", &n);
  for(i=0; i<n; i++){
    int za, zb;
    scanf("%d%d", &za, &zb);
    if(max < za){
      max = za;
      ans = za + zb;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b){int r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5 ;
vector<set<int> > g(N) ;
set<P> s ;
vi deg(N) , a(N) , ans(N);
signed main(){
	int n ,x ,y ; 
	cin >> n ;
	f(n-1){
		cin >> x >> y ;
		g[x].insert(y) ;
		g[y].insert(x) ;

		deg[x]++ , deg[y]++ ;
	}
	f(n) cin >> a[i] ; 
	f(n) s.insert({deg[i] ,i}) ;

	sort( a.begin()+1 , a.begin()+n+1) ;
	int add = 0;
	for ( int i = 1 ;i<=n ;i++){
		if(s.size() == 0 ) break ;
		int x = s.begin()->first ;
		int y = s.begin()->second ;
		s.erase(s.begin()) ;
		

		ans[y] = a[i] ;

		for ( auto it : g[y]){
			s.erase(s.find({deg[it] ,it})) ;
			deg[it]-- ;
		    s.insert({deg[it] , it}) ;

			g[it].erase(y) ;
			add += a[i] ; 
		}
	}

	cout << add << endl ;
	f(n) cout << ans[i] <<" " ;
}

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

int main(){
  
  vector<int> v(6);
  int i, j;
  
  for (i = 0; i < 6; i++){
    cin >> v.at(i);
  }
  
  for (i = 0; i < 5; i++){
    for (j = i + 1; j < 5; j++){
      
      if(abs(v.at(i) - v.at(j)) > v.at(5)){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int n;
long long a[100005];
long long gtotal[100005];
long long total;

bool valid(int i){
	int next = (i+1)%n;
	long long tmp = total - a[next] + a[i];
	if(tmp < 0) return false;
	if((tmp % (long long)n) != 0){
		return false;
	} else {
		gtotal[next] =  tmp / (long long)n;
		return true;
	}
}

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

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

	long long nn = n;
	if((total % (nn*(nn+1)/2)) != 0){
		cout<<"NO"<<endl;
		return 0;
	}

	total /= (nn*(nn+1)/2);

	for(int i=0;i<n;i++){
		if(valid(i) == false){
			cout<<"NO"<<endl;
			return 0;
		}
	}

	long long tt=0LL;
	for(int i=0;i<n;i++){
		tt += gtotal[i]*(((nn-i)%nn)+1);
	}
	if(tt != a[0]){
		cout<<"NO"<<endl;
		return 0;
	}

	cout<<"YES"<<endl;
	return 0;

}

Measured memory_bytes: 1792
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    string S,T;
    cin >> S >> T;
    ll s1 = S.size();
    ll s2 = T.size();
if(s1==s2){
  ll ans =0;
  REP(i,s2){
    if(S[i]==T[i]) ans ++;
  }
  ans = s1 - ans;
  cout << ans << endl;
    }
if(s1!=s2){
    ll ans = 0;
    vvll a(s1,vll(s2,0));

    REP(i,s1-s2){
      REP(j,s2){
        if(T[j]==S[i+j])a[i][j]++;
      }
    }
    //出力
    REP(i,s1){
      ll m1 = 0;
      REP(j,s2){
        m1 += a[i][j];
      }
      ans = max(ans, m1);
    }
    ll ans2 = s2-ans;
    cout << ans2 << endl;
}
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 8688
s = input()[::-1]
# (Xl,0 − Xr−1,0) % 2019 = 0 → Xl,0 % 2019 = Xr−1,0 % 2019
cnts = [1] + [0] * (2019 - 1)
tmp = 0
d = 1

for i in s:
    tmp += int(i) * d
    cnts[tmp % 2019] += 1
    d = d * 10 % 2019 # 桁数が大きくなりすぎる → 10と2019が素だから可能な技

ans = 0
for cnt in cnts:
    ans += (cnt - 1) * cnt // 2

print(ans)

Measured memory_bytes: 9296
a11,a12,a13 = map(int, input().split())
a21,a22,a23 = map(int, input().split())
a31,a32,a33 = map(int, input().split())
n = int(input())
#b = [int(input()) for _ in range(n)]

s11,s12,s13 = -1,-2,-3
s21,s22,s23 = -4,-5,-6
s31,s32,s33 = -7,-8,-9

ans = 'No'
for i in range(n):
    b = int(input())
    if b == a11:
        s11 = 0
    elif b == a12:
        s12 = 0
    elif b == a13:
        s13 = 0
    elif b == a21:
        s21 = 0
    elif b == a22:
        s22 = 0
    elif b == a23:
        s23 = 0
    elif b == a31:
        s31 = 0
    elif b == a32:
        s32 = 0
    elif b == a33:
        s33 = 0

if (s11 == 0 and s12 == 0 and s13 == 0) or \
   (s21 == 0 and s22 == 0 and s23 == 0) or \
   (s31 == 0 and s32 == 0 and s33 == 0) or \
   (s11 == 0 and s21 == 0 and s31 == 0) or \
   (s12 == 0 and s22 == 0 and s32 == 0) or \
   (s13 == 0 and s23 == 0 and s33 == 0) or \
   (s11 == 0 and s22 == 0 and s33 == 0) or \
   (s13 == 0 and s22 == 0 and s31 == 0):
       ans = 'Yes'
        
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s;
   ll k, i, ctr_one = 0, ans = 1;
   cin >> s >> k;
   for (i = 0; i < s.size(); i++)
      if (s[i] == '1')
         ctr_one++;
      else
         break;
   if (ctr_one < k)
      ans = s[i] - '0';
   cout << ans << endl;
   return 0;
}


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

int find(int n) {
    for (int i = 2; i < sqrt(n) + 1; i++) {
        if (n % i == 0) return i;
    }
    return -1;
}

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    
    int d = find(n);
    while (d != -1) {
        while (n % d == 0) {
            cout << " " << d;
            n = n / d;
        }
        d = find(n);
    }
    
    if (n != 1) {
        cout << " " << n << endl;
    } else {
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean odd = false;
        if (a % 2 == 1 && b % 2 == 1) {
            odd = true;
        }
        System.out.println(odd ? "Odd" : "Even");
    }
}

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

using namespace std;

const int N = 100000;

main(){
  int n, l;
  while(cin >> n >> l){
    int data[N];
    for(int i=0;i<n;i++){
      cin >> data[i];
    }
    bool f[N], b[N];
    fill(f, f+n, false);
    fill(b, b+n, false);
    for(int i=0;i<n;i++){
      if(i!=0){
	if(data[i-1]>data[i]){
	  b[i] = true;
	}
      }
      if(i!=n-1){
	if(data[i]<data[i+1]){
	  f[i] = true;
	}
      }
    }
    int r = n;
    int time[N];
    fill(time, time+n, -1);
    while(r>0){
      for(int i=0;i<n;i++){
	if(time[i] != -1) continue;
	if(f[i] && b[i]){
	  if(time[i-1] != -1 && time[i+1] != -1){
	    int t = max(time[i-1], time[i+1]);
	    r--;
	    if(data[i]>=l){
	      time[i] = t;
	    }else{
	      time[i] = l - data[i] + t;
	    }
	  }
	}else if(f[i]){
	  if(time[i+1] != -1){
	    r--;
	    if(data[i]>=l){
	      time[i] = time[i+1];
	    }else{
	      time[i] = l - data[i] + time[i+1];
	    }
	  }
	}else if(b[i]){
	  if(time[i-1] != -1){
	    r--;
	    if(data[i]>=l){
	      time[i] = time[i-1];
	    }else{
	      time[i] = l - data[i] + time[i-1];
	    }
	  }
	}else{
	  r--;
	  if(data[i]>=l){
	    time[i] = 0;
	  }else{
	    time[i] = l - data[i];
	  }
	}
      }
    }
    int ans = -1;
    for(int i=0;i<n;i++){
      if(ans<time[i]) ans = time[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,k,ans=0; cin>>n>>k;
    vector<ll> a(n,0);
    rep(i,n) cin>>a[i];
    for(ll i=0;i<n-1;i++){
        for(ll j=i+1;j<n;j++){
            if(a[i]>a[j]) ans++;
        }
    }
    ans=(ans*k)%MOD;
    ll cnt=0,K=k*(k-1)/2%MOD;
    sort(al(a));
    rep(i,n){
        if(i==0) continue;
        if(a[i-1]==a[i]) cnt++;
        else cnt=0;
        ans=(ans+K*(i-cnt))%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define fastio ios_base::sync_with_stdio(false)
#define ll long long int
#define ld long double
#define ict int t; cin >> t
#define lct ll t; cin >> t;
#define in(a) int a; cin >> a
#define ln(a) ll a; cin >> a
#define loop(i,n) for (ll i = 0; i < n; ++i) 
#define looprev(i,n) for (ll i=n-1; i>=0 ; --i)
#define LOOP(i,k,n) for (ll i = k; i <= n; ++i) 
#define LOOPREV(i,k,n) for (ll i = k; i >= n; --i) 
#define mp make_pair 
#define pa pair <ll,ll>
#define vec vector<ll>
#define vecpa vector<pa>
#define vec2D vector <ll<ll>>
#define que queue<ll>
#define deq deque<ll> 
#define stk stack<ll>
#define iterate vector<ll>::iterator
#define pub push_back
#define pob pop_back
#define pof pop_front
#define puf push_front
#define emp emplace_back
 
using namespace std;
 
int main()
{
    fastio;
    cin.tie(NULL);
    cout.tie(NULL);
  	ict;
 	if(t>=30) cout << "Yes";
  	else cout << "No";
}

Measured memory_bytes: 3556
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 重なるところに注意
A, B, K = lr()
answer = [x for x in range(A, min(A+K, B+1))] + [x for x in range(max(B-K+1, A), B+1)]
answer = sorted(set(answer))
print('\n'.join(map(str, answer)))

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

const int mod = 1e9 + 7;

const int N = 2005;

int n, k;
int a[N];

int main() {
	scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i ++) scanf("%d", &a[i]);
    int ans = 0;
    for (int i = 1; i <= n; i ++) {
		for (int j = 1; j < i; j ++) {
            if (a[j] > a[i]) ans ++;
		}
    }
    ans = 1ll * ans * k % mod;
    int x = 1ll * k * (k - 1) / 2 % mod;
    for (int i = 1; i <= n; i ++) {
		int c = 0;
        for (int j = 1; j <= n; j ++) if (a[j] > a[i]) c ++;
		ans = (ans + 1ll * c * x) % mod;
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
$heap = [nil]
def max_heapify(index)
  left = index * 2
  right = index * 2 + 1
  if left < $heap.length && $heap[left] > $heap[index]
    largest = left
  else
    largest = index
  end
  largest = right if right < $heap.length && $heap[right] > $heap[largest]

  unless largest == index
    $heap[index], $heap[largest] = $heap[largest], $heap[index]
    max_heapify largest
  end
end

def extract_max
  max = $heap[1]
  $heap[1] = $heap.pop
  max_heapify 1
  max
end

def insert(key)
  $heap << key
  i = $heap.length-1
  while i > 1 && !$heap[i / 2].nil? && $heap[i / 2] < $heap[i]
    $heap[i / 2], $heap[i] = $heap[i], $heap[i / 2]
    i = i / 2
  end
end

loop do
  input = gets.split ' '
  case input[0]
  when 'insert'
    insert input[1].to_i
  when 'extract'
    puts extract_max
  when 'end'
    break
  end
end



Measured memory_bytes: 14780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    int sum = 0;
    for(int i=0; i<n+1; i++) sum += abs(a[i+1] -a[i]);
    for(int i=1; i<=n; i++){
        int diff = abs(a[i] -a[i-1]) +abs(a[i+1] -a[i]) -abs(a[i+1] -a[i-1]);
        cout << sum -diff << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;

int main(){
    cin>>N;

    int ans;
    repn(i,9){
        if(N<=i*111){
            ans=i*111;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
B=[int(x) for x in input().split()]
A=[-1 for x in range(N)]
ans=0
bef=0
A[0]=B[0]
for i in range(N-1):
    if B[i]>=A[i]:
        A[i+1]=B[i]
    else:
        A[i]=B[i]
        A[i+1]=B[i]
print(sum(A))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;

int n;
string s, t;


int main(){

cin>>n;
cin>>s>>t;

for(int i=0; i<n; i++){
    int f = 0;
    for(int j=i; j<n; j++){
        if(s[j] != t[j-i]){
            break;
        }
        if(j == n - 1){
            cout << n * 2 - (n - i) << endl;
            return 0;
        }
    }
}

cout << n * 2 << endl;

return 0;

}















Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  int result = 0;
  size_t i = 0;
  while (i + 1 < S.size()) {
    if ((0 == S.compare(i , 2, "01")) ||
        (0 == S.compare(i , 2, "10"))) {
      S.erase(i, 2);
      result += 2;
      if (0 < i) --i;
    } else {
      ++i;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 512
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for s in range(S+1):
        if s-A[i] >= 0:
            dp[i+1][s] = (dp[i][s] * 2 + dp[i][s-A[i]]) % MOD
        else:
            dp[i+1][s] = dp[i][s] * 2 % MOD
print(dp[N][S])



Measured memory_bytes: 132548
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;


void solve(){
  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 1; i <= d; i++){
    for(int j = 0; j < n; j++){
      if((i - 1) % a[j] == 0) ans++;
    }
  }
  cout << ans + x<< endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL a,b,x;cin >> a >> b >> x;

    LL bn = b/x;
    LL an = a/x;

    LL ans;
    ans = bn - an;
    if(a % x == 0)ans++;


    cout << ans << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    forn(i, n) {
        cout << s[i] << t[i];
    }
    cout << "\n";
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static long n;

    // 15:41-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            String s = sc.next();

            int i = 0;
            int ml = 0;
            while (i < s.length()) {
                while (i < s.length() && !b(s.charAt(i))) i++;
                int start = i;
                while (i < s.length() && b(s.charAt(i))) ml = Math.max(ml, ++i - start);
            }

            out.println(ml);
        }
    }

    private static boolean b(char c) {
        switch (c) {
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                return true;
            default:
                return false;
        }
    }
}


Measured memory_bytes: 21460
# -*- coding: utf-8 -*-
import sys

def main():
	a, b, c = map(int, input().split(" "))
	
	if a == b:
		print(c)
	if b == c:
		print(a)
	if c == a:
		print(b)
	
if __name__ == "__main__":
	main()
	

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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 H, W, K, i;
  i64 x1, y1, x2, y2;
  scanf("%lld", &H);
  scanf("%lld", &W);
  scanf("%lld", &K);
  scanf("%lld", &y1); y1--;
  scanf("%lld", &x1); x1--;
  scanf("%lld", &y2); y2--;
  scanf("%lld", &x2); x2--;
  //cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
  vector<string> C(H);
  char buf[1500000];
  REP(0, H, i) {
    getchar();
    scanf("%s", buf);
    C[i] = buf;
  }

  const i64 dy[4] = {1, -1, 0, 0};
  const i64 dx[4] = {0, 0, 1, -1};
  vvi D(H, vi(W, -1));
  D[y1][x1] = 0;
  queue<pi> q;
  q.push({y1, x1});
  while(!q.empty()) {
    pi cur = q.front();
    q.pop();
    
    const i64 &yc = cur.first, &xc = cur.second;
    const i64 D_cur = D[yc][xc];
    //cout << "visit " << yc << " " << xc << " " << D_cur << endl;
    if(yc == y2 && xc == x2) {
      cout << D_cur << endl;
      return 0;
    }
    i64 d;
    REP(0, 4, d) {
      i64 yn = yc, xn = xc;
      REP(0, K, i) {
	yn += dy[d];
	xn += dx[d];
	if(yn < 0 || H <= yn || xn < 0 || W <= xn) {
	  break;
	}
	if(D[yn][xn] == D_cur) {
	  break;
	}
	if(C[yn][xn] == '@') {
	  break;
	}
	if(D[yn][xn] == -1) {
	  D[yn][xn] = D_cur + 1;
	  q.push(pi(yn, xn));
	}
      }
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 20880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

//TAGC
ll dp[101][4][4][4][4];
const int mod=1000000007;
int main(){
    int n;
    cin>>n;
    rep(i,4)rep(j,4){
        dp[2][i][j][0][0]=1;
    }
    
    FOR(i,2,n){
        rep(i1,4){
            rep(i2,4){
                rep(i3,4){
                    rep(i4,4)if(dp[i][i1][i2][i3]>0){
                        dp[i+1][0][i1][i2][i3]+=dp[i][i1][i2][i3][i4];
                        dp[i+1][0][i1][i2][i3]%=mod;
                        dp[i+1][1][i1][i2][i3]+=dp[i][i1][i2][i3][i4];
                        dp[i+1][1][i1][i2][i3]%=mod;
                        if(!(i1==3&&i2==1)){
                            dp[i+1][2][i1][i2][i3]+=dp[i][i1][i2][i3][i4];
                            dp[i+1][2][i1][i2][i3]%=mod;
                        }
                        if(!(i1==2&&i2==1)&&!(i2==2&&i3==1)&&!(i1==1&&i2==2)&&!(i3==1&&i1==2)){
                            dp[i+1][3][i1][i2][i3]+=dp[i][i1][i2][i3][i4];
                            dp[i+1][3][i1][i2][i3]%=mod;
                        }
                    }
                }
            }
        }
    }
    
    ll ans=0;
    rep(i1,4){
        rep(i2,4){
            rep(i3,4){
                rep(i4,4){
                    ans+=dp[n][i1][i2][i3][i4];
                    ans%=mod;
                }
            }
        }
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ACurtain {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt();

            int answer = a - 2 * b;
            answer = Math.max(0, answer);

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> x(n);
    vector<ll> l(n+1);
    vector<ll> r(n+1);
    int right_pointer = -1;
    for(int i = 0; i < n; i++){
        cin >> x[i];
        if(right_pointer == -1 && x[i]>=0){
            right_pointer = i;
        }
    }
  
    if(right_pointer==-1){
        cout << -1*x[n-k] << endl;
        return 0;
    }
  
    int lnum = right_pointer;
    int rnum = n - lnum;

    int p = 0;
    for(int i = right_pointer-1; i >= 0; i--){
        l[p+1] = (-1)*x[i];
        p++;
    }
    p = 0;
    for(int i = right_pointer; i < n; i++){
        r[p+1] =  x[i];
        p++;
    }

    ll ans = 999999999999;
    for(int i = 0; i < k; i++){
        if(i <= lnum && k-i >= 0 && k-i <= rnum){
            ll tmpans = l[i]*2 + r[k-i];
            ans = min(ans, tmpans);
        }
        if(i <= rnum && k-i >= 0 && k-i <= lnum){
            ll tmpans = r[i]*2 + l[k-i];
            ans = min(ans, tmpans);
        }
    }
    cout << ans << endl;
    return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n - 1) cin >> a[i + 1];

  vector<int> buka(n);
  rep(i, n - 1) { buka[a[i + 1] - 1]++; }

  for (int ans : buka) {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        s[i]='x';
    }
    cout<<s<<endl;
    }


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

using namespace std;

const int N = 3e5+5;

typedef long long ll;

char s[N];

int a[N];

int flag[N];

int main()

{

    int n;

    string s;

    cin>>n>>s;

    int l=0,r=0;

    for(int i=1;i<n;i++){

        if(s[i]=='W') r++;

    }

    int ans=n-r-1;

    for(int i=1;i<n;i++){

        if(s[i-1]=='E')  l++;

        if(s[i]=='W') r--;

        ans=min(ans,n-l-r-1);

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 900
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

typedef struct indexVal{
  int64 val;
  int index;
} node;

typedef node dequeval;

typedef struct deque {
  dequeval *array;
  size_t front;
  size_t last;
  size_t mask;
} deque;

deque* newDeque(void){
  const int len=2;
  deque *d=(deque *)calloc(len,sizeof(dequeval));
  d->array=(dequeval *)calloc(len,sizeof(dequeval));
  d->front=d->last=0;
  d->mask=len-1;
  return d;
}

void initDeque(deque *d){
  d->front=d->last=0;
}

void freeDeque(deque *d){
  free(d->array);
  free(d);
}

int isEmpty(deque *d){
  return d->front==d->last;
}

void deque_realloc(deque *d){
  dequeval *array=(dequeval *)calloc(2*(d->mask+1),sizeof(dequeval));
  size_t k=0;
  for(size_t i=d->front;i!=d->last;i=(i+1)&d->mask) array[k++]=d->array[i];
  free(d->array);
  d->array=array;
  d->front=0;
  d->last=k;
  d->mask=2*d->mask+1;
}

dequeval pop_front(deque *d){
  dequeval res=d->array[d->front];
  d->front=(d->front+1)&d->mask;
  return res;
}

dequeval pop_back(deque *d){
  d->last=(d->last+d->mask)&d->mask;
  return d->array[d->last];
}

dequeval get_front(deque *d){
  return d->array[d->front];
}

dequeval get_back(deque *d){
  return d->array[(d->last+d->mask)&d->mask];
}

void push_front(deque *d,dequeval v){
  if(((d->last+1)&d->mask)==d->front){
    deque_realloc(d);
  }
  d->front=(d->front+d->mask)&d->mask;
  d->array[d->front]=v;
}

void push_back(deque *d,dequeval v){
  if(((d->last+1)&d->mask)==d->front){
    deque_realloc(d);
  }
  d->array[d->last]=v;
  d->last=(d->last+1)&d->mask;
}

void run(void){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  int *a=(int *)calloc(n+1,sizeof(int));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  int64 *dp=(int64 *)calloc(n+1,sizeof(int64));
  deque *deq=newDeque();
  for(i=1;i<=k;i++){
    initDeque(deq);
    push_back(deq,(node){dp[i-1],i-1});
    for(int j=i;j<=n;j++){
      node t=get_front(deq);
      while(t.index<j-m){
	pop_front(deq);
	t=get_front(deq);
      }
      int64 local=(int64)i*a[j]+t.val;
      while(!isEmpty(deq)){
	t=get_back(deq);
	if(t.val>dp[j]) break;
	pop_back(deq);
      }
      push_back(deq,(node){dp[j],j});
      dp[j]=local;
    }
  }
  int64 ans=0;
  for(i=k;i<=n;i++) if(ans<dp[i]) ans=dp[i];
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, K, X, Y;
  int res=0;
  cin >> N >> K >> X >> Y;

  res += X*min(K,N);
  res += max(0,N-K)*Y;

  cout << res << endl;
}


Measured memory_bytes: 256