akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> route;
	long long n, k;
	cin >> n >> k;
	int a[n];
	bool vis[200007] = {false};
	for(int i = 1; i <= n; i++) cin >> a[i];
	vis[1] = true;
	int x = 1;
	int st, len1 = 1, len2 = 0;
	while(true){
		if(vis[a[x]] == true){
			st = a[x]; break;
		}
		vis[a[x]] = true;
		x = a[x];
		len1++;
	}
	x = st;
	memset(vis, false, sizeof(vis));
	while(true){
		if(vis[a[x]] == true) break;
		vis[a[x]] = true;
		x = a[x];
		len2++;
	}
//	cout << len1 << " " << len2 << endl;
	if(k < len1){
		x = 1;
		for(int i = 0; i < k; i++){
			x = a[x];
		}
		cout << x << endl;
	}else{
		k -= len1;
		k %= len2;
		x = st;
		for(int i = 0; i < k; i++) x = a[x];
		cout << x << endl;
	}
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    string S, T;
    cin >> S >> T;
    vector<vector<bool>> match(26, vector<bool>(26, false));
    vector<vector<bool>> match2(26, vector<bool>(26, false));
    vector<int> cnt(26, 0);

    bool flag = true;
    rep(i, S.size()) {
        match[S[i] - 'a'][T[i] - 'a'] = true;
        match2[T[i] - 'a'][S[i] - 'a'] = true;
    }

    rep(i, 26) {
        int cnt = 0;
        rep(j, 26) {
            if (match[j][i]) cnt++;
        }
        if (cnt >= 2) {
            flag = false;
            break;
        }
    }

    rep(i, 26) {
        int cnt = 0;
        rep(j, 26) {
            if (match2[j][i]) cnt++;
        }
        if (cnt >= 2) {
            flag = false;
            break;
        }
    }

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

    return 0;
}

Measured memory_bytes: 900
n,m= map(int, input().split())
ab_list=[]
for _ in range(n):
    a, b = map(int, input().split())
    ab_list.append([a,b])
ab_list.sort()

import heapq
l = []
heapq.heapify(l)

ind=0
ans=0
for i in range(1,m+1):
    while n>ind and ab_list[ind][0] <= i:
        heapq.heappush(l,-ab_list[ind][1])
        ind+=1

    if len(l) !=0:
        b = -heapq.heappop(l)
        ans+=b
print(ans)

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

