akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////
vmint f, finv, inv;

void cominit(ll N) {
	f.assign(N + 1, 1);
	finv.assign(N + 1, 1);
	inv.assign(N + 1, 1);
	inv[1] = 1;

	repn(i, N) {
		f[i] = f[i - 1] * i;
		if (i > 1)inv[i] = -inv[MOD % i] * (MOD / i);
		finv[i] = finv[i - 1] * inv[i];
	}
}

mint com(ll a, ll b) {
	if (a < 0 || b < 0 || a < b) { return 0; }
	return f[a] * finv[b] * finv[a - b];
}

int main() {
	ll S;
	cin >> S;

	mint ans = 0;
	cominit(10000);
	repn(i, S) {
		if (3 * i > S) { break; }
		ll t = S - 3 * i;
		ans += com(t + i - 1, i - 1);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3868
s = str(input())
disp = ""

for i in range(0, len(s)):
  if s[i] == "1":
    disp = disp + "1"
  if s[i] == "0":
    disp = disp + "0"
  if s[i] == "B":
    if len(disp) != 0:
      disp = disp[:-1]
    else:
      disp == ""
print(disp)

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

#define ll long long int
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    
    int a[n][3];
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++)
            cin>>a[i][j];
            
    int dp[n][3];
    for(int i=0;i<3;i++)
        dp[0][i]=a[0][i];
    
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][1], dp[i-1][0]);
    }
    
    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

#define N 500000

void insert(int);
void maxHeapify(int);
void buildMaxHeap();

int H[N];
int heapSize;


int main()
{
  int n, i, key;
  heapSize=0;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    {
      scanf("%d", &key);
      insert(key);
    }
  buildMaxHeap();
  for(i=0; i<n; i++)
    {
      printf(" %d", H[i]);
    }
  printf("\n");
  return 0;
}
void insert(int key)
{
  H[heapSize] = key;
  heapSize++;
}
void maxHeapify(int i)
{
  int maxi=i;
  int tmp;

  if((i+1)*2 <= heapSize)
    {
      if(H[(i+1)*2 -1] >= H[i])
	maxi = (i+1)*2 -1;
    }
  if((i+1)*2 +1 <= heapSize)
    if(H[(i+1)*2] >= H[i])
      if(H[(i+1)*2] >= H[maxi])
	maxi = (i+1)*2;

  if(maxi != i)
    {
      tmp = H[i];
      H[i] = H[maxi];
      H[maxi] = tmp;
      
      maxHeapify(maxi);
    }
}
void buildMaxHeap()
{
  int i;
  for(i=heapSize/2 -1; i>=0; i--)
    maxHeapify(i);
}
 

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

