akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>

using namespace std;

vector<int> visited(200007);
vector<vector<int>> path(200007);
int N, M;

int dfs(int start){
  deque<int> s;
  s.push_back(start);
  visited[start] = 0;
  while( s.size() > 0 ){
	int p = s.front();
	s.pop_front();
	int l = path[p].size();
	for( int i = 0; i < l; i++ ){
	  int t = path[p][i];
	  if( visited[t] >= 200000 ){
		visited[t] = visited[p] + 1;
		s.push_back(t);
	  }
	}
  }
  return 0;
}

int main(){
  int a, b;
  cin >> N >> M;
  for( int i = 0; i < M; i++ ){
	cin >> a >> b;
	path[a].push_back(b);
	path[b].push_back(a);
  }
  for( int i = 1; i <= N; i++ ){
	visited[i] = 200000;
  }
  dfs(1);
  if( visited[N] <= 2 ){
	cout << "POSSIBLE" << endl;
  }else{
	cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 13168
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


int N;
int a_dig[int(1e5)];
int b_dig[int(1e5)];

int a_digit(int S) {
    int s_len = 0;
    while (S > 0) {
        a_dig[s_len++] = S % 10;
        S /= 10;
    }
    return s_len;
}

int b_digit(int S) {
    int s_len = 0;
    while (S > 0) {
        b_dig[s_len++] = S % 10;
        S /= 10;
    }
    return s_len;
}

void solve() {
    int ans = INF;
    REPONE(i, N - 1) {
        int A = i, B = N - i;
        int len_a = a_digit(A);
        int res = 0;
        REP(j, len_a) res += a_dig[j];
        int len_b = b_digit(B);
        REP(k, len_b) res += b_dig[k];
        ans = min(ans, res);
    }
    cout << ans << endl;
}

int main() {
    cin >> N;
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        while (true)
        {

            String[] str = Console.ReadLine().Split(' ');

            char[,] ary = new char[int.Parse(str[0]), int.Parse(str[1])];

            if (int.Parse(str[0]) == 0 && int.Parse(str[1]) == 0)
            {
                break;
            }

            for (int i = 0; i < ary.GetLength(0); i++)
            {
                for (int j = 0; j < ary.GetLength(1); j++)
                {
                    if (i == 0 || i + 1 == ary.GetLength(0) || j == 0 || j + 1 == ary.GetLength(1))
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.WriteLine();
            }

            Console.WriteLine();
        }
    }
}

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

#ifdef LOCAL
	#define de(x) cout<<#x<<"="<<x<<endl
	#define rff freopen("input.txt","r",stdin)
#else
	#define de(x)
	#define rff
#endif

#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define PQ priority_queue
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define mp make_pair
#define re return
#define se second
#define fi first
const int INF=0x7fffffff;
const ll MAXN=1e5+3;

int n,k,tmp;
vector <int> a,b;
ll ans=(ll)INFINITY,t;

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	b.pb(0);
	rep(i,n){
		cin>>tmp;
		if (tmp>0){
			b.pb(tmp);
		}else if (tmp<0){
			a.pb(tmp*-1);
		}else{
			n--;
			k--;
			i--;
		}
	}
	int as=a.size(),bs=b.size()-1;
	a.pb(0);
	rep(i,min(k+1,as+1)){
		if (k-i>bs) continue;
		t=min(a[as-i]*2+b[k-i],a[as-i]+b[k-i]*2);
//		de(t);
//		de(i);
		ans=min(ans,t);
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define YOU setprecision
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  string s="2019/04/30",g;
  cin >>g;
  if(s>=g) cout <<"Heisei\n";
  else cout <<"TBD\n";
  return (0);
}


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

using namespace std;

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

	vector<int> a;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		a.push_back(x);
	}

	for (int i = n-1; i >= 0; i--)
	{
		cout << (i == n - 1 ? "" : " ") << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int A[N + 1];
    for (int i = 1; i <= N; i++)
    {
        scanf("%d", &A[i]);
    }
    for (int i = K + 1; i <= N; i++)
    {
        cout << ((A[i] > A[i - K]) ? "Yes" : "No") << endl;
    }

    return 0;
}

Measured memory_bytes: 4540
#include<iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(ans<k)
		ans+=ans;
		else
		ans+=k;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type size_, capacity;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : size_(0), capacity(0), c() {}
	explicit segment_tree(const size_type size)
		: size_(size), capacity(getsize(size_)),
		c(capacity << 1, value_structure::identity()) {}

	bool empty() const { return !size_; }
	size_type size() const { return size_; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + capacity];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += capacity, last += capacity; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < capacity)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - capacity + 1;
	}

	void update(size_type index, const value_type &value) {
		assert(index < size());
		index += capacity;
		c[index] = value;
		while (index >>= 1)
			recalc(index);
	}
};

