akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


char s[N];
int n;
int chk(int x) {
	REP(k,0,1) {
		int a=k, b=x;
		if (a%2!=b%2) --b;
		REP(i,1,n) {
			if (s[i]=='0') --a,--b;
			else if (s[i]=='1') ++a,++b;
			else --a,++b;
			if (a<0) a+=2;
			if (b>x) b-=2;
			if (b<a) break;
			if (i==n) return 1;
		}
	}
	return 0;
}
int main() {
	scanf("%s", s+1);
	n = strlen(s+1);
	int l = 0, r = n;
	while (r-l>1) {
		if (chk(mid)) r=mid;
		else l=mid;
	}
	printf("%d\n", r);
}

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


int main(){
	string s, t;
	cin >> s >> t;

	ll ans = 0;
	rep(i, s.size()){
		if(s.at(i) != t.at(i)){
			ans++;
		}
	}

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

Measured memory_bytes: 3912
<?php
list($N, $K) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$hArray = array_map("intval", explode(" ", trim(fgets(STDIN))));
 
$dp = array_fill(0, $N+1, 10**18);
$dp[0] = 0;
for($i = 1; $i < $N; $i++){
    $dpi = &$dp[$i];
    $limit = min($i, $K);
    $hi = $hArray[$i];
    for($j = $i, $J = $i-$limit; $j >= $J; --$j){
        $new = $dp[$j] + abs($hi - $hArray[$j]);
        if($new < $dpi){
            $dpi = $new;
        }
    }
}
echo $dp[$N-1];

Measured memory_bytes: 16884
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll k; cin >> k;
    ll n = k / 50 + 49;
    vector<ll> A(50, n);

    rep(i, k%50){
        rep(j, 50){
            if(i==j)A[j]+=50;
            else A[j]--;
        }
    }
    cout << 50 << ln;
    rep(i, 50) cout << A[i] << " ";
    cout << ln;
}


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

ll dp[1000001][4];
ll mod = 1'000'000'007;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N; cin >> N;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        dp[i][0] = (dp[i-1][0] * 8) % mod;
        dp[i][1] = (dp[i-1][0] + dp[i-1][1] * 9) % mod;
        dp[i][2] = (dp[i-1][0] + dp[i-1][2] * 9) % mod;
        dp[i][3] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3] * 10) % mod;
        // cout << dp[i][0] << ' ' << dp[i][1] << ' ' << dp[i][2] << ' ' <<dp[i][3] << '\n';
    }
    cout << dp[N][3];
}

Measured memory_bytes: 34896
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char field[1010][1010];
int sum[1010][1010];

