akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;
int main(){
    int n; cin >> n;
    priority_queue<double, vector<double>, greater<double> > p;
    rep(i,n){
        double v; cin >> v;
        p.push(v);
    }
    while(p.size() > 1){
        double f = p.top(); p.pop();
        double s = p.top(); p.pop();
        p.push((f + s) / 2);
    }
    printf("%.10f\n", p.top());
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut garden: Vec<i16> = (0..n).map(|_| read()).collect();
    let mut ans = 0;

    while garden.iter().any(|&x| x != 0){
        let mut start = 0;
        let mut end = 0;
        let mut mizuyari = false;
        for i in 0..garden.len() {
            if garden[i] > 0 {
                end += 1;
                mizuyari = true;
            } else if garden[i] == 0 && mizuyari == false {
                start += 1;
                end += 1;
            } else if garden[i] == 0 && mizuyari == true {
                break;
            } 
        }
        for i in start..end {
            garden[i] -= 1;
        }
        ans += 1;
    }

    println!("{}", ans);
    //println!("{:?}", garden);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
    long long n, s = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
            s = s + i;
    }
    cout << s;
    return 0;
}

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

long long INF = 1e18;

int main(){
    int n;
    
    int a[10][10];
    int d[10][10];
    for (int i = 0; i < 3;i++){
        for (int j = 0; j < 3;j++){
            cin >> a[i][j];
            d[i][j] = 0;
        }
    }
    cin >> n;
    int b[n + 100];
    for (int i = 0; i < n;i++){
        cin >> b[i];
        for (int j = 0; j < 3;j++){
            for (int k = 0; k < 3;k++){
                if(a[j][k] == b[i]){
                    d[k][j] = 1;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++)
    {
       if(d[i][0]==1&&d[i][2]==1&&d[i][1]==1){
           cout << "Yes" << endl;
           return 0;
       }
       if (d[0][i] == 1 && d[1][i] == 1 && d[2][i] == 1)
       {
           cout << "Yes" << endl;
           return 0;
       }
    }
    if (d[0][0] == 1 && d[2][2] == 1 && d[1][1] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (d[0][2] == 1 && d[1][1] == 1 && d[2][0] == 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  long double s = 0;
  cin >> n;
  vector<long double> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
    x[i] = 1 / x[i];
    s += x[i];
  }
  cout << setprecision(100) << 1 / s;
}

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

#define st first
#define nd second
#define pb push_back
#define mp make_pair
typedef pair< int ,int > pii;
typedef vector< pii > vii;
typedef long long ll;
typedef map<int,int> mii;
typedef set<pii> sii;
typedef set<int> si;
typedef vector< int > vi;

const ll MOD = 119 << 23 | 1;

ll gcd(ll x, ll y){
    if(!y)
        return x;
    return gcd(y,x%y);
}

ll inv(ll x) {
    ll r = 1ll, t = x, k = MOD - 2ll;
    while (k) {
        if (k & 1ll) r = (long long) r * t % MOD;
        t = (long long) t * t % MOD;
        k >>= 1;
    }
    return r;
}

const int nax = 2e5+13;

void read(){

}
int n,x,y;

vector<int>G[3000];
int res[3000];

void bfs(int st){
    bool odw[3000];
    int d[3000];
    for(int i=0; i<=n; i++){
        odw[i]=false;
        d[i]=1000000;
    }
    odw[st]=true;
    d[st]=0;
    queue<int>q;
    q.push(st);
    while(!q.empty()){
        int akt=q.front();
        q.pop();
        for(auto u:G[akt]){
            if(!odw[u]){
                q.push(u);
                d[u]=d[akt]+1;
                odw[u]=true;
            }
        }
    }
    for(int i=1; i<=n; i++){
        res[d[i]]++;
    }
}

void solve(){

    cin >> n >> x >> y;
    for(int i=1; i<n; i++){
        G[i].pb(i+1);
        G[i+1].pb(i);
    }
    G[x].pb(y);
    G[y].pb(x);
    for(int i=0; i<n; i++)
        res[i]=0;
    for(int i=1; i<=n; i++){
        bfs(i);
    }
    for(int i=1; i<n; i++)
        cout << res[i]/2<<endl;
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    int t=1;
    //cin >> t;
    while(t--){
        read();
        solve();
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int Z = 26 + 13, maxN = 2e5 + 13;
int n, q;
char d[maxN], t[maxN];
string s;
vector<int> vec[Z];

bool canl (int x) {
    int cur = x;
    for (int i = 0; i < q; i++)
	if (t[i] == s[cur]) {
	    if (d[i] == 'L')
		cur--;
	    else
		cur++;
	    if (cur == -1)
		return 1;
	    if (cur == n)
		return 0;
	}
    return 0;
}

bool canr (int x) {
    int cur = x;
    for (int i = 0; i < q; i++)
	if (t[i] == s[cur]) {
	    if (d[i] == 'L')
		cur--;
	    else
		cur++;
	    if (cur == n)
		return 1;
	    if (cur == -1)
		return 0;
	}
    return 0;
}


		
int main () {
    cin >> n >> q;
    cin >> s;
    for (int i = 0; i < q; i++) {
	cin >> t[i] >> d[i];
    }

    int l = -1, r = n;
    while (r - l > 1) {
	int mid = l + r >> 1;
	if (canl(mid))
	    l = mid;
	else
	    r = mid;
    }

    int st = r;
    l = -2, r = n;
    while (r - l > 1) {
	int mid = l + r >> 1;
	if (canr(mid))
	    r = mid;
	else
	    l = mid;
    }
    int en = r;
    cout << en - st << endl;
	
}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	intt ans = 0;
	while (N != 0) {
		--N;
		ans += N;
	}
	std::cout << ans << std::endl;;
}

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

void solve() {
  int k, s;
  cin >> k >> s;
  long ans = 0;
  rep(i, k+1) rep(j,k+1) {
    int c = s - (i + j);
    if (c <= k && c >= 0) ans++;
  }
  cout << ans << endl;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10005];
int main()
{
    int n;
    cin>>n;
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        while(a[i]%2==0)
        {
            cnt++;
            a[i]/=2;
        }
    }
    cout<<cnt<<endl;
}




Measured memory_bytes: 892
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    char s[h][w];
    int black = 0;
    rep(i, h) rep(j, w) {
        cin >> s[i][j];
        if (s[i][j] == '#') black++;
    }

    vector<vector<int>> d(h, vector<int>(w, -1));
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    d[0][0] = 1;

    while(!que.empty()) {
        pair<int, int> v = que.front();
        que.pop();

        rep(i, 4) {
            int nx = v.second + dx[i];
            int ny = v.first + dy[i];
            if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
            if (s[ny][nx] == '#') continue;
            if (d[ny][nx] != -1) continue;
            d[ny][nx] = d[v.first][v.second] + 1;
            que.push(make_pair(ny, nx));
        }
    }

    if (d[h-1][w-1] == -1) cout << -1 << endl;
    else cout << h * w - black - d[h-1][w-1] << endl;


    return 0;
}

Measured memory_bytes: 256
import sys

x,y = map(int,input().split())
if y % 2 != 0:
    print('No')
    sys.exit()

if 4 * x < y:
    print('No')
    sys.exit()

if 4 * x >= y:
    if 2 * x <= y:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9180
x,k,d = map(int,input().split())

if abs(x)-k*d >= 0: # 0の反対側へ行けない
    ans = abs(x)-k*d
else:
    c = abs(x)//d#0を超えないときの移動回数
    ans1 = abs(x) - c*d
    ans2 = abs(x) - (c+1)*d
    if (k-c)%2 == 0:
        ans = abs(ans1)
    else:
        ans = abs(ans2)

print(ans)

Measured memory_bytes: 9192
main :: IO ()
main = do
  [a, b, c, d] <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ solver a b c d
  
solver :: Int -> Int -> Int -> Int -> String
solver a b c d 
  | c <= 0 = "Yes"
  | a <= 0 = "No"
  | otherwise = solver (a - d) b (c - b) d


Measured memory_bytes: 3916
n = int(input())
s = input()
w = []
e = []
cnt_w, cnt_e = 0, 0
for i in range(n):
    if s[i] == "W":
        cnt_w += 1
    else:
        cnt_e += 1
    w.append(cnt_w)
    e.append(cnt_e)

f_inf = float("inf")
res = f_inf
for i in range(n):
    if s[i] == "W":
        t = w[i] - w[0] + e[len(e) - 1] - e[i]
    else:
        t = w[i] + e[len(e) - 1] - e[i]
    res = min(res, t)
print(res)

Measured memory_bytes: 17620
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
ll M = 1000000007;
set<int> divisor(int n)
{
	set<int> value;
	for( int ite=1; (ll)ite*ite<=n;ite++)
	{
		
			if (n % ite == 0)
			{
				value.insert(ite);
				value.insert(n / ite);
				
			}
		
	}
	return value;
}
/*

set<ll> divisor(ll n)
{
	set<ll> value;
	for( ll i=1; i*i<=n;i++)
	{
		
			if (n % i == 0)
			{
				value.insert(i);
				value.insert(n / i);
			}
		
	}
	return value;
}
*/

void solve() {
    long long N;
    cin >> N;
	ll ans=0;
	rep(i,N){
		int x=i+1;
		int cnt=N/x;
		ans+=(ll)(cnt)*(cnt+1)/2*x;
	}
	cout<<ans<<endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3660
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import itertools as itr

def fact(n):
  for i in range(2,n//2+1):
    if n % i == 0:
      return False
  return True


idx = 1
i = 6
ans = []
while(len(ans) <= 56):
  if fact(i):
    ans.append(i)
  i += 5

n =int(input())
for i in range(n):
  print(ans[i], end=" ")
print()


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> p(n);
	vector<int> q(n);
	rep (i, 0, n)
		cin >> p[i];
	rep (i, 0, n)
		cin >> q[i];

	vector<int> tmp = p;
	sort(tmp.begin(), tmp.end());

	int a = 0, b = 0;
	int counter = 0;
	do {
		if (tmp == p)
			a = counter;
		if (tmp == q)
			b = counter;
		counter++;
	} while (next_permutation(tmp.begin(), tmp.end()));

	cout << abs(a - b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include    <stdio.h>

int main(void)
{
    int	a, b, c, d;

    fscanf(stdin, "%d %d %d %d", &a, &b, &c, &d);

    while (1) {
	// T's turn
	c -= b;
	if (c <= 0) {
	    printf("Yes\n");
	    return 0;
	}

	// A's turn
	a -= d;
	if (a <= 0) {
	    printf("No\n");
	    return 0;
	}
    }

    return 0;
}


Measured memory_bytes: 1648
x = gets.to_i

answer =
  case x
  when 400..599
    8
  when 600..799
    7
  when 800..999
    6
  when 1000..1199
    5
  when 1200..1399
    4
  when 1400..1599
    3
  when 1600..1799
    2
  when 1800..1999
    1
  end

puts answer


Measured memory_bytes: 14308
#include <iostream>
#include <bits/stdc++.h>
using namespace std; 
int main () 
{
  int n; 
  cin >> n ; 
  if (n == 30) 
  {
    cout << "Yes" << endl; 
  }
  else if (n > 30)
  {
    cout << "Yes" << endl; 
  }
  else 
  {
    cout << "No" << endl; 
  }
  return 0; 
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const ll dx[] = {1,0,-1,0};
const ll dy[] = {0,1,0,-1};
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double w,h,x,y,ans1;
    cin >> w >> h >> x >> y;
    int ans2 = 0;
    ans1 = (w*h)/2;
    if(x==w/2 && y==h/2) ans2 = 1;
    printf("%.6f %d\n",ans1,ans2);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long

using namespace std;

int X;

signed main()
{
    cin >> X;
    int under = 400;
    for (int a = 8; a >= 1; a--)
    {
        if (under <= X && X < under + 200)
        {
            cout << a << endl;
            break;
        }
        under += 200;
    }
}

Measured memory_bytes: 3620
from math import floor, ceil

N = int(input())
A = list(map(int, input().split()))

B = [A[i] - (i+1) for i in range(N)]
B.sort()
b = (B[floor((N-1)/2)] + B[ceil((N-1)/2)]) // 2
ans = sum([abs(a-b) for a in B])
print(ans)


Measured memory_bytes: 28276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		ABC11X_A();
		// ABC11X_B();
		// ABC11X_C();
		// ABC11X_D();
	}

	private static void ABC11X_A() {
		Scanner scanner = null;
		int amountX = 0;
		int amountY = 0;

		try {
			scanner = new Scanner(System.in);
			amountX = scanner.nextInt();
			amountY = scanner.nextInt();

			int total = amountX + (amountY / 2);

			System.out.println(total);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_B() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_C() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void ABC11X_D() {
		Scanner scanner = null;
		int lineAB = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println();

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main()
{
	string str;
	int count = 0;
	bool flag;

	while (cin >> str)
	{
		flag = true;
		for (int i = 0; i < str.size() / 2; i++)
		{
			if (str[i] != str[str.size() - 1 - i]) flag = false;
		}
		if (flag) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1184
N = gets.to_i
B = gets.split.map(&:to_i)

sum = 0
N.times do |i|
  if i == 0
    sum += B[i]
  elsif i == N-1
    sum += B[i-1]
  else
    sum += [B[i-1], B[i]].min
  end
end

puts sum


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

long long mx(long long a, long long b)
{
    if(a < b) return b;
    return a;
}

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

    long long a[N+1];
    a[0] = 0;
    for(long long i = 1; i <= N; i++)
    {
        cin >> a[i];
        a[i] += a[i-1];
    }

    long long first[N+1][N+1], second[N+1][N+1];
    for(long long i = 1; i <= N; i++)
    {
        first[i][i] = a[i] - a[i-1];
        second[i][i] = 0;
        //cout << first[i][i] << "/" << second[i][i] << ' ';
    }
    //cout << '\n';
    for(long long l = 2; l <= N; l++)
    {
        for(long long i = 1; i+l-1 <= N; i++)
        {
            long long j = i+l-1;
            //cout << first[i][j] << "/" << second[i][j] << ' ';
            first[i][j] = mx(a[i] - a[i-1] + second[i+1][j], a[j] - a[j-1] + second[i][j-1]);
            second[i][j] = a[j] - a[i-1] - first[i][j];
        }
        //cout << '\n';
    }
    cout << first[1][N] - second[1][N] << '\n';
    return 0;
}

Measured memory_bytes: 140288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  const int NUM_ALPHABET = 26;
  int address_A = 'A';
  //cout << address_A << endl;//65
  //int address_Z = 'Z';
  //cout << address_Z << endl;//90
  for(int i=0; i<S.size(); i++){
    int address = S.at(i);
    address += N;
    if(address >= address_A+NUM_ALPHABET) address -= NUM_ALPHABET;
    S.at(i) = address; 
  }
  
  cout << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Curtain | diff Curtain.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Curtain.cpp && ./a.out

/*
 
 10/19/2019
 
 5:00-
 
 */

int A,B;

void solve() {
  int res=max(0,A-2*B);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#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;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

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


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CModuloSummation {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        int res = accumulate(all(A), 0) - n;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CModuloSummation solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=5*1e4+10;
char s[maxn],a[maxn],b[maxn];
int main()
{
    int x;
    scanf("%d",&x);
    int t1=x/500;
    int t2=x%500;
    int t3=t2/5;
    printf("%d\n",t1*1000+t3*5);
    return 0;
}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    //Sが1、cが2
    //cが4
    input!(input=>(s:i64 c:i64));
    if c <= s * 2 {
        //cが足りない
        c / 2
    } else {
        s + (c - s * 2) / 4
    }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "1 6" => "2",
    test2: "12345 678901" => "175897",
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    int A[N];
    int B[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A + N,greater<>());
    int ans = A[0];
    int ans2 = ans;
    for(int i = 0; i < N; i++)
        B[i] = A[i];
    
    for(int i = 1; i < N; i++){
        if(B[i] > 0){
            B[N-1] -= B[i];
        }else{
            ans2 -= B[i];
        }
    }
    cout << ans2 << "\n";
    
    for(int i = 1; i < N; i++){
        if(A[i] > 0){
            cout << A[N-1] << " " << A[i] << "\n";
            A[N-1] -= A[i];
        }else{
            cout << ans << " " << A[i] << "\n";
            ans -= A[i];
        }
    }
    
    return 0;
} 


Measured memory_bytes: 2688
"""
方針
ペアになっているものは、順序が任意になるという認識
-> UnionFindで行ける
"""

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            # 自分自身じゃない場合は、上にさかのぼって検索(再帰的に)
            self.par[x] = self.find(self.par[x]) #根を置き換えていく
            return self.par[x]

    # 結合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        self.par[x] = y
    
    # 判定
    def judge(self,x,y):
        return self.find(x) == self.find(y)

n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n)

for i in range(m):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    if not uf.judge(x,y):
        uf.union(x,y)
ans = 0
for i,p in enumerate(ps):
    if uf.find(p-1) == uf.find(i):
        ans += 1
print(ans)


Measured memory_bytes: 13812
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 1e5 + 5;

int i,n,m,a[N];

void solve(){
    cin>>n>>m;
    vi p(n+1);
    for(i=1;i<=n;++i){
        cin>>a[i];
        int k=a[i];
        while(k%2==0){
            p[i]++;
            k/=2;
        }
        a[i]/=2;
    }
    bool ok=1;
    for(i=1;i<n;++i){
        ok&=(p[i]==p[i+1]);
    }
    if(ok){
        int ans=0,lcm=a[1];
        for(i=2;i<=n;++i){
            lcm=(a[i]*lcm)/gcd(a[i],lcm);
            if(lcm>m)
                break;
        }
        ans+=(m/lcm+1)/2;
        cout<<ans;
    }
    else{
        cout<<0;
    }
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    sort(all(S));
    if (S[0] == 'A' && S[2] == 'B') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N,C;
typedef pair<LL,LL>P;
vector<P>v;
vector<P>rv;
LL ans[100001];
LL s[100001];

LL rans[100001];
LL rs[100001];
int main(){
	cin>>N>>C;
	REP(i,N){
		LL a,b;
		cin>>a>>b;
		v.push_back(P(a,b));
		rv.push_back(P(C-a,-b));
	}
	sort(v.begin(),v.end());
	sort(rv.begin(),rv.end());
	REP(i,N){
		ans[i]=0;
		if(i!=0){
			s[i]=v[i].second+s[i-1];
		}else{
			s[i]=v[i].second;
		}
	}
	REP(i,N){
		if(i==0){
			ans[i]=max(LL(0),s[i]-v[i].first);
		}else{
			ans[i]=max(ans[i-1],s[i]-v[i].first);
		}
	}
	
	REP(i,N){
		rans[i]=0;
		if(i!=0){
			rs[i]=(-1)*rv[i].second+rs[i-1];
		}else{
			rs[i]=(-1)*rv[i].second;
		}
	}
	REP(i,N){
		if(i==0){
			rans[i]=max(LL(0),rs[i]-rv[i].first);
		}else{
			rans[i]=max(rans[i-1],rs[i]-rv[i].first);
		}
	}
	
	LL aa=0;
	REP(i,N){
		aa=max(aa,rans[i]);
		aa=max(aa,ans[i]);
	}
	
	REP(i,N){
		aa=max(aa,s[i]-2*v[i].first+rans[N-1-i-1]);
		aa=max(aa,rs[i]-2*rv[i].first+ans[N-1-i-1]);
	}
	
	/*REP(i,N){
		cout<<s[i]<<" ri"<<ans[i]<<endl;
	}
	REP(i,N){
		cout<<rs[i]<<" le"<<rans[i]<<endl;
	}*/
	cout<<aa<<endl;
	
	return(0);
}

Measured memory_bytes: 6884
#include<bits/stdc++.h> 
using namespace std; 
  
// Returns the longest repeating non-overlapping 
// substring in str 
int longestRepeatedSubstring(string str) 
{ 
    int n = str.length(); 
    int LCSRe[n+1][n+1]; 
  
    // Setting all to 0 
    memset(LCSRe, 0, sizeof(LCSRe)); 
  
    string res; // To store result 
    int res_length  = 0; // To store length of result 
  
    // building table in bottom-up manner 
    int i, index = 0; 
    for (i=1; i<=n; i++) 
    { 
        for (int j=i+1; j<=n; j++) 
        { 
            // (j-i) > LCSRe[i-1][j-1] to remove 
            // overlapping 
            if (str[i-1] == str[j-1] && 
                LCSRe[i-1][j-1] < (j - i)) 
            { 
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 
  
                // updating maximum length of the 
                // substring and updating the finishing 
                // index of the suffix 
                if (LCSRe[i][j] > res_length) 
                { 
                    res_length = LCSRe[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                LCSRe[i][j] = 0; 
        } 
    }
    return res_length; 
} 
  
// Driver program to test the above function 
int main() 
{ 
    int n;
    string s;
    cin >> n >> s;
    cout << longestRepeatedSubstring(s) << endl; 
    return 0; 
} 

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n,h,w; cin >> n >> h >> w;

	cout << (n-h+1) * (n-w+1) << endl;

	return 0;

}



Measured memory_bytes: 256
import fractions

a, b = map(int, input().split())

ans = 0
g = fractions.gcd(a, b)

i = 2
table = []

while i * i <= g:
    while g % i == 0:
        g //= i
        table.append(i)
    i += 1
if g > 1:
    table.append(g)

print(len(set(table)) + 1)

Measured memory_bytes: 5304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		if(p[0] <= p[1])
		{
		Console.WriteLine("unsafe");
		
		}
		else
		{
		Console.WriteLine("safe");
		
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

const ll INF=10000000000000000;

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

int main(){
    ll N,x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
    }
    vector<ll> minp(N,INF);
    ll move=0,ans=INF;
    rep(i,N){
        ll count=x*i;
        rep(j,N){
            chmin(minp[j],a[(j+i)%N]);
            count+=minp[j];
        }
        chmin(ans,count);
    }
    cout << ans << endl;
}

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

using namespace std;

#define int long long
#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 RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vector<int> a(n/2), b(n/2);
  REP(i, n) {
    if(i % 2 == 0) cin >> a[i/2];
    else cin >> b[i/2];
  }

  map<int, int> c, d;

  REP(i, n/2) {
    c[a[i]]++;
    d[b[i]]++;
  }

  vector<pair<int, int>> s, t;

  for(auto i = c.begin(); i != c.end(); i++) {
    s.pb(pair<int, int>(i->second, i->first));
  }
  for(auto i = d.begin();i != d.end();i++) {
    t.pb(pair<int, int>(i->second, i->first));
  }

  
  sort(s.begin(), s.end(), greater<pair<int, int>>());
  sort(t.begin(), t.end(), greater<pair<int, int>>());

  //cout << s[0].first << " " << s[0].second << endl;
  //cout << t[0].first << " " << t[0].second << endl;

  if (s[0].second != t[0].second) {
    cout << n - s[0].first - t[0].first << endl;
  } else if (s.size() == 1 && t.size() == 1) {
    cout << n/2 << endl;
  } else if (s.size() == 1) {
    cout << n/2 - t[1].first << endl;
  } else if (t.size() == 1) {
    cout << n/2 - s[1].first << endl;
  } else {
    cout << min(n - s[0].first - t[1].first, n - s[1].first - t[0].first) << endl;
  }
}


Measured memory_bytes: 9592
import scala.collection.mutable.ArrayBuffer

object Main extends App {

  private val buf = new Array[Byte](1024)
  //private val input = ListBuffer.empty[Array[Int]]
  private val input = ArrayBuffer.empty[Array[Int]]

  def isChar(c: Int) = 32 <= c && c <= 126
  
  @inline def reads() = {
    var sb = new StringBuilder
    var insize = System.in.read(buf)
    var i = 0
    while(i < insize){
      val c = buf(i)
      if(isChar(c)) {
        sb.append(c.toChar.toString)
        if(i + 1 == insize) {
          input += sb.toString().split(' ').map(_.toInt)
          sb.clear()
        }
      } else { // break
        input += sb.toString().split(' ').map(_.toInt)
        sb.clear()
      }
      i += 1
    }
  }
  
  reads()
  
  val n = input(0)(0)
  val a = input(1)
  val q = input(2)(0)
  val m = input(3)

  @inline def solve(i: Int, m: Int): Boolean = if(m == 0) true
  else if(i >= n) false
  else solve(i+1, m) || solve(i+1, m - a(i))

  val result = m.map(p => if(solve(0, p)) "yes" else "no")

  //print(result.mkString(f"%n") + f"%n")
  result.foreach(println)
}



Measured memory_bytes: 44244
import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
cnt = 0
inf = float('inf')

def merge_sort(left, right):
    if right-left > 1:
        middle = (left+right) // 2
        merge_sort(left, middle)
        merge_sort(middle, right)
        merge(left, middle, right)

def merge(left, middle, right):
    left_part = A[left:middle]
    right_part = A[middle:right]
    left_part.append(inf)
    right_part.append(inf)
    l, r = 0, 0
    global cnt
    left_size = middle-left
    for i in range(left, right):
        if left_part[l] < right_part[r]:
            A[i] = left_part[l]
            l += 1
        else:
            A[i] = right_part[r]
            cnt += max(left_size-l, 0)
            r += 1

def main():
    merge_sort(0, n)
    print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 27596
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      boolean c=false;
      for(int i=(int)Math.ceil(Math.sqrt((double)n));i>=1;i--)
      {
          if(n%i==0&&n/i>=1&&n/i<=9)
          {
              c=true;
              break;
          }
      }
      if(c)
      System.out.println("Yes");
      else
      System.out.println("No");
    }
}


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

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (long long i = 0; i < (long long) (n); ++i)
#define pb emplace_back
#define endl '\n'

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) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

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

const int N = 3 * 1000 + 17;
const int MOD = 998244353;

int n, s;
int a[N];
int dp[N][N][3];

bool read() {
    if (!(cin >> n >> s))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve(int id = 0) {
    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i)
        for (int w = 0; w <= s; ++w) {
            forn (j, 3)
                dp[i][w][j] %= MOD;

            dp[i + 1][w][0] += dp[i][w][0];
            dp[i + 1][w][1] += dp[i][w][0];

            if (w + a[i] <= s)
                dp[i + 1][w + a[i]][1] += dp[i][w][0];

            dp[i + 1][w][1] += dp[i][w][1];

            if (w + a[i] <= s)
                dp[i + 1][w + a[i]][1] += dp[i][w][1];

            dp[i + 1][w][2] += dp[i][w][1];

            dp[i + 1][w][2] += dp[i][w][2];
        }

    cout << (dp[n][s][2] + dp[n][s][1]) % MOD << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    //cin >> T;
    T = 1;

    while (read())
        solve(T++);

    return 0;
}


Measured memory_bytes: 213248
from collections import deque

N, K = [int(s) for s in input().split()]
V = [int(s) for s in input().split()]

best = 0
for a in range(min([K, N]) + 1):
    for b in range(min([K, N]) - a + 1):
        L = V[:a] + V[N - b:]
        Lp = [i for i in L if i >= 0]
        Lm = [i for i in L if i < 0]
        Lm.sort()
        s = sum(Lp + Lm[min([len(Lm), K - a - b]):])
        best = max([best, s])

print(best)


Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  double a, b;
  cin>>a>>b;
  //1 4
  //2 7
  //3 10
  std::cout <<   ceil((b-a)/(a-1))+1 << std::endl;

  
    
  return 0;
}



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

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

  int cnt = 0;
  vector<int> diff;
  long long lack = 0;
  for (int i=0; i<n; i++) {
    if (a[i] < b[i]) {
      ++cnt;
      lack += b[i] - a[i];
    } else {
      diff.push_back(a[i]-b[i]);
    }
  }
  sort(diff.begin(), diff.end());
  reverse(diff.begin(), diff.end());
  for (int i=0; i<diff.size() && lack>0; i++) {
    lack -= diff[i];
    ++cnt;
  }
  if (lack > 0) {
    cout<<-1<<endl;
  } else {
    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 1660
import numpy as np

N = input()
N = int(N)
stN = str(N)
p = input().split()
p_l = [int(s) for s in p]

pn = np.array(p_l)
ones = np.ones(len(p_l))
gyaku = ones/pn
ans = sum(gyaku)
ans = 1/ans
print(ans)

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

using namespace std;

int main()
{
    size_t N;
    vector<size_t> A;

    cin >> N;
    A.resize(N, 0);
    for (size_t i = 0; i < N; ++i) { cin >> A[i]; }

    size_t h = A[0];
    size_t sum = 0;
    for (size_t i = 1; i < N; ++i)
    {
        if (A[i] <= h)    // 前の人以下の背が低いとき
        {
            sum += h - A[i];    // h - A[i] の踏み台を用意
        }
        else    // 前の人以上のとき
        {
            h = A[i];           // 踏み台はいらないが、基準を上げる
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 4784
// Dont be lazy. Dont look for simple and quick implementations. Be ready to do case-work and implement. Make sure the method is fully correct. 
// Read question properly, ques can be tricky
 
 
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
 
#define int long long
 
#define pb push_back
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define f first 
#define s second
#define tup pair<pii,int>
#define ordk order_of_key
// const int M= 998244353;
const int M = 1e9+7;
const int MXN=20; 
 
int power(int a,int b) {int res=1;a%=M;while(b){if((b&1))res=(res*a)%M;a=(a*a)%M;b>>=1;}return res;}
inline void print(int a,int b){ cout << a << ' ' << b << endl;}
inline void print(int a,int b,int c){ cout << a << ' ' << b <<' '<< c << ' ' << endl;}
 
int n;
int g[MXN][MXN];
int vis[MXN];
int tr[MXN];

bool check(int mask){
    for(int i=0;i<n;++i){
        if(!((mask>>i)&1LL))continue;
        for(int j=0;j<n;++j){
            if(g[i][j]!=-1 && g[i][j]!=tr[j])return false;
        }
    }
    return true;
}

int32_t main(){
    fast;
    cin>>n;
    memset(g,-1,sizeof(g));
    for(int i=0;i<n;++i){
        int a;
        cin>>a;
        for(int j=0;j<a;++j){
            int u,v;
            cin>>u>>v;
            u--;
            g[i][u]=v;
        }
    }
    int ans =0;
    for(int i=0;i<(1<<n);++i){
        for(int j=0;j<n;++j){
            tr[j] = ((i>>j)&1LL);
        }
        if(check(i))
            ans=max(ans,(int)__builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;
    int len_A = Sa.length();
    int len_B = Sb.length();
    int len_C = Sc.length();
    string direction = Sa.substr(0,1);
    Sa = Sa.substr(1,len_A);
    len_A = Sa.length();
    while (len_A + len_B + len_C > 0){
        if (direction == "a" && len_A != 0){
            direction = Sa.substr(0,1);
            Sa = Sa.substr(1,len_A);
            len_A = Sa.length();
        }
        else if (direction == "a" && len_A == 0){
            cout << "A" << endl;
            break;
        }
        else if (direction == "b" && len_B != 0){
            direction = Sb.substr(0,1);
            Sb = Sb.substr(1,len_B);
            len_B = Sb.length();
        }
        else if (direction == "b" && len_B == 0){
            cout << "B" << endl;
            break;
        }
        else if (direction == "c" && len_C != 0){
            direction = Sc.substr(0,1);
            Sc = Sc.substr(1,len_C);
            len_C = Sc.length();
        }
        else if (direction == "c" && len_C == 0){
            cout << "C" << endl;
            break;
        }
    }
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N;
  cin >> N;
  map<int, int> mp;
  ll sum = 0;
  REP(i, N){
    int A;
    cin >> A;
    mp[A]++;
    sum+=A;
  }
  int Q;
  cin >>Q;
  while(Q--){
    int B, C;
    cin >> B >> C;
    sum -= (ll)mp[B] * B;
    sum += (ll)mp[B] * C;
    mp[C] += mp[B];
    mp[B] = 0;
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 8068