#include <algorithm>
#include <limits>
template <class T> class min_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return ::std::min(x, y);
	}
	static value_type identity() {
		return 2147483647;
	}
	static value_type reverse(const value_type &x) { return x; }
};

#include <cstdio>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	using uint = unsigned int;

	uint n, q;
	scanf("%u%u", &n, &q);

	segment_tree<min_monoid<uint>, vec_alias> seg(n);

	while (q--) {
		uint c, x, y;
		scanf("%u%u%u", &c, &x, &y);

		if (c)
			printf("%u\n", seg.fold(x, y + 1));
		else
			seg.update(x, y);
	}

	return 0;
}



Measured memory_bytes: 3392
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,q = LI()
    s = S()
    lr = [LI() for _ in range(q)]

    cc = [0,0]
    for i in range(n-1):
        t = cc[-1]
        if s[i:i+2] == 'AC':
            t += 1
        cc.append(t)

    rr = []
    for a,b in lr:
        t = cc[b] - cc[a]
        rr.append(t)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 36908
n, m = map(int, input().split())
k = []
s = []
for i in range(m):
    l = list(map(int, input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int, input().split()))

ans = 0
for bit in range(1<<n):
    q = 1
    for i in range(m):
        sum = 0
        for j in range(k[i]):
            if (bit >> (s[i][j] - 1)) & 1:
                sum += 1
        if sum % 2 != p[i]:
            q = 0
    if q == 1:
        ans += 1

print(ans)

Measured memory_bytes: 3064
c[60000],n;main(i,j){for(i=2;i*i<5e4;i++)for(j=i;!c[i]&&j<5e4;c[j+=i]=1);for(;scanf("%d",&j),j;n=!printf("%d\n",n))for(i=2;i<=j/2;n+=!(c[i]+c[j-i++]));exit(0);}

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

using namespace std;

string StrInput;