int main() {
  int n;
  MEMSET(sum, 0);
  while (scanf("%d", &n), n) {
    REP(i, n) {
      scanf("%s", field[i]);
    }
    REP(y, n) {
      REP(x, n) {
        sum[y + 1][x + 1] = sum[y + 1][x] + sum[y][x + 1] - sum[y][x];
        if (field[y][x] == '*') {
          sum[y + 1][x + 1]++;
        }
      }
    }
    int ans = 0;
    REP(y, n) {
      REP(x, n) {
        int l = ans;
        int r = min(n - y, n - x) + 1;
        while (l < r) {
          int m = (l + r) / 2;
          int nx = x + m;
          int ny = y + m;
          int total = sum[ny][nx] - sum[ny][x] - sum[y][nx] + sum[y][x];
          if (total == 0) {
            ans = m;
            l = m + 1;
          } else {
            r = m;
          }
        }
      }
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 0
from functools import reduce

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

def gcd2(numbers):
    return reduce(gcd, numbers)

n, x = map(int, input().split())
city = list(map(int, input().split()))

dx = [abs(i - x) for i in city]
print(gcd2(dx))


Measured memory_bytes: 14596
#include<stdio.h>
#define MAX 2000000

int size, A[MAX+1];

void maxHeapify(int i);
int extract();
void increaseKey(int i, int key);
void insert(int key);

int main(){
  int key;
  char A[20];
  while(1){
    scanf("%s", A);
    if ( A[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(A, "extract") == 0  ){
      printf("%d\n", extract());
    } else break;
  }
  return 0;
}

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int max;
  if ( size < 1 ) return;
  max = A[1];
  A[1] = A[size--];
  maxHeapify(1);
  return max;
}

void increaseKey(int i, int key){
  int tmp;
  if ( key < A[i] ) return;
  A[i] = key;
  while ( i > 1 && A[i/2] < A[i] ){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}

void insert(int key){
  size++;
  A[size] = -1000000001;
  increaseKey(size, key);
}



Measured memory_bytes: 5592
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
int tp[1000010],tq[1000010];
int main(void){
	
	int n,p;
	
	cin>>n;
	
	if(n<=999){
		cout<<"ABC"<<endl;
	}else{
		cout<<"ABD"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
c = [0]*(n+1)
L, R = [], []
for i in range(m):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
maxL = max(L)
minR = min(R)
print(max(minR+1-maxL, 0))

Measured memory_bytes: 11764
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var s []byte
	fmt.Scan(&s)
	p := s[0]
	cnt := 1
	var ans int
	for i := 1; i < n; i++ {
		if s[i] != p {
			cnt++
		} else {
			ans++
		}
		p = s[i]
	}
	if cnt == 1 {
		fmt.Println(ans)
		return
	}
	cnt -= 2
	if cnt%2 == 1 {
		ans += min((cnt+1)/2, k) * 2
	} else {
		if k >= cnt/2 {
			ans += cnt / 2 * 2
			if k-cnt/2 > 0 {
				ans++
			}
		} else {
			ans += k * 2
		}
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 2616
#include <stdio.h>
int main()
 {

 int a[10000], min, max, n, i;
 long long sum = 0;
 scanf("%d", &n);
for(i = 0; i < n; i++){
 scanf("%d", &a[i]);
 sum += a[i];
 }
 max = min = a[0];
for(i = 1; i < n; i++){
if(a[i] > max)max = a[i];
 if(a[i] < min)min = a[i];
 }
 printf("%d %d %lld\n", min, max, sum);

 return 0;
 }



Measured memory_bytes: 2124
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
int H,W;
cin >>H >>W;

char picture[H][W];
for(int k=0;k<H;k++){
    for(int i=0;i<W;i++){
        cin >> picture[k][i];
    }
}
for(int i=1;i<=W+2;i++){
    cout <<'#';
}
cout <<endl;
for(int k=0;k<H;k++){
    cout <<'#';
    for(int i=0;i<W;i++){
        cout <<picture[k][i];
    }
    cout <<'#'<<endl;
}

for(int i=1;i<=W+2;i++){
    cout <<'#';
}
cout <<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(2e5) +5;



ll ar[ms];
ll mm[ms]={0};

int main()
{
    idfc;

    ll n;
    cin>>n;
    ll i;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        mm[ar[i]]++;
    }


    ll ans=0;


    for(i=1;i<=n;i++)
    {
        ans+=((mm[i]*(mm[i]-1))/2);
    }

    ll pp;
    for(i=1;i<=n;i++)
    {
        pp=mm[ar[i]];
        cout<<(ans-(pp-1))<<"\n";
    }

    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200001;
int a[N];
ll s[N];
ll calc(pair<ll, ll> a, pair<ll, ll> b){
  ll mx = max(max(a.first, a.second), max(b.first, b.second));
  ll mn = min(min(a.first, a.second), min(b.first, b.second));
  if(a.first == -1 || b.first == -1)return 1e18;
  return mx - mn;
}
pair<pair<ll, ll>, pair<ll, ll>> d(int l, int r){
//  cout << l << ' ' << r << endl;
  int lo = l, hi = r - 1;
  ll tot_sum = s[r] - (l ? s[l - 1] : 0);
  while(lo < hi){
    int mid = (lo + hi) / 2;
    ll s1 = s[mid] - (l ? s[l - 1] : 0);
    if(s1 >= tot_sum - s1){
      hi = mid;
    }else{
      lo = mid + 1;
    }
  }
  pair<ll, ll> p1;
  pair<ll, ll> p2;
  ll s1 = s[lo] - (l ? s[l - 1] : 0);
  p1.first = s1;
  p1.second = tot_sum - s1;
  lo--;
  if(lo < l)
    p2.first = -1;
  else{
    ll s1 = s[lo] - (l ? s[l - 1] : 0);
    p2.first = s1;
    p2.second = tot_sum - s1;
  }
  return {p1, p2};
}
void pr(pair<pair<ll, ll>, pair<ll, ll>> p){
  cout << p.first.first << ' ' << p.first.second << ' ' << p.second.first << ' ' << p.second.second << endl;
}
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  for(int i = 0;i < n;i++)
    cin >> a[i];
  s[0] = a[0];
  for(int i = 1;i < n;i++)
    s[i] = a[i] + s[i-1];
  ll res = 1e18;
  for(int i = 1;i < n - 2;i++){


    pair<pair<ll, ll>, pair<ll, ll>> d1 = d(0, i);
    pair<pair<ll, ll>, pair<ll, ll>> d2 = d(i + 1,  n - 1);

    res = min(res, calc(d1.first, d2.first));
    res = min(res, calc(d1.first, d2.second));
    res = min(res, calc(d1.second, d2.first));
    res = min(res, calc(d1.second, d2.second));
//    pr(d1);
//    pr(d2);
  }
    cout << res << endl;
  return 0;
}


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

map<string,bool>m;

int main()
{
	int N;cin>>N;
	m.clear();
	string last="";
	for(register int i=1;i<=N;i++)
	{
		string s;cin>>s;
		if(m[s] || (last!="" && last[last.length()-1]!=s[0]))
		{
			cout<<"No\n";
			return 0;
		}
		m[s]=true;
		last=s;
	}
	cout<<"Yes\n";
	
	return 0;
}

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

int main()
{
	int count=0;
	string s,prv="",cur="";
	cin>>s;
	// int l=s.size(),count=0,c=1,k=0;
	for(int i=0;i<s.size();i++)
	{
		// if(s[i-1]!=s[i])
		// {
		// 	if(c>0)
		// 	{
		// 		cout<<"first\n";
		// 		c++;
		// 	}
		// 	count++;
		// 	k++;
		// 	cout<<"second\n";
		// }
		// else
		// {
		// 	if(s[i-1]==s[i] && (c>0 || k>0))
		// 	{
		// 		count++;
		// 		c=0;
		// 		k==0;
		// 		cout<<"third\n";
		// 	}
		// 	else
		// 	{
		// 		c++;
		// 		cout<<"fourth\n";
		// 	}
		// }
		/*if(s[i]!=s[i+1])
		{
			count++;

		}
		else
		{
			if(s[i]==s[i+1] && c>0)
			{
				count++;
				c=0;
			}
			else
			{
				count++;
				i++;
			}
		}*/
	// 	if(s[i]!=s[i+1])
	// 	{
	// 		k++;
	// 		count++;
	// 		if(k>1)
	// 		{
	// 			c++;
	// 		}
	// 		c=0;
	// 	}
	// 	else
	// 	{
	// 		if(s[i]==s[i+1] && (c>0 || i==l-1))
	// 		{
	// 			count++;
	// 			c=0;
	// 		}
	// 		else
	// 		{
	// 			if(s[i]==s[i-1] && k>0)
	// 			{
	// 				c++;
	// 				k=0;
	// 			}
	// 			else
	// 				c++;

	// 		}
	// 	}
	/*	s2=s[i];
		if(s1==s2)
		{
			c++;
			if(c<2)
			{
				s1+=s[i];
				c++;
			}
			else
			{
				count++;
				c=0;
				s1=s[i];
			}
		}
		else
		{
			count++;
			c=0;
			s1=s[i];
		}*/
		cur+=s[i];
		if(prv!=cur)
		{
			prv=cur;
			cur="";
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 640
from queue import Queue


def main():
    h, w, k = map(int, input().split())
    sx, sy, gx, gy = map(lambda z: int(z) - 1, input().split())
    c = [list(input().replace('\n', '')) for _ in range(h)]
    c[sx][sy] = 0
    q = Queue()
    q.put((sx, sy))
    while not q.empty():
        x, y = q.get()
        d = c[x][y]
        # 南へ移動
        for i in range(1, k + 1):
            if x + i >= h:
                break
            if c[x + i][y] == '@':
                break
            elif isinstance(c[x + i][y], int) and c[x + i][y] < d + 1:
                break
            elif isinstance(c[x + i][y], int) and c[x + i][y] == d + 1:
                continue
            else:
                c[x + i][y] = d + 1
                q.put((x + i, y))
        # 北へ移動
        for i in range(1, k + 1):
            if x - i < 0:
                break
            if c[x - i][y] == '@':
                break
            elif isinstance(c[x - i][y], int) and c[x - i][y] < d + 1:
                break
            elif isinstance(c[x - i][y], int) and c[x - i][y] == d + 1:
                continue
            else:
                c[x - i][y] = d + 1
                q.put((x - i, y))
        # 東へ移動
        for i in range(1, k + 1):
            if y + i >= w:
                break
            if c[x][y + i] == '@':
                break
            elif isinstance(c[x][y + i], int) and c[x][y + i] < d + 1:
                break
            elif isinstance(c[x][y + i], int) and c[x][y + i] == d + 1:
                continue
            else:
                c[x][y + i] = d + 1
                q.put((x, y + i))
        # 西へ移動
        for i in range(1, k + 1):
            if y - i < 0:
                break
            if c[x][y - i] == '@':
                break
            elif isinstance(c[x][y - i], int) and c[x][y - i] < d + 1:
                break
            elif isinstance(c[x][y - i], int) and c[x][y - i] == d + 1:
                continue
            else:
                c[x][y - i] = d + 1
                q.put((x, y - i))
    print(-1 if c[gx][gy] == '.' else c[gx][gy])


if __name__ == '__main__':
    main()


Measured memory_bytes: 194708
def main(m, k):
    # print(m)
    d = max(m) - min(m)
    if d > k:
        return ':('
    else:
        return 'Yay!'
    
if __name__ == '__main__':
    try:
        m = []
        for i in range(5):
            m.append(int(input().strip()))
        k = int(input().strip())
        print('{}'.format(main(m, k)))
    except EOFError:
        pass


Measured memory_bytes: 2940
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    t = list(input()[:-1].decode())

    ans = 0

    for i in range(3):
        if s[i] == t[i]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
#include<stdio.h>
int main(){
	int s[9000],n,m,t,f,i;
	while(scanf("%d%d",&n,&m),n)
		for(i=t=f=1;i<=n+m;i++){
			scanf("%d",&s[i]);
			if(i>n){t+=s[t+=s[i]];
				if(t>=n&f==1){
					printf("%d\n",i-n,f=0);
					;
			}
		}}
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int i,A[N+1];
	
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	int j,k,minj,t,count;
	count=0;
	for(j=0;j<N;j++)
	{
		minj=j;
		for(k=j;k<N;k++)
		{
			if(A[k]<A[minj]){
			minj=k;
			}
		}
		t=A[j];
		A[j]=A[minj];
		A[minj]=t;
		if(A[j]!=A[minj])
		{
		count++;
		}
	}
	
	for(int k=0;k<N;k++)
        {
            //cout<<A[k];
            printf("%d",A[k]);
        	if(k!=N-1){
                printf(" ");
        	}
        }
    printf("\n");
    printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2092
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Integer N = sc.nextInt();
    String S = sc.next();

    for (int i = 0; i < S.length(); i++) {
      char s = S.charAt(i);
      System.out.print((char)('A' + (s - 'A' + N) % 26));
    }
    System.out.println();
  }
}

Measured memory_bytes: 27348
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;

	
int main()
{
	int n;cin>>n;
	cout<<1110-n<<"\n";
	return 0;
}

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

using namespace std;
#define MAX (int)2e5

typedef pair<int,int> p;
typedef long long int ll;
typedef pair<ll,vector<int>> vertex;
vertex v[MAX];
int queri[MAX];
bool used[MAX];
void value(int,ll);

int main(void){
  int N,Q;
  cin >> N >> Q;
  for(int i=0;i<N-1;i++){
    int a,b;
    cin >> a >> b;
    (v[a-1].second).push_back(b-1);
    (v[b-1].second).push_back(a-1);
    v[i].first = 0;
    queri[i] = 0;
    used[i] = true;
  }
  v[N-1].first = 0;
  queri[N-1] = 0;
  used[N-1] = true;
  for(int i=0;i<Q;i++){
    int t,x;
    cin >> t >> x;
    queri[t-1] += x;
  }
  used[0] = false;
  value(0,0);
  for(int i=0;i<N;i++){
    cout << v[i].first << endl;
  }
  
  return 0;
}

void value(int ver,ll num){
  //queriを処理
  num = num + queri[ver];
  v[ver].first += num;
  for(int i=0;i<v[ver].second.size();i++){
    if(used[v[ver].second[i]]){
      used[v[ver].second[i]] = false;
      value(v[ver].second[i],num);
    }
  }
  return;
}



Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std ;
int main(){
    string s ;
    int w ;
    cin >> s ;
    cin >> w ;
    int len = s.length() ;
    for( int i = 0 ; i < len ; i += w )
        printf( "%c" , s[i] ) ;
    printf( "\n" ) ;
    return 0 ;
}

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


int main (void)
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a > k) {
        cout << ":(";
    }  
    else {
        cout << "Yay!";
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

int dp[1<<20];

int main(){
  int num_of_coins;
  int change;
  while(~scanf("%d %d",&num_of_coins,&change)){
    if(num_of_coins == 0 && change == 0) break;
    memset(dp,0x3f,sizeof(dp));

    vector<int> coins;
    for(int coin_i = 0; coin_i < num_of_coins; coin_i++){
      int price;
      scanf("%d",&price);
      coins.push_back(price);
    }

    int sum[1<<12] = {};
    for(int S = 0; S < (1<<num_of_coins); S++){
      for(int coin_i = 0; coin_i < num_of_coins; coin_i++){
        if(!(S & (1<<coin_i))) continue;
        sum[S] += coins[coin_i];
      }
    }

    dp[0] = 0;
    for(int S = 0; S < (1<<num_of_coins); S++){
      for(int prev = 0; prev + sum[S] <= change; prev++){
        int next = prev + sum[S];
        dp[next] = min(dp[prev] + 1,dp[next]);
      }
    }

    printf("%d\n",dp[change]);
  }
}

Measured memory_bytes: 5324
#include <iostream>
#include<cmath>
#include <algorithm>
using namespace std;
int main()
{
	int N, X, Y,max,mini;
	cin >> N >> X >> Y;
	if (N >= X + Y) {
		max = min({ X, Y });
		mini = 0;
	}
	else {
		max = min({ X,Y });
		mini = (X + Y)-N;
	}
	cout << max << " "<< mini << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll x;
		cin >> x;
		ll ans = x / 500 * 1000 + (x % 500) / 5 * 5;
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 1; i <= n; i++)
#define vl vector<ll>

int main(){
    ll n,k;cin>>n>>k;
    double sum=0;
   

    rep(i,n){
        double ka =1;
        ll score =i;
       while(score<k){ka=ka/2;score=score*2;}
       
sum+=(ka/n);
    }
cout<<fixed<<setprecision(15);
    cout<<sum<<endl;
}

Measured memory_bytes: 636
package main

import "fmt"

func main() {
	var c [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j< 3; j++ {
			fmt.Scan(&c[i][j])
		}
	}

	var a [3]int
	var b [3]int
	a[0] = 0
	for i := 0; i < 3; i++ {
		b[i] = c[0][i] - a[0]
	}

	for i := 0; i < 3; i++ {
		a[i] = c[i][0] - b[0]
	}

	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if a[i]+b[j] != c[i][j] {
				fmt.Println("No")
				return

			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  ll x;
  cin >> x;
  vector<ll> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  sort(all(a));
  int ans = 0;
  rep(i, N) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }

  if (ans == N && x > 0)
    ans--;

  cout << ans << endl;
}

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

const long long INF = 1LL << 60;
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() {
    int N;
    cin >> N;
    vector<vector<int>> candyMap(2, vector<int>(N));
    for (int y = 0; y < 2; y++) {
        for (int x = 0; x < N; x++) {
            cin >> candyMap[y][x];
        }
    }
    vector<vector<int>> dp(2 + 1, vector<int>(N + 1));
    for (int y = 1; y < 3; y++) {
        for (int x = 1; x < N + 1; x++) {
            chmax(dp[y][x], dp[y - 1][x] + candyMap[y - 1][x - 1]);
            chmax(dp[y][x], dp[y][x - 1] + candyMap[y - 1][x - 1]);
            // cout << "dp[" << y << "][" << x << "]: " << dp[y][x] << endl;
            // cout << "candyMap[" << y - 1 << "][" << x - 1 << "]: " << candyMap[y - 1][x - 1] << endl;
        }
    }
    cout << dp[2][N] << 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>
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>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inps(n, m);
    if(n>m){
        swap(n, m);
    }
    for(int i=0; i<m; i++){
        cout << n;
    }
}

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

#define int long long

using namespace std;

int sz[100001];
int u[100001];

 main () {
    int n, m;
    cin >> n >> m;
    for (int i = 1;i <= n;i ++) sz[i] = 1;
    u[1] = 1;
    while (m --) {
    	int x, y;
    	cin >> x >> y;
    	sz[x] --;
    	sz[y] ++;
    	if (u[x]) u[y] = 1;
    	if (sz[x] == 0) u[x] = 0;
    }
    int ans = 0;
    for (int i = 1;i <= n;i ++) ans += u[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int W, a, b;
  cin >> W >> a >> b;

  if (abs(b - a) < W) cout << 0 << endl;
  else cout << abs(b - a) - W << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  int n;
  cin>>n;
  map<int,int> m;
  int tmp;
  for(int i = 0;i<n-1;i++){
    cin>>tmp;
    m[tmp]++;
  }
  for(int i=1;i<=n;i++){
    cout<<m[i]<<"\n";  
  } 
  return 0;
}


Measured memory_bytes: 12976
#include<bits/stdc++.h>
#define maxn 110
using namespace std;
int a[maxn][maxn];
int main()
{
    //freopen("ototototootot.txt","w",stdout);
    cin.tie(0);ios_base::sync_with_stdio(false);
    int A,B,cur=0;
    cin>>A>>B;
    A--;
    B--;
    for(int i=1;i<=50;i++)
        for(int j=1;j<=100;j++)a[i][j]=1;
    int x=2;
    while(A)
    {
        for(int i=2;i<99;i+=2)
        {
            a[x][i]=0;
            A--;
            if(A==0)break;
        }
        x+=2;
    }
    x=52;
    while(B)
    {
        for(int i=2;i<99;i+=2)
        {
            a[x][i]=1;
            B--;
            if(B==0)break;
        }
        x+=2;
    }
    cout<<100<<" "<<100<<endl;
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)cout<<(a[i][j]==1?'#':'.');
        cout<<endl;
    }
return 0;
}


Measured memory_bytes: 256
import sys
 
x, n = map(int, input().split())
ps = list(map(int, input().split()))
 
# n=0の時の例外処理
if n==0:
  print(x)
  sys.exit()
 
for i in range(0, 101):
  if not((x-i) in ps):
    print(x-i)
    sys.exit()
  if not((x+i) in ps):
    print(x+i)
    sys.exit()

Measured memory_bytes: 9128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    long long N, M;
    cin >> N >> M;

    vector<long long> A(N), B(M);
    for (int i = 0; i < N; i++)cin >> A[i];
    for (int i = 0; i < M; i++)cin >> B[i];

    long long sum_a = accumulate(A.begin(), A.end(), 0LL);
    long long sum_b = accumulate(B.begin(), B.end(), 0LL);

    cout << sum_a * sum_b << endl;

}












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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> v(N);

    for (auto &&x : v)
    {
        cin >> x;
    }

    for (int k = 0; k < N; ++k)
    {
        cout << v[k] << (k != N - 1 ? " " : "\n");
    }

    for (int i = 1; i < N; i++)
    {
        int tmp = v[i];
        int j = i - 1;
        while (j >= 0 && v[j] > tmp)
        {
            v[j + 1] = v[j];
            j--;
        }
        v[j + 1] = tmp;
        for (int k = 0; k < N; ++k)
        {
            cout << v[k] << (k != N - 1 ? " " : "\n");
        }
    }

    return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<class T, std::size_t N>
class bit_t {
public:
  bit_t() {
    memset(bit_, 0, sizeof(bit_));
  };

public:
  T sum(int i) const {
    T s = 0;

    while (i > 0) {
      s += bit_[i];

      i -= i & -i;
    }

    return s;
  };

  void add(int i, T x) {
    assert(i > 0);

    while (i <= N) {
      bit_[i] += x;

      i += i & -i;
    }
  };

private:
  static T bit_[N + 1];
};

template<class T, std::size_t N>
T bit_t<T, N>::bit_[N + 1];


// Nはa_iの最大値
// a_iは1以上(BITの制限)
// a_iは歯抜けでよし(例えば{13, 5, 7}。この転倒数は2)

template<size_t N>
long long inverse_count(int const* s, int const* e)
{
  bit_t<int, N> bit;

  long long c = 0;

  for (int j = 0; s != e; j ++, s ++) {
    c += j - bit.sum(*s);

    bit.add(*s, 1);
  }

  return c;
}


int N, a[111111], b[111111];

bool test(int x)
{
  int c[111111], acc[111111];

  acc[0] = 0;

  for (int i = 0; i < N; i ++)
    acc[i + 1] = (c[i] = a[i] >= x ? 1 : -1) + acc[i];

  int accm = *std::min_element(acc, acc + N + 1);

  for (int i = 0; i < N + 1; i ++)
    acc[i] = acc[i] - accm + 1;

  long long cnt = inverse_count<111111>(acc, acc + N + 1), CNT = 1LL * (N + 1) * N / 2;

  return CNT - cnt >= CNT / 2;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  memcpy(b, a, sizeof(int) * N);

  std::sort(b, b + N);
  
  int n = std::unique(b, b + N) - b;

  int l = -1, u = n;

  while (u - l > 1) {
    int m = (l + u) / 2;

    (test(b[m]) ? l : u) = m;
  }

  std::cout << b[l] << std::endl;

  return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, k;
  string s;
  cin >> n >> s >> k;

  char c = s[k-1];;
  for (auto &e : s) {
    if (e != c) e = '*';
  }

  cout << s << "\n";

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0], 10);
    var vec_P = input[1].map(e => parseInt(e, 10));
    var vec_Q = input[2].map(e => parseInt(e, 10));
    var pi, qi, a, b;
    a = b = 1;
    for (var i = 0; i < (N - 1); i++){
    	pi = vec_P[0];
    	qi = vec_Q[0];
    	
    	vec_P.shift();
    	vec_Q.shift();
    	a += (N - (i + 1) - countAbove(pi, vec_P)) * kaijo(N - (i + 1));
    	b += (N - (i + 1) - countAbove(qi, vec_Q)) * kaijo(N - (i + 1));
    }
	console.log(Math.abs(a-b));
}

function countAbove(num, vec){
	var ans = 0;
	for (var i = 0; i < vec.length; i++){
		if (vec[i] > num) ans++;
	} 
	return ans;	
}

function kaijo(num){
	var ans = 1;
	for (var i = 2; i <= num; i++){
		ans *= i;
	} 
	return ans;	
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		int n=Integer.parseInt(br.readLine());
		String []s=br.readLine().split(" ");
		
		int a[]=new int[n];
		
		for(int i=0;i<n;i++)
			a[i]=Integer.parseInt(s[i]);
					
		boolean flag=true;
		
		for(int i=n-2;i>=0;i--)
		{
			if(a[i] > a[i+1])
				a[i]--;	
		}
		
		for(int i=1;i<n;i++)
		{
			if(a[i]-a[i-1]<0)
			{
				flag=false;
				//break;
			}
		}
		
		if(flag == true)
			System.out.println("Yes");	
		else
			System.out.println("No");		
	}
}




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

typedef long long int ll;

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll flag=0;
  while(1){
    c-=b;
    if(c<=0){
      flag=1;
      break;
    }
    a-=d;
    if(a<=0){
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	
	cin>>n;
	int arr[n],dp[n+1];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		
	}
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	
	cout<< dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
use std::process;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let (a,b) = get!(i32,i32);

    if a < 2 * b {
        println!("0");
        process::exit(0);
    }
    println!("{}", a - 2*b);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 100000000000000

using namespace std;




int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n;
	
	while(cin>>n){
		lint soma = 0;
		vector<lint> num(n), pda(n+1), pd(n+1);
		for(int i=0;i<n;i++){
			cin>>num[i];
			soma += num[i];
		}
		lint ans;
		for(int i=0;i<n;i++){
			for(int j=0; (i+j)<n;j++){
				pd[j] = max(num[j] - pda[j+1], num[i+j] - pda[j]);
			}
			pda = pd;
		}
		
		cout<<pd[0]<<"\n";
		
	}

	return 0;	
}


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

using namespace std;

int main() {
    int P[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout << P[K-1]<< endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include "../cxx-prettyprint/prettyprint.hpp"
using std::vector;

int main() {
    int H, W;
    std::cin >> H >> W;

    vector<vector<char>> s(H, vector<char>(W));
    vector<vector<bool>> black_bits(H, vector<bool>(W, false));
    for (int i = 0; i < H; i ++) {
        for (int j = 0; j < W; j++) {
            std::cin >> s[i][j];
            if (s[i][j] == '#') black_bits[i][j] = true;
        }
    }

    for (int i = 0; i < H; i ++) {
        for (int j = 0; j < W; j ++) {
            if (!black_bits[i][j]) continue;

            bool is_black_up    = i > 0     && black_bits[i - 1][j];
            bool is_black_down  = i < H - 1 && black_bits[i + 1][j];
            bool is_black_left  = j > 0     && black_bits[i][j - 1];
            bool is_black_right = j < W - 1 && black_bits[i][j + 1];

            if (!(is_black_up || is_black_down || is_black_left || is_black_right)) {
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    
public:
    comb(ll mod=1000000007,ll mx=150000):mod(mod),mx(mx){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        for(int i=0;i<63;i++){
            if(x>>i&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        F={1};
        ll a=1;
        for(ll i=1;i<=mx;i++){
            a*=i;
            a%=mod;
            F.push_back(a);
        }
    }
    
    ll c(ll n,ll k){
        if(n<k){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*R(F[n-k])%mod*R(F[k])%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};



int main(){
    ll n,m;
    cin>>n>>m;
    map<ll,ll> M;
    for(ll i=2;i*i<=m;i++){
        while(m%i==0){
            M[i]++;
            m/=i;
        }
    }
    if(m!=1){M[m]++;}
    vector<ll> a;
    for(auto i=M.begin();i!=M.end();i++){
        a.push_back((*i).S);
    }
    comb C;
    ll ans=1;
    for(int i=0;i<a.size();i++){
        ans*=C.c(n+a[i]-1,n-1);
        ans%=MOD;
    }
    ans%=MOD;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long x;
  cin >> n >> x;
  int i;
  long a[n];
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  long cnt = 0;
  if(a[0]>x){
    cnt += a[0]-x;
    a[0]=x;
  }
  for(i=0;i<n-1;i++){
    if(a[i]+a[i+1]>x){
      cnt += a[i]+a[i+1]-x;
      a[i+1] = x-a[i];
    }
  }
  cout << cnt;


}


Measured memory_bytes: 1024
a,b,k = map(int,input().split())
li = []
if 2 * k > b - a:
    for x in range(a,b+1):
        print(x)
else:
    for i in range(k):
        li.append(a + i)
    for i in range(k):
        li.append(b - i)
    for i in sorted(set(li)):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>

using namespace std;

struct Point {
    double x, y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) {
        return;
    }

    Point s, t, u;
    double th = M_PI * 60 / 180;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;

    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;

    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}

int main() {
    Point a, b;
    int n;
    cin >> n;

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int modpow(ll x, ll n){
    int res = 1;
    while(n){
        if(n % 2) res = (ll)res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }

    return res;
}

int choose(ll n, ll x){
    ll y = 1, z = 1;
    for (int i = n - x + 1; i <= n; ++i) {
        z *= i;
        z %= MOD;
    }
    for (int i = 1; i <= x; ++i) {
        y *= i;
        y %= MOD;
    }

    int res = modpow(y, MOD-2) % MOD;
    return z * res % MOD;
}

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow(2, n) - 1;

    ans = (ans + MOD - choose(n, a)) % MOD;
    ans = (ans + MOD - choose(n, b)) % MOD;

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],t[200005],b[200005],sum;
signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)scanf("%d",&a[i]),t[a[i]]++;//桶存储每个数出现次数
	for(int i=1; i<=n; i++)
		if(t[i]>1)//t[i]<=1时，对答案是没有影响的
		{
			int q=t[i];
			t[i]=(t[i]-1)*t[i]/2;//计算次数
			sum+=t[i];//累加
            b[i]=q-1;
		}
	for(int i=1; i<=n; i++)cout<<sum-b[a[i]]<<endl; 
}

Measured memory_bytes: 6272