int main(){
    int N, T;
    cin >> N >> T;
    int c[N], t[N];
    for(int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
    }

    int minimum = INT_MAX;
    for(int i = 0; i < N; i++){
        if(t[i] <= T){
            minimum = min(c[i], minimum);
        }
    }
    if(minimum == INT_MAX){
        cout << "TLE" << endl;
    }else{
        cout << minimum << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long i64;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

/* include file*/
#include <functional>
#include <vector>
using namespace std;

typedef i64 Monoid;
struct Segment {

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  i64 bin_f(i64 a,i64 b){
    return a + b;
  };
  i64 update_f(i64 a,i64 b){
    return a + b;
  };

  Segment(const vector<Monoid>& init, Monoid ide_)
    : ide(ide_){
      int sz = init.size();
      while (n < sz) n *= 2;
      node.assign(n * 2 - 1, ide);
      for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
      for (int i = n - 2; i >= 0; i--)
        node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1

i64 A,B;
int N;

i64 s[202];
i64 f[202];

int main(){
  cin >> A >> B >> N;
  rep(i,1,N){
    cin >> s[i] >> f[i];
    if(B <= s[i] || f[i] <= A){
    }
    else{
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}



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

using namespace std;

int main(void) {
	int i, j, l;
	string s, abc = "abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	l = s.size();
	if (l == 26) {
		vector<int> d(26, false);
		d[s[s.size() - 1] - 'a'] = true;
		for (i = l - 2; i >= 0; i--) {
			if (s[i] < s[i + 1])
				break;
			d[s[i] - 'a'] = true;
		}
		if (i < 0)
			printf("-1");
		else {
			for (j = s[i] - 'a' + 1; j < 26; j++) {
				if (d[j]) {
					s[i] = abc[j];
					break;
				}
			}
			for (j = 0; j <= i; j++)
				cout << s[j];
		}
	}
	else {
		vector<int> d(26, true);
		for (i = 0; i < l; i++)
			d[s[i] - 'a'] = false;
		cout << s;
		for (i = 0; i < 26; i++) {
			if (d[i]){
				cout << abc[i];
				break;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 100000000;
const int MOD = 1000000007;
int main(){
  int sx,sy,tx,ty;
  std::cin >> sx>>sy>>tx>>ty;
  for (int i = 0; i < tx-sx; i++) {
    /* code */
    std::cout <<'R';
  }
  for (int i = 0; i < ty-sy; i++) {
    /* code */
    std::cout <<'U';
  }
  for (int i = 0; i < tx-sx; i++) {
    /* code */
    std::cout <<'L';
  }
  for (int i = 0; i < ty-sy; i++) {
    /* code */
    std::cout <<'D';
  }
  
  std::cout <<'D';
  for (int i = 0; i < tx-sx+1; i++) {
    /* code */
    std::cout <<'R';
  }
  for (int i = 0; i < ty-sy+1; i++) {
    /* code */
    std::cout <<'U';
  }
  std::cout <<'L';
  std::cout <<'U';
  for (int i = 0; i < tx-sx+1; i++) {
    /* code */
    std::cout <<'L';
  }
  for (int i = 0; i < ty-sy+1; i++) {
    /* code */
    std::cout <<'D';
  }
  std::cout <<'R';
}

Measured memory_bytes: 256
import sys
import heapq

N, M = map(int,input().split())
a_lists = []

if N == 1:
    if M == 0:
        print (1)
        sys.exit()
    else:
        print(0)
        sys.exit()

for m in range (M):
    temp = int(input())
    a_lists.append(temp-1)

a_lists.append(10**6)

datas = [0]*N
if 0 in a_lists:
    datas[0] = 0
    heapq.heappop(a_lists) 
    
else:
    datas[0]=1

if 1 in a_lists:
    datas[1] = 0
    heapq.heappop(a_lists) 
else:
    datas[1]= datas[0]+1
    
heapq.heapify(a_lists)
    
for i in range (2,N):
    if i == a_lists[0]:
        datas[i] =0
        heapq.heappop(a_lists) 
    else:
        datas[i] = datas[i-1] + datas[i -2]

print(datas[-1]%1000000007)

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

int main(void){
    int k;
    string s;
    cin >> k;
    cin >> s;
    int a = s.size();
    if(a <= k){
	cout << s << endl;
    }else{
	for(int i = 0; i < k; ++i){
	    cout << s[i];
	}
	cout << "..." << endl;
    }
    return 0;
}



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

using ll=long long;
using dbl=double;

struct H{
    int id;
    ll x,v;
};
bool operator<(H lhs,H rhs){
    return lhs.x<rhs.x;
}
const dbl INF=1e22;
int n;
vector<dbl> ans;
H zombi;
vector<H> hs;
dbl calc(H x,H y){
    dbl ret=-dbl(y.x-x.x)/(y.v-x.v);
    if(ret<0) return INF;
    else return ret;
}
vector<H> cht(vector<H> &right){
    // cerr<<"$"<<right.size()<<endl;
    vector<H> res;
    for(auto h:right){
        while(res.size()>=2){
            int sz=res.size();
            H h1=res[sz-2],h2=res[sz-1],h3=h;
            if((h3.x-h2.x)*(h2.v-h1.v)<(h2.x-h1.x)*(h3.v-h2.v)) break;
            res.pop_back();
        }
        res.push_back(h);
    }
    // cerr<<"$"<<res.size()<<endl;
    return res;
}

void solve(){
    sort(hs.begin(),hs.end());
    vector<H> left;
    vector<H> right;
    right.push_back(zombi);
    for(auto h:hs){
        if(h.x<zombi.x) left.push_back(h);
        else{
            if(h.v<right.back().v) right.push_back(h);
        }
    }
    
    vector<H> chv=cht(right);
    // cerr<<chv.size()<<endl;

    for(auto h:left){
        int lb=-1,ub=chv.size()-1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(chv[mid].v-h.v>=0) lb=mid;
            else ub=mid;
        }
        lb++;
        ub=(int)chv.size()-1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            if(calc(h,chv[mid])>=calc(h,chv[mid+1])) lb=mid;
            else ub=mid;
        }
        // cerr<<"#"<<h.id<<" "<<lb<<endl;
        if(lb>=chv.size()){
            ans[h.id]=-1;
        }
        else ans[h.id]=min(calc(h,chv[lb]),(lb+1<chv.size() ? calc(h,chv[lb+1]) : INF));
    }
    return;
}

int main(){
    cin>>n;
    ans.assign(n,-1);
    hs.resize(n);
    cin>>zombi.x>>zombi.v;
    for(int i=0;i<n;i++){
        hs[i].id=i;
        cin>>hs[i].x>>hs[i].v;
    }
    
    solve();
    // inverse
    zombi.x=-zombi.x,zombi.v=-zombi.v;
    for(int i=0;i<n;i++) hs[i].x=-hs[i].x,hs[i].v=-hs[i].v;
    solve();
    cout<<setprecision(10)<<fixed;
    for(int i=0;i<n;i++){
        if(ans[i]==-1 || ans[i]>=INF) cout<<-1<<endl;
        else cout<<ans[i]<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(void)
{
    string S;
    cin >> S;

    int win_count = 0;

    for(int i = 0; i < S.size(); i++)
    {
        if(S[i] == 'o')
        {
            win_count++;
        }
    }

    int result = win_count + 15 - S.size();

    if(result >= 8)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const long long mod = 1000000007LL;
int type[1003], n;
vector<int>x[1003];
long long solve(int pos) {
	long long Kakezan = 1;
	long long Tashizan = 0;
	long long Warizan = 1;
	vector<int>vec;
	for (int i = 0; i < x[pos].size(); i++) { vec.push_back(solve(x[pos][i])); }
	for (int i = 0; i < x[pos].size(); i++) { Kakezan *= vec[i]; Kakezan %= mod; }
	for (int i = 0; i < x[pos].size(); i++) { Tashizan += vec[i]; Tashizan %= mod; }
	for (int i = 0; i < x[pos].size(); i++) { Warizan *= (vec[i] + 1); Warizan %= mod; }
	long long D = 0;
	if (type[pos] == 1)D = Kakezan;
	if (type[pos] == 2)D = Kakezan + 1;
	if (type[pos] == 3)D = Tashizan;
	if (type[pos] == 4)D = Tashizan + 1;
	if (type[pos] == 5)D = Warizan - 1;
	if (type[pos] == 6)D = Warizan;
	return D;
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		string S; cin >> S;
		if (S == "E")type[i] = 1;
		if (S == "E?")type[i] = 2;
		if (S == "A")type[i] = 3;
		if (S == "A?")type[i] = 4;
		if (S == "R")type[i] = 5;
		if (S == "R?")type[i] = 6;
	}
	for (int i = 0; i < n - 1; i++) {
		int s, t; cin >> s >> t; x[s].push_back(t);
	}
	cout << solve(1) << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int h[100002];
    for(int i = 0; i < n; i++) cin >> h[i];
    int ans = 0;
    int now = 0;
    for(int i = 1; i < n; i++){
        if(h[i] <= h[i - 1]){
            now++;
        }
        else{
            ans = max(ans, now);
            now = 0;
        }
    }
    ans = max(ans, now);
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];

    int ans = 0;
    while (!all_of(h, h + n, [](int x) { return x == 0; })) {
        int l = 0;
        rep(i, n) if (h[i] > 0) {
            l = i;
            break;
        }
        for (int i = l; i < n; i++) {
            if (h[i] == 0) break;
            h[i]--;
        }
        ans++;
    }

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


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

using namespace std;

typedef long long ll;

int tn;
int t[400005];

void modify(int p){
    for(t[p+=tn]=1;p>1; p>>=1)
        t[p>>1] = t[p]+t[p^1];
}

int query(int l, int r){
    int ans = 0;
    for(l+=tn,r+=tn;l<r;l>>=1,r>>=1){
        if(l&1)
            ans+=t[l++];
        if(r&1)
            ans+=t[--r];
    }
    return ans;
}

int main(){
    ll k;
    int n;
    scanf("%d%lld",&n,&k);
    tn = n+1;
    vector<ll> a(n,0);
    for(int i = 0; i<n; i++)
        scanf("%lld",&a[i]);
    vector<pair<ll,int>> avec;
    avec.push_back({0,0});
    ll pref = 0;
    for(int i = 0; i<n; i++){
        pref += a[i];
        avec.push_back({pref-(k*(i+1)),i+1});
    }
    sort(avec.begin(),avec.end());
    vector<int> ainv(n+1,0);
    for(int i = 0; i<tn; i++)
        ainv[avec[i].second] = i;
    ll ans = 0;
    for(int i = 1; i<=n; i++){
        modify(ainv[i-1]);
        ans+=query(0,ainv[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 8044
#include<iostream>
#include<string>
using namespace std;
int m[4][2]={
    0,1,1,0,0,-1,-1,0
};
string s;
int main()
{
    int n,m;
    cin>>s;
    int l=s.length();
    cout<<s[0]<<l-2<<s[l-1]<<endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static BigInteger MOD = BigInteger.valueOf((long) 1e9 + 7);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();
        int d = in.nextInt();

        out.println((int) Math.ceil((double) n / (double) (d * 2 + 1)));
    }

}


Measured memory_bytes: 21844
H, N = map(int, input().lower().split())
total = 0
count = 0
A = []
input_string = input()
A = input_string.split()

for i in range(N):
    total = total + int(A[i])


while(True):
    H = H - total
    if H <= 0:
        count = count + 1
        break
    else:
        count = count + 1

if count == 1:
    print("Yes")
else:
    print("No")


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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  int L=A+B;
  int R=C+D;
  if (L>R) {
    printf("Left\n");
  } else if (L<R) {
    printf("Right\n");
  } else {
    printf("Balanced\n");
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env -S JULIA_VERSION=1.4.0 julia
# contest: abc167, problem: abc167_b, alphabet: B

function solve(A::Int, B::Int, C::Int, K::Int)
  if K < A
    println(K)
  elseif A+B >= K
    println(A)
  else
    println(A-(K-A-B))
  end
end

function main()
  tokens = Channel{String}(32)
  Task() do
    for line in eachline(@static VERSION < v"0.6" ? STDIN : stdin)
      startswith(line, '\0') && break
      for token in split(chomp(line))
        put!(tokens, token)
      end
    end
    close(tokens)
  end |> schedule
  A = parse(Int, take!(tokens))
  B = parse(Int, take!(tokens))
  C = parse(Int, take!(tokens))
  K = parse(Int, take!(tokens))
  solve(A, B, C, K)
end

if isempty(get(ENV, "ATCODER_LOCAL", ""))
  isempty(ARGS) && main()
else
  @eval begin
    const samples = [("2 1 1 3", "2"), ("1 2 3 4", "0"), ("2000000000 0 0 2000000000", "2000000000")]
    function test(sampleids...)
      isempty(sampleids) && return test(collect(1:length(samples))...)
      ostdin, ostdout = @static VERSION < v"0.6" ? (STDIN, STDOUT) : (stdin, stdout)
      rd, wr = first(redirect_stdout()), last(redirect_stdin())
      try
        map(sampleids) do sampleid
          input, output = samples[sampleid]
          print(ostdout, "Testing sample #$(sampleid)..."); flush(ostdout)
          println(wr, input)
          println(wr, "\0")
          t = @elapsed main()
          println()
          result = strip(String(readavailable(rd)))
          if result == output
            println(ostdout, "OK ($t sec).")
            true
          else
            println(ostdout, "ERROR ($t sec)")
            println(ostdout, "== expected ==\n$output")
            println(ostdout, "== actual ==\n$result\n")
            false
          end
        end |> all
      finally
        redirect_stdin(ostdin)
        redirect_stdout(ostdout)
      end
    end
    submit() = test() && (prog = @__FILE__; run(`atcoder-submit $prog`))
    !isinteractive() && submit()
  end
end


Measured memory_bytes: 181116
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll dp[114514][13];
int main(){
	string s;
	cin>>s;
	ll ss=s.size();
	ll inv[13]={0,1,7,9,10,8,11,2,5,3,4,6,12};
	dp[0][0]=1;
	for(int i=0;i<ss;i++){
		if(s[i] != '?'){
			int cur = s[i]-'0';
			for(int j=0;j<13;j++){
				dp[i+1][(j*10+cur)%13] += dp[i][j];
				dp[i+1][(j*10+cur)%13] %= inf;
			}
		}
		else{
			for(int k=0;k<=9;k++){
				for(int j=0;j<13;j++){
					dp[i+1][(j*10+k)%13] += dp[i][j];
					dp[i+1][(j*10+k)%13] %= inf;
				}
			}
		}
	}
	cout<<dp[ss][5]<<endl;
	return 0;
}

Measured memory_bytes: 10752
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i == n - 1)break;
        if(h[i] >= h[i + 1]){
            int cnt = 0;
            for(int j = i; j < n; j++){
                if(j == n - 1){
                    ans = max(ans, cnt);
                    i = j;
                    break;
                }

                if(h[j] >= h[j + 1]){
                    cnt++;
                } else {
                    ans = max(ans, cnt);
                    i = j;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto c = new int[](n-1), s = new int[](n-1), f = new int[](n-1);
  foreach (i; 0..n-1) {
    auto rd = readln.split.to!(int[]);
    c[i] = rd[0];
    s[i] = rd[1];
    f[i] = rd[2];
  }

  int calc(int i, int t)
  {
    if (i == n-1) return t;
    auto t2 = max(s[i], (t+f[i]-1)/f[i]*f[i])+c[i];
    return calc(i+1, t2);
  }

  foreach (i; 0..n) writeln(calc(i, 0));
}


Measured memory_bytes: 380
from scipy.special import comb

s = int(input())
maxcount = int(s / 3)
amari = s % 3
count = 0
if amari == 0 and maxcount > 0:
    count = 1

for i in range(maxcount):
    amari = s - (i + 1) * 3
    if amari != 0:
        count += comb(amari + i, i, exact=True)
    count %= 1000000007
print(count)

Measured memory_bytes: 42320
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, 0, 2) {
        if (a > b) {
            ans += a;
            a--;
        } else {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int T,A,n;
  cin >> n >> T >> A;
  T--,A--;
  vector<vector<int>> v(n);
  rep(i,n-1){
    int a,b;cin >> a >> b;
    a--,b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  ll res = 0;
  bool is = true;
  vector<int> next(n,T);
  {
    vector<int> dt(n,-1);
    dt[T] = 0;
    queue<int> que;
    que.push(T);
    while(!que.empty()){
      int ov = que.front();que.pop();
      for(int nv : v[ov]){
        if(dt[nv] != -1)continue;
        next[nv] = ov;
        dt[nv] = dt[ov] + 1;
        que.push(nv);
      }
    }
    if(dt[A] & 1){
      int d = dt[A];
      while(dt[next[A]] >= d-d/2)A = next[A];
      T = A;
      while(dt[next[T]] >= d/2 && next[T] != T)T = next[T];
      res += d/2;
    }else{
      int d = dt[A];
      while(dt[next[A]] >= d-(d-2)/2)A = next[A];
      T = A;
      while(dt[next[T]] >= (d-2)/2 && next[T] != T)T = next[T];
      res += (d-2)/2;
      is = false;
    }
  }
  int L = -1;
  {
    for(int ov : v[T])for(int nv : v[ov])if(nv == A){
      L = ov;
      break;
    }
  }
  queue<int> que;
  que.push(T);
  vector<int> d(n,-1);
  d[T] = 0;
  while(!que.empty()){
    int ov = que.front();que.pop();
    for(int nv : v[ov]){
      if(nv == A || d[nv] != -1 || nv == L)continue;
      d[nv] = d[ov]+1;
      que.push(nv);
    }
  }
  int K = T;
  rep(i,n)if(d[i] > d[K])K = i;
  if(is)res += d[K];
  else res += d[K]+1;
  cout << res << endl;

  /*////////////
  cout << "L :" << L << endl;
  printf("T :%d A :%d\n",T+1,A+1);

  */////////////


  return 0;
}
/*
7
4 7
1 2
1 3
2 4
2 5
3 6
3 7
*/

Measured memory_bytes: 6656
N, K = map(int, input().split())
B = [1] * N
ans = 0
for i in range(K):
    d = int(input())
    A =  list(map(int, input().split()))
    for j in range(d):
        x = A[j] - 1
        B[x] = 0
for i in range(N):
    ans = ans + B[i]
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b=0,r=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
            r++;
        else
            b++;
    }
    int h=min(b,r);
    cout<<h*2<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
    }
    else
    cout << n - k << endl;

    return 0;
}

Measured memory_bytes: 888
package main

import (
	"fmt"
)

func main() {
	var H, N int
	fmt.Scanf("%d %d\n", &H, &N)

	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		A[i] = a
		B[i] = b
	}
	dp := [1010][10010]int{}
	for i := 0; i <= H; i++ {
		dp[0][i] = 10e9
	}

	for i := 0; i < N; i++ {
		for j := 1; j <= H; j++ {
			dp[i+1][j] = dp[i][j]
			if j >= A[i] {
				if dp[i][j] > dp[i+1][j-A[i]]+B[i] {
					dp[i+1][j] = dp[i+1][j-A[i]] + B[i]
				}
			} else {
				if dp[i][j] > B[i] {
					dp[i+1][j] = B[i]
				}
			}
		}
	}
	fmt.Println(dp[N][H])
}


Measured memory_bytes: 82560
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,m,i,j;
    vector<string> f1,f2;
    string s;
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>s;
        f1.pb(s);
    }
    cin>>m;
    for (i=0;i<m;i++)
    {
        cin>>s;
        f2.pb(s);
    }
    int ans=0;
    for (i=0;i<n;i++)
    {
        string a=f1[i];
        int tp=0;
        for (j=0;j<n;j++)
        {
            if (a==f1[j])
                tp++;
        }
        for (j=0;j<m;j++)
        {
            if (a==f2[j])
                tp--;
        }
        ans=max(ans,tp);
    }
    cout<<ans<<endl;
}

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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)2e5 + 123;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 9;

inline void boost () {
	ios_base::sync_with_stdio (0);
	cin.tie (0), cout.tie (0);
}
ll n, a[N];

int main () {
	boost ();
	cin >> n;
	for (int i = 1;i <= n;i ++) cin >> a[i];
	ll sum = 0;
	for (int i = 1;i <= n;i ++) sum += a[i];
	if (sum % (n * (n + 1) / 2) != 0) return cout << "NO", 0;
	ll need = sum / (n * (n + 1) / 2);
	for (int i = 2;i <= n;i ++) 
		if ((a[i] - a[i - 1] - need) % n != 0 || a[i] - a[i - 1] > need)
			return cout << "NO", 0;
	cout << "YES";
	return 0;
}                                


Measured memory_bytes: 1024
import numpy as np



def power_set(item_lists):

    p_sets = [[]]

    for item in item_lists:
        tmp = []
        for element in p_sets:
            tmp.append(element + [item])
        p_sets.extend(tmp)

    return p_sets

H, W, K = tuple(map(int,input().split()))

mat = [input() for l in range(H)]
mat = [[s[i] for i in range(W)] for s in mat]

mat = np.array([[(0 if mat[i][j]=='.' else 1) for j in range(W)] for i in range(H)])

row_sums=np.array([np.sum(mat[i]) for i in range(H)])
column_sum=np.array([np.sum(mat[:,i]) for i in range(W)])


row_sets=power_set(list(range(H)))
column_sets=power_set(list(range(W)))

preB=np.sum(row_sums)
count=0
for row_set in row_sets:
    for column_set in column_sets:
# =============================================================================
#         print(row_set,column_set)
#         print(np.sum(row_sums[row_set]),np.sum(column_sum[column_set]))
#         print(np.sum(mat[row_set,column_set]))
# =============================================================================
        dupli=sum([sum([mat[i][j] for j in column_set]) for i in row_set])
        remain=preB-np.sum(row_sums[row_set])-np.sum(column_sum[column_set])+dupli

        if remain==K: 
            count+=1

print(count)


Measured memory_bytes: 27008
using System;
using System.Linq;

namespace aoj_ALDS1_2_C
{
    class MainClass
    {
		private class Card
        {
			public string Character { get; set; }
			public int Number { get; set; }
			public int Order_SameNumber { get; set; }
        }

        public static void Main(string[] args)
        {
			int numberCount = int.Parse(Console.ReadLine());
			string[] tempArray = Console.ReadLine().Split(' ');

			Card[] cardArray = new Card[numberCount];
			for (int i = 0; i < numberCount; i++)
			{
				cardArray[i] = new Card();
				cardArray[i].Number = int.Parse(tempArray[i].Substring(1, 1));
				cardArray[i].Character = tempArray[i];
				cardArray[i].Order_SameNumber = cardArray.Where(card => card != null).Count(card => card.Number == cardArray[i].Number);
			}
            
			Card[] resultArray_Bubble = BubbleSort(cardArray.ToArray());
			Card[] resultArray_Selection = SelectionSort(cardArray.ToArray());

			Console.WriteLine(String.Join(" ", resultArray_Bubble.Select(card => card.Character).ToArray()));
			Console.WriteLine(Judge_IsStable(resultArray_Bubble));

			Console.WriteLine(String.Join(" ", resultArray_Selection.Select(card => card.Character).ToArray()));
			Console.WriteLine(Judge_IsStable(resultArray_Selection));
		}

		private static string Judge_IsStable(Card[] cardArray)
		{
            foreach (var cardGroup in cardArray.GroupBy(card => card.Number).Where(g => g.Count() > 1))
            {
                int order_SameNumber = 1;
                foreach (var card in cardGroup)
                {
                    if (card.Order_SameNumber == order_SameNumber)
                    {
                        order_SameNumber++;
                        continue;
                    }
                    else
                    {
						return "Not stable";
                    }
                }
            }

			return "Stable";
		}

		private static Card[] BubbleSort(Card[] cardArray)
        {
			bool isSorted = true;
            while (isSorted)
            {
                isSorted = false;
                for (int i = cardArray.Length - 1; i > 0; i--)
                {
					if (cardArray[i - 1].Number > cardArray[i].Number)
                    {
						var temp = cardArray[i - 1];
						cardArray[i - 1] = cardArray[i];
						cardArray[i] = temp;

                        isSorted = true;
                    }
                }
            }

			return cardArray;
		}

		private static Card[] SelectionSort(Card[] cardArray)
        {
            for (int i = 0; i < cardArray.Length; i++)
            {
                int minIndex = i;
                for (int j = i; j < cardArray.Length; j++)
                {
                    if (cardArray[j].Number < cardArray[minIndex].Number)
                    {
                        minIndex = j;
                    }
                }

                if (minIndex != i)
                {
                    var temp = cardArray[i];
                    cardArray[i] = cardArray[minIndex];
                    cardArray[minIndex] = temp;
                }
            }

            return cardArray;
        }
    }
}



Measured memory_bytes: 20456
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<bitset>
#include<deque>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 5050
#define maxm 100010
#define mod 1000000007
#define inf 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int K,Q;
int d[maxn];
int main()
{
    K=read();Q=read();
    for(int i=0;i<K;i++)  d[i]=read();
    while(Q--)
    {
        int n=read(),x=read(),m=read();x%=m;
        ll sum=0,cnt=0;
        for(int i=0;i<K;i++)  sum+=(d[i]%m),cnt+=(d[i]%m==0);
        ll add=1ll*((n-1)/K)*sum;cnt=cnt*((n-1)/K);
        for(int i=0;i<=n-2-((n-1)/K)*K;i++)  add+=(d[i]%m),cnt+=(d[i]%m==0);
        cout<<(n-1-(add+x)/m+x/m)-cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/25 10:14:06 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	ll	n;
	cin >> n;
	ll	minv;
	minv = 1000000000000009;
	rep(i, 5)
	{
		ll	x;
		cin >> x;
		minv = min(minv, x);
	}
	cout << (n + (minv - 1)) / minv + 4 << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    int counter = 0;
    int answer = 0;
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }
    for (int k = 0; k < n; k++)
    {
        for (int j = 0; j < m; j++)
        {
            int a;
            cin >> a;
            answer += (a * b[j]);
        }
        if (answer + c > 0)
        {
            counter++;
        }
        answer = 0;
    }
    cout << counter;
}

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

using namespace std;
int main(int argc, const char * argv[]) {
    int n, cnt, i, ans, j;
    cnt = ans = 0;
    cin >> n;
    
    for(j = 1;j <= n;j+=2){
        for(i = 1 ;i <= j;i+=2){
            if(j % i == 0)cnt++;
        }
        if(cnt == 8)ans++;
        cnt = 0;
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a[0];
  }
}
foreach($key->X as $l) {
  printf("%s\n%s\n",$l,$l);
}


Measured memory_bytes: 3832
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int sum = 0;
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				for(int k = 1; k <= n; k++) {
					sum += gcd(i,gcd(j, k));
				}
			}
		}
		System.out.println(sum);

	}

	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}

}

Measured memory_bytes: 35824
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

double const toRad = std::acos(-1)/1.8e2;
double a, b, S;

bool isOK(double deg) {
  double rad = deg*toRad;
  double s = std::sin(rad);
  if(s <= 1e-12) return true; // should be full
  double c = std::cos(rad);
  if(c <= 1e-12) return false; // should be zero
  double h = b*c/s;
  double cS;
  if(h <= a) cS = b*h*0.5;
  else {
    h = a*s/c;
    cS = a*(b - h*0.5);
  }
  return S < cS*(1.0+0.8e-9*a/b);
}

int main() {
  std::cout << std::setprecision(10) << std::fixed;
  double x; std::cin >> a >> b >> x;
  S = x/a;
  double ok = 0.0, ng = 90.0;
  while(ng-ok > 1e-6) {
    double mid = (ok+ng)*0.5;
    if(isOK(mid)) ok = mid; else ng = mid;
  }
  fin((ok+ng)*0.5);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, ans = 1;
	cin >> n;
	map<int, int> m;
	m[n]++;
	while (true) {
		if (n % 2 == 0) {
			n /= 2;
		}
		else {
			n *= 3;
			n++;
		}
		if (m[n]) break;
		else {
			//cout << m[n] << " " << ans << endl;
			m[n]++;
			ans++;
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll s;cin>>s;
  cout<<0<<" "<<0<<" ";
  cout<<1000000000<<" "<<1<<" ";
  cout<<(s+1000000000LL-1LL)/(1000000000LL)*1000000000LL-s<<" "<<(s+1000000000LL-1LL)/(1000000000LL)<<endl;
}

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

int P[100005];

int main() {

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        int x;
        cin >> x;
        P[x] = i;
    }

    for(int i=1; i<=N; i++)
        cout << P[i] << " ";

    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
			for (int i = 0; i < 3; i++) {
				sum += sc.nextInt();
			}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 26200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,ans=0,p=1,q=1;
map<ll,int>mp;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>a>>b;
	c=__gcd(a,b);
	for(ll i=2;i*i<=c;i++)
	{
		while(c%i==0)
		{
			mp[i]++;
			c/=i;
		}
	}
	if(c>1) mp[c]++;
	cout<<mp.size()+1;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A, B = map(int, raw_input().split())
print max(0, A - 2 * B)

Measured memory_bytes: 4268
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
   int a, b, h;

   cin >> a >> b >> h;

   cout << ((a+b)*h)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;cin>>s;
  ll zero=0,one=0;
  ll ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      if(one){one--;ans+=2;}
      else zero++;
    }else{
      if(zero){zero--;ans+=2;}
      else one++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int N, M;
int T[101];
 
int main() {
    int sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        int p, x;
        cin >> p >> x;
        cout << sum - T[p-1] + x << endl;  
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;


class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double x = sc.nextDouble();

    double s = x / a;

    if (s > a * b / 2) {
      double bp = 2 * (b - x / a / a);
      System.out.println(Math.toDegrees(Math.atan2(bp, a)));
    } else {
      double hp = x / b / a * 2;
      System.out.println(90 - Math.atan2(hp, b) / Math.PI * 180);
    }
  }
}

Measured memory_bytes: 24788
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);	
	int a[100005];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int s=0,t;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			s++;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int a[5010];
int dp[5010];
int main(){
	while(cin>>n,n){
		for(int i =0;i < n;i++){
			cin>>a[i];
			dp[i+1]=a[i];
		}
		dp[0] = 0;
		int ans = -(1<<25);
		for(int i =1;i <= n;i++){
			dp[i] =max(dp[i-1]+a[i-1],dp[i]);
			ans =max(ans,dp[i]);
		}
		cout <<ans<<endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef vector<pii> vii;

int n;
const int MAX = 1e5;
vvi x(MAX + 5, vi(3));
vvi dp(MAX + 5, vi(4, -1));

int sol(int i, int j){
    if(i == n) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    dp[i][j] = 0;
    for(int k = 0; k < 3; ++k){
        if(k == j) continue;
        dp[i][j] = max(dp[i][j], x[i][k] + sol(i + 1, k));
    }
    return dp[i][j];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #else
        #define endl '\n'
    #endif

    cin >> n;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> x[i][j];
        }
    }
    cout << sol(0, 3) << endl;
    return 0;
}


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

int main() {
  int x,a,b; cin >> x >> a >> b;
  if (b-a > x) cout << "dangerous";
  else if (b-a > 0) cout << "safe";
  else cout << "delicious";
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x,y,srx,sum=0;
    scanf("%lld%lld",&x,&y);
    srx=((long long)(y/x));
    while(srx>=1)
    {srx/=2;
    sum++;}
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n,i,ans=0,l=0;
  cin>>s;
  n=s.length();
  for(i=0;i<n;i++){
    if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='C'||s.at(i)=='G'){
      l++;
      if(ans<l) ans=l;
    }
    else l=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
typedef long long ll;
typedef pair<int, int> pii;
bool vis[N][N];
char mp[N][N];
int h, w;
int dx[2] = {1, 0}, dy[2] = {0, 1};
ll f[N][N], mod = 1e9 + 7;
int main()
{
    scanf("%d %d", &h, &w);
    for (int i = 1; i <= h; i++)
        scanf("%s", mp[i] + 1);
    queue<pii> q;
    q.push(make_pair(1, 1));
    f[1][1] = 1;
    vis[1][1] = 1;
    while (!q.empty())
    {
        pii t = q.front();
        q.pop();
        for (int i = 0; i < 2; i++)
        {
            int tx = t.first + dx[i], ty = t.second + dy[i];
            if (tx <= h && ty <= w && mp[tx][ty] == '.')
            {
                f[tx][ty] = (f[tx][ty] + f[t.first][t.second]) % mod;
                if (!vis[tx][ty])
                    q.push(make_pair(tx, ty)), vis[tx][ty] = 1;
            }
        }
    }
    printf("%lld\n", f[h][w]);
    return 0;
}

Measured memory_bytes: 10240