int main() {
  int N, sum = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  for (int i = 0; i < N-1; i++) sum += vec.at(i);
  if (vec.at(N-1) < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n,c,k;
    cin >> n >> c >> k;
    ll a[n];
    ll x=0;
    ll t;
    ll ans=1;
    for (ll i=0;i<n;i++){
        cin >> a[i];
    }
  	sort(a,a+n);
  	t=a[0];
  	for (ll i=0;i<n;i++){
      	x++;
        if (a[i]-t>k or x>c){
            x=1;
          	t=a[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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




using namespace std;



int main() {
	long long int W, H;
	cin >> W >> H;
	vector<long long int>P( W ), Q( H );
	for( size_t i = 0; i < W; i++ ) {
		cin >> P[i];
	}
	for( size_t i = 0; i < H; i++ ) {
		cin >> Q[i];
	}

	sort( P.begin(), P.end() );
	sort( Q.begin(), Q.end() );
	long long int Pi = 0, Qi = 0;
	long long int ans = 0;
	while( Pi < W || Qi < H ) {
		if( Pi == W ) {
			ans += Q[Qi];
			Qi++;
			continue;
		}
		if( Qi == H ) {
			ans += P[Pi];
			Pi++;
			continue;
		}
		if( P[Pi] < Q[Qi] ) {
			ans += P[Pi] * (H - Qi + 1);
			Pi++;
		} else {
			ans += Q[Qi] * (W - Pi + 1);
			Qi++;
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
// 幅優先探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

#include<queue>

using namespace std;

#define MAX_N 100
// 値の定義
const int INV = -1;
const int EXIST = 1;
const int NO_EXIST = 0;

const int YES = 0;
const int NO = -1;

// グラフ情報を保持する配列
int ary_graph[MAX_N + 1][MAX_N + 1];

// 頂点１からの距離を保持する配列
int vertex_distance[MAX_N + 1];
// 頂点１からの訪問状態を保持する配列
int ary_visit[MAX_N + 1];

int n = 0;
int nt[MAX_N + 1];

void widthFirstSearch(int start_vertex);

int main(void)
{
    int u, num, v_num;

    for(int i = 0; i < MAX_N + 1; i++)
    {
    	vertex_distance[i] = 0;
        ary_visit[i] = NO;

        for(int j = 0; j < MAX_N + 1; j++)
        {
            // 配列の初期化
            ary_graph[i][j] = NO_EXIST;
        }
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u >> num;

        // 0オリジンにする
        u--;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;

            // 0オリジンにする
            v_num--;
            ary_graph[u][v_num] = EXIST;
        }
    }

    // 頂点１から幅優先探索を実施
    widthFirstSearch(0);

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        if( i != 0 && vertex_distance[i] == 0 )
        {
            // 開始点から到達不可能な点は, 距離に-1を設定
            // ただし, 開始点自身は除く
            vertex_distance[i] = INV;
        }

        printf("%d %d\n", i + 1, vertex_distance[i]);
    }

    return 0;
}

// u に隣接する v を番号順に取得
int next(int u)
{
    int ret = INV;

    for(int v = nt[u]; v < n; v++)
    {
        nt[u] = v + 1;

        if( ary_graph[u][v] == EXIST )
        {
            // 隣接点が存在する
            ret = v;
            break;
        }
    }

    return ret;
}

// 幅優先探索を実施する関数
// start_vertex : 起点となる頂点のNo.
// vertex_num : グラフの頂点数
void widthFirstSearch(int start_vertex)
{

    queue<int> Q;

    Q.push(start_vertex);
    vertex_distance[start_vertex] = 0;
    ary_visit[start_vertex] = YES;

    while( !Q.empty() )
    {
        int u = Q.front();

        for(int i = 0; i < n; i++)
        {
            // 隣接点を全て検索する
            int v = next(u);

            if( v == INV )
            {
                // 隣接点が無くなったらキューから削除して, 処理終了
                Q.pop();
                break;
            }

            if( ary_visit[v] == NO
                && ary_graph[u][v] == EXIST )
            {
                // 訪問済み
                ary_visit[v] = YES;

                Q.push(v);
                vertex_distance[v] = vertex_distance[u] + 1;
            }
        }
    }

    return;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, x[1010], y[1010], z[1010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	
	i64 dx[8] = {1,1,1,1,-1,-1,-1,-1},dy[8] = {1,1,-1,-1,1,1,-1,-1},dz[8] = {1,-1,1,-1,1,-1,1,-1};
	i64 ans = 0;
	for(int k = 0; k < 8; k++){
		i64 cnt[1010] = {0};
		for(int i = 0; i < n; i++){
			cnt[i] += x[i]*dx[k] + y[i]*dy[k] + z[i]*dz[k];
		}
		sort(cnt, cnt+n);
		
		i64 c = 0;
		for(int i = 1; i <= m; i++){
			c += cnt[n-i];
		}
		ans = max(ans, c);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
ll INF = (1LL << 60) - 1;
int MOD = 1e9+7;
ll N, K;
vector<ll> A,B;
bool judge(ll lim){
    ll cnt = 0;
    rep(i,0,N){
        ll k = (A[i] * B[i] - lim + B[i] - 1) / B[i];
        k = max(k, 0LL);
        cnt += k;
    }
    return cnt <= K;
}
main(){
    
    cin >> N >> K;
    A.resize(N);
    B.resize(N);
    rep(i,0,N)cin >> A[i];
    rep(i,0,N)cin >> B[i];
    sort(A.begin(), A.end());
    sort(B.rbegin(), B.rend());

    //rep(i, 0, N) cout << A[i] << " \n"[i == N - 1];
    //rep(i, 0, N) cout << B[i] << " \n"[i == N - 1];
    
    ll ok = INF, ng = -1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        //cout << mid << endl;
        if(judge(mid)){
            //cout << "ok" << endl;
            ok = mid;
        }else{
            //cout << "ng" << endl;
            ng = mid;
        }
    }
    cout << ok << endl;
}

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

int main(){
  int x;
  cin>>x;
  for(int i=1;i<=9;i++){
    for(int j=0;j<=9;j++){
      if(x==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

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


void solve(long long N, std::vector<long long> A){
    map<long long,int> m;

    for(long long i=0; i<N; i++) {
        m[A[i]] = (m[A[i]] + 1) % 2;
    }
    long long count1=0;
    for(auto i = m.begin(); i != m.end(); ++i) {
        if (i->second == 1) count1++;
    }
    cout << count1 << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 7296
parseInt x = read x :: Int

solve :: [Int] -> String
solve input =
    case input of [a, b, c] -> if a + b == c || b + c == a || c + a == b then "Yes"
                               else "No"
                  _         -> "Invalid input"

main :: IO()
main = do
    line <- getLine
    let input = Prelude.map parseInt . words $ line
    putStrLn $ solve input


Measured memory_bytes: 3844
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int n,m,q,res;
vector<int> path;
const int N = 55;
int a[N],b[N],c[N],d[N];
void dfs(int u,int last)
{
	if(u == n + 1)
	{
		// for(int i = 1;i <= n;++i)
			// cout << path[i] << " ";
		// cout << endl;
		int sum = 0;
		for(int i = 1;i <= q;++i)
			if(path[b[i]] - path[a[i]] == c[i])	sum += d[i];
		res = max(res,sum);
		return ;
	}
	for(int i = last;i <= m;++i)
	{
		path.push_back(i);
		dfs(u + 1,i);
		path.pop_back();
	}
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m >> q;
	for(int i = 1;i <= q;++i)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(0,1);
	cout << res;
    return 0;
}


Measured memory_bytes: 3652
class UnionFind(object):
    def __init__(self, n):
        self.parent = {i: i for i in range(n)}
        self.rank = {i: 0 for i in range(n)}
        self.size = {i: 1 for i in range(n)}
    
    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])

        return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y

        else:
            self.parent[y] = x

            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

        self.size[x] += self.size[y]
        self.size[y] = self.size[x]


    def get_size(self, x):
        return self.size[self.find(x)]


n, m = map(int, input().split())
tree = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree.union(a, b)

print(len({tree.find(i) for i in range(n)}) - 1)


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

#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nrep(i,a,b) for(int i=int(a);i>=int(b);--i)
#define trv(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define watch(x) cout<<"\n"<<#x<<" is "<<x<<"\n"
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define ZERO(box) memset(box, 0, sizeof(box));
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define chkbit(s, b) (s & (1<<b))
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1e9+7;


void solve(){
	ll n;
	cin>>n;
	cout<<(n*(n+1))/2;
}


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		String g = sc.next();
		//long n = sc.nextLong();
		//long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;

		/*for(int i=1;i<10000;i++) {
			if(n<500*(i+1)) {
				count=i;
				break;
			}
		}*/
		/*if(500*count+m>=n) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}*/
		//System.out.println((int)Math.ceil((n+m)/2.0));
		System.out.println(s.substring(0,1)+t.substring(1,2)+g.substring(2,3));
	}
}




Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int a, b, m;
    cin>>a>>b>>m;
    vector<int> A(a);
    vector<int> B(b);
    int mina=pow(10, 9);
    int minb=pow(10, 9);
    for(int i=0; i<a; i++){
        cin>>A.at(i);
        mina=min(mina, A.at(i));
    }
    for(int i=0; i<b; i++){
        cin>>B.at(i);
        minb=min(minb, B.at(i));
    }
    
    vector<vector<int>> c(m, vector<int> (3));
    for(int i=0; i<m; i++){
        for(int j=0; j<3; j++){
            cin>>c.at(i).at(j);
        }
    }
    
    long long int ans=mina+minb;
    for(int i=0; i<m; i++){
        long long int preans=A.at(c.at(i).at(0)-1)+B.at(c.at(i).at(1)-1)-c.at(i).at(2);
        ans=min(ans, preans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn prime_factors(n: usize) -> Vec<(usize, usize)> {
    let mut result = vec![];
    let mut m = n;
    for d in 2.. {
        if d * d > n {
            break;
        }
        let mut count = 0;
        while m % d == 0 {
            count += 1;
            m /= d;
        }
        if count > 0 {
            result.push((d, count));
        }
    }
    if m > 1 {
        result.push((m, 1));
    }
    result
}

fn inv(a: usize) -> usize {
    let m = M as i64;
    let mut a = a as i64;
    let mut b = m as i64;
    let mut u = 1;
    let mut v = 0;
    let mut tmp;
    while b != 0 {
        let t = a / b;
        a -= t * b;
        tmp = a;
        a = b;
        b = tmp;
        u -= t * v;
        tmp = u;
        u = v;
        v = tmp;
    }
    u %= m;
    if u < 0 {
        u += m;
    }
    return u as usize;
}

struct Combination {
    m: usize,
    f: Vec<usize>,
    g: Vec<usize>,
}

impl Combination {
    fn new(m: usize) -> Combination {
        Combination {
            m,
            f: vec![1],
            g: vec![1],
        }
    }

    fn combinations(&mut self, n: usize, k: usize) -> usize {
        for i in self.f.len()..=n {
            self.f.push(self.f[i - 1] * i % self.m);
            self.g.push(inv(self.f[i]));
        }
        self.f[n] * self.g[k] % self.m * self.g[n - k] % self.m
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let mut c = Combination::new(M);
    let mut result = 1;
    for &(_, k) in &prime_factors(m) {
        result = result * c.combinations(n + k - 1, k) % M
    }
    println!("{}", result);
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M_PI 3.14159265359
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double hour_hand=30*h+30*((double)m/60);
    double min_hand=6*m;
    //cout<<hour_hand<<" "<<min_hand<<endl;
    double diff=hour_hand-min_hand;
    
    if(diff<0)diff*=-1;
    diff=min(diff,360-diff);
    //cout<<diff<<endl;
    diff*=M_PI;
    diff/=180;
    //cout<<diff<<endl;
    double ans=sqrt(pow(a,2)+pow(b,2)-((double)2*a*b*cos(diff)));
    printf("%.12f",ans);
    //cout<<ans;
    return 0;
}

Measured memory_bytes: 4248
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string s;
  ll k;
  cin >> s >> k;
  if(s[0]!='1'){
    cout << s[0] << endl; return 0;
  }
  int n=s.size();
  ll cnt = 0;
  while(cnt<n && s[cnt]=='1' ){ cnt++; }
  cnt--;
  if(cnt>=k-1){
    cout << '1' << endl; return 0;
  }
  cout << s[cnt+1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)

lld arr[111111],ans,dp[111111];
int main(void){
	int n;
	scanf("%d",&n);
	n++;
	lld tot = 0;
	for(int e=0;e<n;e++){
		scanf("%lld",&arr[e]);
		tot += arr[e];
	}
	if(n==1){
		if(arr[0]==1) printf("1");
		else printf("-1");
		return 0;
	}
	for(int e=n-1;e>=0;e--) dp[e] = dp[e+1] + arr[e];
	if(arr[n-1]==0||arr[0]){
		printf("-1");
		return 0;
	}
	lld ll = 1;
	for(int e=1;e<n;e++){
		ll *= 2;
		if(ll<arr[e]){
			printf("-1");
			return 0;
		}
		ll -= arr[e];
		ll = min(ll,dp[e+1]);
		tot += ll;
	}
	printf("%lld",tot+1);
	return 0;
}


Measured memory_bytes: 5392
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 301;
int a[4];
double n, dp[N][N][N]; //dp[i][j][k] - expected number of operations with i plates of 1 sushi, j plates of 2 sushi, k plates of 3 sushi, and n-i-j-k plates of 0 sushi

double rec(int i, int j, int k) {
	if(i < 0 || j < 0 || k < 0) return 0;
	double& memo = dp[i][j][k];
	if(memo != -1) return memo;
	return memo = (n + i*rec(i-1, j, k) + j*rec(i+1, j-1, k) + k*rec(i, j+1, k-1))/(i+j+k);
}

signed main() {
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    REP(i, N) REP(j, N) REP(k, N) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    cin >> n;
    REP(i, n) {
    	int x;
    	cin >> x;
    	++a[x];
    }
    cout << rec(a[1], a[2], a[3]) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


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

int main()
{
	double a[6], x, y;

	while(cin>>a[0]){
		for(int i = 1; i < 6; i++){
			cin>>a[i];
		}
		y = (a[2]*a[3]-a[0]*a[5])/(a[1]*a[3]-a[0]*a[4]);
		x = (a[2]-a[1]*y)/a[0];


		if(x >= 0) x = ((double)((int)(x*1000+0.5)))/1000;
		else x = ((double)((int)(x*1000-0.5)))/1000;
		if(y >= 0) y = ((double)((int)(y*1000+0.5)))/1000;
		else y = ((double)((int)(y*1000-0.5)))/1000;

		printf("%.03f %.03f\n", x, y);
	}
}

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

using namespace std;

int main() {
  long long H, W;
  cin >> H >> W;
  long long C = H * W;
  if (H > 1 && W > 1) {
    if (C % 2 == 0) {
      cout << C / 2 << endl;
    } else {
      cout << (C + 1) / 2 << endl;
    }
  } else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 3556
#include<stdio.h>
#include<math.h>
 
int main(void)
{
 int d;
 int i;
 int S ;
 while(scanf("%d",&d) != EOF)
 {
  S = 0;
  for(i = 1; i < 600/d; i++)
  {
   S += d * pow(i * d,2);
  }
  printf("%d\n",S);
 }
 return (0);
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int main(){
    int n, max_w;
    cin >> n >> max_w;
    vector<vint> dp(n+1, vint(max_w+1, 0));
    // dp[i][j] = v; は、i番目までの品物で、重さj以下においてvの価値を持つ。
    rep(i,n){
        int v, w;
        cin >> v >> w;
        rep(j, max_w+1){
            if(j < w){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w] + v);
            }
        }
    }
    // rep(i,n+1){
    //     rep(j,max_w+1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout <<endl;
    // }
    cout << dp[n][max_w] << endl;
}



Measured memory_bytes: 6840
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
int n, q, n2;
vector<ll> node, lazy;

void eval(int k, int l, int r){
    node[k] += lazy[k];
    if(r - l > 1){
        lazy[k * 2 + 1] += lazy[k] / 2;
        lazy[k * 2 + 2] += lazy[k] / 2;
    }
    lazy[k] = 0;
}

void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
    if(r < 0) r = n2;

    eval(k, l, r);

    if(b <= l || r <= a) return;
    if(a <= l && r <= b){
        lazy[k] += x *(ll)(r - l);
        eval(k, l, r);
        return;
    }
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
}

ll get(int a, int b, int k = 0, int l = 0, int r = -1){
    if(r < 0) r = n2;

    eval(k, l, r);
    if(b <= l || r <= a) return 0;
    if(a <= l && r <= b) return node[k];
    ll vl = get(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = get(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;
}

void init(){
    cin >> n >> q;
    n2 = 1;
    while(n2 < n) n2 <<= 1;
    node.resize(n2 * 2);
    lazy.resize(n2 * 2);
}

void solve(){
    for(int i= 0; i < q; i++){
        int query;
        cin >> query;
        if(query){
            int g;
            cin >> g;
            cout << get(g - 1, g) << endl;
        }else{
            int s, t, x;
            cin >> s >> t >> x;
            add(s - 1, t, x);
        }
    }
}

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


Measured memory_bytes: 7056
#include <iostream>

using namespace std;

int main() {
string s;
cin>>s;
int arr[26]={0};

for(int i=0;i<s.size();i++){
arr[s[i]-'a']++;
}

for(int j=0;j<26;j++){
	
if(arr[j]==0){char c = j+'a';cout<<c;return 0;}
}
cout<<"None";


}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int i, n, x;
    cin >> n;
    for(i=1;i<=n;i++){
        x = i;
        if(x % 3 == 0)
            cout << " " << i;
        else  {
            while(x >= 10 | x == 3) {
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}

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

#define Art Code
#define Artist Shivam Gupta
#define MoT This Art belongs to Artist
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FoR(i,s,x) for(i=s-1;i>=x;i--)
#define ForE(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define mod 1000000007
#define MAX 200005

int main() {
    FASTIO;
    ll t=1, i, j, k, l;
    // cin>>t;
    W(t--) {
        ll n, m;
        cin>>n>>m;
        ld p[n+1], q[n+1];
        Fore(i,1,n) cin>>p[i];
        Fore(i,1,n) q[i]=1-p[i];
        ld R[n+1][n+1]={};
        R[0][0]=1;
        Fore(i,1,n) {
            Fore(j,0,i) {
                if(j>0) R[i][j]+=R[i-1][j-1]*p[i];
                if(j<n) R[i][j]+=R[i-1][j]*q[i];
            }
        }
        ld ans=0;
        Fore(i,n/2+1,n) ans+=R[n][i];
        cout<<fixed<<setprecision(10)<<ans;
        nl;
    }
    return 0;
}

Measured memory_bytes: 144424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll k;
  cin>>k;
  vector<ll> used(k,1e9);


  deque<P> q;
  q.push_back(P(1,1));
  while(!q.empty()){
    ll s=q.front().fi;
    ll w=q.front().se;
    q.pop_front();
    if(used[s]<1e9) continue;
    if((w*10)%k==s) used[s]=used[w];
    else used[s]=used[w]+1;
    used[1]=1;
    if(s==0) {
      cout<<used[s]<<endl;
      return 0;
    }
    if(used[(s*10)%k]==1e9) q.push_front(P((s*10)%k,s));
    if(used[(s+1)%k]==1e9) q.push_back(P((s+1)%k,s));
  }

  return 0;

}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    string s;
    cin >> s;
    char c1, c2;
    c1 = s[0];
    bool flag = false;
    if (s[1] == c1) {
        c2 = s[2];
        if (s[3] == c2) {
            flag = true;
        }
    }
    else {
        c2 = s[1];
        if ((c1 == s[2] || c1 == s[3]) && (c2 == s[2] || s[3] == c2)) {
            flag = true;
        }
    }
    if (c1 == c2) {
        flag = false;
    }

    if (flag) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}
 
void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

const int maxn = 2e5+10;
const int inf = 1e9;
const lf eps = 1e-8;

int mx,mn=1e9,n,mn1=1e9,mx1;
struct data{
    int x,y;
    bool operator < (const data &rhs) const {return x<rhs.x;}
}a[maxn];

signed main() {
    read(n);
    for(int i=1;i<=n;i++) {
        read(a[i].x),read(a[i].y);if(a[i].x>a[i].y) swap(a[i].x,a[i].y);
        mx=max(mx,a[i].y),mn=min(mn,a[i].x);
        mn1=min(mn1,a[i].y),mx1=max(mx1,a[i].x);
    }sort(a+1,a+n+1);
    int ans=(mx-mn1)*(mx1-mn),res,mn2=a[1].y,mx2=a[1].y;
    res=max(a[1].y,a[n].x)-min(a[1].y,a[2].x);
    for(int i=2;i<=n;i++) {
        mn2=min(mn2,a[i].y),mx2=max(mx2,a[i].y);
        if(i!=n) res=min(res,max(mx2,a[n].x)-min(mn2,a[i+1].x));
    }ans=min(ans,res*(mx-mn));
    write(ans);
    return 0;
}


Measured memory_bytes: 3328
#encoding:utf-8 No.0013 2014.10.1
shed = []
while gets
  shed.push $_.chomp.to_i
end

cars_out = []

until shed.length == 0
  shed.length.times do |i|
    if shed[i] == 0
      cars_out.push shed[i-1]
      shed.delete_at(i)
      shed.delete_at(i-1)
      break
    end
  end
end

puts cars_out

Measured memory_bytes: 6092
def do_max_counter():
    N, X = map(int, input().split())
    m = []
    for _ in range(N):
        m.append(int(input()))
    count = len(m)
    m_min = min(m)

    X = X - sum(m)

    while X >= m_min:
        X = X - m_min
        count = count + 1

    print(count)

if __name__ == '__main__':
    do_max_counter()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<long long> > dp(3001, vector<long long> (3001, -1));
vector<long long> A;
long long solve(int i ,int j)
{
    if(i>j)
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    int p = (j-i+1)%2;
    if(p==m)
    {
       dp[i][j] = max(A[i]+ solve(i+1,j), solve(i,j-1)+A[j]);
    }
    else
       dp[i][j] = min( solve(i+1,j) - A[i], solve(i,j-1)-A[j]);

    return dp[i][j];
}
int main()
{
   cin>>n;
   A.resize(n);
   for(int i=0; i<n; i++)
      cin>>A[i];

   m = n%2;
   long long ans = solve(0,n-1);
   cout<<ans;
   return 0;

}


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

using namespace std;
typedef long long ll;
    
int main()
{
    char s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    int result = 0;
    if (s1 == '1') { result++; }
    if (s2 == '1') { result++; }
    if (s3 == '1') { result++; }
    cout << result;

    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 50
i64 N;
i64 A[MAX_N + 1]; // 1-indexed


int main() {
  cin >> N;
  REPS(i, N) cin >> A[i];

  i64 not_aligned = 0;
  i64 can_swap = 0;
  REPS(i, N) {
    if (A[i] != i) {
      not_aligned++;
      if(A[A[i]] == i) can_swap++;
    }
  }
  if (can_swap <= 2 && not_aligned <= 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{int A,B,C,D,N,K,S,X,Y,Z,k,l,i,m,tmp;
	scanf("%d%d%d%d",&A,&B,&C,&D);
	tmp=0;
	printf("%d",((A*B>=C*D)?A*B:C*D));


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
    
using namespace std; 
    
long long int gcd(long long int a, long long int b) 
{   
  if (a%b==0) 
  { 
    return(b); 
  } else { 
    return(gcd(b,a%b)); 
  } 
}   
    
vector<long long int> divisor(long long int n) { 
  vector<long long int> ret; 
  for(long long int i = 1; i * i <= n; i++) { 
    if(n % i == 0) { 
      ret.push_back(i); 
      if(i * i != n) ret.push_back(n / i); 
    } 
  } 
  return (ret); 
}   

bool IsPrime(long long int num) 
{ 
    if (num < 2) return false; 
    else if (num == 2) return true; 
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く 
 
    double sqrtNum = sqrt(num); 
    for (long long int i = 3; i <= sqrtNum; i += 2) 
    { 
        if (num % i == 0) 
        { 
            // 素数ではない 
            return false; 
        } 
    } 
 
    // 素数である 
    return true; 
} 
 
int main() { 
  int ans = 0; 
  long long int A, B; 
  cin >> A >> B; 
 
  long long int _gcd = gcd(A, B); 
  vector<long long int> divisors = divisor(_gcd); 
 
  for (long long int i = 0; i < (long long int)divisors.size(); i++) { 
    if (IsPrime(divisors[i])) ans++; 
  } 
  ans++; // 1は必ず含まれる。 

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

Measured memory_bytes: 384
N = int(input())
Ps = []
for n in range(N):
    Ps.append(int(input()))

counter = [0] * (N + 1)

for p in Ps:
    counter[p] = counter[p-1] + 1

ans = 0
for c in counter:
    ans = max(ans, c)
print(N - ans)


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

int main(){
  int a,b,b2,res;
  cin >> a >> b;

  b2=b*2;
  res=0;
  if(a>b2){
    res=a-b2;
  }else{
    res=0;
  }

  cout << res << endl;
  return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;



signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	vector<int>cnt(N);
	REP(i,N){
		cin >> a[i];
		++cnt[--a[i]];
	}
	int ans = 0;
	REP(i,N){
		ans += (cnt[i] - 1) * cnt[i] / 2;
	}
	REP(i,N){
		int tmp = ans;
		tmp -= (cnt[a[i]] - 1) * cnt[a[i]] / 2;
		--cnt[a[i]];
		tmp += (cnt[a[i]] - 1) * cnt[a[i]] / 2;
		++cnt[a[i]];
		out(tmp);
	}
}

Measured memory_bytes: 5760
h,n=map(int,input().split())
a,b=[],[]
for i in range(n):
    a_sub,b_sub=map(int,input().split())
    a.append(a_sub)
    b.append(b_sub)
inf=10000000000000
ma=max(a)
dp=[inf]*(h+1+ma)
dp[0]=0
for i in range(n):
    x=[a[i],b[i]]
    for j in range(h+1+ma):
        if dp[j]!=inf:
            if j+x[0]<=h+ma:
                dp[j+x[0]]=min(dp[j+x[0]],dp[j]+x[1])
            else:
                break
print(min(dp[h:]))

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

int main() 
{
    long long x,i,j,k;
    scanf("%lld",&x);
    i=x/500;
    x=x-500*i;
    j=x/5;
    printf("%lld",1000*i+5*j);
    return 0;
}








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

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
    private static StringTokenizer st;

    public static void main ( String [] args ) throws IOException
    {
	new Main().cal();
    }

    private class Card {
	public char pattern;
	public int num;
	public int order;

	public String toString() {
	    return pattern + String.valueOf(num);
	}
    }

 
    private void cal() throws IOException 
    {
	int N = Integer.parseInt(br.readLine());
	Card [] cards = new Card[N];
	st = new StringTokenizer(br.readLine());


	for(int i = 0; i < cards.length; i++) {
	    String s = st.nextToken();
	    cards[i] = new Card();
	    cards[i].pattern = s.charAt(0);
	    cards[i].num = Integer.parseInt(s.substring(1));
	    cards[i].order = i;
	}

	Card [] c1 = BubbleSort(cards);
	Card [] c2 = SelectionSort(cards);

	for(int i = 0; i < c1.length; i++) {
	    if ( i > 0 ) System.out.print(" ");
	    System.out.print(c1[i]);
	}
	System.out.println("");

	if ( isStable(c1) ) System.out.println("Stable");
	else System.out.println("Not stable");

	


	for(int i = 0; i < c2.length; i++) {
	    if ( i > 0 ) System.out.print(" ");
	    System.out.print(c2[i]);
	}
	System.out.println("");

	if ( isStable(c2) ) System.out.println("Stable");
	else System.out.println("Not stable");



	

    }

    private Card[] BubbleSort(final Card[] c) {
	assert c!= null;

	Card[] ret = (Card[])c.clone();
	
	//	System.out.println("ret length: " + ret.length + "ret[0] : " + ret[0]);

	for(int i = 0; i < ret.length; i++) {
	    for(int j = ret.length -1; j >= i+1; j--) {
		if ( ret[j].num < ret[j-1].num ) 
		    swap(ret, j, j-1);
	    }

	}

	return ret;
    }

    private Card[] SelectionSort(final Card[] c) {
	assert c != null;

	Card[] ret = (Card[])c.clone();
	for(int i = 0; i < ret.length; i++) {
	    int mini = i;
	    for(int j = i; j < ret.length; j++) {
		if ( ret[j].num < ret[mini].num ) mini = j;
	    }
	    if ( mini != i ) swap(ret, i, mini);
	}

	return ret;
    }

    private void swap(Object [] o, final int i, final int j) {
	Object temp = o[i];
	o[i] = o[j];
	o[j] = temp;
    }

    private boolean isStable(final Card [] c) {
	assert c != null;
	
	for(int i = 0; i < c.length-1; i++) {
	    if ( c[i].num == c[i+1].num && c[i].order > c[i+1].order ) return false;
	}
	
	return true;

    }
    
}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	string S, T;
	cin >> S >> T;

	string copy = S + S;
	// cout << copy << endl;
	rep(i, (int)(S.size())){
		rep(n, (int)(T.size())){
			// cout << "1" << endl;
			// cout << copy.at(i + n) << T.at(n) << endl;
			if (copy.at(i + n) != T.at(n)) break;
			if (n + 1 == (int)(T.size())){
				cout << "Yes" << endl;
				return 0;
			}
			// cout << "o" << endl;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
B = [[] for _ in range(M+1)]
q = []
ans = 0
for i in range(N):
    a, b = map(int, input().split())
    if a>M:
        continue
    B[M-a].append(b)
for i in range(M+1)[::-1]:
    for b in B[i]:
        heapq.heappush(q, -b)
    if q:
        m = -heapq.heappop(q)
        ans+=m
print(ans)
    
    

Measured memory_bytes: 72224
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ll T[2],A[2],B[2];
  ll count = 0;
  ll times = 0;
  cin >> T[0] >> T[1];
  cin >> A[0] >> A[1];
  cin >> B[0] >> B[1];
  ll interval = (A[0]*T[0] + A[1]*T[1]) - (B[0]*T[0]+B[1]*T[1]);
  if(interval==0) {
    cout << "infinity" << endl;
    return 0;
    }
  if(not(A[0]>B[0] xor A[1]>B[1])) {
    cout << 0 << endl;
    return 0;
    }
  if(not(A[0]>B[0] xor interval>0)) {
    cout << 0 << endl;
    return 0;
    }

  count = (A[0]*T[0] - B[0]*T[0])/interval;
  int count2 = (A[0]*T[0] - B[0]*T[0]) % interval;
  count = abs(count);
  if(count2!=0)times = 2*count+1;
  else times = 2*count;
  cout << times << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    if (a > b) {
        cout << a - 1;
    } else {
        cout << a;
    }
    cout << endl;

    return 0;
}



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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c) cout <<"Yes"<<endl;
  else if(b+c==a) cout<<"Yes"<<endl;
  else if(c+a==b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let mut vec: Vec<i32> = (0..3).map(|_| read()).collect();
    vec.sort();

    let max = vec[2];
    let middle = vec[1];
    let mut min = vec[0];

    let mut count = 0;
    count += max-middle;

    min+=(max-middle);

    if (max-min) % 2 == 0 {
        count += (max-min) / 2;
    } else {
        count += (max-min)/2 + 2;
    }

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

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 gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4352