void convertToBinary() {
	double num;
	stringstream ss;
	string result;

	ss << StrInput;
	ss >> num;
	//cout << num << endl;
	result = "";
	for (double i = (1 << 7); i > 0.03125; i /= 2.0) {
		result += (int)(num / i) + '0';
		num -= (int)(num / i) * i;
		if (i == 1) {
			result += '.';
		}
		//cout << "result:" << result << endl;
	}

	if (num == 0) {
		cout << result << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

int main() {
	
	while (cin >> StrInput, StrInput[0] != '-') {
		convertToBinary();
	}

	return 0;
}


Measured memory_bytes: 3292
#include <iostream>
#include <cmath>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

int check(int ind) {
	if ((ind%2) == 0) {
		return 10 * pow(10,(int)(ind/2));
	}
	else {
		return 50 * pow(10,(int)(ind/2));
	}
}

bool can_ex(std::vector<int> v, std::vector<int> m, int ind) {
	if (ind == 3) {
		return false;
	}

	if (v[ind+1] == 0) {
		return true;
	}
	else {
		if (v[3] > 0) {
			return false;
		}

		int change;
		if (ind == 0) {
			change = m[ind]/5;
			if (change+m[ind+1] > 1) {
				return true;
			}
		}
		if (ind == 1) {
			change = m[ind]/2;
			if (change+m[ind+1] > 4) {
				return true;
			}
		}
	}

	return true;
}


int main(void) {
	int p;
	bool fn = false;

	cin >> p;

	while (p != 0) {
		int sum = 0;
		int change;
		int temp;
		int out = 0;
		std::vector<int> m(4,0);
		std::vector<int> pay(4);

		if (fn) {
			cout << endl;
		}
		else {
			fn = true;
		}

		for (int i = 0; i < 4; i++) {
			cin >> m[i];
		}

		for (int i = 0; sum < p; i++) {
			while (sum < p && m[i] > 0) {
				m[i]--;
				pay[i]++;
				sum += check(i);
			}
		}

		change = sum - p;

		for (int i = 0; i < 4; i++) {
			temp = change/check(3-i);
			if (change/check(3-i) > 0) {
				if (pay[3-i] > 0) {
					pay[3-i] -= temp;
					m[3-i] += temp;
				}
			}
			change = change%check(3-i);
		}

		int ex10 = 0;
		int ex50 = 0;

		for (int i = 0; i < 4; i++) {
			if (can_ex(pay,m,i)) {
				if (i == 0) {
					if (m[i] > 4) {
						ex10 = m[i]/5;
						m[i+1] += ex10;
						pay[i] += m[i] - m[i]%5; 
						m[i] = m[i]%5;
					}
				}
				else if (i == 1) {
					if (m[i] > 1) {
						ex50 = m[i]/2;
						m[i+1] += ex50;
						pay[i] += m[i] - m[i]%2 - ex10; 
						m[i] = m[i]%2;
					}
				}
				else {
					if (m[i] > 4) {
						m[i+1] += m[i]/5;
						pay[i] += m[i] - m[i]%5 - ex50; 
						m[i] = m[i]%5;
					}
				}
			}

			if (pay[i] > 0) {
				cout << check(i) << " " << pay[i] << endl;
			}
		}
		cin >> p;
	}

	return 0;
}

Measured memory_bytes: 3220
import sys
from collections import deque, defaultdict, Counter
# from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
import math
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
S = [input() for _ in range(H)]

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			L[i][j] = 0
		elif j == 0:
			L[i][j] = 1
		else:
			L[i][j] = L[i][j-1] + 1

for i in range(H):
	for j in range(W-1, -1, -1):
		if S[i][j] == '#':
			R[i][j] = 0
		elif j == W-1:
			R[i][j] = 1
		else:
			R[i][j] = R[i][j+1] + 1

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			U[i][j] = 0
		elif i == 0:
			U[i][j] = 1
		else:
			U[i][j] = U[i-1][j] + 1

for i in range(H-1, -1, -1):
	for j in range(W):
		if S[i][j] == '#':
			D[i][j] = 0
		elif i == H-1:
			D[i][j] = 1
		else:
			D[i][j] = D[i+1][j] + 1

ans = 0
for i in range(H):
	for j in range(W):
		ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

print(ans)


Measured memory_bytes: 186204
#include <bits/stdc++.h>
using namespace std;
int a[222222], b[222222], n;
bool check(int x) {
  b[n] = a[n]>=x;
  for (int i=1; i<n; i++) {
    b[n+i] = a[n+i]>=x;
    b[n-i] = a[n-i]>=x;
    if (b[n+i]==b[n+i-1] || b[n-i]==b[n-i+1]) return b[n+i-1];
  }
  return b[1];
}
int main () {
  scanf("%d", &n);
  for (int i=1; i<=2*n+1; i++) {
    scanf("%d", &a[i]);
  }
  int l = 1, r = 2*n-1, ans;
  while (l<=r) {
    int mid = (l+r)/2;
    if (check(mid)) {
      ans=mid;
      l=mid+1;
    } else {
      r=mid-1;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1792
N, x = map(int, input().split())
nums = list(map(int, input().split()))
# print(nums)
ans = 0
for i in range(1, N):
    if nums[i - 1] + nums[i] > x:
        diff = nums[i - 1] + nums[i] - x
        if diff > nums[i]:
            nums[i - 1] -= (diff - nums[i])
            nums[i] = 0
        else:
            nums[i] -= diff
        ans += diff
# print(nums)
print(ans)


Measured memory_bytes: 20000
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli up(lli a,lli b){
	if(a%b==0)return a/b;
	else return a/b+1;
}

signed main(){

	string s,t;
	cin>>s>>t;
	vector<vector<lli>> data(26);

	lli size = s.size();

	REP(i,0,size){
		data[s.at(i)-'a'].push_back(i);
	}

	lli sum=0;

	REP(i,0,t.size()){
		lli now = t.at(i)-'a';
		if(DEBUG)cout<<now<<endl;

		auto pos = lower_bound(data[now].begin(),data[now].end(),sum%size);
		if(pos == data[now].end()){
			sum = up(sum,size)*size;

			auto pos2 = lower_bound(data[now].begin(),data[now].end(),sum%size);
			if(pos2 == data[now].end()){
				cout<<-1<<endl;
				return 0;
			}
			if(DEBUG)cout<<*pos2<<endl;
			sum += *pos2 -sum%size;
		}
		else{
			if(DEBUG)cout<<*pos<<endl;
			sum += *pos - sum%size;
		}
		sum++;
		if(DEBUG)cout<<sum<<endl;
	}
	cout<<sum<<endl;

	return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  ll ans = 0;
  int N;
  cin >> N;
  vector<int> a(N);
  
  rep(i, N) cin >> a[i];
  
  int prev = a[0];
  rep(i, 1, N) {
    if (prev < a[i]) {
      prev = a[i];
      continue;
    }
    
    ans += (prev - a[i]);
    if (prev < a[i]) prev = a[i];
  }
  
  cout << ans << endl;
  return 0;
}


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

int main()
{
    long long result=9999999999,r=0;
    int min=100,max=0;
    int x[100];
    int n,i,j;
    
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
        if(x[i]>max)
        {
            max=x[i];
        }
        if(x[i]<min)
        {
            min=x[i];
        }
    }
    for(i=min;i<=max;i++)
    {
        for(j=0;j<n;j++)
        {
            r+=(i-x[j])*(i-x[j]);
        }
        if(r<result)
        {
            result=r;
        }
        r=0;
    }
    printf("%lld\n",result);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

bool negative_circle_flag = false;
vector<long long> bellman_ford(vector<vector<pair<ll, ll>>> g, long long start){
    vector<ll> distance(g.size(), INF);
    distance[start] = 0;
    ll count = 0;
    while(true){
        bool update = false;
        for(ll i = 0; i < g.size(); i++){
            for(ll j = 0; j < g[i].size(); j++){
                if(distance[i] != INF && distance[g[i][j].second] > distance[i] + g[i][j].first){
                    distance[g[i][j].second] = distance[i] + g[i][j].first;
                    update = true;
                }
            }
        }
        if(!update) break;
        count++;
        if(count == g.size()){
            negative_circle_flag = true;
            return distance;
        }
    }
    return distance;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll h, w; cin >> h >> w;
    vector<vector<ll>> c(10, vector<ll>(10));
    for(long long i = 0; i < 10; i++){
        for(long long j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }
    vector<vector<ll>> vec(h, vector<ll>(w));
    for(long long i = 0; i < h; i++){
        for(long long j = 0; j < w; j++){
            cin >> vec[i][j];
        }
    }

    vector<vector<pair<ll,ll>>> g(10);
    rep(i, 10){
        rep(j, 10){
            g[i].emplace_back(c[i][j], j);
        }
    }

    vector<ll> res(10);
    rep(i, 10){
        vector<ll> dis = bellman_ford(g, i);
        res[i] = dis[1];
    }

    ll ans = 0;
    rep(i, h){
        rep(j, w){
            if(vec[i][j] == -1){
                continue;
            }
            ans += res[vec[i][j]];
        }
    }

    cout << ans << endl;




}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vll A(N);
  repeat(i,N){
    cin>>A[i];
  }
  sort(A.begin(),A.end(),greater<ll>());
  ll ans = 0;
  repeat(i,N-1){
    if(A[i]==A[i+1]){
      for(int j=i+2;j<N-1;j++){
        if(A[j]==A[j+1]){
          ans = A[i]*A[j];
          break;
        }
      }
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut c4: usize = 0;
    let mut c2: usize = 0;
    for _ in 0..n {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        if a % 4 == 0 {
            c4 += 1;
        } else if a % 2 == 0 {
            c2 += 1;
        }
    }

    if c4 + c2 / 2 >= n / 2 {
        return String::from("Yes");
    }
    return String::from("No");
}


Measured memory_bytes: 4352
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;
    
#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long
    
typedef long long ll;
typedef pair<int,int> Pair;

int A,B,K,ans,cnt=0;

// int 
    
signed main(){
    cin >> A >> B >> K;
    for(int i =MIN(A,B);i>0;i--){
        if(A%i==0 && B%i==0) cnt++;
        if(cnt == K) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import Counter
from sys import exit
def imp():
    print('Impossible')
    exit()

N = int(input())
A = list(map(int, input().split()))
mia = min(A)
maa = max(A)
if mia != -(-maa//2):
    imp()
if maa % 2:
    CA = Counter(A)
    if CA[mia] != 2:
        imp()
    for i in range(mia +1, maa+1):
        if CA[i] < 2:
            imp()
else:
    CA = Counter(A)
    if CA[mia] != 1:
        imp()
    for i in range(mia +1, maa+1):
        if CA[i] < 2:
            imp()
print('Possible')

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>>s(m);
    for(int i=0;i<m;++i){
        int k;
        cin>>k;
        s[i].resize(k);
        for(int j=0;j<k;++j){
            cin>>s[i][j];
            --s[i][j];
        }
    }
    vector<int>p(m);
    for(int i=0;i<m;++i){
        cin>>p[i];
    }

    int ans=0;
    for(int i=0;i<1<<n;++i){
        bool is_ok=true;
        for(int j=0;j<m;++j){
            int on_cnt=0;
            for(auto on:s[j]){
                if(i&1<<on){
                    ++on_cnt;
                }
            }
            is_ok&=on_cnt%2==p[j];
        }
        if(is_ok)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
nums = list(map(int, input().split()))

import random

class dice:
    def __init__(self):
        self.top = 0
        self.right = 0
        self.front = 0
        self.left = 0
        self.back = 0
        self.bottom = 0
    
    def set_num(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums
        return self
    
    def get_right(self, f_top, f_front):
        while f_top!=self.top or f_front!=self.front:
            self.roll(random.randint(0,3))
        return self.right
        
    def roll(self, command):
        if command==0:
            self.top, self.front, self.right, self.left, self.back, self.bottom = self.left, self.front, self.top, self.bottom, self.back, self.right
        elif command==1:
            self.top, self.front, self.right, self.left, self.back, self.bottom = self.right, self.front, self.bottom, self.top, self.back, self.left
        elif command==2:
            self.top, self.front, self.right, self.left, self.back, self.bottom = self.front, self.bottom, self.right, self.left, self.top, self.back
        elif command==3:
            self.top, self.front, self.right, self.left, self.back, self.bottom = self.back, self.top, self.right, self.left, self.bottom, self.front
            

d = dice()
d.set_num(nums)

n = int(input())
for i in range(n):
    f_t, f_r = map(int, input().split())
    print(d.get_right(f_t, f_r))


Measured memory_bytes: 8184
#include <iostream>
using namespace std;
int main()
{
    string a;
    int b=0;
    cin>>a;
    if(a[0]=='o')
        b+=100;
    if(a[1]=='o')
        b+=100;
    if(a[2]=='o')
        b+=100;
    b=b+700;
    cout<<b;
	return 0;
}


Measured memory_bytes: 3576
l=a,b,c,d=list(map(int,input().split()))
l1=sorted(l)
if (l1.index(c)==0 and l1.index(d)==1) or (l1.index(c)==2):
        print(0)
elif l1.index(c)==0 and l1.index(d)==2:
        print(d-a)
elif l1.index(c)==1 and l1.index(d)==3:
        print(b-c)
elif l1.index(c)==1 and l1.index(d)==2:
        print(d-c)
elif l1.index(c)==0 and l1.index(d)==3:
        print(b-a)
        


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using std::cout;
using std::cin;
using std::endl;
using std::vector;

int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    ll a,b;
    vector<ll> A(N+1), B(M+1);
    A[0] = 0; B[0] = 0;
    for(ll i=0; i<N; i++){
        cin >> a;
        A[i+1] = a + A[i];
    }
    for(ll i=0; i<M; i++){
        cin >> b;
        B[i+1] = b + B[i];
    }
    
    ll ans = 0;
    ll i=0,j=0;
    while(A[i]+B[j]<=K && i<=N){
        i++;
    }
    i--;
    while(A[i]+B[j]<=K && j<=M){
        j++;
    }
    j--;
    ans = i+j;
    while(i>0 && j<=M){
        while(A[i-1]+B[j]<=K && j<=M){
            j++;
        }
        j--;
        i--;
        ans = std::max(ans, i+j);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6404
def main():
    S = input()
    T = input()
    N = len(S)
    M = len(T)
    ans = ""
    for i, s in enumerate(S[::-1]):
        cur = S[-(M+i):-i] if i != 0 else S[(-(M+i)):]
        if len(cur) == M:
            pass
        else:
            continue
        if (s == T[-1] or s == "?") and \
                all(ss == "?" or ss == t for ss, t in zip(cur, T)):
            if i != 0:
                ans = S[:-(M+i)] + T + S[-i:]
            else:
                ans = S[:-(M+i)] + T
            break
    if ans:
        ans = ans.replace("?", "a")
        print(ans)
    else:
        print("UNRESTORABLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		int number = 0;

		String Word = stdin.nextLine();

		List<String> result = new ArrayList<>();

		while (true) {
			String word = stdin.next();
			if (word.equals("END_OF_TEXT")) {
				break;
			} else {
				result.add(word);
			}
		}
		for(int i = 0; i< result.size();i++) {
            if(result.get(i).equalsIgnoreCase(Word)) {
            	number++;
            }          

    }
    System.out.println(number);

}

	}

Measured memory_bytes: 26296
import java.util.Arrays;
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();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int[] result = new int[3];
    int max = Math.max(X, Y);
    int min = Math.min(X, Y);
    int max_value = 0;
    if(max == X){
    	max_value = A;
    }
    if(max == Y){
    	max_value = B;
    }
    
    result[0] = 2 * C * max;
    result[1] = 2 * C * min + (max-min) * max_value;
    result[2] = A * X + B * Y;
    Arrays.sort(result);
    
    System.out.println(result[0]);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >> s;
    if(s[1]==s[2]){
        if(s[0]==s[1]){
          cout << "Yes";
          return 0;
        }
        if(s[2]==s[3]){
          cout << "Yes";
          return 0;
        }
    }
    cout << "No";
    return 0;
}


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

const long long modnum = 1e9+7;

int main(){
    long long N;
    long long K;
    long long A[2010];
    long long turn1[2010] = {};
    long long turn2[2010] = {};
    long long ans = 0;

    cin >> N >> K;
    for(long long n=0;n<N;n++) cin >> A[n];

    for(long long i=0;i<N;i++){
        for(long long j=i+1;j<N;j++){
            if(A[i] > A[j]) turn1[i]++;
        }
    }

    for(long long i=0;i<N;i++){
        for(long long j=0;j<N;j++){
            if(A[i] > A[j]) turn2[i]++;
        }
    }


    for(long long i=0;i<N;i++){
        ans += ((K*turn1[i]) % modnum + (((K*(K-1)/2) % modnum)* turn2[i]) % modnum) % modnum;
    }
    cout << ans % modnum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int index;

	for ( int i = 1; i <= 5; i++ )
	{
		int x;
		cin >> x;
		if ( x == 0 )
		{
			index = i;
		}
	}
	cout << index << endl;
}

Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
int	c,r,x[100][100] = {}, y[100][100] = {},i,j,k,l,m,n,sum1=0,sum2=0,sum3=0;
cin>>c>>r;
for(i=0;i<c;i++){
	for(j=0;j<r;j++){
		cin>>x[i][j];
	}
}
for(k=0;k<c;k++){
	for(l=0;l<r;l++){
		sum1+=x[k][l];
		sum3+=x[k][l];
		cout<<x[k][l]<<" ";
	}
	cout<<sum1;
	sum1=0;
	cout<<endl;
}

for(m=0;m<r;m++){
	for(n=0;n<c;n++){
		sum2+=x[n][m];
		
	}
	cout<<sum2<<" ";
	sum2=0;
}

cout<<sum3<<endl;
return 0;
}

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

main(){
  string s;
  int flag = 0;
  cin>>s;
  for(int i=0;i<s.size();i+=2){
    if (s[i]=='L') flag = 1;
  }
  for(int i=1;i<s.size();i+=2){
    if (s[i]=='R') flag = 1;
  }
  if(flag==1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3612
H,W=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(H)]

list_=[]
cnt=0
for i in range(H):
    if i%2==0:
        for j in range(W):
            if j!=W-1:
                if a[i][j]%2==1:
                    a[i][j]-=1
                    a[i][j+1]+=1
                    list_.append([i+1,j+1,i+1,j+2])
            else:
                if a[i][j]%2==1 and i!=H-1:
                    a[i][j]-=1
                    a[i+1][j]+=1
                    list_.append([i+1,j+1,i+2,j+1])
    else:
        for j in range(W-1,-1,-1):
            if j!=0:
                if a[i][j]%2==1:
                    a[i][j]-=1
                    a[i][j-1]+=1
                    list_.append([i+1,j+1,i+1,j])
            else:
                if a[i][j]%2==1 and i!=H-1:
                    a[i][j]-=1
                    a[i+1][j]+=1
                    list_.append([i+1,j+1,i+2,j+1])
N=len(list_)
print(N)
for l in list_:
    print(" ".join(map(str,l)))

Measured memory_bytes: 31404
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

  return 0;
}


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

int main() {
    string s;
    bool ans = false;
    
    cin >> s;
    
    if (
        ((s[0] == s[1]) && (s[1] == s[2])) ||
        ((s[1] == s[2]) && (s[2] == s[3]))
    ) {
        ans = true;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8
N=input()
A=map(int,raw_input().split())

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


# L[i]:=gcd(A_0, ..., A_i)
# R[i]:=gcd(A_i, ..., A_{N-1})
L=[0]*N
R=[0]*N

L[0]=A[0]
R[N-1]=A[N-1]
for i,a in enumerate(A):
    if i==0:continue
    L[i]=gcd(L[i-1],a)
for i,a in enumerate(reversed(A)):
    if i==0:continue
    R[N-i-1]=gcd(R[N-i],a)
ans=R[1] 
ans=max(ans,L[N-2])
for i in range(N-1):
    if i==0:continue
    ans=max(ans,gcd(L[i-1],R[i+1]))
print(ans)    


        







Measured memory_bytes: 43048
# -*- coding:utf-8 -*-
""" 考え方
T=5のとき

0 2 6 10 20 25 30

total = 0  # お湯が出る総時間

・0~2
2-0 <= Tより、お湯が出てる時間は2

・2~6
6-2 <= Tより、お湯が出てる時間は4

・6~10
10-6 <= Tより、お湯が出てる時間は4

・10~20
20-10 > Tより、お湯が出てる時間はT

...

という風に、全探索すればOK

N = 2* 10**5なのでO(N)でも間に合うでしょ

"""
def solve():
    N, T = list(map(int, input().split()))
    t = list(map(int, input().split()))

    total = 0
    for i in range(1, len(t)):
        diff = t[i] - t[i-1]
        if diff <= T:
            total += diff
        else:
            total += T
    total += T  # 最後にTを足すのを忘れないこと

    print(total)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 25712
#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;

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

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

int main(){
  ll a,b,g,m;
  while(cin>>a>>b){
    g=__gcd(a,b);
    m=a/g*b;
    cout<< g << " " << m <<endl;
  }
    
  return 0;
}


Measured memory_bytes: 3076
#include<iostream>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long  long int lli;

int main(){
  int K, S;
  cin >> K >> S;

  lli ans = 0;
  
  REP(x, 0, K + 1) {
    REP (y, 0, K + 1) {
      int z = S - x - y;
      if (0 <= z && z <= K) ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  char str[201];
  int nh, h, is, iis, ih;
  while(scanf("%s", str), strcmp(str, "-")) {
    scanf("%d", &nh);
    for(is = ih = 0; ih < nh; ++ih) {
      scanf("%d", &h);
      is = (is + h) % strlen(str);
    }
    for(iis = 0; iis < strlen(str); ++iis) printf("%c", str[(is + iis) % strlen(str)]);
    printf("\n");
  }
  return 0;
}

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

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 = read::<u32>();
    let m = read::<u32>();

    let mut l = 0;
    let mut r = n - 1;

    for _i in 0..m {
        l = std::cmp::max(l, read::<u32>() - 1);
        r = std::cmp::min(r, read::<u32>() - 1);
    }

    let ans = if l <= r { r - l + 1 } else { 0 };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[100];
int main()
{
	int num, mini = 100000, maxi = -1;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		mini = min(mini, z), maxi = max(maxi, z);
	}
	printf("%d\n", maxi - mini);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

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

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
//     FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/
//     int T;
//     //scanf("%d", &T);
    int T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int a, b;
        cin >> a >> b;
        cout << max(0, a - 2 * b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

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

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll X, Y;
    cin >> X >> Y;
    const int MAX = 1001;
    for (int x = 0; x <= X; ++x) {
        int y = X - x;
        bool good = 2 * x + 4 * y == Y;
        if (good) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

int main(){
  int K,S;
  cin >> K >> S;
  
  int count=0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      if(S-(x+y) <= K && S-(x+y) >= 0){
        count++;
      }
    }
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


ll N,P, M, K,A,B;
string S;


int main() {
	
	cin >> A>>P;

	P+=A*3;
	cout << P / 2 << endl;



	return 0;
}

Measured memory_bytes: 256
import math


def float_print(v):
    print('{:.5f}'.format(v))


a, b, C = map(float, input().split())
C = math.radians(C)

float_print(a * b * math.sin(C) / 2)
float_print(a + b + math.sqrt(math.pow(a, 2) + math.pow(b, 2) - 2 * a * b * math.cos(C)))
float_print(b * math.sin(C))

Measured memory_bytes: 7776
//http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3727691#1
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
using LD = long double;
#define int LL
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n) - 1, 0, i)
#define sp << " "
#define ln << "\n"
#define size(v) ((int)(v).size())
template<class T> using vec = vector<T>;
template<class T> using vvec = vec<vec<T>>;

vvec<int> edges;
vec<pair<LD, int>> om0, oms;
vec<LD> oa0, oap, ans;

inline LD CORE(LD a, int b) { return b == 0 ? 0 : a / b; }

void dfs1(int a, int p) {
  LD s = 0;
  int n = 0;
  for(int c : edges[a]) {
    if(c == p) continue;
    dfs1(c, a);
    s += oa0[c] + 1;
    ++n;
  }
  om0[a] = {s, n}; // FOLD
  oa0[a] = CORE(s, n);
}

void dfs2(int a, int p) {
  if(a == 0) {
    oms[0] = om0[0];
  } else {
    oap[a] = CORE(oms[p].first - oa0[a] - 1, oms[p].second - 1); // RMV
    LD s = 0;
    int n = 0;
    for(int c : edges[a]) {
      if(c == p) {
        s += oap[a] + 1;
        ++n;
      } else {
        s += oa0[c] + 1;
        ++n;
      }
    }
    oms[a] = {s, n}; // FOLD
  }
  ans[a] = CORE(oms[a].first, oms[a].second);

  for(int c : edges[a]) {
    if(c != p) dfs2(c, a);
  }
}

void solve() {
  int N; cin >> N;
  edges.clear(); edges.resize(N);
  om0.clear(); om0.resize(N);
  oms.clear(); oms.resize(N);
  oa0.clear(); oa0.resize(N);
  oap.clear(); oap.resize(N);
  ans.clear(); ans.resize(N);

  times(N-1, i) {
    int S, T;
    cin >> S >> T; --S; --T;
    edges[S].push_back(T);
    edges[T].push_back(S);
  }

  dfs1(0, 0);
  dfs2(0, 0);
  //times(N, i) cerr << om0[i].first sp << om0[i].second sp sp; cerr ln;
  //times(N, i) cerr << oa0[i] sp; cerr ln;
  //times(N, i) cerr << oap[i] sp; cerr ln;
  //times(N, i) cerr << oms[i].first sp << oms[i].second sp sp; cerr ln;
  times(N, i) cout << ans[i] ln;
}

signed main(){
  cin.tie(0);
  cerr.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 35328